From 4921dd1c8d3f391c0ba855a6a8de6d9cb4e2cd52 Mon Sep 17 00:00:00 2001
From: "d.buechler" <d.buechler@adito.de>
Date: Fri, 23 Aug 2019 11:03:34 +0200
Subject: [PATCH] =?UTF-8?q?Aktion=20eingef=C3=BCgt,=20dass=20ganze=20Clust?=
 =?UTF-8?q?er=20auf=20einmal=20ignoriert=20werden=20k=C3=B6nnen.=20Logausg?=
 =?UTF-8?q?aben=20entfernt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../Duplicates_entity/Duplicates_entity.aod   | 11 ++++++++++
 .../ignorewholecluster/onActionProcess.js     | 22 +++++++++++++++++++
 .../onlyshowcontactids_param/valueProcess.js  |  2 +-
 .../children/clusterid_param/valueProcess.js  |  2 --
 .../children/targetentity/valueProcess.js     |  2 --
 .../recordcontainer/contentProcess.js         |  3 +--
 .../recordcontainers/db/conditionProcess.js   |  2 +-
 .../PersonDuplicatesFilter_view.aod           |  2 ++
 process/DuplicateScanner_lib/process.js       | 12 ++++++++--
 9 files changed, 48 insertions(+), 10 deletions(-)
 create mode 100644 entity/Duplicates_entity/entityfields/duplicateclusteractiongroup/children/ignorewholecluster/onActionProcess.js

diff --git a/entity/Duplicates_entity/Duplicates_entity.aod b/entity/Duplicates_entity/Duplicates_entity.aod
index 01053a50ee..186cff25d1 100644
--- a/entity/Duplicates_entity/Duplicates_entity.aod
+++ b/entity/Duplicates_entity/Duplicates_entity.aod
@@ -106,6 +106,17 @@
         </entityParameter>
       </children>
     </entityConsumer>
+    <entityActionGroup>
+      <name>DuplicateClusterActionGroup</name>
+      <children>
+        <entityActionField>
+          <name>IgnoreWholeCluster</name>
+          <title>Ignore whole Cluster</title>
+          <onActionProcess>%aditoprj%/entity/Duplicates_entity/entityfields/duplicateclusteractiongroup/children/ignorewholecluster/onActionProcess.js</onActionProcess>
+          <iconId>VAADIN:CLOSE</iconId>
+        </entityActionField>
+      </children>
+    </entityActionGroup>
   </entityFields>
   <recordContainers>
     <jDitoRecordContainer>
diff --git a/entity/Duplicates_entity/entityfields/duplicateclusteractiongroup/children/ignorewholecluster/onActionProcess.js b/entity/Duplicates_entity/entityfields/duplicateclusteractiongroup/children/ignorewholecluster/onActionProcess.js
new file mode 100644
index 0000000000..55999e01b7
--- /dev/null
+++ b/entity/Duplicates_entity/entityfields/duplicateclusteractiongroup/children/ignorewholecluster/onActionProcess.js
@@ -0,0 +1,22 @@
+import("system.logging");
+import("system.neon");
+import("system.vars");
+import("DuplicateScanner_lib");
+import("system.notification");
+
+let clusterId = vars.get("$sys.selection");
+
+let duplicateContactIdsInClusterRay = DuplicateScannerUtils.GetCachedDuplicatesForClusterId(clusterId)
+
+if(duplicateContactIdsInClusterRay.length > 1)
+{
+    let referenceDuplicateId = duplicateContactIdsInClusterRay[0];
+    for (let i = 1; i < duplicateContactIdsInClusterRay.length; i++) 
+    {
+        DuplicateScannerUtils.CreateUnrelatedDuplicateRelation(referenceDuplicateId, duplicateContactIdsInClusterRay[i], clusterId);
+    }
+    //notification.createConfig().notificationType(notification.t)
+    //neon.refreshAll();
+}
+
+
diff --git a/entity/Duplicates_entity/entityfields/duplicatepersonsconsumer/children/onlyshowcontactids_param/valueProcess.js b/entity/Duplicates_entity/entityfields/duplicatepersonsconsumer/children/onlyshowcontactids_param/valueProcess.js
index be997d2e02..918a8f2f26 100644
--- a/entity/Duplicates_entity/entityfields/duplicatepersonsconsumer/children/onlyshowcontactids_param/valueProcess.js
+++ b/entity/Duplicates_entity/entityfields/duplicatepersonsconsumer/children/onlyshowcontactids_param/valueProcess.js
@@ -6,7 +6,7 @@ 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.
diff --git a/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/clusterid_param/valueProcess.js b/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/clusterid_param/valueProcess.js
index a2437e4fe7..152dfe0324 100644
--- a/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/clusterid_param/valueProcess.js
+++ b/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/clusterid_param/valueProcess.js
@@ -1,7 +1,5 @@
-import("system.logging");
 import("system.vars");
 import("system.result");
 
 let clusterId = vars.get("$field.UID");
