From e0f7d156573d4dda0e9f02f8005e13b621278573 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            | 14 +++++---------
 2 files changed, 6 insertions(+), 12 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 6e10377791..2ea26a9c22 100644
--- a/process/DuplicateScanner_lib/process.js
+++ b/process/DuplicateScanner_lib/process.js
@@ -752,7 +752,7 @@ DuplicateScannerUtils.BuildEntityFieldConfigValueRays = function(pDuplicateField
         }
         
         let valuelength = fieldConfig.length; 
-        logging.log(valuelength)
+
         if ( valuelength )
             entityFieldValue = entityFieldValue.substr(0, parseInt(valuelength)) + "*";
         
@@ -789,22 +789,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);
         }
-- 
GitLab