Skip to content
Snippets Groups Projects
Commit eed94091 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

1064436 Duplicate merge

parent 40b871ac
No related branches found
No related tags found
No related merge requests found
......@@ -1234,23 +1234,12 @@ _DuplicateScannerUtils._migrateLinkedContactData = function (pSourceContactId, p
_DuplicateScannerUtils._getLinkedTableInfos = function(pTargetContactId)
{
//don't use communications that the target already has
var communicationDedupCondition = newWhere(null, newSelect("targetComm.COMMUNICATIONID")
.from("COMMUNICATION", "targetComm")
.where(["COMMUNICATION", "CONTACT_ID", "targetComm"], pTargetContactId)
.and("targetComm.ADDR = COMMUNICATION.ADDR"),
SqlBuilder.NOT_EXISTS());
//don't use attributes that the contact already has
var targetAttributeSubselect = newSelect("targetAttr.AB_ATTRIBUTERELATIONID")
.from("AB_ATTRIBUTERELATION", "targetAttr")
.where(["AB_ATTRIBUTERELATION", "OBJECT_ROWID", "targetAttr"], pTargetContactId)
.and("targetAttr.AB_ATTRIBUTE_ID = AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID");
AttributeTypeUtil.getAllDatabaseFields().forEach(function (dbColumn)
{
targetAttributeSubselect.and(newWhere("targetAttr." + dbColumn + " = AB_ATTRIBUTERELATION." + dbColumn)
.or("targetAttr." + dbColumn + " is null"));
});
var targetComms = newSelect("COMMUNICATION.ADDR")
.from("COMMUNICATION")
.where("COMMUNICATION.CONTACT_ID", pTargetContactId)
.arrayColumn();
var communicationDedupCondition = newWhere("COMMUNICATION.ADDR", targetComms, SqlBuilder.NOT_IN());
return[
["AB_APPOINTMENTLINK", "OBJECT_ROWID"],
......@@ -1284,7 +1273,7 @@ _DuplicateScannerUtils._getLinkedTableInfos = function(pTargetContactId)
["DSGVOINFO", "CONTACT_ID"],
["TIMETRACKING", "CONTACT_ID"],
["ACTIVITYLINK", "OBJECT_ROWID"],
["AB_ATTRIBUTERELATION", "OBJECT_ROWID", newWhere(null, targetAttributeSubselect, SqlBuilder.NOT_EXISTS())],
["AB_ATTRIBUTERELATION", "OBJECT_ROWID"],
["ASYS_CALENDARLINK", "DBID", "", SqlUtils.getSystemAlias()]
];
......
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