-logging.log("duplicatesunrelatedpersonsconsumer clusterId -> " + clusterId);
 result.string(clusterId);
\ No newline at end of file
diff --git a/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/targetentity/valueProcess.js b/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/targetentity/valueProcess.js
index 4d238b29d4..f8b07f56ab 100644
--- a/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/targetentity/valueProcess.js
+++ b/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/targetentity/valueProcess.js
@@ -1,6 +1,4 @@
 import("system.vars");
-import("system.logging");
 import("system.result");
 
-logging.log("consumer  selection -> " + vars.get("$sys.selection"));
 result.string("Person_entity");
\ 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 84018ae8fd..b41c7170c7 100644
--- a/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js
+++ b/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js
@@ -13,7 +13,6 @@ let targetEntity = vars.get("$param.TargetEntity");
 let duplicates = [];
 
 let test = vars.get("$local.idvalues");
-logging.log("test -> " + test);
 
 let duplicateInfosQuery = "";
 
@@ -33,7 +32,7 @@ else
     duplicateInfosQuery = "orgquery";
                     
 let duplicateInfos = db.table(duplicateInfosQuery);
-logging.log("duplicateInfos -> " + JSON.stringify(duplicateInfos));
+
 let recordClusterId = "";
 let recordDescription = "";
 let recordDuplicateInClusterCount = 0;
diff --git a/entity/Person_entity/recordcontainers/db/conditionProcess.js b/entity/Person_entity/recordcontainers/db/conditionProcess.js
index 79f11bba47..617f399b00 100644
--- a/entity/Person_entity/recordcontainers/db/conditionProcess.js
+++ b/entity/Person_entity/recordcontainers/db/conditionProcess.js
@@ -34,6 +34,6 @@ if(onlyShowContactIds != null && onlyShowContactIds.length > 0)
     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/neonView/PersonDuplicatesFilter_view/PersonDuplicatesFilter_view.aod b/neonView/PersonDuplicatesFilter_view/PersonDuplicatesFilter_view.aod
index aa244f7a44..10b5a46f60 100644
--- a/neonView/PersonDuplicatesFilter_view/PersonDuplicatesFilter_view.aod
+++ b/neonView/PersonDuplicatesFilter_view/PersonDuplicatesFilter_view.aod
@@ -10,6 +10,8 @@
   <children>
     <tableViewTemplate>
       <name>PersonDuplicatesTable</name>
+      <favoriteActionGroup2>DuplicateClusterActionGroup</favoriteActionGroup2>
+      <hideContentSearch v="true" />
       <entityField>#ENTITY</entityField>
       <isCreatable v="false" />
       <isEditable v="false" />
diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js
index 9602fba3f0..956343f485 100644
--- a/process/DuplicateScanner_lib/process.js
+++ b/process/DuplicateScanner_lib/process.js
@@ -109,13 +109,21 @@ DuplicateScannerUtils.GetCachedDuplicatesForContactId = function(pDuplicateId)
     return db.array(db.COLUMN, querySelectDuplicateContactIds);
 }
 
+/*
+ * Returns all duplicate ids which haven't been marked as unrelated for the given cluster id.
+ * 
+ * @return Array of ContactIds of duplicates not including those marked as unrelated
+ */
 DuplicateScannerUtils.GetCachedDuplicatesForClusterId = function(pClusterId)
 {
+    let clusterIdRay = [];
+    clusterIdRay.push(pClusterId);
+    
     let duplicateIdsOfClusterWithoutUnrelated = SqlCondition.begin()
     .and("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)")
-    .andIn("DUPLICATECLUSTERS.CLUSTERID", [pClusterId])
+    .and("DUPLICATECLUSTERS.CLUSTERID = '" + clusterIdRay + "'")
     .buildSql("select DUPLICATEID from DUPLICATECLUSTERS");
-     
+    
     return db.array(db.COLUMN, duplicateIdsOfClusterWithoutUnrelated);
 }
 
-- 
GitLab