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

First version of the functional table merge for "Person"s

Addtitional tables have been added
It's now differentiated between the current alias and the system alias because both contain tables which have to be merged
parent 8fc453a7
No related branches found
No related tags found
No related merge requests found
......@@ -473,6 +473,7 @@
<dbRecordFieldMapping>
<name>ZIP.value</name>
<recordfield>ADDRESS.ZIP</recordfield>
<isFilterable v="true" />
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>ADDR_TYPE.displayValue</name>
......
......@@ -1280,6 +1280,11 @@ Usually this is used for filtering COMMUNICATION-entries by a specified contact
<isFilterable v="true" />
<filtertype>EXTENDED</filtertype>
</consumerMapping>
<consumerMapping>
<name>PersAddresses</name>
<isFilterable v="true" />
<filtertype>EXTENDED</filtertype>
</consumerMapping>
</recordFieldMappings>
<filterExtensions>
<filterExtensionSet>
......
......@@ -284,29 +284,38 @@ pQueryTargetRecords, pFilterFields, pRecordIdFieldToIgnore)
DuplicateScannerUtils.MergePerson = function(pSourceContactId, pTargetContactId)
{
let updateStatements = [];
let updateStatementsCurrentAlias = [];
let updateStatementsSystemAlias = [];
let deleteStatements = [];
var sourcePersonId = db.cell("select PERSON_ID from CONTACT where CONTACTID = '" + pSourceContactId + "'");
var tableInfos = _DuplicateScannerUtils._getMergeUpdateTableInfos();
var tableInfosCurrentAlias = _DuplicateScannerUtils._getMergeUpdateTableInfosCurrentAlias();
var tableInfosSystemAlias = _DuplicateScannerUtils._getMergeUpdateTableInfosSystemAlias();
updateStatements = updateStatements.concat(_DuplicateScannerUtils._buildUpdateContactIdStatements(tableInfos, pSourceContactId, pTargetContactId));
updateStatements = updateStatements.concat(_DuplicateScannerUtils._buildUpdateAttachParticipantsToNewContactQuery("CAMPAIGNPARTICIPANT", "CONTACT_ID", "CAMPAIGN_ID", pSourceContactId, pTargetContactId));
updateStatementsCurrentAlias = updateStatementsCurrentAlias.concat(_DuplicateScannerUtils._buildUpdateContactIdStatements(tableInfosCurrentAlias, pSourceContactId, pTargetContactId));
updateStatementsCurrentAlias = updateStatementsCurrentAlias.concat(_DuplicateScannerUtils._buildUpdateAttachParticipantsToNewContactQuery("CAMPAIGNPARTICIPANT", "CONTACT_ID", "CAMPAIGN_ID", pSourceContactId, pTargetContactId));
updateStatementsCurrentAlias = updateStatementsCurrentAlias.concat(_DuplicateScannerUtils._buildUpdateContactIdStatements(tableInfosCurrentAlias, pSourceContactId, pTargetContactId));
updateStatementsSystemAlias = updateStatementsSystemAlias.concat(_DuplicateScannerUtils._buildUpdateContactIdStatements(tableInfosSystemAlias, pSourceContactId, pTargetContactId));
deleteStatements = deleteStatements.concat(_DuplicateScannerUtils._buildDeleteRemoveObsoleteParticipantsRecordsQuery("CAMPAIGNPARTICIPANT", "CONTACT_ID", "CAMPAIGN_ID", pSourceContactId, pTargetContactId));
deleteStatements = deleteStatements.concat(_DuplicateScannerUtils._buildDeletePersonAndContactQuery(sourcePersonId, pSourceContactId));
deleteStatements = deleteStatements.concat(_DuplicateScannerUtils._buildDeleteCachedUnrelatedDuplicateQuery(pSourceContactId));
logging.log("updateStatements -> " + JSON.stringify(updateStatements));
logging.log("updateStatementsCurrentAlias -> " + JSON.stringify(updateStatementsCurrentAlias));
logging.log("deleteStatements -> " + JSON.stringify(deleteStatements));
let affectedRows = db.updates(updateStatements);
let affectedRowsCurrentAlias = db.updates(updateStatementsCurrentAlias);
let affectedRowsSystemAlias = db.updates(updateStatementsSystemAlias, "_____SYSTEMALIAS");
let deletedRows = db.deletes(deleteStatements)
logging.log("affectedRowsCurrentAlias -> " + affectedRowsCurrentAlias);
logging.log("deletedRows -> " + deletedRows);
DuplicateScannerUtils.DeleteCachedDuplicate(pSourceContactId);
return (affectedRows > 0 && deletedRows >= 2);
return (affectedRowsCurrentAlias > 0 && deletedRows >= 2);
}
DuplicateScannerUtils.MergeOrganisation = function(pSourceContactId, pTargetContactId)
......@@ -477,7 +486,7 @@ _DuplicateScannerUtils._buildStatement = function(pTableinfos, pSourceContactId,
return [tableName, [columnName], null, [pTargetContactId], condition];
}
_DuplicateScannerUtils._getMergeUpdateTableInfos = function(pSourceContactId, pTargetContactId)
_DuplicateScannerUtils._getMergeUpdateTableInfosCurrentAlias = function(pSourceContactId, pTargetContactId)
{
var tableInfos = new Array();
tableInfos.push(["AB_APPOINTMENTLINK", "OBJECT_ROWID", ""]);
......@@ -511,11 +520,18 @@ _DuplicateScannerUtils._getMergeUpdateTableInfos = function(pSourceContactId, pT
tableInfos.push(["DSGVOINFO", "CONTACT_ID", ""]);
tableInfos.push(["TIMETRACKING", "CONTACT_ID", ""]);
tableInfos.push(["ACTIVITYLINK", "OBJECT_ROWID", ""]);
tableInfos.push(["AB_ATTRIBUTERELATION", "OBJECT_ROWID", ""]);
return tableInfos;
}
_DuplicateScannerUtils._getMergeUpdateTableInfosSystemAlias = function(pSourceContactId, pTargetContactId)
{
var tableInfos = new Array();
tableInfos.push(["ASYS_CALENDARLINK", "DBID", ""]);
tableInfos.push(["ASYS_BINARIES", "ROW_ID", "TABLENAME = 'CONTACT'"]);
return tableInfos;
}
/*
* The pre filter is used to narrow the records to be searched by the duplicate scan service
......
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