From 8e5d1b26d497a811b94bd1d4d84207958ee7d910 Mon Sep 17 00:00:00 2001
From: "d.buechler" <d.buechler@adito.de>
Date: Wed, 21 Aug 2019 10:37:50 +0200
Subject: [PATCH] =?UTF-8?q?Ignorierte=20Dubletten=20Treffer=20werden=20nun?=
 =?UTF-8?q?=20in=20einem=20separaten=20Entity=20ermittelt=20und=20auf=20de?=
 =?UTF-8?q?r=20Dubletten=C3=BCbersichtsseite=20angezeigt.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../DuplicatesUnrelated_entity.aod            | 80 +++++++++----------
 .../jditorecordcontainer/contentProcess.js    | 39 +++++++++
 .../Duplicates_entity/Duplicates_entity.aod   | 14 ++++
 .../children/targetentity/valueProcess.js     |  2 +
 neonContext/Duplicates/Duplicates.aod         |  4 +
 .../DuplicatesOverview_view.aod               | 11 +--
 .../DuplicatesUnrelatedPersonFilter_view.aod  | 18 +++++
 .../PersonDublicatesTab_view.aod              | 24 ++++++
 8 files changed, 144 insertions(+), 48 deletions(-)
 create mode 100644 entity/DuplicatesUnrelated_entity/recordcontainers/jditorecordcontainer/contentProcess.js
 create mode 100644 entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/targetentity/valueProcess.js
 create mode 100644 neonView/PersonDublicatesTab_view/PersonDublicatesTab_view.aod

diff --git a/entity/DuplicatesUnrelated_entity/DuplicatesUnrelated_entity.aod b/entity/DuplicatesUnrelated_entity/DuplicatesUnrelated_entity.aod
index 77c9ac4403..442d4d2c2c 100644
--- a/entity/DuplicatesUnrelated_entity/DuplicatesUnrelated_entity.aod
+++ b/entity/DuplicatesUnrelated_entity/DuplicatesUnrelated_entity.aod
@@ -2,13 +2,20 @@
 <entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.11" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.11">
   <name>DuplicatesUnrelated_entity</name>
   <majorModelMode>DISTRIBUTED</majorModelMode>
-  <recordContainer>recordContainer</recordContainer>
+  <recordContainer>jditoRecordContainer</recordContainer>
   <entityFields>
     <entityProvider>
       <name>#PROVIDER</name>
     </entityProvider>
     <entityProvider>
       <name>UnrelatedPersonsProvider</name>
+      <children>
+        <entityParameter>
+          <name>TargetEntity</name>
+          <expose v="true" />
+          <mandatory v="true" />
+        </entityParameter>
+      </children>
     </entityProvider>
     <entityParameter>
       <name>TargetEntity</name>
@@ -17,47 +24,40 @@
     </entityParameter>
     <entityProvider>
       <name>UnrelatedOrganisationsProvider</name>
+      <children>
+        <entityParameter>
+          <name>TargetEntity</name>
+          <expose v="true" />
+          <mandatory v="true" />
+        </entityParameter>
+      </children>
     </entityProvider>
-    <entityConsumer>
-      <name>UnrelatedPersonsConsumer</name>
-      <dependency>
-        <name>dependency</name>
-      </dependency>
-    </entityConsumer>
-    <entityConsumer>
-      <name>UnrelatedOrganisationsConsumer</name>
-      <dependency>
-        <name>dependency</name>
-      </dependency>
-    </entityConsumer>
+    <entityField>
+      <name>SourceDuplicateDescription</name>
+    </entityField>
+    <entityField>
+      <name>UnrelatedDuplicateDescription</name>
+    </entityField>
+    <entityField>
+      <name>UID</name>
+    </entityField>
   </entityFields>
   <recordContainers>
-    <dbRecordContainer>
-      <name>recordContainer</name>
-      <alias>Data_alias</alias>
-      <linkInformation>
-        <linkInformation>
-          <name>c5e79738-a374-4f09-8bc3-aafe5cd7f582</name>
-          <tableName>UNRELATEDDUPLICATES</tableName>
-          <primaryKey>ID</primaryKey>
-          <isUIDTable v="true" />
-          <readonly v="false" />
-        </linkInformation>
-        <linkInformation>
-          <name>214774c2-bf2f-460e-9931-5cdc27be1b5d</name>
-          <tableName>CONTACT</tableName>
-          <primaryKey>CONTACTID</primaryKey>
-          <isUIDTable v="false" />
-          <readonly v="false" />
-        </linkInformation>
-        <linkInformation>
-          <name>820d9ef7-c3fe-4a0b-9170-5526efccfbae</name>
-          <tableName>PERSON</tableName>
-          <primaryKey>PERSONID</primaryKey>
-          <isUIDTable v="false" />
-          <readonly v="false" />
-        </linkInformation>
-      </linkInformation>
-    </dbRecordContainer>
+    <jDitoRecordContainer>
+      <name>jditoRecordContainer</name>
+      <jDitoRecordAlias>Data_alias</jDitoRecordAlias>
+      <contentProcess>%aditoprj%/entity/DuplicatesUnrelated_entity/recordcontainers/jditorecordcontainer/contentProcess.js</contentProcess>
+      <recordFieldMappings>
+        <jDitoRecordFieldMapping>
+          <name>UID.value</name>
+        </jDitoRecordFieldMapping>
+        <jDitoRecordFieldMapping>
+          <name>SourceDuplicateDescription.value</name>
+        </jDitoRecordFieldMapping>
+        <jDitoRecordFieldMapping>
+          <name>UnrelatedDuplicateDescription.value</name>
+        </jDitoRecordFieldMapping>
+      </recordFieldMappings>
+    </jDitoRecordContainer>
   </recordContainers>
 </entity>
