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

Aktionen in der Dublettenansicht einer Organisation wurden entsprechend dem...

Aktionen in der Dublettenansicht einer Organisation wurden entsprechend dem Person pendant eingefügt und angepasst
Organisationsdubletten werden  nun als zusätzlicher Reiter in der Org-Mainview angezeigt
Der Organisation Recordcontainer wurde um die Duplicate-Teile erweitert
Duplicates lib Funktion refactored
parent 89a40100
No related branches found
No related tags found
No related merge requests found
Showing
with 263 additions and 18 deletions
......@@ -934,6 +934,83 @@
</entityParameter>
</children>
</entityConsumer>
<entityProvider>
<name>SelfDuplicatesProvider</name>
<titlePlural>Duplicates</titlePlural>
</entityProvider>
<entityConsumer>
<name>SelfDuplicatesConsumer</name>
<dependency>
<name>dependency</name>
<entityName>Organisation_entity</entityName>
<fieldName>SelfDuplicatesProvider</fieldName>
</dependency>
<children>
<entityParameter>
<name>OnlyShowContactIds_param</name>
<valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/onlyshowcontactids_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>DuplicateCurrentContactId_param</name>
<valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicatecurrentcontactid_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>DuplicateActionsControl_param</name>
<valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/selfduplicatesconsumer/children/duplicateactionscontrol_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityParameter>
<name>OnlyShowContactIds_param</name>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>DuplicateActionsControl_param</name>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>DuplicateCurrentContactId_param</name>
<expose v="true" />
</entityParameter>
<entityActionGroup>
<name>DuplicateActions</name>
<title>Duplicate actions</title>
<state>AUTO</state>
<stateProcess>%aditoprj%/entity/Organisation_entity/entityfields/duplicateactions/stateProcess.js</stateProcess>
<children>
<entityActionField>
<name>IntegrateSelectedIntoCurrentAction</name>
<title>Integrate selected into current contact</title>
<onActionProcess>%aditoprj%/entity/Organisation_entity/entityfields/duplicateactions/children/integrateselectedintocurrentaction/onActionProcess.js</onActionProcess>
<isSelectionAction v="true" />
<iconId>NEON:IMPORT</iconId>
<stateProcess>%aditoprj%/entity/Organisation_entity/entityfields/duplicateactions/children/integrateselectedintocurrentaction/stateProcess.js</stateProcess>
</entityActionField>
<entityActionField>
<name>IntegrateCurrentIntoSelectedAction</name>
<title>Integrate current into selected contact</title>
<onActionProcess>%aditoprj%/entity/Organisation_entity/entityfields/duplicateactions/children/integratecurrentintoselectedaction/onActionProcess.js</onActionProcess>
<isSelectionAction v="true" />
<iconId>NEON:EXPORT</iconId>
<stateProcess>%aditoprj%/entity/Organisation_entity/entityfields/duplicateactions/children/integratecurrentintoselectedaction/stateProcess.js</stateProcess>
</entityActionField>
<entityActionField>
<name>IgnoreDuplicate</name>
<title>Ignore Duplicate</title>
<onActionProcess>%aditoprj%/entity/Organisation_entity/entityfields/duplicateactions/children/ignoreduplicate/onActionProcess.js</onActionProcess>
<isSelectionAction v="true" />
<iconId>VAADIN:CLOSE</iconId>
<stateProcess>%aditoprj%/entity/Organisation_entity/entityfields/duplicateactions/children/ignoreduplicate/stateProcess.js</stateProcess>
</entityActionField>
<entityActionField>
<name>IgnoreWholeCluster</name>
<title>Ignore whole Cluster</title>
<onActionProcess>%aditoprj%/entity/Organisation_entity/entityfields/duplicateactions/children/ignorewholecluster/onActionProcess.js</onActionProcess>
<iconId>VAADIN:CLOSE</iconId>
<stateProcess>%aditoprj%/entity/Organisation_entity/entityfields/duplicateactions/children/ignorewholecluster/stateProcess.js</stateProcess>
</entityActionField>
</children>
</entityActionGroup>
</entityFields>
<recordContainers>
<dbRecordContainer>
......@@ -943,6 +1020,7 @@
<conditionProcess>%aditoprj%/entity/Organisation_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
<orderClauseProcess>%aditoprj%/entity/Organisation_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess>
<onDBUpdate>%aditoprj%/entity/Organisation_entity/recordcontainers/db/onDBUpdate.js</onDBUpdate>
<onDBDelete>%aditoprj%/entity/Organisation_entity/recordcontainers/db/onDBDelete.js</onDBDelete>
<linkInformation>
<linkInformation>
<name>5808a4a3-f2c1-4ccd-bad1-4e8a834ec7a4</name>
......
import("system.neon");
import("system.vars");
import("DuplicateScanner_lib");
let sourceContactId = vars.get("$param.DuplicateCurrentContactId_param");
let selectedContactId = vars.get("$sys.selection");
let clusterId = DuplicateScannerUtils.GetClusterId(sourceContactId);
DuplicateScannerUtils.CreateUnrelatedDuplicateRelation(sourceContactId, selectedContactId, clusterId);
neon.refreshAll();
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.neon");
import("system.result");
//Actions to show in the duplicates view inside the persons main view
let actionState = vars.get("$param.DuplicateActionsControl_param");
if(actionState != null && actionState != "1")//todo replace with keyword
result.string(neon.COMPONENTSTATE_INVISIBLE);
\ No newline at end of file
import("system.logging");
import("system.neon");
import("system.vars");
import("DuplicateScanner_lib");
import("system.notification");
let contactId = vars.get("$field.CONTACTID");
let clusterId = DuplicateScannerUtils.GetClusterId(contactId);
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);
}
}
import("system.logging");
import("system.vars");
import("system.neon");
import("system.result");
//Actions to show in the duplicates view inside the persons main view
let actionState = vars.get("$param.DuplicateActionsControl_param");
if(actionState != null && actionState != "2")//todo replace with keyword
result.string(neon.COMPONENTSTATE_INVISIBLE);
\ No newline at end of file
import("system.vars");
import("system.neon");
import("DuplicateScanner_lib");
let sourceContactId = vars.get("$param.DuplicateCurrentContactId_param");
let targetContactId = vars.get("$sys.selection");
//todo the actual merge ought to happen in a separate view where the contact infos can be merged manually by the user.
let mergeSuccess = DuplicateScannerUtils.MergeOrganisation(sourceContactId, targetContactId);
if(mergeSuccess)
{
neon.openContext("Organisation", "OrganisationMain_view", [targetContactId], neon.OPERATINGSTATE_VIEW, null)
}
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.neon");
import("system.result");
//Actions to show in the duplicates view inside the persons main view
let actionState = vars.get("$param.DuplicateActionsControl_param");
if(actionState != null && actionState != "1")//todo replace with keyword
result.string(neon.COMPONENTSTATE_INVISIBLE);
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.neon");
import("DuplicateScanner_lib");
let targetContactId = vars.get("$param.DuplicateCurrentContactId_param");
let sourceContactId = vars.get("$sys.selection");
logging.log("targetContactId -> " + targetContactId);
logging.log("sourceContactId -> "+ sourceContactId);
//todo the actual merge ought to happen in a separate view where the contact infos can be merged manually by the user.
let mergeSuccess = DuplicateScannerUtils.MergeOrganisation(sourceContactId, targetContactId);
if(mergeSuccess)
{
neon.refreshAll();
}
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.neon");
import("system.result");
//Actions to show in the duplicates view inside the persons main view
let actionState = vars.get("$param.DuplicateActionsControl_param");
if(actionState != null && actionState != "1")//todo replace with keyword
result.string(neon.COMPONENTSTATE_INVISIBLE);
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.neon");
import("system.result");
//Actions to show in the duplicates view inside the persons main view
let actionState = vars.get("$param.DuplicateActionsControl_param");
if(actionState == null || actionState == "0")//todo replace with keyword
result.string(neon.COMPONENTSTATE_INVISIBLE);
\ No newline at end of file
import("system.result");
result.string("1");//todo use keyword
\ No newline at end of file
import("system.vars");
import("system.result");
result.string(vars.get("$field.CONTACTID"));
\ No newline at end of file
import("system.logging");
import("system.vars");
import("DuplicateScanner_lib");
import("system.result");
let contactIdToCheck = vars.get("$field.CONTACTID");
let duplicateIds = DuplicateScannerUtils.GetCachedDuplicatesForContactId(contactIdToCheck);
/*
* 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(duplicateIds.length == 0)
result.string(JSON.stringify(["nodata"]));
else
result.string(JSON.stringify(duplicateIds));
\ No newline at end of file
......@@ -5,7 +5,9 @@ import("Sql_lib");
import("Context_lib");
var cond = SqlCondition.begin();
let alternativeCondition = "1 = 1";
var onlyShowContactIds = JSON.parse(vars.get("$param.OnlyShowContactIds_param"));
// filter privat company if it is not needed
if (vars.getString("$param.WithPrivate_param") != "true")
cond.andPrepare("ORGANISATION.ORGANISATIONID", "0", "# <> ?");
......@@ -41,5 +43,17 @@ if (vars.exists("$param.ExcludedContactIds_param") && vars.get("$param.ExcludedC
cond.andPrepareVars("ORGANISATION.KIND", "$param.OrganisationType_param");
if(onlyShowContactIds != null && onlyShowContactIds.length > 0)
{
let additionalCondition = SqlCondition.begin();
onlyShowContactIds.forEach(function(pContactId)
{
additionalCondition.orPrepare("CONTACT.CONTACTID", pContactId);
});
cond.andSqlCondition(additionalCondition, "1=2");
alternativeCondition = "1 = 2";
}
//TODO: use a preparedCondition when available #1030812 #1034026
result.string(db.translateCondition(cond.build("1 = 1")));
\ No newline at end of file
result.string(db.translateCondition(cond.build(alternativeCondition)));
\ No newline at end of file
import("system.vars");
import("DuplicateScanner_lib");
let contactId = vars.get("$field.CONTACTID");
DuplicateScannerUtils.DeleteCachedDuplicate(contactId);
\ No newline at end of file
import("system.result");
result.string("1");
\ No newline at end of file
result.string("1");//todo use keyword
\ No newline at end of file
......@@ -9,7 +9,7 @@ cond.andPrepareVars("CONTACT.ORGANISATION_ID", "$param.OrgId_param")
.andPrepareVars("PERSON.CONTACT_ID", "$param.ContactId_param");
var onlyShowContactIds = JSON.parse(vars.get("$param.OnlyShowContactIds_param"));
var additionalCondition = SqlCondition.begin();
let alternativeCondition = "1 = 1";
if (vars.exists("$param.ExcludedContactIds_param") && vars.get("$param.ExcludedContactIds_param"))
......
......@@ -33,6 +33,7 @@
<tableViewTemplate>
<name>Organisations</name>
<favoriteActionGroup1>campaignActionGroup</favoriteActionGroup1>
<favoriteActionGroup2>DuplicateActions</favoriteActionGroup2>
<subtitleField>CUSTOMERCODE_DISPLAY_fieldGroup</subtitleField>
<entityField>#ENTITY</entityField>
<columns>
......
......@@ -61,9 +61,9 @@
<view>LogHistoryFilter_view</view>
</neonViewReference>
<neonViewReference>
<name>100e9c93-0d63-4dd5-94b3-b88fe24f1954</name>
<entityField>OrganisationDuplicates</entityField>
<view>DuplicatesFilter_view</view>
<name>cbac7602-9eba-4e5d-8617-3d0b33e55ca1</name>
<entityField>SelfDuplicatesConsumer</entityField>
<view>OrganisationFilter_view</view>
</neonViewReference>
</children>
</neonView>
......@@ -29,11 +29,18 @@ DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, p
return possibleDuplicates;
}
DuplicateScannerUtils.DeleteCachedDuplicate = function(pContactId)
/*
* Deletes the cached duplicate for the given id.
* If there would only remains one item in the cluster after deletion, the whole cluster including the duplicate gets deleted.
* In this case, all records marked as unrelated duplicate will be deleted aswell.
*
* @param {String} pDuplicateId Id of the duplicate to delete
*/
DuplicateScannerUtils.DeleteCachedDuplicate = function(pDuplicateId)
{
let query = "select count(ID), CLUSTERID from DUPLICATECLUSTERS"
+ " where CLUSTERID = (select CLUSTERID from DUPLICATECLUSTERS where DUPLICATEID = '"+ pContactId +"')"
+ " and DUPLICATEID != '"+ pContactId +"'"
+ " where CLUSTERID = (select CLUSTERID from DUPLICATECLUSTERS where DUPLICATEID = '"+ pDuplicateId +"')"
+ " and DUPLICATEID != '"+ pDuplicateId +"'"
+ " group by CLUSTERID";
let coundAndClusterId = db.array(db.ROW, query);
......@@ -45,22 +52,23 @@ DuplicateScannerUtils.DeleteCachedDuplicate = function(pContactId)
//Otherwise delete just the single duplicate.
if(countDuplicatesInClusterWithoutParameterId <= 1)
{
let deleteClusterCondition = "DUPLICATECLUSTERS.CLUSTERID = '"+ clusterId +"'";
db.deleteData("DUPLICATECLUSTERS", pCondition);
let deleteStatements = [];
deleteStatements.push(["DUPLICATECLUSTERS", "DUPLICATECLUSTERS.CLUSTERID = '"+ clusterId +"'"]);
deleteStatements.push(["UNRELATEDDUPLICATES", "UNRELATEDDUPLICATES.CLUSTERID = '"+ clusterId +"'"]);
let deleteUnrelatedForClusterCondition = "UNRELATEDDUPLICATES.CLUSTERID = '"+ clusterId +"'";
db.deleteData("UNRELATEDDUPLICATES", pCondition);
db.deletes(deleteStatements);
}
else
{
db.deleteData("DUPLICATECLUSTERS", "DUPLICATECLUSTERS.DUPLICATEID = '"+ pContactId +"'");
db.deleteData("DUPLICATECLUSTERS", "DUPLICATECLUSTERS.DUPLICATEID = '"+ pDuplicateId +"'");
//Delete all records where this duplicateId is mentioned
DuplicateScannerUtils.DeleteAllUnrelatedDuplicateRelations(pDuplicateId);
}
DuplicateScannerUtils.DeleteAllUnrelatedDuplicateRelations(pContactId);
}
/*
* Deletes all CLusters for the given Target Entity.
* No unrelated-duplicate records are being deleted.
* Deletes all CLusters for the given target Entity.
* No records markes as unrelated duplicate are being deleted.
*
* @return Count of deleted rows
*/
......
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