From 0dc56bc8698b344959a610c78c59bea3fc0e6f4f Mon Sep 17 00:00:00 2001 From: "h.boesl" <h.boesl@adito.de> Date: Fri, 13 Dec 2019 13:33:58 +0100 Subject: [PATCH] small adjustments DuplicatsScanner --- entity/Person_entity/Person_entity.aod | 23 +++++++++++++++++++---- process/DuplicateScanner_lib/process.js | 21 ++++++++++----------- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod index 0a325415b1..3265022fd8 100644 --- a/entity/Person_entity/Person_entity.aod +++ b/entity/Person_entity/Person_entity.aod @@ -1388,15 +1388,15 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <expression>%aditoprj%/entity/Person_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js</expression> </dbRecordFieldMapping> <dbRecordFieldMapping> - <name>STANDRAD_ADDRESS.value</name> + <name>STANDARD_ADDRESS.value</name> <recordfield>ADDRESS.ADDRESS</recordfield> </dbRecordFieldMapping> <dbRecordFieldMapping> - <name>STANDRAD_CITY.value</name> + <name>STANDARD_CITY.value</name> <recordfield>ADDRESS.CITY</recordfield> </dbRecordFieldMapping> <dbRecordFieldMapping> - <name>STANDRAD_ZIP.value</name> + <name>STANDARD_ZIP.value</name> <recordfield>ADDRESS.ZIP</recordfield> </dbRecordFieldMapping> </recordFieldMappings> @@ -1455,7 +1455,12 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <indexFieldType>PROPER_NAME</indexFieldType> </indexRecordFieldMapping> <indexRecordFieldMapping> - <name>STANDARD_ADDRESS.displayValue</name> + <name>STANDARD_ADDRESS.value</name> + <indexFieldType>ADDRESS</indexFieldType> + <additionalFieldNameAliases> + <element>address</element> + </additionalFieldNameAliases> + <isMultiValued v="true" /> </indexRecordFieldMapping> <indexRecordFieldMapping> <name>STANDARD_COUNTRY.value</name> @@ -1467,9 +1472,19 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact </indexRecordFieldMapping> <indexRecordFieldMapping> <name>STANDARD_ZIP.value</name> + <indexFieldType>ADDRESS</indexFieldType> + <additionalFieldNameAliases> + <element>zip</element> + </additionalFieldNameAliases> + <isMultiValued v="true" /> </indexRecordFieldMapping> <indexRecordFieldMapping> <name>STANDARD_CITY.value</name> + <indexFieldType>ADDRESS</indexFieldType> + <additionalFieldNameAliases> + <element>city</element> + </additionalFieldNameAliases> + <isMultiValued v="true" /> </indexRecordFieldMapping> <indexRecordFieldMapping> <name>STANDARD_EMAIL_COMMUNICATION.value</name> diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js index 0227fea565..d6c2443ed1 100644 --- a/process/DuplicateScanner_lib/process.js +++ b/process/DuplicateScanner_lib/process.js @@ -332,7 +332,7 @@ DuplicateScannerUtils.ScanRecords = function(pTargetEntity, pTargetRecordsData, //If the contact id loading query has no results, stop. //No ids should be deleted if an error has been made in this query. if(pTargetRecordsData.length <= 0) - return; + return foundDuplicateIds; //First it gets checked if the current id has already been identified. If that's the case it'll continue with the next. //Otherwise an object gets build in the form of ["FilterFieldName" = "FilterFieldValueFromQuery"] with which a scan for possible duplicates get's started @@ -351,7 +351,7 @@ DuplicateScannerUtils.ScanRecords = function(pTargetEntity, pTargetRecordsData, } let foundDuplicates = _DuplicateScannerUtils._scanForDuplicates(pTargetEntity, - entityFieldValuesRay, pResultFields, pEntityIdField, idValue, pFormatValuesConsumeWebserviceCallback, pUseExternalWebservice, pIndexPattern) + entityFieldValuesRay, pResultFields, idValue, pFormatValuesConsumeWebserviceCallback, pUseExternalWebservice, pIndexPattern) if(foundDuplicates == null || foundDuplicates.length == 0) { @@ -574,7 +574,7 @@ DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, p let idValue = pValuesToCheck[entityIdField]; return _DuplicateScannerUtils._scanForDuplicates(pTargetEntity, - entityFieldConfigValuesRay, resultFields, entityIdField, idValue, + entityFieldConfigValuesRay, resultFields, idValue, pFormatValuesConsumeWebserviceCallback, useExternalWebservice, indexPattern) } @@ -732,7 +732,7 @@ DuplicateScannerUtils.BuildEntityFieldConfigValueRays = function(pDuplicateField if(entityFieldValue == null) entityFieldValue = ""; else - entityFieldValue = entityFieldValue.toLowerCase().replace(/[():\.\/!]/gi, ""); + entityFieldValue = entityFieldValue.toLowerCase().replace(/[():\.\/!]/gi, "").trim(); let exclude = fieldConfig.exclude; if ( exclude ) @@ -748,8 +748,8 @@ DuplicateScannerUtils.BuildEntityFieldConfigValueRays = function(pDuplicateField if ( valuelength ) entityFieldValue = entityFieldValue.substr(0, parseInt(valuelength)) + "*"; - let emptyall = fieldConfig.emptyall; - if ( fieldConfig.emptyall && entityFieldValue == "") + let empty = fieldConfig.empty; + if ( !empty && entityFieldValue == "") entityFieldValue = "*"; entityFieldValue = entityFieldValue.trim(); @@ -884,14 +884,14 @@ _DuplicateScannerUtils._loadEntityIdField = function(pFilterName, pTargetEntity) * @see DuplicateScannerUtils.ScanForDuplicates for the documentation */ _DuplicateScannerUtils._scanForDuplicates = function(pTargetEntity, pEntityFieldConfigValuesRay, -pResultFields, pRecordIdFieldToIgnore, pRecordIdValueToIgnore, pFormatValuesConsumeWebserviceCallback, pUseExternalWebservice, pIndexPattern) +pResultFields, pRecordIdValueToIgnore, pFormatValuesConsumeWebserviceCallback, pUseExternalWebservice, pIndexPattern) { //No filterfields/indexpattern => No indexsearch if(pEntityFieldConfigValuesRay.length < 1 || pIndexPattern == null || pIndexPattern == "") return null; let possibleDuplicates = []; - let ignoreSourceRecordPattern = _DuplicateScannerUtils._getIgnoreSourceRecordPattern(pRecordIdFieldToIgnore, pRecordIdValueToIgnore); + let ignoreSourceRecordPattern = _DuplicateScannerUtils._getIgnoreSourceRecordPattern(pRecordIdValueToIgnore); let indexPatternWithValues = _DuplicateScannerUtils._replacePlaceholderForValuesInPattern(pIndexPattern, pEntityFieldConfigValuesRay); indexPatternWithValues = ignoreSourceRecordPattern + indexPatternWithValues + ")"; @@ -1116,13 +1116,12 @@ _DuplicateScannerUtils._buildDeleteCachedUnrelatedDuplicateQuery = function(pSou /* * Creates a pattern which excludes the field and it's value * - * @param {String} pRecordIdFieldToIgnore Field to be ignored * @param {String} pRecordIdValueToIgnore The fields value * @returns {String} Pattern which excludes the gived field in combination with the value */ -_DuplicateScannerUtils._getIgnoreSourceRecordPattern = function(pRecordIdFieldToIgnore, pRecordIdValueToIgnore) +_DuplicateScannerUtils._getIgnoreSourceRecordPattern = function(pRecordIdValueToIgnore) { - return "(+(-" + pRecordIdFieldToIgnore.toLowerCase() + "_value:(" + pRecordIdValueToIgnore + ")) "; + return "( +( -" + indexsearch.FIELD_ID + ":(" + pRecordIdValueToIgnore + ") ) "; } _DuplicateScannerUtils._buildUpdateContactIdStatements = function(pTableInfos, pSourceContactId, pTargetContactId) -- GitLab