diff --git a/entity/DuplicatesUnrelated_entity/recordcontainers/jditorecordcontainer/contentProcess.js b/entity/DuplicatesUnrelated_entity/recordcontainers/jditorecordcontainer/contentProcess.js
new file mode 100644
index 0000000000..5dcaa82556
--- /dev/null
+++ b/entity/DuplicatesUnrelated_entity/recordcontainers/jditorecordcontainer/contentProcess.js
@@ -0,0 +1,39 @@
+import("system.result");
+import("system.vars");
+import("system.db");
+
+var INDEX_ID = 0;
+var INDEX_SOURCE_INFO1 = 1;
+var INDEX_SOURCE_INFO2 = 2;
+var INDEX_UNRELATED_INFO1 = 3;
+var INDEX_UNRELATED_INFO2 = 4;
+
+let unrelatedDuplicates = [];
+let resultUnrelatedDuplicates = [];
+let targetEntity = vars.get("$param.TargetEntity");
+let query = "";
+if(targetEntity == 'Person_entity')
+{
+    query = "select ud.ID,"
+            + " pSource.FIRSTNAME, pSource.LASTNAME,"
+            + " pUnrelated.FIRSTNAME, pUnrelated.LASTNAME"
+            + " from UNRELATEDDUPLICATES ud"
+            + " join CONTACT cUnrelated on cUnrelated.CONTACTID = ud.UNRELATEDDUPLICATEID"
+            + " join PERSON pUnrelated on pUnrelated.PERSONID = cUnrelated.PERSON_ID"
+            + " join CONTACT cSource on cSource.CONTACTID = ud.SOURCEDUPLICATEID"
+            + " join PERSON pSource on pSource.PERSONID = cSource.PERSON_ID";
+}
+
+unrelatedDuplicates = db.table(query);
+
+for (let i = 0; i < unrelatedDuplicates.length; i++) 
+{
+    let id = unrelatedDuplicates[i][INDEX_ID];
+    let sourceInfo1 = unrelatedDuplicates[i][INDEX_SOURCE_INFO1];
+    let sourceInfo2 = unrelatedDuplicates[i][INDEX_SOURCE_INFO2];
+    let unrelatedInfo1 = unrelatedDuplicates[i][INDEX_UNRELATED_INFO1];
+    let unrelatedInfo2 = unrelatedDuplicates[i][INDEX_UNRELATED_INFO2];
+    
+    resultUnrelatedDuplicates.push([id, sourceInfo1 + " " + sourceInfo2, unrelatedInfo1 + " " + unrelatedInfo2]);
+}
+result.object(resultUnrelatedDuplicates);
\ No newline at end of file
diff --git a/entity/Duplicates_entity/Duplicates_entity.aod b/entity/Duplicates_entity/Duplicates_entity.aod
index c3fcb61abf..3416708185 100644
--- a/entity/Duplicates_entity/Duplicates_entity.aod
+++ b/entity/Duplicates_entity/Duplicates_entity.aod
@@ -71,6 +71,20 @@
       <name>SelfOrganisationDuplicatesProvider</name>
       <titlePlural>Organisation duplicates</titlePlural>
     </entityProvider>
+    <entityConsumer>
+      <name>DuplicatesUnrelatedPersonConsumer</name>
+      <dependency>
+        <name>dependency</name>
+        <entityName>DuplicatesUnrelated_entity</entityName>
+        <fieldName>UnrelatedPersonsProvider</fieldName>
+      </dependency>
+      <children>
+        <entityParameter>
+          <name>TargetEntity</name>
+          <valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/targetentity/valueProcess.js</valueProcess>
+        </entityParameter>
+      </children>
+    </entityConsumer>
   </entityFields>
   <recordContainers>
     <jDitoRecordContainer>
