Skip to content
Snippets Groups Projects
Commit 45f0537e authored by David Büchler's avatar David Büchler
Browse files

Detailansicht zeigt nun alle Kontakte innerhalb des selektierten Clusters

Sql Query umgebaut auf Nutzung des Sql Builders
Auf der ClusterDetailSeite wird nun die Person Filter view angezeigt
parent 420a9c56
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@
</entityProvider>
<entityProvider>
<name>UnrelatedPersonsProvider</name>
<titlePlural>Unrelated person duplicates</titlePlural>
<children>
<entityParameter>
<name>TargetEntity</name>
......
......@@ -85,6 +85,23 @@
</entityParameter>
</children>
</entityConsumer>
<entityConsumer>
<name>PersonsConsumer</name>
<dependency>
<name>dependency</name>
<entityName>Person_entity</entityName>
<fieldName>Contacts</fieldName>
</dependency>
<children>
<entityParameter>
<name>OnlyShowContactIds_param</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/personsconsumer/children/onlyshowcontactids_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityField>
<name>CLUSTER_ID</name>
</entityField>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
......@@ -104,6 +121,9 @@
<jDitoRecordFieldMapping>
<name>TARGET_ENTITY.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>CLUSTER_ID.value</name>
</jDitoRecordFieldMapping>
</recordFieldMappings>
</jDitoRecordContainer>
</recordContainers>
......
import("system.logging");
import("system.result");
import("system.vars");
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.
* Because of its invalidity, no records are shown.
*/
if(contactIdsInCluster.length == 0)
result.string(JSON.stringify(["nodata"]));
else
result.string(JSON.stringify(contactIdsInCluster));
\ No newline at end of file
import("Sql_lib");
import("system.logging");
import("system.db");
import("system.vars");
import("system.result");
......@@ -10,21 +12,28 @@ var INDEX_LASTNAME = 3;
let targetEntity = vars.get("$param.TargetEntity");
let duplicates = [];
let test = vars.get("$local.idvalues");
logging.log("test -> " + test);
let duplicateInfosQuery = "";
if(targetEntity == "Person_entity")
duplicateInfosQuery = "select DUPLICATECLUSTERS.ID, CLUSTERID, FIRSTNAME, LASTNAME"
{
duplicateInfosQuery = SqlCondition.begin()
.and("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)")
.andIn("DUPLICATECLUSTERS.CLUSTERID", vars.get("$local.idvalues"))
.buildSql("select DUPLICATECLUSTERS.ID, CLUSTERID, FIRSTNAME, LASTNAME"
+ " from DUPLICATECLUSTERS"
+ " join CONTACT on CONTACT.CONTACTID = DUPLICATEID"
+ " join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID"
+ " where DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)"
+ " ORDER BY CLUSTERID";
+ " join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID", "1=2", " ORDER BY CLUSTERID");
}
else
duplicateInfosQuery = "orgquery";
let duplicateInfos = db.table(duplicateInfosQuery);
logging.log("duplicateInfos -> " + JSON.stringify(duplicateInfos));
let recordClusterId = "";
let recordDescription = "";
let recordDuplicateInClusterCount = 0;
......@@ -48,6 +57,7 @@ for (let i = 0; i < duplicateInfos.length; i++)
recordDuplicateInClusterCount = 1;
continue;
}
//If the record belongs to the same Cluster as the one before, append its value and increase the counter
//otherwise write the clusters record an start a new record.
if(recordClusterId == currentClusterId)
......@@ -63,7 +73,7 @@ for (let i = 0; i < duplicateInfos.length; i++)
* As there are then no interactions possible (and a cluster of one is no cluster), this cluster musn't be shown in the list.
*/
if(i == duplicateInfos.length-1 && recordDuplicateInClusterCount > 1)
duplicates.push([currentRecordId, recordDescription, recordDuplicateInClusterCount, targetEntity]);
duplicates.push([recordClusterId, recordDescription, recordDuplicateInClusterCount, targetEntity, recordClusterId]);
}
else
{
......@@ -75,7 +85,7 @@ for (let i = 0; i < duplicateInfos.length; i++)
* As there would be no interactions possible (and a cluster of one is no cluster), this cluster musn't be shown in the list.
*/
if(recordDuplicateInClusterCount > 1)
duplicates.push([currentRecordId, recordDescription, recordDuplicateInClusterCount, targetEntity]);
duplicates.push([recordClusterId, recordDescription, recordDuplicateInClusterCount, targetEntity, recordClusterId]);
recordClusterId = currentClusterId
recordDescription = currentDescription
......
......@@ -30,10 +30,10 @@ if(onlyShowContactIds != null && onlyShowContactIds.length > 0)
{
additionalCondition.orPrepare("CONTACT.CONTACTID", pContactId);
});
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
......@@ -3,6 +3,7 @@
<name>Duplicates</name>
<title>Duplicates</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<mainview>PersonDuplicatesEdit_view</mainview>
<filterview>DuplicatesOverview_view</filterview>
<entity>Duplicates_entity</entity>
<references>
......@@ -22,5 +23,9 @@
<name>5bdeb931-4e69-4520-bbc9-94fb17679331</name>
<view>PersonDublicatesTab_view</view>
</neonViewReference>
<neonViewReference>
<name>d66a4eda-b7cc-4afe-9360-5e8413427946</name>
<view>PersonDuplicatesEdit_view</view>
</neonViewReference>
</references>
</neonContext>
......@@ -13,6 +13,7 @@
<entityField>#ENTITY</entityField>
<isCreatable v="false" />
<isEditable v="false" />
<title>Unrelated person duplicates</title>
<columns>
<neonTableColumn>
<name>734re984-6a0b-4126-ab49-452e2b54f76d</name>
......
<?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>PersonDuplicatesEdit_view</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<layout>
<boxLayout>
<name>layout</name>
<direction>HORIZONTAL</direction>
</boxLayout>
</layout>
<children>
<neonViewReference>
<name>65ba4e07-2ac1-49be-a61e-56d9bc54e7fb</name>
<entityField>PersonsConsumer</entityField>
<view>PersonFilter_view</view>
</neonViewReference>
</children>
</neonView>
......@@ -98,6 +98,22 @@ DuplicateScannerUtils.GetCachedDuplicatesForContactId = function(pDuplicateId)
return db.array(db.COLUMN, querySelectDuplicateContactIds);
}
DuplicateScannerUtils.GetCachedDuplicatesForClusterId = function(pClusterId)
{
let query = "select DUPLICATEID from DUPLICATECLUSTERS"
+ " where CLUSTERID = '"+ pClusterId +"' ";
return db.array(db.COLUMN, query);
}
DuplicateScannerUtils.GetCachedDuplicatesForId = function(pClusterRecordId)
{
let query = "select DUPLICATEID from DUPLICATECLUSTERS"
+ " where CLUSTERID = (select CLUSTERID from DUPLICATECLUSTERS"
+ " where ID = '"+ pClusterRecordId +"')"
return db.array(db.COLUMN, query);
}
//Später mal eigentsändiger Serverprozess ohne externe Konfiguration
DuplicateScannerUtils.RebuildDuplicatesCache = function(pFilterName, pTargetEntity,
pQueryTargetRecords, pFilterFields, pRecordIdFieldToIgnore)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment