Skip to content
Snippets Groups Projects
Commit c62dafb1 authored by Sebastian Pongratz's avatar Sebastian Pongratz :ping_pong:
Browse files

Merge branch '2021.0_duplicates' into '2021.0'

2021.0 duplicates

See merge request xrm/basic!742
parents df671c04 9d0a859a
No related branches found
No related tags found
No related merge requests found
Showing
with 13 additions and 950 deletions
import("system.vars");
import("system.result");
result.string(vars.get("$field.UID"));
\ No newline at end of file
import("system.process");
import("KeywordRegistry_basic");
import("system.db");
import("ActivityTask_lib");
import("Employee_lib");
import("system.util");
import("system.notification");
import("system.notificationtypes");
import("system.entities");
import("system.project");
import("system.indexsearch");
import("system.question");
import("system.logging");
import("DuplicateScanner_lib");
import("JditoFilter_lib");
//let testFields = [];
//let filters = DuplicateScannerUtils.loadFilters("PersonDuplicates", "Person_entity")
//logging.log("filters -> " + filters);
//
//for (let i = 0; i < filters.length; i++)
//{
// logging.log("filters[i] -> " + filters[i]);
// let filter = JSON.parse(filters[i][0]).filter;
// let fields = JditoFilterUtils.getFilterFields(filter.childs);
// testFields = testFields.concat(fields);
//}
//logging.log("testFields -> " + testFields);
//##############################Test Duplicate Scan######################################################
//var filterName = "PersonDuplicates";
//var targetEntity = "Person_entity";
//var resultFieldsIdFieldName = "CONTACTID";
//
//var tmpFieldsInFilterRay = ["CONTACTID", "FIRSTNAME", "LASTNAME", "GENDER"];
//var queryPersonContactIds = "select CONTACTID, FIRSTNAME, LASTNAME, GENDER from CONTACT"
// + " join PERSON on PERSONID = PERSON_ID";
//
//
//var filterFieldValueRays = [["CONTACTID", "29271db0-4253-46c9-b7c2-5e25376b9d19"], ["FIRSTNAME", "Narkus"], ["LASTNAME", "Bltinger"], ["GENDER", "m"]];
//
////DuplicateScannerUtils.ScanForDuplicatesIndex = function(pFilterName, pTargetEntity, pFilterFieldValueRays,
////pTargetEntityResultFields, pRecordIdFieldToIgnore, pRecordIdValueToIgnore)
//
///*
// *
// */
//
//
//
//let duplicateFieldsConfig = DuplicateScannerUtils.LoadDuplicateIndexFieldsConfiguration(filterName, targetEntity);
//
//let querySelectFields = "";
//for (let i = 0; i < duplicateFieldsConfig.length; i++)
//{
// querySelectFields += duplicateFieldsConfig[i][0];
//
// if(i < duplicateFieldsConfig.length)
// querySelectFields += ", ";
//}
//
//let queryPersonFieldData = "select " + querySelectFields + " from CONTACT"
// + " join PERSON on PERSONID = PERSON_ID";
//
//DuplicateScannerUtils.GetEntityFieldNameValueMap(duplicateFieldsConfig);
//
//DuplicateScannerUtils.ScanForDuplicatesIndex(filterName, targetEntity,
//filterFieldValueRays, [], resultFieldsIdFieldName, "29271db0-4253-46c9-b7c2-5e25376b9d19");
//##############################ANs Beispiel######################################################
//logging.log("TEST INDEX API with Entities");
//logging.log(indexsearch.lookupIndexField("Person_entity", "FIRSTNAME"));
//logging.log(indexsearch.lookupIndexField("Person_entity", "FIRSTNAME.value"));
//logging.log(indexsearch.lookupIndexField("Person_entity", "PersAddresses.CITY"));
//logging.log(indexsearch.lookupIndexField("Person_entity", "PersAddresses.CITY.value"));
//logging.log(indexsearch.lookupIndexField(null, "Person_entity.FIRSTNAME.value"));
//logging.log(indexsearch.lookupIndexField(null, "Person_entity.PersAddresses.CITY.value"));
//var json = '{"entity":"Person_entity","filter":{"type":"group","operator":"AND","childs":[{"type":"row","name":"FIRSTNAME","operator":"STARTSWITH","value":"asd","key":"","contenttype":"TEXT"},{"type":"group","operator":"OR","childs":[{"type":"row","name":"LASTNAME","operator":"STARTSWITH","value":"L","key":"","contenttype":"TEXT"}]}]}}';
//logging.log(indexsearch.buildQueryFromSearchCondition(json));
//
//var t1 = indexsearch.createTerm("lisa").setEntityField("Person_entity.FIRSTNAME");
//var t2 = indexsearch.createTerm("sommer").setEntityField("Person_entity.LASTNAME");
//var t3 = indexsearch.createWildcardTerm("L").setEntityField("Person_entity.PersAddresses.CITY");
//
//var patternConf = indexsearch.createPatternConfig().or(t1).or(t2).or(t3);
//var pattern = indexsearch.buildPatternString(patternConf);
//logging.log(pattern);
//
//var query = indexsearch.createIndexQuery()
//.setPattern(pattern)
//.setEntities("Person_entity")
////.addResultIndexFields(indexsearch.FIELD_ID)
//.addResultFields("Person_entity.FIRSTNAME")
//.addSearchFields("Person_entity.FIRSTNAME", "Person_entity.LASTNAME");
//
//var res = indexsearch.searchIndex(query);
//logging.log("" + res);
//######################################Demosuche nach Datensatz##############################################
//
//let indexQuery = indexsearch.createIndexQuery()
// .setPattern("(+(-contactid_value:(29271db0-4253-46c9-b7c2-5e25376b9d19)) +gender_value:m*)")
// .setEntities(["Person_entity"])
// .addResultFields("Person_entity.FIRSTNAME")
// .setRows(50);
//
//
//let filterTerm1 = indexsearch.createTerm("Barkus")
// .setIndexField("firstname_value")
// .setFuzzySearchFactor(0);
////let filterTerm2 = indexsearch.createTerm("Altinger")
//// .setIndexField("lastname_value")
//// .setFuzzySearchFactor(0);
//
//let filterPatternConfig = indexsearch.createPatternConfig().and(filterTerm1);
//
//let filterPatternString = indexsearch.buildPatternString(filterPatternConfig);
//logging.log("Hauptsuche filterPatternString -> " + filterPatternString);
//indexQuery = indexQuery.addFilter(filterPatternString);
//
//let searchResult = indexsearch.searchIndex(indexQuery);
//logging.log("searchResult -> " + searchResult);
//
//logging.log("searchResults hits length -> " + searchResult[indexsearch.HITS].length);
//
//for (let i = 0; i < searchResult[indexsearch.HITS].length; i++)
//{
// logging.log("Treffer Nr -> " + i);
// //searchResults hits 0 -> {#ADITO_SEARCH_ID=1868bd3a-05af-4b7f-a633-e3aec50ac45c, _index_group_=Person, #ADITO_SEARCH_TYPE=Person, firstname_value=Peter, _local_id_=1868bd3a-05af-4b7f-a633-e3aec50ac45c}
// let localId = searchResult[indexsearch.HITS][i]["_local_id_"];
// let firstname = searchResult[indexsearch.HITS][i]["firstname_value"];
// let indexGroup = searchResult[indexsearch.HITS][i]["_index_group_"];
// logging.log("localId -> " + localId);
// logging.log("firstname -> " + firstname);
// logging.log("indexGroup -> " + indexGroup);
//}
//####################################################################################
//
//var filterName = "PersonDuplicates";
//var targetEntity = "Person_entity";
//var resultFieldsIdFieldName = "CONTACTID";
//var queryPersonContactIds = "select CONTACTID, FIRSTNAME, LASTNAME, GENDER from CONTACT"
// + " join PERSON on PERSONID = PERSON_ID";
//var tmpFieldsInFilterRay = ["CONTACTID", "FIRSTNAME", "LASTNAME", "GENDER"];
//
//logging.log("Löschen von PERSON Dubletten -> ");
//DuplicateScannerUtils.deleteClustersByTargetEntity("Person_entity");
//
//logging.log("Neu berechnen von PERSON Dubletten -> ");
//DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, queryPersonContactIds,
//tmpFieldsInFilterRay, resultFieldsIdFieldName);
//
//DuplicateScannerUtils.refreshUnrelatedDuplicateRelations(targetEntity);
//##############################################################################
//filterName = "OrganisationDuplicates";
//targetEntity = "Organisation_entity";
//resultFieldsIdFieldName = "CONTACTID";
//queryPersonContactIds = "select CONTACTID, ORGANISATION.NAME from ORGANISATION"
// + " join CONTACT on CONTACT.CONTACTID = ORGANISATION.ORGANISATIONID"
// + " where CONTACTID != '0'";
//tmpFieldsInFilterRay = ["CONTACTID", "NAME"];
//
//
//logging.log("Löschen von ORGANISATION Dubletten -> ");
//DuplicateScannerUtils.deleteClustersByTargetEntity(targetEntity)
//
//logging.log("Neu berechnen von ORGANISATION Dubletten -> ");
//DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, queryPersonContactIds,
//tmpFieldsInFilterRay, resultFieldsIdFieldName);
//
//DuplicateScannerUtils.refreshUnrelatedDuplicateRelations(targetEntity);
//####################################Rebuild person duplicates##########################################
//var filterName = "PersonDuplicates";
//var targetEntity = "Person_entity";
//
//let duplicateFieldsConfig = DuplicateScannerUtils.LoadIndexFieldsConfiguration(filterName, targetEntity);
//let resultFields = DuplicateScannerUtils.getResultFields(filterName, targetEntity);
//
//logging.log("duplicateFieldsConfig -> " + duplicateFieldsConfig);
//logging.log("resultFields -> " + resultFields);
//
//let querySelectFields = DuplicateScannerUtils.BuildSqlSelectFieldsFromFieldConfig(duplicateFieldsConfig);
//logging.log("querySelectFields -> " + querySelectFields);
//
//let queryPersonFieldData = "select " + querySelectFields + " from CONTACT"
// + " join PERSON on PERSONID = PERSON_ID"
// + " left join ADDRESS on ADDRESS.CONTACT_ID = CONTACT.CONTACTID";
//
//logging.log("Löschen von PERSON Dubletten -> ");
//DuplicateScannerUtils.deleteClustersByTargetEntity(targetEntity);
//
//let formatToJsonAndCallWsCallback = function(pPossibleDuplicatesRay)
//{
// let indexResultFields = DuplicateScannerUtils.translateEntityToIndexFields(targetEntity, resultFields)
//
// //Run thru every duplicate result an read out the resultfields
// for (let i = 0; i < pPossibleDuplicatesRay.length; i++)
// {
// for (let b = 0; b < resultFields.length; b++)
// {
// let entityFieldName = resultFields[b];
// let indexFieldName = indexResultFields[entityFieldName];
// //logging.log("Entity Field -> "+ pPossibleDuplicatesRay[i][indexFieldName]);
// //format values
// }
// }
// //call webservice
// //reformat results to same structure as before
// return pPossibleDuplicatesRay;
//};
//
//logging.log("Neu berechnen von PERSON Dubletten -> ");
//DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, queryPersonFieldData,
//duplicateFieldsConfig, resultFields, formatToJsonAndCallWsCallback);
//
//DuplicateScannerUtils.refreshUnrelatedDuplicateRelations(targetEntity);
//##################################single scanForDuplicates#######################################################################
//var filterName = "PersonDuplicates";
//var targetEntity = "Person_entity";
//
////Values to check, the same fields as configured
//let valuesToCheck = {};
//valuesToCheck["CONTACTID"] = "c7ddf982-0e58-4152-b82b-8f5673b0b729";
//valuesToCheck["FIRSTNAME"] = "Tim";
//valuesToCheck["GENDER"] = "m ";
//
////The result values can be accessed as seen above in "formatToJsonAndCallWsCallback"
//let pPossibleDuplicatesRay = DuplicateScannerUtils.scanForDuplicates(filterName, targetEntity, valuesToCheck, null);
//
//logging.log(" pPossibleDuplicatesRay-> " + pPossibleDuplicatesRay);
//
//for (let i = 0; i < pPossibleDuplicatesRay.length; i++)
//{
// logging.log("pPossibleDuplicatesRay[i] -> " + pPossibleDuplicatesRay[i]);
//}
//
//################################ entity structure auslesen ##############################################
//var model = project.getEntityStructure("Person_entity");
//logging.log("Name: " + model.name);
//logging.log("Title: " + model.title);
//logging.log("Description: " + model.description);
//logging.log("UsePermissions: " + model.usePermissions);
//
//for (fieldname in model.fields)
//{
// field = model.fields[fieldname];
// if(field.fieldType == project.ENTITYFIELDTYPE_FIELD)
// {
// logging.log(" Name: " + field.name);
// logging.log(" Type: " + field.fieldType);
// logging.log(" Title: " + field.title);
// logging.log(" Description: " + field.description);
// logging.log(" UsePermissions: " + field.usePermissions);
// logging.log("###################### -> ");
// }
// if(field.fieldType == project.ENTITYFIELDTYPE_CONSUMER)
// {
// let consumerEntity = field.entityName;
//
// if(consumerEntity == null || consumerEntity == "")
// continue;
//
// let consumerEntityFields = project.getEntityStructure(consumerEntity);
// for (consumerEntityFieldname in consumerEntityFields.fields)
// {
// consumerField = consumerEntityFields.fields[consumerEntityFieldname];
// if(consumerField.fieldType == project.ENTITYFIELDTYPE_FIELD)
// {
// logging.log(" Name: " + consumerField.name);
// logging.log(" Type: " + consumerField.fieldType);
// logging.log(" Title: " + consumerField.title);
// logging.log(" Description: " + consumerField.description);
// logging.log(" UsePermissions: " + consumerField.usePermissions);
// logging.log("###################### -> ");
// }
// }
// }
//}
//##############################################################################
//var model = project.getEntityStructure("Person_entity");
//let duplicateFieldsConfig = DuplicateScannerUtils.LoadIndexFieldsConfiguration(filterName, targetEntity);
//
//let combinedData = []
//let entityFieldsToLoad = [];
//for (field in duplicateFieldsConfig)
//{
// let entityFieldName = duplicateFieldsConfig[field][0];
// let isIdField = duplicateFieldsConfig[field][1];
// let useForIndexSearch = duplicateFieldsConfig[field][2];
// let entityFieldData = model[entiyFieldName];
// combinedData.push(entityFieldName, isIdField, useForIndexSearch, entityFieldData);
//}
//
//var filterName = "PersonDuplicates";
//var targetEntity = "Person_entity";
//DuplicateScannerUtils.getEntityRecords(targetEntity, entityFieldsToLoad, 0, 50);
//Beispiel 1:
//Feld mit verknüpftem Consumer
//[entity, feldname, consumerName, ProviderName]
//let test = ["Communication_entity", "STANDARD_EMAIL_COMMUNICATION", "EmailCommunications", "EmailCommunications"];
//
//let testrow = entities.createConfigForLoadingRows()
// .fields([test[1]])
// .entity(test[0])
// .provider(test[3])
// .addParameter("ContactId_param", "d4c1bec3-656f-45ec-ae03-1c4d729d99fe")
// //.uid()
//let resultTest = entities.getRows(testrow);
//logging.log("resultTest -> " + JSON.stringify(resultTest));
//Beispiel 2:
//Feld direkt von anderem Entity
//let testrow = entities.createConfigForLoadingRows()
// .fields(["ZIP"])
// .entity("Address_entity")
// .uid("1a67eaa7-21da-4a18-97ab-755ac5cb74f7")
//
//let resultTest = entities.getRows(testrow);
//logging.log("resultTest Beispiel 2 -> " + JSON.stringify(resultTest));
//indexsearch.runIndexer(["Person"]);
//let resultClusterId = DuplicateScannerUtils.GetClusterWithDuplicates(["7a34d9d0-04c7-478c-a8e2-f584fe625c45", "c7ddf982-0e58-4152-b82b-8f5673b0b729"]);
//logging.log("resultClusterId -> " + resultClusterId);
//
//var filterName = "PersonDuplicates";
//var targetEntity = "Person_entity";
//var recordBlockSize = DuplicateScannerUtils.GetBlockSizeForScanner(filterName, targetEntity);
//
//logging.log("recordBlockSize -> " + recordBlockSize);
//try
//{
// let sourceContactId = "sourceContactId";
// let targetContactId = "targetContactId";
//
// var activityDataForInsert = {
// subject: "Es wurde ein Personendatensatz in diesen integriert",
// content: "Person mit ID " + sourceContactId + " wurde in Person mit ID " + targetContactId + " integriert",
// //categoryKeywordId: $KeywordRegistry.ac
// directionKeywordId: "x",
// responsibleContactId: EmployeeUtils.getCurrentContactId()
// };
//
// var activityLinks = [["Person", "6e667085-bb97-4039-8dfe-2230002985e0"]]
//
// //activityLinks = ArrayUtils.distinct2d(activityLinks);//TODO: better check before adding the elements into the array if it already exists there
//
// var activityRes = ActivityUtils.insertNewActivity(activityDataForInsert, activityLinks, null, db.getCurrentAlias());
//}
//catch (exception)
//{
// logging.log("exception -> " + exception);
//}
////notification.addNotification(util.getNewUUID(), null, null, null, notification., notification.PRIO_NORMAL, 2, notification.STATE_UNSEEN, [user], message, description);
//let currentContactId = EmployeeUtils.getCurrentContactId();
//DuplicateScannerUtils.CreateMergeSuccessActivity("a2e084e2-d68a-4f1e-a1bb-f8d46ad6293d", "6e667085-bb97-4039-8dfe-2230002985e0", currentContactId, "Person");
//logging.log("$KeywordRegistry.activityDirection$internal() -> " + $KeywordRegistry.activityDirection$internal());
//let processParameters = {
// filterName: "PersonDuplicates",
// targetEntity: "Person_entity" //process.execute is only able to handle strings
//}
//let userId = EmployeeUtils.getCurrentUserId();
//if(userId == null)
// userId == "";
//try
//{
// let processId = "manualrun_rebuild_duplicatecache_" + util.getNewUUID();
// process.executeTimer(processId, "RebuildAllDuplicatesCache_serverProcess", 0, true, false, process.TIMERTYPE_SERVER_RUN, userId, false, process.THREADPRIORITY_LOW)
// process.stopTimer(processId);
// logging.log("test -> ");
// process.executeAsync("RebuildAllDuplicateCaches_serverProcess", processParameters, false, userId, process.THREADPRIORITY_LOW)
// logging.log("test2 -> ");
//}
//catch (exception)
//{
// logging.log(" exception-> " + exception);
//}
import("system.result");
import("Sql_lib");
var subselect = newSelect("count(*)").from("UNRELATEDDUPLICATES")
.where("UNRELATEDDUPLICATES.DUPLICATETYPE = HASDUPLICATE.OBJECT_TYPE")
.and("UNRELATEDDUPLICATES.SOURCEDUPLICATEID = HASDUPLICATE.OBJECT_ROWID");
result.string(
newSelect("count(*)")
.from("HASDUPLICATE")
.where("HASDUPLICATE.OBJECT_TYPE = DUPLICATESCANNER.ENTITY_TO_SCAN_NAME")
.and("(HASDUPLICATE.DUPLICATECOUNT - (" + subselect.toString() + ")) > 0")
.toString()
);
<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.18" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.18">
<name>DuplicatesUnrelated_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<documentation>%aditoprj%/entity/DuplicatesUnrelated_entity/documentation.adoc</documentation>
<siblings>
<element>Duplicates_entity</element>
</siblings>
<recordContainer>jditoRecordContainer</recordContainer>
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
</entityProvider>
<entityProvider>
<name>UnrelatedPersonsProvider</name>
<titlePlural>Unrelated person duplicates</titlePlural>
<children>
<entityParameter>
<name>TargetEntity</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
<entityParameter>
<name>ClusterId_param</name>
<expose v="true" />
<mandatory v="false" />
</entityParameter>
</children>
</entityProvider>
<entityParameter>
<name>TargetEntity</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
<entityProvider>
<name>UnrelatedOrganisationsProvider</name>
<titlePlural>Unrelated organisations duplicates</titlePlural>
<children>
<entityParameter>
<name>TargetEntity</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
<entityParameter>
<name>ClusterId_param</name>
<expose v="true" />
<mandatory v="false" />
</entityParameter>
</children>
</entityProvider>
<entityField>
<name>SourceDuplicateDescription</name>
<title>Source duplicate</title>
</entityField>
<entityField>
<name>UnrelatedDuplicateDescription</name>
<title>Unrelated duplicate</title>
</entityField>
<entityField>
<name>UID</name>
</entityField>
<entityParameter>
<name>ClusterId_param</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
<entityProvider>
<name>#PROVIDER_AGGREGATES</name>
<useAggregates v="true" />
</entityProvider>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
<name>jditoRecordContainer</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<contentProcess>%aditoprj%/entity/DuplicatesUnrelated_entity/recordcontainers/jditorecordcontainer/contentProcess.js</contentProcess>
<onDelete>%aditoprj%/entity/DuplicatesUnrelated_entity/recordcontainers/jditorecordcontainer/onDelete.js</onDelete>
<recordFieldMappings>
<jDitoRecordFieldMapping>
<name>UID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>SourceDuplicateDescription.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>UnrelatedDuplicateDescription.value</name>
</jDitoRecordFieldMapping>
</recordFieldMappings>
</jDitoRecordContainer>
</recordContainers>
</entity>
=DuplicateUnrelated_entity
These Duplicates not related to another Entity.
\ No newline at end of file
import("system.result");
import("system.vars");
import("system.db");
import("Sql_lib");
var INDEX_ID = 0;
var INDEX_SOURCE_INFO1 = 1;
var INDEX_SOURCE_INFO2 = 3;
var INDEX_UNRELATED_INFO1 = 2;
var INDEX_UNRELATED_INFO2 = 4;
var INDEX_SOURCE_INFO = 1;
var INDEX_UNRELATED_INFO = 2;
let unrelatedDuplicates = [];
let resultUnrelatedDuplicates = [];
let targetEntity = vars.get("$param.TargetEntity");
let clusterId = vars.get("$param.ClusterId_param");
let querySelect = new SqlBuilder();
if(targetEntity == 'Person_entity')
{
querySelect.select("ud.ID,"
+ " pSource.FIRSTNAME, pUnrelated.FIRSTNAME,"
+ " pSource.LASTNAME, pUnrelated.LASTNAME")
.from("UNRELATEDDUPLICATES", "ud")
.join("CONTACT", "cUnrelated.CONTACTID = ud.UNRELATEDDUPLICATEID", "cUnrelated")
.join("PERSON", "pUnrelated.PERSONID = cUnrelated.PERSON_ID", "pUnrelated")
.join("CONTACT", "cSource.CONTACTID = ud.SOURCEDUPLICATEID", "cSource")
.join("PERSON", "pSource.PERSONID = cSource.PERSON_ID", "pSource")
//If the clusterid parameter is present, only load the duplicates for this particular cluster
.whereIfSet(["UNRELATEDDUPLICATES", "CLUSTERID", "ud"], clusterId);
}
else
{
querySelect.select("ud.ID,"
+ " oSource.\"NAME\","
+ " oUnrelated.\"NAME\"")
.from("UNRELATEDDUPLICATES", "ud")
.join("CONTACT", "cUnrelated.CONTACTID = ud.UNRELATEDDUPLICATEID", "cUnrelated")
.join("ORGANISATION", "oUnrelated.ORGANISATIONID = cUnrelated.CONTACTID", "oUnrelated")
.join("CONTACT", "cSource.CONTACTID = ud.SOURCEDUPLICATEID", "cSource")
.join("ORGANISATION", "oSource.ORGANISATIONID = cSource.CONTACTID", "oSource")
//If the clusterid parameter is present, only load the duplicates for this particular cluster
.whereIfSet(["UNRELATEDDUPLICATES", "CLUSTERID", "ud"], clusterId);
}
unrelatedDuplicates = querySelect.table();
for (let i = 0; i < unrelatedDuplicates.length; i++)
{
let id = unrelatedDuplicates[i][INDEX_ID];
let sourceInfo = "";
let unrelatedInfo = "";
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];
sourceInfo = sourceInfo1;
if(sourceInfo2 != undefined)
sourceInfo += " " + sourceInfo2;
unrelatedInfo = unrelatedInfo1;
if(unrelatedInfo2 != undefined)
unrelatedInfo += " " + unrelatedInfo2;
resultUnrelatedDuplicates.push([id, sourceInfo, unrelatedInfo]);
}
result.object(resultUnrelatedDuplicates);
\ No newline at end of file
import("Sql_lib");
newWhere("UNRELATEDDUPLICATES.ID", "$local.uid").deleteData();
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.18" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.18">
<name>Duplicates_entity</name>
<title>Duplicates</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<documentation>%aditoprj%/entity/Duplicates_entity/documentation.adoc</documentation>
<siblings>
<element>DuplicatesUnrelated_entity</element>
</siblings>
<iconId>VAADIN:DATABASE</iconId>
<recordContainer>recordContainer</recordContainer>
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
</entityProvider>
<entityField>
<name>CLUSTER_DESCRIPTION</name>
<title>Cluster description</title>
</entityField>
<entityField>
<name>COUNT_DUPLICATES_IN_CLUSTER</name>
<title>Count duplicates in cluster</title>
<contentType>NUMBER</contentType>
</entityField>
<entityField>
<name>TARGET_ENTITY</name>
</entityField>
<entityField>
<name>UID</name>
</entityField>
<entityProvider>
<name>SelfPersonDuplicatesProvider</name>
<titlePluralProcess>%aditoprj%/entity/Duplicates_entity/entityfields/selfpersonduplicatesprovider/titlePluralProcess.js</titlePluralProcess>
<titlePlural>Person duplicates</titlePlural>
<children>
<entityParameter>
<name>TargetEntity</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
</children>
</entityProvider>
<entityConsumer>
<name>SelfPersonDuplicatesConsumer</name>
<dependency>
<name>dependency</name>
<entityName>Duplicates_entity</entityName>
<fieldName>SelfPersonDuplicatesProvider</fieldName>
</dependency>
<children>
<entityParameter>
<name>TargetEntity</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/selfpersonduplicatesconsumer/children/targetentity/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>ClusterId_param</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/selfpersonduplicatesconsumer/children/clusterid_param/valueProcess.js</valueProcess>
<title></title>
</entityParameter>
</children>
</entityConsumer>
<entityParameter>
<name>TargetEntity</name>
<expose v="true" />
<mandatory v="true" />
</entityParameter>
<entityConsumer>
<name>SelfOrganisationDuplicatesConsumer</name>
<dependency>
<name>dependency</name>
<entityName>Duplicates_entity</entityName>
<fieldName>SelfOrganisationDuplicatesProvider</fieldName>
</dependency>
<children>
<entityParameter>
<name>TargetEntity</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/selforganisationduplicatesconsumer/children/targetentity/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>ClusterId_param</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/selforganisationduplicatesconsumer/children/clusterid_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityProvider>
<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>
<entityParameter>
<name>ClusterId_param</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/duplicatesunrelatedpersonconsumer/children/clusterid_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityField>
<name>CLUSTER_ID</name>
</entityField>
<entityConsumer>
<name>DuplicatePersonsConsumer</name>
<dependency>
<name>dependency</name>
<entityName>Person_entity</entityName>
<fieldName>NonselfDuplicates</fieldName>
</dependency>
<children>
<entityParameter>
<name>OnlyShowContactIds_param</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/duplicatepersonsconsumer/children/onlyshowcontactids_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>DuplicateActionsControl_param</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/duplicatepersonsconsumer/children/duplicateactionscontrol_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityActionGroup>
<name>DuplicateClusterActionGroup</name>
<title>Duplicate actions</title>
<children>
<entityActionField>
<name>IgnoreWholeCluster</name>
<title>Ignore whole cluster</title>
<onActionProcess>%aditoprj%/entity/Duplicates_entity/entityfields/duplicateclusteractiongroup/children/ignorewholecluster/onActionProcess.js</onActionProcess>
<isSelectionAction v="true" />
<iconId>VAADIN:CLOSE</iconId>
</entityActionField>
</children>
</entityActionGroup>
<entityConsumer>
<name>DuplicatesUnrelatedOrganisationConsumer</name>
<dependency>
<name>dependency</name>
<entityName>DuplicatesUnrelated_entity</entityName>
<fieldName>UnrelatedOrganisationsProvider</fieldName>
</dependency>
<children>
<entityParameter>
<name>TargetEntity</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/duplicatesunrelatedorganisationconsumer/children/targetentity/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>ClusterId_param</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/duplicatesunrelatedorganisationconsumer/children/clusterid_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityActionGroup>
<name>PersonOpenClusterDetailActionGroup</name>
<children>
<entityActionField>
<name>PersonOpenClusterDetail</name>
<title></title>
<onActionProcess>%aditoprj%/entity/Duplicates_entity/entityfields/personopenclusterdetailactiongroup/children/personopenclusterdetail/onActionProcess.js</onActionProcess>
<isSelectionAction v="true" />
<iconId>VAADIN:FOLDER_OPEN</iconId>
</entityActionField>
</children>
</entityActionGroup>
<entityParameter>
<name>ClusterId_param</name>
<expose v="true" />
</entityParameter>
<entityActionGroup>
<name>OrganisationOpenClusterDetailActionGroup</name>
<children>
<entityActionField>
<name>OrganisationOpenClusterDetail</name>
<title>Open cluster detail</title>
<onActionProcess>%aditoprj%/entity/Duplicates_entity/entityfields/organisationopenclusterdetailactiongroup/children/organisationopenclusterdetail/onActionProcess.js</onActionProcess>
<isSelectionAction v="true" />
<iconId>VAADIN:FOLDER_OPEN</iconId>
</entityActionField>
</children>
</entityActionGroup>
<entityConsumer>
<name>DuplicateOrganisationsConsumer</name>
<dependency>
<name>dependency</name>
<entityName>Organisation_entity</entityName>
<fieldName>NonselfDuplicates</fieldName>
</dependency>
<children>
<entityParameter>
<name>DuplicateActionsControl_param</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/duplicateorganisationsconsumer/children/duplicateactionscontrol_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>OnlyShowContactIds_param</name>
<valueProcess>%aditoprj%/entity/Duplicates_entity/entityfields/duplicateorganisationsconsumer/children/onlyshowcontactids_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityProvider>
<name>#PROVIDER_AGGREGATES</name>
<useAggregates v="true" />
</entityProvider>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
<name>recordContainer</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<contentProcess>%aditoprj%/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js</contentProcess>
<recordFieldMappings>
<jDitoRecordFieldMapping>
<name>UID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>CLUSTER_DESCRIPTION.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>COUNT_DUPLICATES_IN_CLUSTER.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>TARGET_ENTITY.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>CLUSTER_ID.value</name>
</jDitoRecordFieldMapping>
</recordFieldMappings>
</jDitoRecordContainer>
</recordContainers>
</entity>
=Duplicates_entity
This Entity shows the Duplicates of
\ No newline at end of file
import("system.logging");
import("system.neon");
import("system.vars");
import("DuplicateScanner_lib");
import("system.notification");
let clusterId = vars.get("$sys.selection");
let duplicateContactIdsInClusterRay = DuplicateScannerUtils.getCachedDuplicatesForClusterId(clusterId)
if(duplicateContactIdsInClusterRay.length > 1)
{
let referenceDuplicateId = duplicateContactIdsInClusterRay[0];
for (let i = 1; i < duplicateContactIdsInClusterRay.length; i++)
{
DuplicateScannerUtils.createUnrelatedDuplicateRelation(referenceDuplicateId, duplicateContactIdsInClusterRay[i], clusterId);
}
//notification.createConfig().notificationType(notification.t)
//neon.refresh(["$field.SelfPersonDuplicatesConsumer"])
//todo Temporary!!! In the first refresh is the record via idValue selected and gets refreshed but stays visible in the record container
//todo Temporary!!! on the second refresh, no selecten remains and the container loads the remaining records as expected
neon.refreshAll();
neon.refreshAll();
}
import("system.result");
result.string("2");//todo exchange with keyword
import("system.logging");
import("system.result");
import("system.vars");
import("DuplicateScanner_lib");
let clusterRecordId = vars.get("$field.UID");
let contactIdsInCluster = DuplicateScannerUtils.getCachedDuplicatesForClusterId(clusterRecordId);
/*
* 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("system.result");
result.string("2");//todo exchange with keyword
import("system.logging");
import("system.result");
import("system.vars");
import("DuplicateScanner_lib");
let clusterRecordId = vars.get("$field.UID");
let contactIdsInCluster = DuplicateScannerUtils.getCachedDuplicatesForClusterId(clusterRecordId);
/*
* 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("system.vars");
import("system.result");
result.string("Organisation_entity");
\ No newline at end of file
import("system.vars");
import("system.result");
//let clusterId = vars.get("$field.UID");
let clusterId = vars.get("$param.ClusterId_param");
result.string(clusterId);
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.neon");
let contextName = "Duplicates";
let viewName = "OrganisationClusterMain_view";
var params = {};
params["ClusterId_param"] = vars.get("$sys.selection")[0];
params["TargetEntity"] = "Organisation_entity";
neon.openContext(contextName, viewName, null, neon.OPERATINGSTATE_VIEW, params);
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.neon");
let contextName = "Duplicates";
let viewName = "PersonClusterMain_view";
var params = {};
params["ClusterId_param"] = vars.get("$sys.selection")[0];
params["TargetEntity"] = "Person_entity";
neon.openContext(contextName, viewName, null, neon.OPERATINGSTATE_VIEW, params);
\ No newline at end of file
import("system.vars");
import("system.result");
let clusterId = vars.get("$param.ClusterId_param");
result.string(clusterId);
\ No newline at end of file
import("system.result");
result.string("Organisation_entity");
\ No newline at end of file
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