From 353c75e9f10c991d570d73e4362d4afc13c92770 Mon Sep 17 00:00:00 2001
From: "d.buechler" <d.buechler@adito.de>
Date: Mon, 2 Dec 2019 15:57:42 +0100
Subject: [PATCH] Removed the tabs which displayed the cached duplicates for a
 particular person/organisation Consumer of uncached duplicates doesnt load
 all entity fields via project.getstructure, instead it only loads the fields
 mentioned in the configurated pattern

---
 .../Organisation_entity.aod                   | 22 ----------------
 .../valueProcess.js                           |  2 --
 .../valueProcess.js                           |  3 ---
 .../onlyshowcontactids_param/valueProcess.js  | 18 -------------
 .../onlyshowcontactids_param/valueProcess.js  | 25 ++++++++++---------
 entity/Person_entity/Person_entity.aod        | 22 ----------------
 .../valueProcess.js                           |  2 --
 .../valueProcess.js                           |  3 ---
 .../onlyshowcontactids_param/valueProcess.js  | 18 -------------
 .../onlyshowcontactids_param/valueProcess.js  | 23 ++++++++---------
 .../OrganisationMain_view.aod                 |  2 +-
 neonView/PersonMain_view/PersonMain_view.aod  |  2 +-
 process/DuplicateScanner_lib/process.js       |  6 +++++
 13 files changed, 31 insertions(+), 117 deletions(-)
 delete mode 100644 entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicateactionscontrol_param/valueProcess.js
 delete mode 100644 entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicatecurrentcontactid_param/valueProcess.js
 delete mode 100644 entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/onlyshowcontactids_param/valueProcess.js
 delete mode 100644 entity/Person_entity/entityfields/selfduplicates/children/duplicateactionscontrol_param/valueProcess.js
 delete mode 100644 entity/Person_entity/entityfields/selfduplicates/children/duplicatecurrentcontactid_param/valueProcess.js
 delete mode 100644 entity/Person_entity/entityfields/selfduplicates/children/onlyshowcontactids_param/valueProcess.js

diff --git a/entity/Organisation_entity/Organisation_entity.aod b/entity/Organisation_entity/Organisation_entity.aod
index b66a7a2379..76cce88c02 100644
--- a/entity/Organisation_entity/Organisation_entity.aod
+++ b/entity/Organisation_entity/Organisation_entity.aod
@@ -914,28 +914,6 @@
       <name>SelfDuplicatesProvider</name>
       <titlePlural>Duplicates</titlePlural>
     </entityProvider>
-    <entityConsumer>
-      <name>SelfDuplicatesConsumer</name>
-      <dependency>
-        <name>dependency</name>
-        <entityName>Organisation_entity</entityName>
-        <fieldName>SelfDuplicatesProvider</fieldName>
-      </dependency>
-      <children>
-        <entityParameter>
-          <name>OnlyShowContactIds_param</name>
-          <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/onlyshowcontactids_param/valueProcess.js</valueProcess>
-        </entityParameter>
-        <entityParameter>
-          <name>DuplicateCurrentContactId_param</name>
-          <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicatecurrentcontactid_param/valueProcess.js</valueProcess>
-        </entityParameter>
-        <entityParameter>
-          <name>DuplicateActionsControl_param</name>
-          <valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicateactionscontrol_param/valueProcess.js</valueProcess>
-        </entityParameter>
-      </children>
-    </entityConsumer>
     <entityParameter>
       <name>OnlyShowContactIds_param</name>
       <expose v="true" />
