diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod index 76cce88c0219c362a252c8d088b605176ad6134a..3636e907bd5d0eec2977b648967da89cb22a0051 100644 --- a/entity/Organisation_entity/Organisation_entity.aod +++ b/entity/Organisation_entity/Organisation_entity.aod @@ -1010,6 +1010,10 @@ <name>OnlyShowContactIds_param</name> <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js</valueProcess> </entityParameter> + <entityParameter> + <name>ExcludedContactIds_param</name> + <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/excludedcontactids_param/valueProcess.js</valueProcess> + </entityParameter> </children> </entityConsumer> <entityConsumer> diff --git a/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/excludedcontactids_param/valueProcess.js b/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/excludedcontactids_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..30b7732937f200956ed88f41b8a4665f37953aad --- /dev/null +++ b/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/excludedcontactids_param/valueProcess.js @@ -0,0 +1,7 @@ +import("system.logging"); +import("system.vars"); +import("system.result"); +import("DuplicateScanner_lib"); + +let unrelatedIds = DuplicateScannerUtils.GetUnrelatedRelationsForDuplicate(vars.get("$field.CONTACTID")); +result.string(JSON.stringify(unrelatedIds)); \ No newline at end of file diff --git a/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js b/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js index 4024668e40db9cb823c5beacc015904e2ab73d68..fb1fb5a8a32712bada3cc0eae50a16cf5983fcd3 100644 --- a/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js +++ b/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js @@ -9,7 +9,6 @@ let scannerName = "OrganisationDuplicates"; let targetEntity = "Organisation_entity"; let valuesToCheck = {}; var entityFieldsToLoad = DuplicateScannerUtils.GetEntityFieldsFromConfig(scannerName, targetEntity); -//project.getEntityStructure(targetEntity); //Read the values of all available entity fields and write the fieldname7value combination //as key/value pairs into an object. This is used to trigger the scan for duplicates @@ -18,11 +17,11 @@ let entityFields = []; for (fieldname in entityFieldsToLoad) { field = entityFieldsToLoad[fieldname]; - fieldValue = vars.get("$field." + field.name); + fieldValue = vars.get("$field." + field); if(fieldValue != null && fieldValue != "") { - valuesToCheck[field.name] = fieldValue; + valuesToCheck[field] = fieldValue; } } diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod index 5796e1ce02ae3b170a66610f3319caa6160c6f8a..1add27c57b8d9c6e66f5ed674837bdb121b0a111 100644 --- a/entity/Person_entity/Person_entity.aod +++ b/entity/Person_entity/Person_entity.aod @@ -1077,6 +1077,10 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact <name>OnlyShowContactIds_param</name> <valueProcess>%aditoprj%/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js</valueProcess> </entityParameter> + <entityParameter> + <name>ExcludedContactIds_param</name> + <valueProcess>%aditoprj%/entity/Person_entity/entityfields/selfduplicatesuncached/children/excludedcontactids_param/valueProcess.js</valueProcess> + </entityParameter> </children> </entityConsumer> <entityField> diff --git a/entity/Person_entity/entityfields/selfduplicatesuncached/children/excludedcontactids_param/valueProcess.js b/entity/Person_entity/entityfields/selfduplicatesuncached/children/excludedcontactids_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..30b7732937f200956ed88f41b8a4665f37953aad --- /dev/null +++ b/entity/Person_entity/entityfields/selfduplicatesuncached/children/excludedcontactids_param/valueProcess.js @@ -0,0 +1,7 @@ +import("system.logging"); +import("system.vars"); +import("system.result"); +import("DuplicateScanner_lib"); + +let unrelatedIds = DuplicateScannerUtils.GetUnrelatedRelationsForDuplicate(vars.get("$field.CONTACTID")); +result.string(JSON.stringify(unrelatedIds)); \ No newline at end of file diff --git a/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js b/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js index b352b88a57f806f0d1448f6166bf278ce25aecab..eaa45a32c9f221d9bb2e124bede3207572809258 100644 --- a/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js +++ b/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js @@ -18,11 +18,11 @@ let entityFields = []; for (fieldname in entityFieldsToLoad) { field = entityFieldsToLoad[fieldname]; - fieldValue = vars.get("$field." + field.name); + fieldValue = vars.get("$field." + field); if(fieldValue != null && fieldValue != "") { - valuesToCheck[field.name] = fieldValue; + valuesToCheck[field] = fieldValue; } } diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js index 190b3733aa4cafb201dadfcb6e9363899430e68d..6e10377791b9529a11d9450b76adac9e5f8d6fcf 100644 --- a/process/DuplicateScanner_lib/process.js +++ b/process/DuplicateScanner_lib/process.js @@ -775,7 +775,41 @@ DuplicateScannerUtils.GetEntityFieldsFromConfig = function(pFilterName, pTargetE { let indexPattern = _DuplicateScannerUtils._loadIndexPattern(pFilterName, pTargetEntity); let fieldConfigs = _DuplicateScannerUtils._loadEntityFieldConfigsFromPattern(indexPattern); - return _DuplicateScannerUtils._loadEntityFieldsFromFieldConfigs(fieldConfigs); + let entityFields = _DuplicateScannerUtils._loadEntityFieldsFromFieldConfigs(fieldConfigs); + let entityIdField = _DuplicateScannerUtils._loadEntityIdField(pFilterName, pTargetEntity); + entityFields.push(entityIdField); + return entityFields; +} + +DuplicateScannerUtils.GetUnrelatedRelationsForDuplicate = function(pDuplicateId) +{ + let unrelatedIds = []; + let duplicateIds = newSelect("SOURCEDUPLICATEID, UNRELATEDDUPLICATEID") + .from("UNRELATEDDUPLICATES") + .where("UNRELATEDDUPLICATES.SOURCEDUPLICATEID", pDuplicateId) + .or("UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID", pDuplicateId) + .table(); + + let sourceDuplicateId = ""; + let unrelatedDuplicateId = ""; + for (let i = 0; i < duplicateIds.length; i++) + { + sourceDuplicateId = duplicateIds[0]; + unrelatedDuplicateId = duplicateIds[1]; + + if(sourceDuplicateId == pDuplicateId || unrelatedDuplicateId == pDuplicateId) + continue; + + if(sourceDuplicateId != null && sourceDuplicateId != "") + { + unrelatedIds.push(sourceDuplicateId); + } + else if(unrelatedDuplicateId != null && unrelatedDuplicateId != "") + { + unrelatedIds.push(unrelatedDuplicateId); + } + } + return unrelatedIds; } function _DuplicateScannerUtils() {}