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

Merge branch 'cm_1078967_Refactoring_Dublettenerkennung' into '2021.1'

Cm 1078967 refactoring dublettenerkennung

See merge request xrm/basic!1093
parents b78542a9 f36f0a7b
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 460 deletions
import("system.result");
import("Communication_lib");
result.string(CommUtil.getStandardSubSqlMail());
import("system.result");
import("Communication_lib");
result.string(CommUtil.getStandardSubSqlPhone());
import("system.result");
import("Keyword_lib");
import("KeywordRegistry_basic");
var sql = KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.contactStatus(), "CONTACT.STATUS");
result.string(sql);
import("system.result");
import("Keyword_lib");
import("KeywordRegistry_basic");
var sql = KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.organisationType(), "ORGANISATION.KIND");
result.string(sql);
<?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.21" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.21">
<name>DuplicatePerson_entity</name>
<title>Duplicate</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<documentation>%aditoprj%/entity/DuplicatePerson_entity/documentation.adoc</documentation>
<grantCreate v="false" />
<grantUpdate v="false" />
<grantDelete v="false" />
<initFilterProcess>%aditoprj%/entity/DuplicatePerson_entity/initFilterProcess.js</initFilterProcess>
<titlePlural>Duplicates</titlePlural>
<recordContainer>db</recordContainer>
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
<targetContextField>parentContext</targetContextField>
<targetIdField>CONTACTID</targetIdField>
</entityProvider>
<entityProvider>
<name>#PROVIDER_AGGREGATES</name>
<useAggregates v="true" />
</entityProvider>
<entityParameter>
<name>Obj_param</name>
<expose v="true" />
<mandatory v="true" />
<description>Contains a name value object of all variables that can be used to scan for duplicates</description>
</entityParameter>
<entityActionGroup>
<name>filterActions</name>
<children>
<entityActionField>
<name>ignoreDuplicates</name>
<title>${IGNORE_DUPLICATE}</title>
<onActionProcess>%aditoprj%/entity/DuplicatePerson_entity/entityfields/filteractions/children/ignoreduplicates/onActionProcess.js</onActionProcess>
<isObjectAction v="false" />
<selectionType>MULTI</selectionType>
<iconId>VAADIN:CLOSE</iconId>
<titleProcess>%aditoprj%/entity/DuplicatePerson_entity/entityfields/filteractions/children/ignoreduplicates/titleProcess.js</titleProcess>
</entityActionField>
<entityActionField>
<name>mergeselectedintocurrent</name>
<title>Integrate selected into current contact</title>
<onActionProcess>%aditoprj%/entity/DuplicatePerson_entity/entityfields/filteractions/children/mergeselectedintocurrent/onActionProcess.js</onActionProcess>
<selectionType>MULTI</selectionType>
<iconId>NEON:IMPORT</iconId>
</entityActionField>
<entityActionField>
<name>mergecurrentintoselected</name>
<title>Integrate current into selected contact</title>
<onActionProcess>%aditoprj%/entity/DuplicatePerson_entity/entityfields/filteractions/children/mergecurrentintoselected/onActionProcess.js</onActionProcess>
<selectionType>MULTI</selectionType>
<iconId>NEON:EXPORT</iconId>
</entityActionField>
</children>
</entityActionGroup>
<entityField>
<name>CONTACTID</name>
<linkedContext>Person</linkedContext>
</entityField>
<entityParameter>
<name>Id_param</name>
<valueProcess>%aditoprj%/entity/DuplicatePerson_entity/entityfields/id_param/valueProcess.js</valueProcess>
<mandatory v="true" />
</entityParameter>
<entityField>
<name>FIRSTNAME</name>
<title>Firstname</title>
</entityField>
<entityField>
<name>LASTNAME</name>
<title>Lastname</title>
<linkedContext>Person</linkedContext>
</entityField>
<entityField>
<name>MIDDLENAME</name>
<title>Middlename</title>
</entityField>
<entityField>
<name>LETTERSALUTATION</name>
<title>Salutation</title>
</entityField>
<entityField>
<name>TITLE</name>
<title>Title</title>
</entityField>
<entityField>
<name>PICTURE</name>
<title>Picture</title>
<contentType>IMAGE</contentType>
<displayValueProcess>%aditoprj%/entity/DuplicatePerson_entity/entityfields/picture/displayValueProcess.js</displayValueProcess>
</entityField>
<entityField>
<name>STANDARD_EMAIL_COMMUNICATION</name>
<title>E-Mail</title>
</entityField>
<entityField>
<name>STANDARD_PHONE_COMMUNICATION</name>
<title>Phone</title>
</entityField>
<entityField>
<name>ORGANISATION_ID</name>
<title>Company</title>
<consumer>Organisations</consumer>
<linkedContext>Organisation</linkedContext>
</entityField>
<entityConsumer>
<name>Organisations</name>
<dependency>
<name>dependency</name>
<entityName>Organisation_entity</entityName>
<fieldName>Organisations</fieldName>
</dependency>
</entityConsumer>
<entityField>
<name>STATUS</name>
<title>Status</title>
<consumer>KeywordContactStates</consumer>
</entityField>
<entityConsumer>
<name>KeywordContactStates</name>
<dependency>
<name>dependency</name>
<entityName>KeywordEntry_entity</entityName>
<fieldName>SpecificContainerKeywords</fieldName>
</dependency>
<children>
<entityParameter>
<name>ContainerName_param</name>
<valueProcess>%aditoprj%/entity/DuplicatePerson_entity/entityfields/keywordcontactstates/children/containername_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityField>
<name>STANDARD_ADDRESS</name>
<title>Address</title>
</entityField>
<entityField>
<name>parentContext</name>
<valueProcess>%aditoprj%/entity/DuplicatePerson_entity/entityfields/parentcontext/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>DUPLICATE</name>
<title>Duplicate</title>
<contentType>BOOLEAN</contentType>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
<name>db</name>
<isReadOnly v="true" />
<fromClauseProcess>%aditoprj%/entity/DuplicatePerson_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess>
<conditionProcess>%aditoprj%/entity/DuplicatePerson_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
<alias>Data_alias</alias>
<recordFieldMappings>
<dbRecordFieldMapping>
<name>CONTACTID.value</name>
<recordfield>CONTACT.CONTACTID</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>MIDDLENAME.value</name>
<recordfield>PERSON.MIDDLENAME</recordfield>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>LASTNAME.value</name>
<recordfield>CONTACT.CONTACTID</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>FIRSTNAME.value</name>
<recordfield>PERSON.FIRSTNAME</recordfield>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>LETTERSALUTATION.value</name>
<recordfield>PERSON.SALUTATION</recordfield>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>LASTNAME.displayValue</name>
<recordfield>PERSON.LASTNAME</recordfield>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>TITLE.value</name>
<recordfield>PERSON.TITLE</recordfield>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>PICTURE.value</name>
<recordfield>PERSON.PICTURE</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>STANDARD_PHONE_COMMUNICATION.value</name>
<expression>%aditoprj%/entity/DuplicatePerson_entity/recordcontainers/db/recordfieldmappings/standard_phone_communication.value/expression.js</expression>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>STANDARD_EMAIL_COMMUNICATION.value</name>
<expression>%aditoprj%/entity/DuplicatePerson_entity/recordcontainers/db/recordfieldmappings/standard_email_communication.value/expression.js</expression>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>ORGANISATION_ID.value</name>
<expression>%aditoprj%/entity/DuplicatePerson_entity/recordcontainers/db/recordfieldmappings/organisation_id.value/expression.js</expression>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>STATUS.value</name>
<recordfield>CONTACT.STATUS</recordfield>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>STATUS.displayValue</name>
<expression>%aditoprj%/entity/DuplicatePerson_entity/recordcontainers/db/recordfieldmappings/status.displayvalue/expression.js</expression>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>STANDARD_ADDRESS.value</name>
<recordfield>ADDRESS.ADDRESS</recordfield>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>ORGANISATION_ID.displayValue</name>
<expression>%aditoprj%/entity/DuplicatePerson_entity/recordcontainers/db/recordfieldmappings/organisation_id.displayvalue/expression.js</expression>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>DUPLICATE.value</name>
<expression>%aditoprj%/entity/DuplicatePerson_entity/recordcontainers/db/recordfieldmappings/duplicate.value/expression.js</expression>
<isFilterable v="true" />
</dbRecordFieldMapping>
</recordFieldMappings>
<linkInformation>
<linkInformation>
<name>93f86a28-8c69-491e-8f62-79f5840e23a5</name>
<tableName>PERSON</tableName>
<primaryKey>PERSONID</primaryKey>
<isUIDTable v="false" />
<readonly v="true" />
</linkInformation>
<linkInformation>
<name>c989f19d-d211-4f54-9ea5-ddf16e5a13a0</name>
<tableName>CONTACT</tableName>
<primaryKey>CONTACTID</primaryKey>
<isUIDTable v="true" />
<readonly v="true" />
</linkInformation>
<linkInformation>
<name>7ff69154-f1ff-4e33-8cd4-5a88e3b18269</name>
<tableName>ADDRESS</tableName>
<primaryKey>ADDRESSID</primaryKey>
<isUIDTable v="false" />
<readonly v="true" />
</linkInformation>
</linkInformation>
</dbRecordContainer>
</recordContainers>
</entity>
= DuplicateOrganisation_entity
== Overview
Shows the duplicates of a record.
The views are only referenced in the PersonMain_view.
This entity is used to show all duplicates of a person, merge duplicates to one record and to ignore duplicates.
==== Actions
* ignoreDuplicates: The selected record is marked as no duplicate.
* mergeselectedintocurrent: The selected record will be merged into the current opened one.
* mergecurrentintoselected: Same behavior as with the mergeselectedintocurrent action only the other way.
== AID
More information on duplicates can be found in the AID60 or in the documentation of the DuplicateScanner_entity
import("system.translate");
import("system.question");
import("system.tools");
import("Employee_lib");
import("system.vars");
import("system.neon");
import("DuplicateMerge_lib");
if(vars.get("$sys.selection").length == 1)
{
var sourceContactId = vars.get("$param.Id_param");
var targetContactId = vars.get("$sys.selection")[0];
//todo the actual merge ought to happen in a separate view where the contact infos can be merged manually by the user.
var mergeSuccess = DuplicateMergeUtils.mergePerson(sourceContactId, targetContactId);
if(mergeSuccess)
{
var user = tools.getUserByAttribute(tools.CONTACTID, sourceContactId);
if (user) {
user[tools.PARAMS][tools.CONTACTID] = targetContactId;
tools.updateUser(user);
}
var currentContactId = EmployeeUtils.getCurrentContactId();
if(currentContactId == null)
currentContactId = "";
DuplicateMergeUtils.createMergeSuccessActivity(sourceContactId, targetContactId, currentContactId, "Person");
neon.openContext("Person", "PersonMain_view", [targetContactId], neon.OPERATINGSTATE_VIEW, null)
}
}
else
{
question.showMessage(translate.text("Please select only one element"));
}
import("system.translate");
import("system.question");
import("system.tools");
import("system.db");
import("Employee_lib");
import("KeywordRegistry_basic");
import("ActivityTask_lib");
import("system.vars");
import("system.neon");
import("DuplicateMerge_lib");
if(vars.get("$sys.selection").length == 1)
{
var targetContactId = vars.get("$param.Id_param");
var sourceContactIdArray = vars.get("$sys.selection");
var sourceContactId = sourceContactIdArray[0];
//todo the actual merge ought to happen in a separate view where the contact infos can be merged manually by the user.
var mergeSuccess = DuplicateMergeUtils.mergePerson(sourceContactId, targetContactId);
if(mergeSuccess)
{
var user = tools.getUserByAttribute(tools.CONTACTID, sourceContactId);
if (user) {
user[tools.PARAMS][tools.CONTACTID] = targetContactId;
tools.updateUser(user);
}
var currentContactId = EmployeeUtils.getCurrentContactId();
if(currentContactId == null)
currentContactId = "";
DuplicateMergeUtils.createMergeSuccessActivity(sourceContactId, targetContactId, currentContactId, "Person");
//neon.refresh() with no fields will refresh the current image (and all sub images) but NOT the preview. neon.refreshAll() would refresh both,
//why it would lead to an error because it's trying to load the already opened preview of the duplicateContact which just got deleted
//and does not exist any more which results in an exception
neon.refresh();
}
}
else
{
question.showMessage(translate.text("Please select only one element"));
}
import("system.result");
import("system.vars");
var jsonObj = JSON.parse(vars.get("$param.Obj_param"));
result.string(jsonObj["CONTACTID"]);
import("system.result");
import("Keyword_lib");
import("KeywordRegistry_basic");
result.string($KeywordRegistry.contactStatus());
import("system.result");
import("Context_lib");
result.string(ContextUtils.getContextName("Person"));
import("system.result");
import("system.vars");
if (vars.get("$field.PICTURE"))
{
result.string(vars.get("$field.PICTURE"));
}
else
{
result.string("TEXT:" + (vars.getString("$field.FIRSTNAME") + " " + vars.getString("$field.LASTNAME")).trim());
}
import("system.translate");
import("system.result");
result.string(JSON.stringify({
type: "group",
operator: "AND",
childs: [{
type: "row",
name: "DUPLICATE",
operator: "EQUAL",
contenttype: "BOOLEAN",
key: "1",
value: translate.text("Yes")
}]
}));
import("system.vars");
import("Sql_lib");
import("DuplicateScanner_lib");
import("system.result");
var duplicateIds = DuplicateScannerUtils.getDuplicateIdsByEntityObj("Person_entity", JSON.parse(vars.get("$param.Obj_param")));
duplicateIds.push("-"); // workaround empty arrays
result.string(newWhere("CONTACT.CONTACTID", duplicateIds, SqlBuilder.IN()).toString());
import("Sql_lib");
import("system.vars");
import("system.result");
var unrelatedCondition = newWhere("UNRELATEDDUPLICATES.DUPLICATETYPE", "Person_entity")
.and("UNRELATEDDUPLICATES.SOURCEDUPLICATEID", vars.get("$param.Id_param"))
.and("UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID = CONTACT.CONTACTID");
result.string(
"PERSON " +
"join CONTACT on (PERSON.PERSONID = CONTACT.PERSON_ID) " +
"left join ADDRESS on (ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID) " +
"left join UNRELATEDDUPLICATES on " + unrelatedCondition.toString()
);
import("system.result");
import("Sql_lib");
var statement = SqlBuilder.caseStatement()
.when("UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID is not null")
.thenString("0").elseString("1");
result.string(statement);
import("Sql_lib");
import("system.result");
result.string(newSelect("ORGANISATION.NAME").from("ORGANISATION")
.where("ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID").toString());
import("system.result");
import("Sql_lib");
result.string(newSelect("c.CONTACTID").from("CONTACT as c")
.where("c.ORGANISATION_ID = CONTACT.ORGANISATION_ID")
.and("c.PERSON_ID is null").toString());
import("system.result");
import("Communication_lib");
result.string(CommUtil.getStandardSubSqlMail());
import("system.result");
import("Communication_lib");
result.string(CommUtil.getStandardSubSqlPhone());
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