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

DuplicateScanner_lib methods renamed to match coding guidelines

parent 20e1edf8
No related branches found
No related tags found
No related merge requests found
Showing
with 66 additions and 65 deletions
...@@ -7,12 +7,12 @@ var targetEntity = "Organisation_entity"; ...@@ -7,12 +7,12 @@ var targetEntity = "Organisation_entity";
var recordBlockSize = DuplicateScannerUtils.getBlockSize(); var recordBlockSize = DuplicateScannerUtils.getBlockSize();
logging.log(filterName + ": Delete duplicates -> "); logging.log(filterName + ": Delete duplicates -> ");
DuplicateScannerUtils.DeleteDuplicateClustersByTargetEntity(targetEntity); DuplicateScannerUtils.deleteClustersByTargetEntity(targetEntity);
logging.log(filterName + ": Recalculate duplicates -> "); logging.log(filterName + ": Recalculate duplicates -> ");
DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, recordBlockSize, null); DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, recordBlockSize, null);
logging.log(filterName + ": Refresh unrelated duplicates -> "); logging.log(filterName + ": Refresh unrelated duplicates -> ");
DuplicateScannerUtils.RefreshUnrelatedDuplicateRelations(targetEntity); DuplicateScannerUtils.refreshUnrelatedDuplicateRelations(targetEntity);
logging.log(filterName + ": Done rebuilding "); logging.log(filterName + ": Done rebuilding ");
\ No newline at end of file
...@@ -7,12 +7,12 @@ var targetEntity = "Person_entity"; ...@@ -7,12 +7,12 @@ var targetEntity = "Person_entity";
var recordBlockSize = DuplicateScannerUtils.getBlockSize(); var recordBlockSize = DuplicateScannerUtils.getBlockSize();
logging.log(filterName + ": Delete duplicates -> "); logging.log(filterName + ": Delete duplicates -> ");
DuplicateScannerUtils.DeleteDuplicateClustersByTargetEntity(targetEntity); DuplicateScannerUtils.deleteClustersByTargetEntity(targetEntity);
logging.log(filterName + ": Recalculate duplicates -> "); logging.log(filterName + ": Recalculate duplicates -> ");
DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, recordBlockSize, null); DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, recordBlockSize, null);
logging.log(filterName + ": Refresh unrelated duplicates -> "); logging.log(filterName + ": Refresh unrelated duplicates -> ");
DuplicateScannerUtils.RefreshUnrelatedDuplicateRelations(targetEntity); DuplicateScannerUtils.refreshUnrelatedDuplicateRelations(targetEntity);
logging.log(filterName + ": Done rebuilding "); logging.log(filterName + ": Done rebuilding ");
\ No newline at end of file
...@@ -162,13 +162,13 @@ import("JditoFilter_lib"); ...@@ -162,13 +162,13 @@ import("JditoFilter_lib");
//var tmpFieldsInFilterRay = ["CONTACTID", "FIRSTNAME", "LASTNAME", "GENDER"]; //var tmpFieldsInFilterRay = ["CONTACTID", "FIRSTNAME", "LASTNAME", "GENDER"];
// //
//logging.log("Löschen von PERSON Dubletten -> "); //logging.log("Löschen von PERSON Dubletten -> ");
//DuplicateScannerUtils.DeleteDuplicateClustersByTargetEntity("Person_entity"); //DuplicateScannerUtils.deleteClustersByTargetEntity("Person_entity");
// //
//logging.log("Neu berechnen von PERSON Dubletten -> "); //logging.log("Neu berechnen von PERSON Dubletten -> ");
//DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, queryPersonContactIds, //DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, queryPersonContactIds,
//tmpFieldsInFilterRay, resultFieldsIdFieldName); //tmpFieldsInFilterRay, resultFieldsIdFieldName);
// //
//DuplicateScannerUtils.RefreshUnrelatedDuplicateRelations(targetEntity); //DuplicateScannerUtils.refreshUnrelatedDuplicateRelations(targetEntity);
//############################################################################## //##############################################################################
...@@ -182,13 +182,13 @@ import("JditoFilter_lib"); ...@@ -182,13 +182,13 @@ import("JditoFilter_lib");
// //
// //
//logging.log("Löschen von ORGANISATION Dubletten -> "); //logging.log("Löschen von ORGANISATION Dubletten -> ");
//DuplicateScannerUtils.DeleteDuplicateClustersByTargetEntity(targetEntity) //DuplicateScannerUtils.deleteClustersByTargetEntity(targetEntity)
// //
//logging.log("Neu berechnen von ORGANISATION Dubletten -> "); //logging.log("Neu berechnen von ORGANISATION Dubletten -> ");
//DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, queryPersonContactIds, //DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, queryPersonContactIds,
//tmpFieldsInFilterRay, resultFieldsIdFieldName); //tmpFieldsInFilterRay, resultFieldsIdFieldName);
// //
//DuplicateScannerUtils.RefreshUnrelatedDuplicateRelations(targetEntity); //DuplicateScannerUtils.refreshUnrelatedDuplicateRelations(targetEntity);
//####################################Rebuild person duplicates########################################## //####################################Rebuild person duplicates##########################################
...@@ -210,11 +210,11 @@ import("JditoFilter_lib"); ...@@ -210,11 +210,11 @@ import("JditoFilter_lib");
// + " left join ADDRESS on ADDRESS.CONTACT_ID = CONTACT.CONTACTID"; // + " left join ADDRESS on ADDRESS.CONTACT_ID = CONTACT.CONTACTID";
// //
//logging.log("Löschen von PERSON Dubletten -> "); //logging.log("Löschen von PERSON Dubletten -> ");
//DuplicateScannerUtils.DeleteDuplicateClustersByTargetEntity(targetEntity); //DuplicateScannerUtils.deleteClustersByTargetEntity(targetEntity);
// //
//let formatToJsonAndCallWsCallback = function(pPossibleDuplicatesRay) //let formatToJsonAndCallWsCallback = function(pPossibleDuplicatesRay)
//{ //{
// let indexResultFields = DuplicateScannerUtils.TranslateEntityToIndexFields(targetEntity, resultFields) // let indexResultFields = DuplicateScannerUtils.translateEntityToIndexFields(targetEntity, resultFields)
// //
// //Run thru every duplicate result an read out the resultfields // //Run thru every duplicate result an read out the resultfields
// for (let i = 0; i < pPossibleDuplicatesRay.length; i++) // for (let i = 0; i < pPossibleDuplicatesRay.length; i++)
...@@ -236,7 +236,7 @@ import("JditoFilter_lib"); ...@@ -236,7 +236,7 @@ import("JditoFilter_lib");
//DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, queryPersonFieldData, //DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, queryPersonFieldData,
//duplicateFieldsConfig, resultFields, formatToJsonAndCallWsCallback); //duplicateFieldsConfig, resultFields, formatToJsonAndCallWsCallback);
// //
//DuplicateScannerUtils.RefreshUnrelatedDuplicateRelations(targetEntity); //DuplicateScannerUtils.refreshUnrelatedDuplicateRelations(targetEntity);
...@@ -255,7 +255,7 @@ import("JditoFilter_lib"); ...@@ -255,7 +255,7 @@ import("JditoFilter_lib");
//valuesToCheck["GENDER"] = "m "; //valuesToCheck["GENDER"] = "m ";
// //
////The result values can be accessed as seen above in "formatToJsonAndCallWsCallback" ////The result values can be accessed as seen above in "formatToJsonAndCallWsCallback"
//let pPossibleDuplicatesRay = DuplicateScannerUtils.ScanForDuplicates(filterName, targetEntity, valuesToCheck, null); //let pPossibleDuplicatesRay = DuplicateScannerUtils.scanForDuplicates(filterName, targetEntity, valuesToCheck, null);
// //
//logging.log(" pPossibleDuplicatesRay-> " + pPossibleDuplicatesRay); //logging.log(" pPossibleDuplicatesRay-> " + pPossibleDuplicatesRay);
// //
......
...@@ -6,14 +6,14 @@ import("system.notification"); ...@@ -6,14 +6,14 @@ import("system.notification");
let clusterId = vars.get("$sys.selection"); let clusterId = vars.get("$sys.selection");
let duplicateContactIdsInClusterRay = DuplicateScannerUtils.GetCachedDuplicatesForClusterId(clusterId) let duplicateContactIdsInClusterRay = DuplicateScannerUtils.getCachedDuplicatesForClusterId(clusterId)
if(duplicateContactIdsInClusterRay.length > 1) if(duplicateContactIdsInClusterRay.length > 1)
{ {
let referenceDuplicateId = duplicateContactIdsInClusterRay[0]; let referenceDuplicateId = duplicateContactIdsInClusterRay[0];
for (let i = 1; i < duplicateContactIdsInClusterRay.length; i++) for (let i = 1; i < duplicateContactIdsInClusterRay.length; i++)
{ {
DuplicateScannerUtils.CreateUnrelatedDuplicateRelation(referenceDuplicateId, duplicateContactIdsInClusterRay[i], clusterId); DuplicateScannerUtils.createUnrelatedDuplicateRelation(referenceDuplicateId, duplicateContactIdsInClusterRay[i], clusterId);
} }
//notification.createConfig().notificationType(notification.t) //notification.createConfig().notificationType(notification.t)
//neon.refresh(["$field.SelfPersonDuplicatesConsumer"]) //neon.refresh(["$field.SelfPersonDuplicatesConsumer"])
......
...@@ -5,7 +5,7 @@ import("DuplicateScanner_lib"); ...@@ -5,7 +5,7 @@ import("DuplicateScanner_lib");
let clusterRecordId = vars.get("$field.UID"); let clusterRecordId = vars.get("$field.UID");
let contactIdsInCluster = DuplicateScannerUtils.GetCachedDuplicatesForClusterId(clusterRecordId); let contactIdsInCluster = DuplicateScannerUtils.getCachedDuplicatesForClusterId(clusterRecordId);
/* /*
* To achieve that if there are no duplicates, no contacts should be shown and therefore returned by the * To achieve that if there are no duplicates, no contacts should be shown and therefore returned by the
......
...@@ -5,7 +5,7 @@ import("DuplicateScanner_lib"); ...@@ -5,7 +5,7 @@ import("DuplicateScanner_lib");
let clusterRecordId = vars.get("$field.UID"); let clusterRecordId = vars.get("$field.UID");
let contactIdsInCluster = DuplicateScannerUtils.GetCachedDuplicatesForClusterId(clusterRecordId); let contactIdsInCluster = DuplicateScannerUtils.getCachedDuplicatesForClusterId(clusterRecordId);
/* /*
* To achieve that if there are no duplicates, no contacts should be shown and therefore returned by the * To achieve that if there are no duplicates, no contacts should be shown and therefore returned by the
......
...@@ -4,7 +4,7 @@ import("DuplicateScanner_lib"); ...@@ -4,7 +4,7 @@ import("DuplicateScanner_lib");
let sourceContactId = vars.get("$param.DuplicateCurrentContactId_param"); let sourceContactId = vars.get("$param.DuplicateCurrentContactId_param");
let selectedContactId = vars.get("$sys.selection"); let selectedContactId = vars.get("$sys.selection");
let clusterId = DuplicateScannerUtils.GetClusterId(sourceContactId); let clusterId = DuplicateScannerUtils.getClusterId(sourceContactId);
DuplicateScannerUtils.CreateUnrelatedDuplicateRelation(sourceContactId, selectedContactId, clusterId); DuplicateScannerUtils.createUnrelatedDuplicateRelation(sourceContactId, selectedContactId, clusterId);
neon.refreshAll(); neon.refreshAll();
\ No newline at end of file
...@@ -5,16 +5,16 @@ import("DuplicateScanner_lib"); ...@@ -5,16 +5,16 @@ import("DuplicateScanner_lib");
import("system.notification"); import("system.notification");
let contactId = vars.get("$field.CONTACTID"); let contactId = vars.get("$field.CONTACTID");
let clusterId = DuplicateScannerUtils.GetClusterId(contactId); let clusterId = DuplicateScannerUtils.getClusterId(contactId);
let duplicateContactIdsInClusterRay = DuplicateScannerUtils.GetCachedDuplicatesForClusterId(clusterId) let duplicateContactIdsInClusterRay = DuplicateScannerUtils.getCachedDuplicatesForClusterId(clusterId)
if(duplicateContactIdsInClusterRay.length > 1) if(duplicateContactIdsInClusterRay.length > 1)
{ {
let referenceDuplicateId = duplicateContactIdsInClusterRay[0]; let referenceDuplicateId = duplicateContactIdsInClusterRay[0];
for (let i = 1; i < duplicateContactIdsInClusterRay.length; i++) for (let i = 1; i < duplicateContactIdsInClusterRay.length; i++)
{ {
DuplicateScannerUtils.CreateUnrelatedDuplicateRelation(referenceDuplicateId, duplicateContactIdsInClusterRay[i], clusterId); DuplicateScannerUtils.createUnrelatedDuplicateRelation(referenceDuplicateId, duplicateContactIdsInClusterRay[i], clusterId);
} }
} }
......
...@@ -3,5 +3,5 @@ import("system.vars"); ...@@ -3,5 +3,5 @@ import("system.vars");
import("system.result"); import("system.result");
import("DuplicateScanner_lib"); import("DuplicateScanner_lib");
let unrelatedIds = DuplicateScannerUtils.GetUnrelatedRelationsForDuplicate(vars.get("$field.CONTACTID")); let unrelatedIds = DuplicateScannerUtils.getUnrelatedRelationsForDuplicate(vars.get("$field.CONTACTID"));
result.string(JSON.stringify(unrelatedIds)); result.string(JSON.stringify(unrelatedIds));
\ No newline at end of file
...@@ -36,7 +36,7 @@ else ...@@ -36,7 +36,7 @@ else
//don't search if only the id field has a value //don't search if only the id field has a value
var fieldsToCheck = Object.keys(valuesToCheck); var fieldsToCheck = Object.keys(valuesToCheck);
if (!(fieldsToCheck.length === 0 || (fieldsToCheck.length === 1 && entityFieldsToLoad.entityIdField in valuesToCheck))) if (!(fieldsToCheck.length === 0 || (fieldsToCheck.length === 1 && entityFieldsToLoad.entityIdField in valuesToCheck)))
scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity, valuesToCheck, null) || []; scanResults = DuplicateScannerUtils.scanForDuplicates(scannerName, targetEntity, valuesToCheck, null) || [];
var duplicateIds = scanResults.map(function (scanResult) var duplicateIds = scanResults.map(function (scanResult)
{ {
......
...@@ -4,7 +4,7 @@ import("DuplicateScanner_lib"); ...@@ -4,7 +4,7 @@ import("DuplicateScanner_lib");
let sourceContactId = vars.get("$param.DuplicateCurrentContactId_param"); let sourceContactId = vars.get("$param.DuplicateCurrentContactId_param");
let selectedContactId = vars.get("$sys.selection"); let selectedContactId = vars.get("$sys.selection");
let clusterId = DuplicateScannerUtils.GetClusterId(sourceContactId); let clusterId = DuplicateScannerUtils.getClusterId(sourceContactId);
DuplicateScannerUtils.CreateUnrelatedDuplicateRelation(sourceContactId, selectedContactId, clusterId); DuplicateScannerUtils.createUnrelatedDuplicateRelation(sourceContactId, selectedContactId, clusterId);
neon.refreshAll(); neon.refreshAll();
\ No newline at end of file
...@@ -6,16 +6,16 @@ import("system.notification"); ...@@ -6,16 +6,16 @@ import("system.notification");
let contactId = vars.get("$field.CONTACTID"); let contactId = vars.get("$field.CONTACTID");
logging.log("contactId -> " + contactId); logging.log("contactId -> " + contactId);
let clusterId = DuplicateScannerUtils.GetClusterId(contactId); let clusterId = DuplicateScannerUtils.getClusterId(contactId);
logging.log("clusterId -> " + clusterId); logging.log("clusterId -> " + clusterId);
let duplicateContactIdsInClusterRay = DuplicateScannerUtils.GetCachedDuplicatesForClusterId(clusterId) let duplicateContactIdsInClusterRay = DuplicateScannerUtils.getCachedDuplicatesForClusterId(clusterId)
logging.log("duplicateContactIdsInClusterRay -> " + duplicateContactIdsInClusterRay); logging.log("duplicateContactIdsInClusterRay -> " + duplicateContactIdsInClusterRay);
if(duplicateContactIdsInClusterRay.length > 1) if(duplicateContactIdsInClusterRay.length > 1)
{ {
let referenceDuplicateId = duplicateContactIdsInClusterRay[0]; let referenceDuplicateId = duplicateContactIdsInClusterRay[0];
for (let i = 1; i < duplicateContactIdsInClusterRay.length; i++) for (let i = 1; i < duplicateContactIdsInClusterRay.length; i++)
{ {
DuplicateScannerUtils.CreateUnrelatedDuplicateRelation(referenceDuplicateId, duplicateContactIdsInClusterRay[i], clusterId); DuplicateScannerUtils.createUnrelatedDuplicateRelation(referenceDuplicateId, duplicateContactIdsInClusterRay[i], clusterId);
} }
neon.refreshAll(); neon.refreshAll();
......
...@@ -3,5 +3,5 @@ import("system.vars"); ...@@ -3,5 +3,5 @@ import("system.vars");
import("system.result"); import("system.result");
import("DuplicateScanner_lib"); import("DuplicateScanner_lib");
let unrelatedIds = DuplicateScannerUtils.GetUnrelatedRelationsForDuplicate(vars.get("$field.CONTACTID")); let unrelatedIds = DuplicateScannerUtils.getUnrelatedRelationsForDuplicate(vars.get("$field.CONTACTID"));
result.string(JSON.stringify(unrelatedIds)); result.string(JSON.stringify(unrelatedIds));
\ No newline at end of file
...@@ -41,7 +41,7 @@ else ...@@ -41,7 +41,7 @@ else
//don't search if only the id field has a value //don't search if only the id field has a value
var fieldsToCheck = Object.keys(valuesToCheck); var fieldsToCheck = Object.keys(valuesToCheck);
if (!(fieldsToCheck.length === 0 || (fieldsToCheck.length === 1 && entityFieldsToLoad.entityIdField in valuesToCheck))) if (!(fieldsToCheck.length === 0 || (fieldsToCheck.length === 1 && entityFieldsToLoad.entityIdField in valuesToCheck)))
scanResults = DuplicateScannerUtils.ScanForDuplicates(scannerName, targetEntity, valuesToCheck, null) || []; scanResults = DuplicateScannerUtils.scanForDuplicates(scannerName, targetEntity, valuesToCheck, null) || [];
var duplicateIds = scanResults.map(function (duplicate) var duplicateIds = scanResults.map(function (duplicate)
{ {
......
...@@ -36,7 +36,7 @@ WorkflowSignalSender.inserted(); ...@@ -36,7 +36,7 @@ WorkflowSignalSender.inserted();
// } // }
//} //}
// //
//let scanResults = DuplicateScannerUtils.ScanForDuplicates("PersonDuplicates", targetEntity, //let scanResults = DuplicateScannerUtils.scanForDuplicates("PersonDuplicates", targetEntity,
//valuesToCheck, null); //valuesToCheck, null);
// //
////If we found duplicates, cache them ////If we found duplicates, cache them
......
...@@ -77,7 +77,7 @@ function _getDuplicates (pScannerName, pEntity, pEntityFieldValues) ...@@ -77,7 +77,7 @@ function _getDuplicates (pScannerName, pEntity, pEntityFieldValues)
if (fieldsToCheck.length === 0 || (fieldsToCheck.length === 1 && fieldsToLoad.entityIdField in valuesToCheck)) if (fieldsToCheck.length === 0 || (fieldsToCheck.length === 1 && fieldsToLoad.entityIdField in valuesToCheck))
return []; return [];
var scanResults = DuplicateScannerUtils.ScanForDuplicates(pScannerName, pEntity, valuesToCheck, null) || []; var scanResults = DuplicateScannerUtils.scanForDuplicates(pScannerName, pEntity, valuesToCheck, null) || [];
var duplicateIds = scanResults.map(function (duplicate) var duplicateIds = scanResults.map(function (duplicate)
{ {
return duplicate[indexsearch.FIELD_ID]; return duplicate[indexsearch.FIELD_ID];
......
...@@ -76,7 +76,7 @@ DuplicateScannerUtils.deleteCachedDuplicate = function(pDuplicateId) ...@@ -76,7 +76,7 @@ DuplicateScannerUtils.deleteCachedDuplicate = function(pDuplicateId)
newWhereIfSet("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId).deleteData(); newWhereIfSet("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId).deleteData();
//Delete all records where this duplicateId is mentioned //Delete all records where this duplicateId is mentioned
DuplicateScannerUtils.DeleteAllUnrelatedDuplicateRelations(pDuplicateId); DuplicateScannerUtils.deleteAllUnrelatedDuplicateRelations(pDuplicateId);
} }
} }
...@@ -87,7 +87,7 @@ DuplicateScannerUtils.deleteCachedDuplicate = function(pDuplicateId) ...@@ -87,7 +87,7 @@ DuplicateScannerUtils.deleteCachedDuplicate = function(pDuplicateId)
* @param {String} pTargetEntity Entity which has been configured * @param {String} pTargetEntity Entity which has been configured
* @return Count of deleted rows * @return Count of deleted rows
*/ */
DuplicateScannerUtils.DeleteDuplicateClustersByTargetEntity = function(pTargetEntity) DuplicateScannerUtils.deleteClustersByTargetEntity = function(pTargetEntity)
{ {
return newWhereIfSet("DUPLICATECLUSTERS.TARGET_ENTITY", pTargetEntity).deleteData(); return newWhereIfSet("DUPLICATECLUSTERS.TARGET_ENTITY", pTargetEntity).deleteData();
} }
...@@ -101,7 +101,7 @@ DuplicateScannerUtils.DeleteDuplicateClustersByTargetEntity = function(pTargetEn ...@@ -101,7 +101,7 @@ DuplicateScannerUtils.DeleteDuplicateClustersByTargetEntity = function(pTargetEn
* *
* @param {String} pTargetEntity Name of Entity whose duplicates should be updated * @param {String} pTargetEntity Name of Entity whose duplicates should be updated
*/ */
DuplicateScannerUtils.RefreshUnrelatedDuplicateRelations = function(pTargetEntity) DuplicateScannerUtils.refreshUnrelatedDuplicateRelations = function(pTargetEntity)
{ {
/* /*
* Update all records with the current valid clusterId where the same duplicateId combination exists * Update all records with the current valid clusterId where the same duplicateId combination exists
...@@ -133,14 +133,14 @@ DuplicateScannerUtils.RefreshUnrelatedDuplicateRelations = function(pTargetEntit ...@@ -133,14 +133,14 @@ DuplicateScannerUtils.RefreshUnrelatedDuplicateRelations = function(pTargetEntit
/* /*
* Creates a relation between two duplicates which means they are unrelated. * Creates a relation between two duplicates which means they are unrelated.
* They will not appear in each others duplicate tab any more. * They will not appear in each others duplicate tab any more.
* To remove this relation use DuplicateScannerUtils.DeleteUnrelatedDuplicateRelation * To remove this relation use DuplicateScannerUtils.deleteUnrelatedDuplicateRelation
* *
* @param {String} pSourceContactId Id of first duplicate * @param {String} pSourceContactId Id of first duplicate
* @param {String} pUnrelatedContactId Id of second duplicate * @param {String} pUnrelatedContactId Id of second duplicate
* @param {String} pClusterId Id of the cluster in which the duplicates are aggregated * @param {String} pClusterId Id of the cluster in which the duplicates are aggregated
* @returns {String} Number of Records inserted * @returns {String} Number of Records inserted
*/ */
DuplicateScannerUtils.CreateUnrelatedDuplicateRelation = function(pSourceContactId, pUnrelatedContactId, pClusterId) DuplicateScannerUtils.createUnrelatedDuplicateRelation = function(pSourceContactId, pUnrelatedContactId, pClusterId)
{ {
return new SqlBuilder().insertFields({ return new SqlBuilder().insertFields({
"UNRELATEDDUPLICATEID": pUnrelatedContactId, "UNRELATEDDUPLICATEID": pUnrelatedContactId,
...@@ -155,7 +155,7 @@ DuplicateScannerUtils.CreateUnrelatedDuplicateRelation = function(pSourceContact ...@@ -155,7 +155,7 @@ DuplicateScannerUtils.CreateUnrelatedDuplicateRelation = function(pSourceContact
* @param {String} pDuplicateId whose cluster id should be searched * @param {String} pDuplicateId whose cluster id should be searched
* @returns {String} Cluster id * @returns {String} Cluster id
*/ */
DuplicateScannerUtils.GetClusterId = function(pDuplicateId) DuplicateScannerUtils.getClusterId = function(pDuplicateId)
{ {
return newSelect("CLUSTERID") return newSelect("CLUSTERID")
.from("DUPLICATECLUSTERS") .from("DUPLICATECLUSTERS")
...@@ -170,7 +170,7 @@ DuplicateScannerUtils.GetClusterId = function(pDuplicateId) ...@@ -170,7 +170,7 @@ DuplicateScannerUtils.GetClusterId = function(pDuplicateId)
* @param {String} pUnrelatedDuplicateId Id of the source duplicate * @param {String} pUnrelatedDuplicateId Id of the source duplicate
* @returns {String} Number of records deleted * @returns {String} Number of records deleted
*/ */
DuplicateScannerUtils.DeleteUnrelatedDuplicateRelation = function(pSourceDuplicateId, pUnrelatedDuplicateId) DuplicateScannerUtils.deleteUnrelatedDuplicateRelation = function(pSourceDuplicateId, pUnrelatedDuplicateId)
{ {
return newWhere("UNRELATEDDUPLICATES.SOURCEDUPLICATEID", pSourceDuplicateId) return newWhere("UNRELATEDDUPLICATES.SOURCEDUPLICATEID", pSourceDuplicateId)
.and("UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID", pUnrelatedDuplicateId) .and("UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID", pUnrelatedDuplicateId)
...@@ -183,9 +183,9 @@ DuplicateScannerUtils.DeleteUnrelatedDuplicateRelation = function(pSourceDuplica ...@@ -183,9 +183,9 @@ DuplicateScannerUtils.DeleteUnrelatedDuplicateRelation = function(pSourceDuplica
* @param {String} pDuplicateId Duplicate id whose "unrelated" relations are to delete * @param {String} pDuplicateId Duplicate id whose "unrelated" relations are to delete
* @returns {String} Number of records deleted * @returns {String} Number of records deleted
*/ */
DuplicateScannerUtils.DeleteAllUnrelatedDuplicateRelations = function(pDuplicateId) DuplicateScannerUtils.deleteAllUnrelatedDuplicateRelations = function(pDuplicateId)
{ {
DuplicateScannerUtils.DeleteUnrelatedDuplicateRelation(pDuplicateId, pDuplicateId); DuplicateScannerUtils.deleteUnrelatedDuplicateRelation(pDuplicateId, pDuplicateId);
} }
/* /*
...@@ -194,7 +194,7 @@ DuplicateScannerUtils.DeleteAllUnrelatedDuplicateRelations = function(pDuplicate ...@@ -194,7 +194,7 @@ DuplicateScannerUtils.DeleteAllUnrelatedDuplicateRelations = function(pDuplicate
* @param {String} pDuplicateId * @param {String} pDuplicateId
* @returns {String[]} Array of duplicate ids * @returns {String[]} Array of duplicate ids
*/ */
DuplicateScannerUtils.GetCachedDuplicatesForDuplicateId = function(pDuplicateId) DuplicateScannerUtils.getCachedDuplicatesForDuplicateId = function(pDuplicateId)
{ {
return newSelect("DUPLICATEID") return newSelect("DUPLICATEID")
.from("DUPLICATECLUSTERS") .from("DUPLICATECLUSTERS")
...@@ -220,7 +220,7 @@ DuplicateScannerUtils.GetCachedDuplicatesForDuplicateId = function(pDuplicateId) ...@@ -220,7 +220,7 @@ DuplicateScannerUtils.GetCachedDuplicatesForDuplicateId = function(pDuplicateId)
* @param {String} pClusterId The clusters id * @param {String} pClusterId The clusters id
* @return {String[]} Array of duplicate ids excluding those marked as unrelated * @return {String[]} Array of duplicate ids excluding those marked as unrelated
*/ */
DuplicateScannerUtils.GetCachedDuplicatesForClusterId = function(pClusterId) DuplicateScannerUtils.getCachedDuplicatesForClusterId = function(pClusterId)
{ {
return newSelect("DUPLICATEID") return newSelect("DUPLICATEID")
.from("DUPLICATECLUSTERS") .from("DUPLICATECLUSTERS")
...@@ -232,13 +232,13 @@ DuplicateScannerUtils.GetCachedDuplicatesForClusterId = function(pClusterId) ...@@ -232,13 +232,13 @@ DuplicateScannerUtils.GetCachedDuplicatesForClusterId = function(pClusterId)
/* /*
* Recreates the cached duplicate clusters based on the configured pattern. <br /> * Recreates the cached duplicate clusters based on the configured pattern. <br />
* The old clusters have to be deleted manually beforehand or by using "DeleteDuplicateClustersByTargetEntity".<br /> * The old clusters have to be deleted manually beforehand or by using "deleteClustersByTargetEntity".<br />
* If there have already been ignored relations between duplicate records, it's advised to call "RefreshUnrelatedDuplicateRelations" after the recreation of the duplicates cache.<br /> * If there have already been ignored relations between duplicate records, it's advised to call "refreshUnrelatedDuplicateRelations" after the recreation of the duplicates cache.<br />
* Please check the documentation of the params on how to get the infos required.<br /> * Please check the documentation of the params on how to get the infos required.<br />
* <br /> * <br />
* If the usage of an external webservice has been activated, the search will be executed beforehand and the results will then be given to the pFormatValuesConsumeWebserviceCallback via parameter.<br /> * If the usage of an external webservice has been activated, the search will be executed beforehand and the results will then be given to the pFormatValuesConsumeWebserviceCallback via parameter.<br />
* To access the values it is advised to run thru the parameter like an array and access its value by key which is the index field name. The entity<br /> * To access the values it is advised to run thru the parameter like an array and access its value by key which is the index field name. The entity<br />
* field names can be converted using DuplicateScannerUtils.TranslateEntityToIndexFields. For further infos see the example section below.<br /> * field names can be converted using DuplicateScannerUtils.translateEntityToIndexFields. For further infos see the example section below.<br />
* <br /> * <br />
* Attention!<br /> * Attention!<br />
* If it is configured to use the external webservice callback the values have to be in the same format as they are in the parameter of the callback.<br /> * If it is configured to use the external webservice callback the values have to be in the same format as they are in the parameter of the callback.<br />
...@@ -334,7 +334,7 @@ DuplicateScannerUtils.scanRecords = function(pTargetEntity, pTargetRecordsData, ...@@ -334,7 +334,7 @@ DuplicateScannerUtils.scanRecords = function(pTargetEntity, pTargetRecordsData,
var duplicatesToInsertQueries = []; var duplicatesToInsertQueries = [];
for (let b = 0; b < pTargetRecordsData.length; b++) for (let b = 0; b < pTargetRecordsData.length; b++)
{ {
let entityFieldValuesRay = DuplicateScannerUtils.BuildEntityFieldConfigValueRays(pEntityFieldConfigs, pTargetRecordsData[b]); let entityFieldValuesRay = DuplicateScannerUtils.buildEntityFieldConfigs(pEntityFieldConfigs, pTargetRecordsData[b]);
//The first field in this Array must always be the configured id field. This is ensured using onValidation-logic //The first field in this Array must always be the configured id field. This is ensured using onValidation-logic
let idValue = pTargetRecordsData[b][pEntityIdField]; let idValue = pTargetRecordsData[b][pEntityIdField];
...@@ -490,11 +490,11 @@ DuplicateScannerUtils.getResultFields = function(pFilterName, pTargetEntity) ...@@ -490,11 +490,11 @@ DuplicateScannerUtils.getResultFields = function(pFilterName, pTargetEntity)
*<br /> *<br />
* If the usage of an external webservice has been activated, the result will then be given to the pFormatValuesConsumeWebserviceCallback via parameter.<br /> * If the usage of an external webservice has been activated, the result will then be given to the pFormatValuesConsumeWebserviceCallback via parameter.<br />
* To access the values it is advised to run thru the parameter like an array and access its value by key which is the index field name. The entity * To access the values it is advised to run thru the parameter like an array and access its value by key which is the index field name. The entity
* field names can be converted using DuplicateScannerUtils.TranslateEntityToIndexFields * field names can be converted using DuplicateScannerUtils.translateEntityToIndexFields
* <br /> * <br />
* <br /> * <br />
* Attention!<br /> * Attention!<br />
* If it's a single ScanForDuplicates call it doesn't matter what the callback returns because after the callback, no more modifications follow before * If it's a single scanForDuplicates call it doesn't matter what the callback returns because after the callback, no more modifications follow before
* returning the data.<br /> * returning the data.<br />
* If it's inside the RebuildCache the values have to be in the same format as the parameter * If it's inside the RebuildCache the values have to be in the same format as the parameter
* *
...@@ -553,7 +553,7 @@ DuplicateScannerUtils.getResultFields = function(pFilterName, pTargetEntity) ...@@ -553,7 +553,7 @@ DuplicateScannerUtils.getResultFields = function(pFilterName, pTargetEntity)
* DuplicateScannerUtils.ScanForDuplicates(filterName, targetEntity, valuesToCheck, * DuplicateScannerUtils.ScanForDuplicates(filterName, targetEntity, valuesToCheck,
* formatToJsonAndCallWsCallback); * formatToJsonAndCallWsCallback);
*/ */
DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, pValuesToCheck, pFormatValuesConsumeWebserviceCallback) DuplicateScannerUtils.scanForDuplicates = function(pFilterName, pTargetEntity, pValuesToCheck, pFormatValuesConsumeWebserviceCallback)
{ {
let useExternalWebservice = _DuplicateScannerUtils._isUseExternalWebservice(pFilterName, pTargetEntity); let useExternalWebservice = _DuplicateScannerUtils._isUseExternalWebservice(pFilterName, pTargetEntity);
let resultFields = DuplicateScannerUtils.getResultFields(pFilterName, pTargetEntity); let resultFields = DuplicateScannerUtils.getResultFields(pFilterName, pTargetEntity);
...@@ -562,7 +562,7 @@ DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, p ...@@ -562,7 +562,7 @@ DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, p
let entityFieldConfigs = _DuplicateScannerUtils._loadEntityFieldConfigsFromPattern(indexPattern); let entityFieldConfigs = _DuplicateScannerUtils._loadEntityFieldConfigsFromPattern(indexPattern);
let entityIdField = _DuplicateScannerUtils._loadEntityIdField(pFilterName, pTargetEntity); let entityIdField = _DuplicateScannerUtils._loadEntityIdField(pFilterName, pTargetEntity);
let entityFieldConfigValuesRay = DuplicateScannerUtils.BuildEntityFieldConfigValueRays(entityFieldConfigs, pValuesToCheck); let entityFieldConfigValuesRay = DuplicateScannerUtils.buildEntityFieldConfigs(entityFieldConfigs, pValuesToCheck);
//The first field in this Array must always be the configured id field. //The first field in this Array must always be the configured id field.
let idValue = pValuesToCheck[entityIdField]; let idValue = pValuesToCheck[entityIdField];
...@@ -582,10 +582,10 @@ DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, p ...@@ -582,10 +582,10 @@ DuplicateScannerUtils.ScanForDuplicates = function(pFilterName, pTargetEntity, p
* *
* @example * @example
* let entityResultFields = ["LASTNAME"]; * let entityResultFields = ["LASTNAME"];
* let entityIndexFields = DuplicateScannerUtils.TranslateEntityToIndexFields("Person_entity", entityResultFields); * let entityIndexFields = DuplicateScannerUtils.translateEntityToIndexFields("Person_entity", entityResultFields);
* *
*/ */
DuplicateScannerUtils.TranslateEntityToIndexFields = function(pEntityName, pEntityFields) DuplicateScannerUtils.translateEntityToIndexFields = function(pEntityName, pEntityFields)
{ {
let entityIndexFields = {}; let entityIndexFields = {};
for (let i = 0; i < pEntityFields.length; i++) for (let i = 0; i < pEntityFields.length; i++)
...@@ -711,7 +711,7 @@ DuplicateScannerUtils.mergeOrganisation = function(pSourceContactId, pTargetCont ...@@ -711,7 +711,7 @@ DuplicateScannerUtils.mergeOrganisation = function(pSourceContactId, pTargetCont
* *
* => ["{entityfield: FIRSTNAME}", "PETER"]] * => ["{entityfield: FIRSTNAME}", "PETER"]]
*/ */
DuplicateScannerUtils.BuildEntityFieldConfigValueRays = function(pDuplicateFieldsConfig, pTargetRecordData) DuplicateScannerUtils.buildEntityFieldConfigs = function(pDuplicateFieldsConfig, pTargetRecordData)
{ {
let INDEX_CONFIG_ENTITY_FIELD = 0; let INDEX_CONFIG_ENTITY_FIELD = 0;
let entityFieldConfigValuesRay = []; let entityFieldConfigValuesRay = [];
...@@ -799,7 +799,7 @@ DuplicateScannerUtils.getEntityFieldObjectFromConfig = function (pFilterName, pT ...@@ -799,7 +799,7 @@ DuplicateScannerUtils.getEntityFieldObjectFromConfig = function (pFilterName, pT
}; };
} }
DuplicateScannerUtils.GetUnrelatedRelationsForDuplicate = function(pDuplicateId) DuplicateScannerUtils.getUnrelatedRelationsForDuplicate = function(pDuplicateId)
{ {
let unrelatedIds = []; let unrelatedIds = [];
let duplicateIds = newSelect("SOURCEDUPLICATEID, UNRELATEDDUPLICATEID") let duplicateIds = newSelect("SOURCEDUPLICATEID, UNRELATEDDUPLICATEID")
...@@ -933,7 +933,7 @@ _DuplicateScannerUtils._loadEntityIdField = function(pFilterName, pTargetEntity) ...@@ -933,7 +933,7 @@ _DuplicateScannerUtils._loadEntityIdField = function(pFilterName, pTargetEntity)
} }
/* /*
* @see DuplicateScannerUtils.ScanForDuplicates for the documentation * @see DuplicateScannerUtils.scanForDuplicates for the documentation
*/ */
_DuplicateScannerUtils._scanForDuplicates = function(pTargetEntity, pEntityFieldConfigValuesRay, _DuplicateScannerUtils._scanForDuplicates = function(pTargetEntity, pEntityFieldConfigValuesRay,
pResultFields, pRecordIdValueToIgnore, pFormatValuesConsumeWebserviceCallback, pUseExternalWebservice, pIndexPattern) pResultFields, pRecordIdValueToIgnore, pFormatValuesConsumeWebserviceCallback, pUseExternalWebservice, pIndexPattern)
......
import("system.tools"); import("system.tools");
import("system.logging"); import("system.logging");
import("Sql_lib"); import("Sql_lib");
import("Util_lib");
import("system.datetime"); import("system.datetime");
/** /**
...@@ -222,7 +223,7 @@ JditoFilterUtils.getSqlCondition = function (pFilter, pTable, pTableAlias, pColu ...@@ -222,7 +223,7 @@ JditoFilterUtils.getSqlCondition = function (pFilter, pTable, pTableAlias, pColu
for (let fieldName in pColumnOrFnMap) for (let fieldName in pColumnOrFnMap)
{ {
var columnOrFn = pColumnOrFnMap[fieldName]; var columnOrFn = pColumnOrFnMap[fieldName];
if (typeof columnOrFn === "function") if (Utils.isFunction(columnOrFn))
filterTranslator.addSpecialFieldConditionFn(fieldName, columnOrFn); filterTranslator.addSpecialFieldConditionFn(fieldName, columnOrFn);
else else
filterTranslator.addSqlFieldMapping(fieldName, columnOrFn); filterTranslator.addSqlFieldMapping(fieldName, columnOrFn);
...@@ -269,7 +270,7 @@ FilterSqlTranslator.prototype.filter = function (pFilter) ...@@ -269,7 +270,7 @@ FilterSqlTranslator.prototype.filter = function (pFilter)
{ {
if (pFilter) if (pFilter)
{ {
if (typeof pFilter !== "object") if (!Utils.isObject(pFilter))
throw new TypeError("FilterSqlTranslator: Wrong type for the filter, expected 'object' but got '" + (typeof pFilter) + "'"); throw new TypeError("FilterSqlTranslator: Wrong type for the filter, expected 'object' but got '" + (typeof pFilter) + "'");
this._filter = pFilter.filter || pFilter; this._filter = pFilter.filter || pFilter;
} }
...@@ -409,7 +410,7 @@ FilterSqlTranslator.prototype.getSqlCondition = function () ...@@ -409,7 +410,7 @@ FilterSqlTranslator.prototype.getSqlCondition = function ()
sqlField = table + "." + pFilter.name; sqlField = table + "." + pFilter.name;
var generatedCondition = _getCondition(filterValue, pFilter.operator, sqlField); var generatedCondition = _getCondition(filterValue, pFilter.operator, sqlField);
if (generatedCondition instanceof SqlBuilder || typeof generatedCondition === "string") if (generatedCondition instanceof SqlBuilder || Utils.isString(generatedCondition))
{ {
if (pOperator == "AND") if (pOperator == "AND")
this.andIfSet(generatedCondition); this.andIfSet(generatedCondition);
......
...@@ -886,7 +886,7 @@ LeadImportUtils.scanLeadDups = function(pAllContactData) ...@@ -886,7 +886,7 @@ LeadImportUtils.scanLeadDups = function(pAllContactData)
if (orgObj != undefined && Object.keys(orgObj).length > 0)//checks if there is an ORGANISATIONDUPLICATE if (orgObj != undefined && Object.keys(orgObj).length > 0)//checks if there is an ORGANISATIONDUPLICATE
{ {
let scanResultsOrg = DuplicateScannerUtils.ScanForDuplicates("OrganisationDuplicates", "Organisation_entity", orgObj, null); let scanResultsOrg = DuplicateScannerUtils.scanForDuplicates("OrganisationDuplicates", "Organisation_entity", orgObj, null);
if (scanResultsOrg != null && scanResultsOrg.length > 0) if (scanResultsOrg != null && scanResultsOrg.length > 0)
{ {
let insertCountOrg = DuplicateScannerUtils.cacheNewScanResults(orgObj["CONTACTID"], scanResultsOrg, "Organisation_entity"); let insertCountOrg = DuplicateScannerUtils.cacheNewScanResults(orgObj["CONTACTID"], scanResultsOrg, "Organisation_entity");
...@@ -895,7 +895,7 @@ LeadImportUtils.scanLeadDups = function(pAllContactData) ...@@ -895,7 +895,7 @@ LeadImportUtils.scanLeadDups = function(pAllContactData)
} }
if (persObj != undefined && Object.keys(persObj).length > 0)//checks if there is an PERSONDUPLICATE if (persObj != undefined && Object.keys(persObj).length > 0)//checks if there is an PERSONDUPLICATE
{ {
let scanResultsPers = DuplicateScannerUtils.ScanForDuplicates("PersonDuplicates", "Person_entity", persObj, null); let scanResultsPers = DuplicateScannerUtils.scanForDuplicates("PersonDuplicates", "Person_entity", persObj, null);
if (scanResultsPers != null && scanResultsPers.length > 0) if (scanResultsPers != null && scanResultsPers.length > 0)
{ {
let insertCountPers = DuplicateScannerUtils.cacheNewScanResults(persObj["CONTACTID"], scanResultsPers, "Person_entity"); let insertCountPers = DuplicateScannerUtils.cacheNewScanResults(persObj["CONTACTID"], scanResultsPers, "Person_entity");
......
...@@ -27,13 +27,13 @@ var targetEntity = "Person_entity"; ...@@ -27,13 +27,13 @@ var targetEntity = "Person_entity";
var recordBlockSize = DuplicateScannerUtils.getBlockSize(); var recordBlockSize = DuplicateScannerUtils.getBlockSize();
logging.log(filterName + ": Delete duplicates -> "); logging.log(filterName + ": Delete duplicates -> ");
DuplicateScannerUtils.DeleteDuplicateClustersByTargetEntity(targetEntity); DuplicateScannerUtils.deleteClustersByTargetEntity(targetEntity);
logging.log(filterName + ": Recalculate duplicates -> "); logging.log(filterName + ": Recalculate duplicates -> ");
DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, recordBlockSize, null); DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, recordBlockSize, null);
logging.log(filterName + ": Refresh unrelated duplicates -> "); logging.log(filterName + ": Refresh unrelated duplicates -> ");
DuplicateScannerUtils.RefreshUnrelatedDuplicateRelations(targetEntity); DuplicateScannerUtils.refreshUnrelatedDuplicateRelations(targetEntity);
logging.log(filterName + ": Done rebuilding "); logging.log(filterName + ": Done rebuilding ");
...@@ -44,12 +44,12 @@ filterName = "OrganisationDuplicates"; ...@@ -44,12 +44,12 @@ filterName = "OrganisationDuplicates";
targetEntity = "Organisation_entity"; targetEntity = "Organisation_entity";
logging.log(filterName + ": Delete duplicates -> "); logging.log(filterName + ": Delete duplicates -> ");
DuplicateScannerUtils.DeleteDuplicateClustersByTargetEntity(targetEntity); DuplicateScannerUtils.deleteClustersByTargetEntity(targetEntity);
logging.log(filterName + ": Recalculate duplicates -> "); logging.log(filterName + ": Recalculate duplicates -> ");
DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, recordBlockSize, null); DuplicateScannerUtils.rebuildDuplicatesCache(filterName, targetEntity, recordBlockSize, null);
logging.log(filterName + ": Refresh unrelated duplicates -> "); logging.log(filterName + ": Refresh unrelated duplicates -> ");
DuplicateScannerUtils.RefreshUnrelatedDuplicateRelations(targetEntity); DuplicateScannerUtils.refreshUnrelatedDuplicateRelations(targetEntity);
logging.log(filterName + ": Done rebuilding "); logging.log(filterName + ": Done rebuilding ");
\ No newline at end of file
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