diff --git a/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicateactionscontrol_param/valueProcess.js b/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicateactionscontrol_param/valueProcess.js
deleted file mode 100644
index 81570217c3..0000000000
--- a/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicateactionscontrol_param/valueProcess.js
+++ /dev/null
@@ -1,2 +0,0 @@
-import("system.result");
-result.string("1");//todo use keyword
\ No newline at end of file
diff --git a/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicatecurrentcontactid_param/valueProcess.js b/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicatecurrentcontactid_param/valueProcess.js
deleted file mode 100644
index 821415ae69..0000000000
--- a/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicatecurrentcontactid_param/valueProcess.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import("system.vars");
-import("system.result");
-result.string(vars.get("$field.CONTACTID"));
\ No newline at end of file
diff --git a/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/onlyshowcontactids_param/valueProcess.js b/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/onlyshowcontactids_param/valueProcess.js
deleted file mode 100644
index fa8ef63877..0000000000
--- a/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/onlyshowcontactids_param/valueProcess.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import("system.logging");
-import("system.vars");
-import("DuplicateScanner_lib");
-import("system.result");
-
-let contactIdToCheck = vars.get("$field.CONTACTID");
-
-let duplicateIds = DuplicateScannerUtils.GetCachedDuplicatesForDuplicateId(contactIdToCheck);
-
-/*
- * 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(duplicateIds.length == 0)
-    result.string(JSON.stringify(["nodata"]));
-else
-    result.string(JSON.stringify(duplicateIds));
\ 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 f3168178a3..4024668e40 100644
--- a/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js
+++ b/entity/Organisation_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js
@@ -5,29 +5,30 @@ import("system.vars");
 import("DuplicateScanner_lib");
 import("system.result");
 
+let scannerName = "OrganisationDuplicates";
 let targetEntity = "Organisation_entity";
 let valuesToCheck = {};
-var entityModel = project.getEntityStructure(targetEntity);
+var entityFieldsToLoad = DuplicateScannerUtils.GetEntityFieldsFromConfig(scannerName, targetEntity);
+//project.getEntityStructure(targetEntity);
 
- //Read the values of all available entity fields and write the fieldname/value combination
+ //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
 let fieldValue = "";
 let entityFields = [];
-for (fieldname in entityModel.fields) 
+for (fieldname in entityFieldsToLoad) 
 { 
-    field = entityModel.fields[fieldname]; 
-    if(field.fieldType == project.ENTITYFIELDTYPE_FIELD)
+    field = entityFieldsToLoad[fieldname]; 
+    fieldValue = vars.get("$field." + field.name);
+
+    if(fieldValue != null && fieldValue != "")
     {
-        fieldValue = vars.get("$field." + field.name);
-        
-        if(fieldValue != null && fieldValue != "")
-        {
-            valuesToCheck[field.name] = fieldValue;
-        }
+        valuesToCheck[field.name] = fieldValue;
     }
 }
-let scanResults = DuplicateScannerUtils.ScanForDuplicates("OrganisationDuplicates", targetEntity,
+
+let scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity,
 valuesToCheck, null);
+
 let duplicateIds = [];
 
 if(scanResults != undefined && scanResults != null)
diff --git a/entity/Person_entity/Person_entity.aod b/entity/Person_entity/Person_entity.aod
index 2934d74521..5796e1ce02 100644
--- a/entity/Person_entity/Person_entity.aod
+++ b/entity/Person_entity/Person_entity.aod
@@ -999,28 +999,6 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
       <name>OnlyShowContactIds_param</name>
       <expose v="true" />
     </entityParameter>
-    <entityConsumer>
-      <name>SelfDuplicates</name>
-      <dependency>
-        <name>dependency</name>
-        <entityName>Person_entity</entityName>
-        <fieldName>SelfDuplicatesProvider</fieldName>
-      </dependency>
-      <children>
-        <entityParameter>
-          <name>OnlyShowContactIds_param</name>
-          <valueProcess>%aditoprj%/entity/Person_entity/entityfields/selfduplicates/children/onlyshowcontactids_param/valueProcess.js</valueProcess>
-        </entityParameter>
-        <entityParameter>
-          <name>DuplicateCurrentContactId_param</name>
-          <valueProcess>%aditoprj%/entity/Person_entity/entityfields/selfduplicates/children/duplicatecurrentcontactid_param/valueProcess.js</valueProcess>
-        </entityParameter>
-        <entityParameter>
-          <name>DuplicateActionsControl_param</name>
-          <valueProcess>%aditoprj%/entity/Person_entity/entityfields/selfduplicates/children/duplicateactionscontrol_param/valueProcess.js</valueProcess>
-        </entityParameter>
-      </children>
-    </entityConsumer>
     <entityProvider>
       <name>SelfDuplicatesProvider</name>
       <titlePlural>Duplicates</titlePlural>
diff --git a/entity/Person_entity/entityfields/selfduplicates/children/duplicateactionscontrol_param/valueProcess.js b/entity/Person_entity/entityfields/selfduplicates/children/duplicateactionscontrol_param/valueProcess.js
deleted file mode 100644
index 81570217c3..0000000000
--- a/entity/Person_entity/entityfields/selfduplicates/children/duplicateactionscontrol_param/valueProcess.js
+++ /dev/null
@@ -1,2 +0,0 @@
-import("system.result");
-result.string("1");//todo use keyword
\ No newline at end of file
diff --git a/entity/Person_entity/entityfields/selfduplicates/children/duplicatecurrentcontactid_param/valueProcess.js b/entity/Person_entity/entityfields/selfduplicates/children/duplicatecurrentcontactid_param/valueProcess.js
deleted file mode 100644
index 821415ae69..0000000000
--- a/entity/Person_entity/entityfields/selfduplicates/children/duplicatecurrentcontactid_param/valueProcess.js
+++ /dev/null
@@ -1,3 +0,0 @@
-import("system.vars");
-import("system.result");
-result.string(vars.get("$field.CONTACTID"));
\ No newline at end of file
diff --git a/entity/Person_entity/entityfields/selfduplicates/children/onlyshowcontactids_param/valueProcess.js b/entity/Person_entity/entityfields/selfduplicates/children/onlyshowcontactids_param/valueProcess.js
deleted file mode 100644
index fa8ef63877..0000000000
--- a/entity/Person_entity/entityfields/selfduplicates/children/onlyshowcontactids_param/valueProcess.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import("system.logging");
-import("system.vars");
-import("DuplicateScanner_lib");
-import("system.result");
-
-let contactIdToCheck = vars.get("$field.CONTACTID");
-
-let duplicateIds = DuplicateScannerUtils.GetCachedDuplicatesForDuplicateId(contactIdToCheck);
-
-/*
- * 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(duplicateIds.length == 0)
-    result.string(JSON.stringify(["nodata"]));
-else
-    result.string(JSON.stringify(duplicateIds));
\ 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 476e86c009..b352b88a57 100644
--- a/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js
+++ b/entity/Person_entity/entityfields/selfduplicatesuncached/children/onlyshowcontactids_param/valueProcess.js
@@ -5,31 +5,28 @@ import("system.vars");
 import("DuplicateScanner_lib");
 import("system.result");
 
+let scannerName = "PersonDuplicates";
 let targetEntity = "Person_entity";
 let valuesToCheck = {};
-var entityModel = project.getEntityStructure(targetEntity);
+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
 let fieldValue = "";
 let entityFields = [];
-for (fieldname in entityModel.fields) 
+for (fieldname in entityFieldsToLoad) 
 { 
-    field = entityModel.fields[fieldname]; 
-    if(field.fieldType == project.ENTITYFIELDTYPE_FIELD)
+    field = entityFieldsToLoad[fieldname]; 
+    fieldValue = vars.get("$field." + field.name);
+
+    if(fieldValue != null && fieldValue != "")
     {
-        fieldValue = vars.get("$field." + field.name);
-        
-        if(fieldValue != null && fieldValue != "")
-        {
-//            logging.log("field.name -> " + field.name);
-            valuesToCheck[field.name] = fieldValue;
-//            logging.log("field value -> " + fieldValue);
-        }
+        valuesToCheck[field.name] = fieldValue;
     }
 }
 
-let scanResults = DuplicateScannerUtils.ScanForDuplicates("PersonDuplicates", targetEntity,
+let scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity,
 valuesToCheck, null);
 
 let duplicateIds = [];
diff --git a/neonView/OrganisationMain_view/OrganisationMain_view.aod b/neonView/OrganisationMain_view/OrganisationMain_view.aod
index 8e50548035..db111a3765 100644
--- a/neonView/OrganisationMain_view/OrganisationMain_view.aod
+++ b/neonView/OrganisationMain_view/OrganisationMain_view.aod
@@ -62,7 +62,7 @@
     </neonViewReference>
     <neonViewReference>
       <name>cbac7602-9eba-4e5d-8617-3d0b33e55ca1</name>
-      <entityField>SelfDuplicatesConsumer</entityField>
+      <entityField>SelfDuplicatesUncached</entityField>
       <view>OrganisationFilter_view</view>
     </neonViewReference>
   </children>
diff --git a/neonView/PersonMain_view/PersonMain_view.aod b/neonView/PersonMain_view/PersonMain_view.aod
index 88a8e5367f..1c44780e94 100644
--- a/neonView/PersonMain_view/PersonMain_view.aod
+++ b/neonView/PersonMain_view/PersonMain_view.aod
@@ -61,7 +61,7 @@
     </neonViewReference>
     <neonViewReference>
       <name>d128a678-b1c0-49d0-a74c-7860d3a85247</name>
-      <entityField>SelfDuplicates</entityField>
+      <entityField>SelfDuplicatesUncached</entityField>
       <view>PersonFilter_view</view>
     </neonViewReference>
   </children>
diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js
index 4d090a9a62..190b3733aa 100644
--- a/process/DuplicateScanner_lib/process.js
+++ b/process/DuplicateScanner_lib/process.js
@@ -771,6 +771,12 @@ DuplicateScannerUtils.GetBlockSize = function()
     return project.getPreferenceValue("custom.duplicates.dataBlockSize", "5000");
 }
 
+DuplicateScannerUtils.GetEntityFieldsFromConfig = function(pFilterName, pTargetEntity)
+{
+    let indexPattern = _DuplicateScannerUtils._loadIndexPattern(pFilterName, pTargetEntity);
+    let fieldConfigs = _DuplicateScannerUtils._loadEntityFieldConfigsFromPattern(indexPattern);
+    return _DuplicateScannerUtils._loadEntityFieldsFromFieldConfigs(fieldConfigs);
+}
 
 function _DuplicateScannerUtils() {}
 
-- 
GitLab