From 8fc453a77f4b5a3d6270b5d90cb9184b6e71ae61 Mon Sep 17 00:00:00 2001 From: "d.buechler" <d.buechler@adito.de> Date: Mon, 2 Sep 2019 15:48:02 +0200 Subject: [PATCH] =?UTF-8?q?Werden=20Cluster=20auf=20der=20=C3=9Cbersichtss?= =?UTF-8?q?eite=20ignoriert,=20wird=20nun=20kein=20Fehler=20mehr=20geworfe?= =?UTF-8?q?n.=20Tempor=C3=A4re=20fixes,=20TobiF=20fragen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aliasDefinition/Data_alias/Data_alias.aod | 1 - .../ignorewholecluster/onActionProcess.js | 4 + .../recordcontainer/contentProcess.js | 168 ++++++++++-------- process/DuplicateScanner_lib/process.js | 4 +- 4 files changed, 100 insertions(+), 77 deletions(-) diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod index c113c1042ac..85f669d76b5 100644 --- a/aliasDefinition/Data_alias/Data_alias.aod +++ b/aliasDefinition/Data_alias/Data_alias.aod @@ -7589,7 +7589,6 @@ <entityDb> <name>AB_LOGHISTORY</name> <dbName></dbName> - <idColumn>AB_LOGHISTORYID</idColumn> <idGeneratorType v="0" /> <idGeneratorInterval v="1" /> <documentation></documentation> diff --git a/entity/Duplicates_entity/entityfields/duplicateclusteractiongroup/children/ignorewholecluster/onActionProcess.js b/entity/Duplicates_entity/entityfields/duplicateclusteractiongroup/children/ignorewholecluster/onActionProcess.js index 29247963878..115c4e363f0 100644 --- a/entity/Duplicates_entity/entityfields/duplicateclusteractiongroup/children/ignorewholecluster/onActionProcess.js +++ b/entity/Duplicates_entity/entityfields/duplicateclusteractiongroup/children/ignorewholecluster/onActionProcess.js @@ -17,6 +17,10 @@ if(duplicateContactIdsInClusterRay.length > 1) } //notification.createConfig().notificationType(notification.t) //neon.refresh(["$field.SelfPersonDuplicatesConsumer"]) + + //todo Temporary!!! In the first refresh is the record via idValue selected and gets refreshed but stays visible in the record container + //todo Temporary!!! on the second refresh, no selecten remains and the container loads the remaining records as expected + neon.refreshAll(); neon.refreshAll(); } diff --git a/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js b/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js index 664ef1ce83f..4e268d83ca3 100644 --- a/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js +++ b/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js @@ -16,90 +16,108 @@ let selectedClusterId = vars.get("$param.ClusterId_param"); let duplicateInfosQuery = ""; -if(targetEntity == "Person_entity") +let selectedId = vars.get("$local.idvalues"); +logging.log("selectedId -> " + selectedId); +if(selectedId) { - - duplicateInfosQuery = SqlCondition.begin() - .and("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)") - - if(selectedClusterId) - duplicateInfosQuery = duplicateInfosQuery.and("DUPLICATECLUSTERS.CLUSTERID = '" + selectedClusterId + "'") - - duplicateInfosQuery = duplicateInfosQuery.buildSql("select CLUSTERID, FIRSTNAME, LASTNAME" - + " from DUPLICATECLUSTERS" - + " join CONTACT on CONTACT.CONTACTID = DUPLICATEID" - + " join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID", "1=2", " ORDER BY CLUSTERID"); + /* + * Definitely a todo. + * Support for the action "Ignore whole cluster" + * If this action is used two times in a row, an error occurs on the second time. + * Although the selected record isn't present in the recordcontainer any more, the core tries to load a record with the same id. + * As a result an error gets thrown. If a dummy record gets returned here, it plays along with the current internal logic and doesn't throw an error. + * If a preview should be shown, this part of the container has to be extended. + */ + duplicates.push([selectedId, "", "", "", ""]); + result.object(duplicates); } else { - duplicateInfosQuery = SqlCondition.begin() - .and("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)") - .andIn("DUPLICATECLUSTERS.CLUSTERID", vars.get("$local.idvalues")) - .buildSql("select CLUSTERID, ORGANISATION.\"NAME\"" - + " from DUPLICATECLUSTERS" - + " join CONTACT on CONTACT.CONTACTID = DUPLICATEID" - + " join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.CONTACTID", "1=2", " ORDER BY CLUSTERID"); -} - -let duplicateInfos = db.table(duplicateInfosQuery); - -let recordClusterId = ""; -let recordDescription = ""; -let recordDuplicateInClusterCount = 0; - -for (let i = 0; i < duplicateInfos.length; i++) -{ - let currentClusterId = duplicateInfos[i][INDEX_CLUSTERID]; - let currentDescription = ""; - - //Build the description depending on the targetEntity + logging.log("was nun -> "); if(targetEntity == "Person_entity") - currentDescription = duplicateInfos[i][INDEX_FIRSTNAME] + " " + duplicateInfos[i][INDEX_LASTNAME]; - else - currentDescription = duplicateInfos[i][INDEX_ORGNAME]; - - if(i == 0) { - recordClusterId = currentClusterId; - recordDescription = currentDescription; - 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) - { - recordDescription += ", " + currentDescription; - recordDuplicateInClusterCount++; - - /* - * Finish the current record if its the last duplicate. - * It has to be checked wether or not more than one element is currently in the cluster: - * Normally, there are always at least 2 elements in a cluster. If then a duplicate relation - * is beign ignored, there's only one record left in this particluar cluster. - * 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([recordClusterId, recordDescription, recordDuplicateInClusterCount, targetEntity, recordClusterId]); + duplicateInfosQuery = SqlCondition.begin() + .and("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)") + + if(selectedClusterId) + duplicateInfosQuery = duplicateInfosQuery.and("DUPLICATECLUSTERS.CLUSTERID = '" + selectedClusterId + "'") + + duplicateInfosQuery = duplicateInfosQuery.buildSql("select CLUSTERID, FIRSTNAME, LASTNAME" + + " from DUPLICATECLUSTERS" + + " join CONTACT on CONTACT.CONTACTID = DUPLICATEID" + + " join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID", "1=2", " ORDER BY CLUSTERID"); } else { - /* - * Finish the current record if its the next cluster. - * It has to be checked wether or not more than one element is currently in the cluster: - * Normally, there are always at least 2 elements in a cluster. If then a duplicate relation - * is beign ignored, there's only one record left in this particluar cluster. - * 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([recordClusterId, recordDescription, recordDuplicateInClusterCount, targetEntity, recordClusterId]); - - recordClusterId = currentClusterId - recordDescription = currentDescription - recordDuplicateInClusterCount = 1; + duplicateInfosQuery = SqlCondition.begin() + .and("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)") + .andIn("DUPLICATECLUSTERS.CLUSTERID", vars.get("$local.idvalues")) + .buildSql("select CLUSTERID, ORGANISATION.\"NAME\"" + + " from DUPLICATECLUSTERS" + + " join CONTACT on CONTACT.CONTACTID = DUPLICATEID" + + " join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.CONTACTID", "1=2", " ORDER BY CLUSTERID"); + } + + let duplicateInfos = db.table(duplicateInfosQuery); + + let recordClusterId = ""; + let recordDescription = ""; + let recordDuplicateInClusterCount = 0; + + for (let i = 0; i < duplicateInfos.length; i++) + { + let currentClusterId = duplicateInfos[i][INDEX_CLUSTERID]; + let currentDescription = ""; + + //Build the description depending on the targetEntity + if(targetEntity == "Person_entity") + currentDescription = duplicateInfos[i][INDEX_FIRSTNAME] + " " + duplicateInfos[i][INDEX_LASTNAME]; + else + currentDescription = duplicateInfos[i][INDEX_ORGNAME]; + + if(i == 0) + { + recordClusterId = currentClusterId; + recordDescription = currentDescription; + 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) + { + recordDescription += ", " + currentDescription; + recordDuplicateInClusterCount++; + + /* + * Finish the current record if its the last duplicate. + * It has to be checked wether or not more than one element is currently in the cluster: + * Normally, there are always at least 2 elements in a cluster. If then a duplicate relation + * is beign ignored, there's only one record left in this particluar cluster. + * 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([recordClusterId, recordDescription, recordDuplicateInClusterCount, targetEntity, recordClusterId]); + } + else + { + /* + * Finish the current record if its the next cluster. + * It has to be checked wether or not more than one element is currently in the cluster: + * Normally, there are always at least 2 elements in a cluster. If then a duplicate relation + * is beign ignored, there's only one record left in this particluar cluster. + * 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([recordClusterId, recordDescription, recordDuplicateInClusterCount, targetEntity, recordClusterId]); + + recordClusterId = currentClusterId + recordDescription = currentDescription + recordDuplicateInClusterCount = 1; + } } + + result.object(duplicates); } - -logging.log("duplicates -> " + JSON.stringify(duplicates)); -result.object(duplicates); \ No newline at end of file diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js index 24dab1caf71..4239a644ee3 100644 --- a/process/DuplicateScanner_lib/process.js +++ b/process/DuplicateScanner_lib/process.js @@ -15,7 +15,8 @@ import("Sql_lib"); */ function DuplicateScannerUtils() {} -DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, pFilterValues, pTargetEntityResultFields, pRecordIdFieldToIgnore, pRecordIdValueToIgnore) +DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, pFilterValues, +pTargetEntityResultFields, pRecordIdFieldToIgnore, pRecordIdValueToIgnore) { let ignoredRecordFilter = _DuplicateScannerUtils._getIgnoreRecordFilter(pRecordIdFieldToIgnore, pRecordIdValueToIgnore, pTargetEntity); let configuredFilters = _DuplicateScannerUtils._loadFilters(pFilterName, pTargetEntity); @@ -642,6 +643,7 @@ _DuplicateScannerUtils._insertValuesInFilterTemplate = function(pJsonRootNode, p let fieldValue = pEntitiyFieldAndValueMap[fieldName]; pCountCharsOfValueToUse = parseInt(pCountCharsOfValueToUse, 10); + logging.log("fieldValue -> " + JSON.stringify(pEntitiyFieldAndValueMap)); if(fieldValue == null) { logging.show("Duplicate Scan: Requested value for field " + fieldName + " not present in the provided valueslist"); -- GitLab