diff --git a/entity/DuplicatesUnrelated_entity/DuplicatesUnrelated_entity.aod b/entity/DuplicatesUnrelated_entity/DuplicatesUnrelated_entity.aod index 5bfeba2bcd19624dab78a4b27cf18d8debe91448..d93ebef053648381a224b9428c7c6b2e5138ce88 100644 --- a/entity/DuplicatesUnrelated_entity/DuplicatesUnrelated_entity.aod +++ b/entity/DuplicatesUnrelated_entity/DuplicatesUnrelated_entity.aod @@ -13,6 +13,7 @@ </entityProvider> <entityProvider> <name>UnrelatedPersonsProvider</name> + <titlePlural>Unrelated person duplicates</titlePlural> <children> <entityParameter> <name>TargetEntity</name> diff --git a/entity/Duplicates_entity/Duplicates_entity.aod b/entity/Duplicates_entity/Duplicates_entity.aod index 3416708185e25a5faa4da9a4df2a42a1178fd3be..3fdc791d1a7f149b03bab0ce642648e21a8ed2dc 100644 --- a/entity/Duplicates_entity/Duplicates_entity.aod +++ b/entity/Duplicates_entity/Duplicates_entity.aod @@ -85,6 +85,23 @@ </entityParameter> </children> </entityConsumer> + <entityConsumer> + <name>PersonsConsumer</name> + <dependency> + <name>dependency</name> + <entityName>Person_entity</entityName> + <fieldName>Contacts</fieldName> + </dependency> + <children> + <entityParameter> + <name>OnlyShowContactIds_param</name> + <valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/personsconsumer/children/onlyshowcontactids_param/valueProcess.js</valueProcess> + </entityParameter> + </children> + </entityConsumer> + <entityField> + <name>CLUSTER_ID</name> + </entityField> </entityFields> <recordContainers> <jDitoRecordContainer> @@ -104,6 +121,9 @@ <jDitoRecordFieldMapping> <name>TARGET_ENTITY.value</name> </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>CLUSTER_ID.value</name> + </jDitoRecordFieldMapping> </recordFieldMappings> </jDitoRecordContainer> </recordContainers> diff --git a/entity/Duplicates_entity/entityfields/personsconsumer/children/onlyshowcontactids_param/valueProcess.js b/entity/Duplicates_entity/entityfields/personsconsumer/children/onlyshowcontactids_param/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..be997d2e02356a2735af41a1d6a926b86d011d72 --- /dev/null +++ b/entity/Duplicates_entity/entityfields/personsconsumer/children/onlyshowcontactids_param/valueProcess.js @@ -0,0 +1,18 @@ +import("system.logging"); +import("system.result"); +import("system.vars"); +import("DuplicateScanner_lib"); + +let clusterRecordId = vars.get("$field.UID"); + +let contactIdsInCluster = DuplicateScannerUtils.GetCachedDuplicatesForClusterId(clusterRecordId); +logging.log("contactIdsInCluster -> " + contactIdsInCluster); +/* + * To achieve that if there are no duplicates, no contacts should be shown and therefore returned by the + * recordcontainer, an invalid id gets returned. It then is used in the conditionProcess to load the duplicates. + * Because of its invalidity, no records are shown. +*/ +if(contactIdsInCluster.length == 0) + result.string(JSON.stringify(["nodata"])); +else + result.string(JSON.stringify(contactIdsInCluster)); \ No newline at end of file diff --git a/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js b/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js index 2c215355e52c732f620cf4297584cab54a80d24a..84018ae8fdd12e01df0830fd6243be55c7c828c7 100644 --- a/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js +++ b/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js @@ -1,3 +1,5 @@ +import("Sql_lib"); +import("system.logging"); import("system.db"); import("system.vars"); import("system.result"); @@ -10,21 +12,28 @@ var INDEX_LASTNAME = 3; let targetEntity = vars.get("$param.TargetEntity"); let duplicates = []; +let test = vars.get("$local.idvalues"); +logging.log("test -> " + test); let duplicateInfosQuery = ""; if(targetEntity == "Person_entity") - duplicateInfosQuery = "select DUPLICATECLUSTERS.ID, CLUSTERID, FIRSTNAME, LASTNAME" +{ + + duplicateInfosQuery = SqlCondition.begin() + .and("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)") + .andIn("DUPLICATECLUSTERS.CLUSTERID", vars.get("$local.idvalues")) + .buildSql("select DUPLICATECLUSTERS.ID, CLUSTERID, FIRSTNAME, LASTNAME" + " from DUPLICATECLUSTERS" + " join CONTACT on CONTACT.CONTACTID = DUPLICATEID" - + " join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID" - + " where DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)" - + " ORDER BY CLUSTERID"; + + " join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID", "1=2", " ORDER BY CLUSTERID"); + +} else duplicateInfosQuery = "orgquery"; let duplicateInfos = db.table(duplicateInfosQuery); - +logging.log("duplicateInfos -> " + JSON.stringify(duplicateInfos)); let recordClusterId = ""; let recordDescription = ""; let recordDuplicateInClusterCount = 0; @@ -48,6 +57,7 @@ for (let i = 0; i < duplicateInfos.length; i++) recordDuplicateInClusterCount = 1; continue; } + //If the record belongs to the same Cluster as the one before, append its value and increase the counter //otherwise write the clusters record an start a new record. if(recordClusterId == currentClusterId) @@ -63,7 +73,7 @@ for (let i = 0; i < duplicateInfos.length; i++) * As there are then no interactions possible (and a cluster of one is no cluster), this cluster musn't be shown in the list. */ if(i == duplicateInfos.length-1 && recordDuplicateInClusterCount > 1) - duplicates.push([currentRecordId, recordDescription, recordDuplicateInClusterCount, targetEntity]); + duplicates.push([recordClusterId, recordDescription, recordDuplicateInClusterCount, targetEntity, recordClusterId]); } else { @@ -75,7 +85,7 @@ for (let i = 0; i < duplicateInfos.length; i++) * As there would be no interactions possible (and a cluster of one is no cluster), this cluster musn't be shown in the list. */ if(recordDuplicateInClusterCount > 1) - duplicates.push([currentRecordId, recordDescription, recordDuplicateInClusterCount, targetEntity]); + duplicates.push([recordClusterId, recordDescription, recordDuplicateInClusterCount, targetEntity, recordClusterId]); recordClusterId = currentClusterId recordDescription = currentDescription diff --git a/entity/Person_entity/recordcontainers/db/conditionProcess.js b/entity/Person_entity/recordcontainers/db/conditionProcess.js index 160904cb58cbda216b5918341bf113ec70585cec..79f11bba472b7d8411d786b27139e05c0d3d6cc6 100644 --- a/entity/Person_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Person_entity/recordcontainers/db/conditionProcess.js @@ -30,10 +30,10 @@ if(onlyShowContactIds != null && onlyShowContactIds.length > 0) { additionalCondition.orPrepare("CONTACT.CONTACTID", pContactId); }); - + cond.andSqlCondition(additionalCondition, "1=2"); alternativeCondition = "1 = 2"; } - + logging.log("additionalCondition -> " + db.translateCondition(cond.build(alternativeCondition))); //TODO: use a preparedCondition when available #1030812 #1034026 result.string(db.translateCondition(cond.build(alternativeCondition))); \ No newline at end of file diff --git a/neonContext/Duplicates/Duplicates.aod b/neonContext/Duplicates/Duplicates.aod index 198c0374f2343fbe8336cb5b624330d838f2ae23..49b8140cf51e36a0d809b7c2b714d0578fa5a440 100644 --- a/neonContext/Duplicates/Duplicates.aod +++ b/neonContext/Duplicates/Duplicates.aod @@ -3,6 +3,7 @@ <name>Duplicates</name> <title>Duplicates</title> <majorModelMode>DISTRIBUTED</majorModelMode> + <mainview>PersonDuplicatesEdit_view</mainview> <filterview>DuplicatesOverview_view</filterview> <entity>Duplicates_entity</entity> <references> @@ -22,5 +23,9 @@ <name>5bdeb931-4e69-4520-bbc9-94fb17679331</name> <view>PersonDublicatesTab_view</view> </neonViewReference> + <neonViewReference> + <name>d66a4eda-b7cc-4afe-9360-5e8413427946</name> + <view>PersonDuplicatesEdit_view</view> + </neonViewReference> </references> </neonContext> diff --git a/neonView/DuplicatesUnrelatedPersonFilter_view/DuplicatesUnrelatedPersonFilter_view.aod b/neonView/DuplicatesUnrelatedPersonFilter_view/DuplicatesUnrelatedPersonFilter_view.aod index 9fcb7fbe3592c792d55d5295e985c6668269327d..43ae6c629938e32ca980e1d8122054c8609d49fd 100644 --- a/neonView/DuplicatesUnrelatedPersonFilter_view/DuplicatesUnrelatedPersonFilter_view.aod +++ b/neonView/DuplicatesUnrelatedPersonFilter_view/DuplicatesUnrelatedPersonFilter_view.aod @@ -13,6 +13,7 @@ <entityField>#ENTITY</entityField> <isCreatable v="false" /> <isEditable v="false" /> + <title>Unrelated person duplicates</title> <columns> <neonTableColumn> <name>734re984-6a0b-4126-ab49-452e2b54f76d</name> diff --git a/neonView/PersonDuplicatesEdit_view/PersonDuplicatesEdit_view.aod b/neonView/PersonDuplicatesEdit_view/PersonDuplicatesEdit_view.aod new file mode 100644 index 0000000000000000000000000000000000000000..3e73542ce084bf65aa3945d2f255899a4659edee --- /dev/null +++ b/neonView/PersonDuplicatesEdit_view/PersonDuplicatesEdit_view.aod @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="UTF-8"?> +<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.2"> + <name>PersonDuplicatesEdit_view</name> + <majorModelMode>DISTRIBUTED</majorModelMode> + <layout> + <boxLayout> + <name>layout</name> + <direction>HORIZONTAL</direction> + </boxLayout> + </layout> + <children> + <neonViewReference> + <name>65ba4e07-2ac1-49be-a61e-56d9bc54e7fb</name> + <entityField>PersonsConsumer</entityField> + <view>PersonFilter_view</view> + </neonViewReference> + </children> +</neonView> diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js index 2665f5dd7391b0461bf91ce58246a8116883739b..f9c657b2ded81c3ee67d35b4670c1f5dae1f3226 100644 --- a/process/DuplicateScanner_lib/process.js +++ b/process/DuplicateScanner_lib/process.js @@ -98,6 +98,22 @@ DuplicateScannerUtils.GetCachedDuplicatesForContactId = function(pDuplicateId) return db.array(db.COLUMN, querySelectDuplicateContactIds); } +DuplicateScannerUtils.GetCachedDuplicatesForClusterId = function(pClusterId) +{ + let query = "select DUPLICATEID from DUPLICATECLUSTERS" + + " where CLUSTERID = '"+ pClusterId +"' "; + + return db.array(db.COLUMN, query); +} + +DuplicateScannerUtils.GetCachedDuplicatesForId = function(pClusterRecordId) +{ + let query = "select DUPLICATEID from DUPLICATECLUSTERS" + + " where CLUSTERID = (select CLUSTERID from DUPLICATECLUSTERS" + + " where ID = '"+ pClusterRecordId +"')" + return db.array(db.COLUMN, query); +} + //Später mal eigentsändiger Serverprozess ohne externe Konfiguration DuplicateScannerUtils.RebuildDuplicatesCache = function(pFilterName, pTargetEntity, pQueryTargetRecords, pFilterFields, pRecordIdFieldToIgnore)