Skip to content
Snippets Groups Projects
Commit 67c72553 authored by b.ulrich's avatar b.ulrich
Browse files

zwischencommit

parent 2f8afb14
No related branches found
No related tags found
No related merge requests found
......@@ -50,7 +50,16 @@ DuplicateScannerUtils.loadFilters = function(pFilterName, pTargetEntity)
*/
DuplicateScannerUtils.DeleteCachedDuplicate = function(pDuplicateId)
{
var query = newSelect("count(ID), CLUSTERID from DUPLICATECLUSTERS")
var query = newSelect("count(ID)")
.from("DUPLICATECLUSTERS")
.where("DUPLICATECLUSTERS.CLUSTERID", newSelect("CLUSTERID")
.from("DUPLICATECLUSTERS")
.where("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId).build(),
SqlBuilder.IN())
.and("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId, SqlBuilder.NOT_EQUAL());
var test = newSelect("CLUSTERID")
.from("DUPLICATECLUSTERS")
.where("DUPLICATECLUSTERS.CLUSTERID", newSelect("CLUSTERID")
.from("DUPLICATECLUSTERS")
......@@ -58,10 +67,20 @@ DuplicateScannerUtils.DeleteCachedDuplicate = function(pDuplicateId)
SqlBuilder.IN())
.and("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId, SqlBuilder.NOT_EQUAL())
.groupBy("CLUSTERID");
var so = "select count(ID),( select CLUSTERID from DUPLICATECLUSTERS)"
+ " from DUPLICATECLUSTERS where DUPLICATECLUSTERS.CLUSTERID in"
+ " (select CLUSTERID from DUPLICATECLUSTERS where(DUPLICATECLUSTERS.DUPLICATEID = ('" + pDuplicateId + "')))"
+ " and("
+ " DUPLICATECLUSTERS.DUPLICATEID <> ('" + pDuplicateId + "')"
+ " )"
+ " group by CLUSTERID"
var countAndClusterId = query.arrayRow();
var testundso = test.arrayRow()
let countDuplicatesInClusterWithoutParameterId = countAndClusterId[0];
let clusterId = countAndClusterId[1];
let clusterId = testundso[0];
//If only one duplicate would be remaining,
//the whole cluster has to be deleted because there are no more duplicates.
......@@ -70,9 +89,10 @@ DuplicateScannerUtils.DeleteCachedDuplicate = function(pDuplicateId)
if(countDuplicatesInClusterWithoutParameterId <= 1)
{
let deleteStatements = [];
if(clusterId != null && clusterId != undefined){
deleteStatements.push(["DUPLICATECLUSTERS", newWhere("DUPLICATECLUSTERS.CLUSTERID", clusterId).build()]);
deleteStatements.push(["UNRELATEDDUPLICATES", newWhere("UNRELATEDDUPLICATES.CLUSTERID", clusterId).build()]);
}
db.deletes(deleteStatements);
}
else
......@@ -635,9 +655,9 @@ DuplicateScannerUtils.TranslateEntityToIndexFields = function(pEntityName, pEnti
*/
DuplicateScannerUtils.MergePerson = function(pSourceContactId, pTargetContactId)
{
let updateStatementsCurrentAlias = [];
let updateStatementsSystemAlias = [];
let deleteStatements = [];
var updateStatementsCurrentAlias = [];
var updateStatementsSystemAlias = [];
var deleteStatements = [];
var sourcePersonId = newSelect("PERSON_ID")
.from("CONTACT")
......@@ -656,9 +676,9 @@ DuplicateScannerUtils.MergePerson = function(pSourceContactId, pTargetContactId)
deleteStatements = deleteStatements.concat(_DuplicateScannerUtils._buildDeletePersonAndContactQuery(sourcePersonId, pSourceContactId));
deleteStatements = deleteStatements.concat(_DuplicateScannerUtils._buildDeleteCachedUnrelatedDuplicateQuery(pSourceContactId));
let affectedRowsCurrentAlias = db.updates(updateStatementsCurrentAlias);
let affectedRowsSystemAlias = db.updates(updateStatementsSystemAlias, SqlUtils.getSystemAlias());
let deletedRows = db.deletes(deleteStatements)
var affectedRowsCurrentAlias = db.updates(updateStatementsCurrentAlias);
var affectedRowsSystemAlias = db.updates(updateStatementsSystemAlias, SqlUtils.getSystemAlias());
var deletedRows = db.deletes(deleteStatements)
DuplicateScannerUtils.DeleteCachedDuplicate(pSourceContactId);
......
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