diff --git a/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/targetentity/valueProcess.js b/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/targetentity/valueProcess.js
new file mode 100644
index 0000000000..0f7bee25ea
--- /dev/null
+++ b/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/targetentity/valueProcess.js
@@ -0,0 +1,2 @@
+import("system.result");
+result.string("Person_entity");
\ No newline at end of file
diff --git a/neonContext/Duplicates/Duplicates.aod b/neonContext/Duplicates/Duplicates.aod
index 168f8b176a..198c0374f2 100644
--- a/neonContext/Duplicates/Duplicates.aod
+++ b/neonContext/Duplicates/Duplicates.aod
@@ -18,5 +18,9 @@
       <name>89fb0738-6d12-4bc1-9c4f-bb27c19ae9a3</name>
       <view>OrganisationDuplicatesFilter_view</view>
     </neonViewReference>
+    <neonViewReference>
+      <name>5bdeb931-4e69-4520-bbc9-94fb17679331</name>
+      <view>PersonDublicatesTab_view</view>
+    </neonViewReference>
   </references>
 </neonContext>
diff --git a/neonView/DuplicatesOverview_view/DuplicatesOverview_view.aod b/neonView/DuplicatesOverview_view/DuplicatesOverview_view.aod
index be92bf036f..cdbcf32c67 100644
--- a/neonView/DuplicatesOverview_view/DuplicatesOverview_view.aod
+++ b/neonView/DuplicatesOverview_view/DuplicatesOverview_view.aod
@@ -9,14 +9,9 @@
   </layout>
   <children>
     <neonViewReference>
-      <name>a858aa7c-a751-4e99-87df-08ae3d1ea1b9</name>
-      <entityField>SelfPersonDuplicatesConsumer</entityField>
-      <view>PersonDuplicatesFilter_view</view>
-    </neonViewReference>
-    <neonViewReference>
-      <name>98f44c67-4371-45bf-9458-b41ec28753b3</name>
-      <entityField>SelfOrganisationDuplicatesConsumer</entityField>
-      <view>OrganisationDuplicatesFilter_view</view>
+      <name>b3164f16-fa7e-42b0-829f-88553add7c08</name>
+      <entityField>#ENTITY</entityField>
+      <view>PersonDublicatesTab_view</view>
     </neonViewReference>
   </children>
 </neonView>
diff --git a/neonView/DuplicatesUnrelatedPersonFilter_view/DuplicatesUnrelatedPersonFilter_view.aod b/neonView/DuplicatesUnrelatedPersonFilter_view/DuplicatesUnrelatedPersonFilter_view.aod
index 324006b6d7..9fcb7fbe35 100644
--- a/neonView/DuplicatesUnrelatedPersonFilter_view/DuplicatesUnrelatedPersonFilter_view.aod
+++ b/neonView/DuplicatesUnrelatedPersonFilter_view/DuplicatesUnrelatedPersonFilter_view.aod
@@ -7,4 +7,22 @@
       <name>layout</name>
     </boxLayout>
   </layout>
+  <children>
+    <tableViewTemplate>
+      <name>UnrelatedPersons</name>
+      <entityField>#ENTITY</entityField>
+      <isCreatable v="false" />
+      <isEditable v="false" />
+      <columns>
+        <neonTableColumn>
+          <name>734re984-6a0b-4126-ab49-452e2b54f76d</name>
+          <entityField>SourceDuplicateDescription</entityField>
+        </neonTableColumn>
+        <neonTableColumn>
+          <name>8615259b-de5b-378u-945d-2ff934ae1b8c</name>
+          <entityField>UnrelatedDuplicateDescription</entityField>
+        </neonTableColumn>
+      </columns>
+    </tableViewTemplate>
+  </children>
 </neonView>
diff --git a/neonView/PersonDublicatesTab_view/PersonDublicatesTab_view.aod b/neonView/PersonDublicatesTab_view/PersonDublicatesTab_view.aod
new file mode 100644
index 0000000000..3edc37c8e3
--- /dev/null
+++ b/neonView/PersonDublicatesTab_view/PersonDublicatesTab_view.aod
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.2">
+  <name>PersonDublicatesTab_view</name>
+  <title>Person duplicates</title>
+  <majorModelMode>DISTRIBUTED</majorModelMode>
+  <layout>
+    <boxLayout>
+      <name>layout</name>
+      <direction>HORIZONTAL</direction>
+    </boxLayout>
+  </layout>
+  <children>
+    <neonViewReference>
+      <name>c82a1ae2-9f8f-4149-8bac-5621e36d779b</name>
+      <entityField>SelfPersonDuplicatesConsumer</entityField>
+      <view>PersonDuplicatesFilter_view</view>
+    </neonViewReference>
+    <neonViewReference>
+      <name>2aee29fb-9844-4e3a-a284-a04dadf9eadc</name>
+      <entityField>DuplicatesUnrelatedPersonConsumer</entityField>
+      <view>DuplicatesUnrelatedPersonFilter_view</view>
+    </neonViewReference>
+  </children>
+</neonView>
-- 
GitLab