From f670f5021134e897937f48b4a89b86701f388c3a Mon Sep 17 00:00:00 2001
From: "d.buechler" <d.buechler@adito.de>
Date: Tue, 3 Dec 2019 11:31:14 +0100
Subject: [PATCH] Fixed Bug in GetUnrelatedRelationsForDuplicate Removed all
 loggings Changed the constraint on nullable=false on Column CLUSTERID in
 unrelatedDuplicates. This is necessary because of the live view of the
 duplicates. If the duplicates arent determined beforehand and sorted into
 clusters, the creation of a unrelated relation would fail because the used
 duplicate is not in a cluster

---
 .../Duplicates/create_unrelatedDuplicates.xml    |  4 +---
 process/DuplicateScanner_lib/process.js          | 16 ++++++----------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/.liquibase/Data_alias/basic/2019.2.1/Duplicates/create_unrelatedDuplicates.xml b/.liquibase/Data_alias/basic/2019.2.1/Duplicates/create_unrelatedDuplicates.xml
index aff186e25c..639ac544c4 100644
--- a/.liquibase/Data_alias/basic/2019.2.1/Duplicates/create_unrelatedDuplicates.xml
+++ b/.liquibase/Data_alias/basic/2019.2.1/Duplicates/create_unrelatedDuplicates.xml
@@ -11,9 +11,7 @@
             <column name="UNRELATEDDUPLICATEID" type="CHAR(36)" >
                 <constraints nullable="false"/>
             </column>
-            <column name="CLUSTERID" type="CHAR(36)" >
-                <constraints nullable="false"/>
-            </column>
+            <column name="CLUSTERID" type="CHAR(36)" />
         </createTable>
     </changeSet>
 </databaseChangeLog>
\ No newline at end of file
diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js
index e7c815e35e..4e06686112 100644
--- a/process/DuplicateScanner_lib/process.js
+++ b/process/DuplicateScanner_lib/process.js
@@ -740,7 +740,7 @@ DuplicateScannerUtils.BuildEntityFieldConfigValueRays = function(pDuplicateField
         }
         
         let valuelength = fieldConfig.length; 
-        logging.log(valuelength)
+
         if ( valuelength )
             entityFieldValue = entityFieldValue.substr(0, parseInt(valuelength)) + "*";
         
@@ -777,22 +777,18 @@ DuplicateScannerUtils.GetUnrelatedRelationsForDuplicate = function(pDuplicateId)
                 .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;
+        sourceDuplicateId = duplicateIds[i][0];
+        unrelatedDuplicateId = duplicateIds[i][1];
         
-        if(sourceDuplicateId != null && sourceDuplicateId != "")
+        if(sourceDuplicateId != null && sourceDuplicateId != "" && sourceDuplicateId != pDuplicateId)
         {
             unrelatedIds.push(sourceDuplicateId);
         }
-        else if(unrelatedDuplicateId != null && unrelatedDuplicateId != "")
+        else if(unrelatedDuplicateId != null && unrelatedDuplicateId != "" && unrelatedDuplicateId != pDuplicateId)
         {
             unrelatedIds.push(unrelatedDuplicateId);
         }
@@ -934,7 +930,7 @@ _DuplicateScannerUtils._isUseExternalWebservice = function(pFilterName, pTargetE
  */
 _DuplicateScannerUtils._callIndexSearch = function(pTargetEntity, pIndexPatternWithValues, pResultFields, pResultSetRows)
 {
-    logging.log(pIndexPatternWithValues)
+//    logging.log(pIndexPatternWithValues)
     //The indexPattern can't be null because it is required to run the search.
     if(pIndexPatternWithValues == null || pIndexPatternWithValues == "")
         return null;
-- 
GitLab