diff --git a/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBDelete.js b/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBDelete.js index 06be87508d798ea937da7530587a5f96a2b7e472..298126d301bfe7c26ea3d4ae0a1f88d5566d5560 100644 --- a/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBDelete.js +++ b/entity/DuplicateScanner_entity/recordcontainers/dbrecordcontainer/onDBDelete.js @@ -12,7 +12,7 @@ if (currentId) toDelete = toDelete.map(function(pTable) { - return [pTable, SqlCondition.equals(pTable + ".DUPLICATESCANNER_ID", currentId, "1=2")] + return [pTable, newWhere(pTable + ".DUPLICATESCANNER_ID", currentId).build()] }); db.deletes(toDelete); diff --git a/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js b/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js index 2e4953a02cea7cdb29ba1bd9f891a4400a179913..63c2dfb52cc37147ef1f45bb4e5038fe29070e58 100644 --- a/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js +++ b/entity/Duplicates_entity/recordcontainers/recordcontainer/contentProcess.js @@ -14,7 +14,7 @@ let duplicates = []; let selectedClusterId = vars.get("$param.ClusterId_param"); -let duplicateInfosQuery = ""; +let duplicateInfosQuery = new SqlBuilder(); let selectedId = vars.get("$local.idvalues"); @@ -35,29 +35,25 @@ else { if(targetEntity == "Person_entity") { - - duplicateInfosQuery = SqlCondition.begin() - .and("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)") - - if(selectedClusterId) - duplicateInfosQuery = duplicateInfosQuery.and("DUPLICATECLUSTERS.CLUSTERID = '" + selectedClusterId + "'") - - duplicateInfosQuery = duplicateInfosQuery.buildSql("select CLUSTERID, FIRSTNAME, LASTNAME" - + " from DUPLICATECLUSTERS" - + " join CONTACT on CONTACT.CONTACTID = DUPLICATEID" - + " join PERSON on PERSON.PERSONID = CONTACT.PERSON_ID", "1=2", " ORDER BY CLUSTERID"); + duplicateInfosQuery.select("CLUSTERID, FIRSTNAME, LASTNAME") + .from("DUPLICATECLUSTERS") + .join("CONTACT", "CONTACT.CONTACTID = DUPLICATEID") + .join("PERSON", "PERSON.PERSONID = CONTACT.PERSON_ID") + .where("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)") + .andIfSet("DUPLICATECLUSTERS.CLUSTERID", selectedClusterId) + .orderBy("CLUSTERID"); } else { - duplicateInfosQuery = SqlCondition.begin() - .and("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)") - .andIn("DUPLICATECLUSTERS.CLUSTERID", vars.get("$local.idvalues")) - .buildSql("select CLUSTERID, ORGANISATION.\"NAME\"" - + " from DUPLICATECLUSTERS" - + " join CONTACT on CONTACT.CONTACTID = DUPLICATEID" - + " join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.CONTACTID", "1=2", " ORDER BY CLUSTERID"); + duplicateInfosQuery.select("CLUSTERID, ORGANISATION.\"NAME\"") + .from("DUPLICATECLUSTERS") + .join("CONTACT", "CONTACT.CONTACTID = DUPLICATEID") + .join("ORGANISATION", "ORGANISATION.ORGANISATIONID = CONTACT.CONTACTID") + .where("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)") + .andIfSet("DUPLICATECLUSTERS.CLUSTERID", vars.get("$local.idvalues"), SqlBuilder.IN()) + .orderBy("CLUSTERID"); } - let duplicateInfos = db.table(duplicateInfosQuery); + let duplicateInfos = duplicateInfosQuery.table(); let MAX_SHOW_CLUSTER_RECORDS = 4; let recordClusterId = ""; diff --git a/entity/Person_entity/recordcontainers/db/conditionProcess.js b/entity/Person_entity/recordcontainers/db/conditionProcess.js index e17e72de64c9cdb0dad3c9f6751b6e9d61af991a..1e0540f68a5cba2e997720f724556fa80ef84399 100644 --- a/entity/Person_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Person_entity/recordcontainers/db/conditionProcess.js @@ -12,15 +12,7 @@ if (vars.exists("$param.ExcludedContactIds_param") && vars.get("$param.ExcludedC cond.andIfSet("CONTACT.CONTACTID", excludedContacts, SqlBuilder.NOT_IN()); } var onlyShowContactIds = JSON.parse(vars.get("$param.OnlyShowContactIds_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"; -} +cond.andIfSet("CONTACT.CONTACTID", onlyShowContactIds, SqlBuilder.IN()); + //TODO: use a preparedCondition (.build instead of .toString) when available #1030812 #1034026 result.string(cond.toString()); \ No newline at end of file diff --git a/neonContext/DuplicateScanner/DuplicateScanner.aod b/neonContext/DuplicateScanner/DuplicateScanner.aod index 4f2a161e174e2748ca51b65ddd3083fa094ccdfa..b8b57677d5da8322b8ba0963ce4a4bfdf7434942 100644 --- a/neonContext/DuplicateScanner/DuplicateScanner.aod +++ b/neonContext/DuplicateScanner/DuplicateScanner.aod @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="UTF-8"?> -<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0"> +<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.1"> <name>DuplicateScanner</name> <title>Duplicate configuration</title> <majorModelMode>DISTRIBUTED</majorModelMode> - <filterview>DuplicateScannerFilter_view</filterview> - <editview>DuplicateScannerEdit_view</editview> - <preview>DuplicateScannerPreview_view</preview> + <filterView>DuplicateScannerFilter_view</filterView> + <editView>DuplicateScannerEdit_view</editView> + <previewView>DuplicateScannerPreview_view</previewView> <entity>DuplicateScanner_entity</entity> <references> <neonViewReference> diff --git a/neonContext/DuplicateScannerIndexConfig/DuplicateScannerIndexConfig.aod b/neonContext/DuplicateScannerIndexConfig/DuplicateScannerIndexConfig.aod index a5865209024dae7e2813ef96a0b2a1e8a054c8ee..6acb8abaa0f5b85399fac4caf242ae4efa150be9 100644 --- a/neonContext/DuplicateScannerIndexConfig/DuplicateScannerIndexConfig.aod +++ b/neonContext/DuplicateScannerIndexConfig/DuplicateScannerIndexConfig.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0"> +<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.1"> <name>DuplicateScannerIndexConfig</name> <majorModelMode>DISTRIBUTED</majorModelMode> <entity>DuplicateScannerIndexConfig_entity</entity> diff --git a/neonContext/DuplicateScannerPrefilterConfig/DuplicateScannerPrefilterConfig.aod b/neonContext/DuplicateScannerPrefilterConfig/DuplicateScannerPrefilterConfig.aod index 5e8c1485487dffff2f01aa4dc4bfe82756cac700..c4781dce749f9aa341a334e8fdf52a2ace67e6f0 100644 --- a/neonContext/DuplicateScannerPrefilterConfig/DuplicateScannerPrefilterConfig.aod +++ b/neonContext/DuplicateScannerPrefilterConfig/DuplicateScannerPrefilterConfig.aod @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0"> +<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.1"> <name>DuplicateScannerPrefilterConfig</name> <title>Prefilter Configuration</title> <majorModelMode>DISTRIBUTED</majorModelMode> - <editview>DuplicateEdit_view</editview> + <editView>DuplicateEdit_view</editView> <entity>DuplicateScannerPrefilterConfig_entity</entity> <references> <neonViewReference> diff --git a/neonContext/DuplicateScannerResultFieldConfig/DuplicateScannerResultFieldConfig.aod b/neonContext/DuplicateScannerResultFieldConfig/DuplicateScannerResultFieldConfig.aod index 054a1c7fe2c2ea3e3df0e046afc8e03a1ccf3d02..79d97363fbb75d25de88168f1dbd76713df82073 100644 --- a/neonContext/DuplicateScannerResultFieldConfig/DuplicateScannerResultFieldConfig.aod +++ b/neonContext/DuplicateScannerResultFieldConfig/DuplicateScannerResultFieldConfig.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0"> +<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.1"> <name>DuplicateScannerResultFieldConfig</name> <majorModelMode>DISTRIBUTED</majorModelMode> <entity>DuplicateScannerResultFieldConfig_entity</entity> diff --git a/neonContext/Duplicates/Duplicates.aod b/neonContext/Duplicates/Duplicates.aod index 629703f915b4387ca98859bd24f8f5025db5b750..5de0f3a1913c9bb49aecba2c8ea9998e23ad1faf 100644 --- a/neonContext/Duplicates/Duplicates.aod +++ b/neonContext/Duplicates/Duplicates.aod @@ -1,9 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> -<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0"> +<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.1"> <name>Duplicates</name> <title>Duplicates</title> <majorModelMode>DISTRIBUTED</majorModelMode> - <filterview>DuplicatesOverview_view</filterview> + <filterView>DuplicatesOverview_view</filterView> <entity>Duplicates_entity</entity> <references> <neonViewReference> diff --git a/neonContext/DuplicatesUnrelated/DuplicatesUnrelated.aod b/neonContext/DuplicatesUnrelated/DuplicatesUnrelated.aod index 88f2b1a2c591571db685f16b2ef043ceb6584a34..56bf4fd8574682d13f54fd2c5628fde361465b46 100644 --- a/neonContext/DuplicatesUnrelated/DuplicatesUnrelated.aod +++ b/neonContext/DuplicatesUnrelated/DuplicatesUnrelated.aod @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.0"> +<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.1"> <name>DuplicatesUnrelated</name> <majorModelMode>DISTRIBUTED</majorModelMode> <entity>DuplicatesUnrelated_entity</entity> diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js index e9ad1638d401a0e4aceafd4970c456bf81581aa0..c0f9856047b82a2eb6660c16f5581f53beeb64be 100644 --- a/process/Context_lib/process.js +++ b/process/Context_lib/process.js @@ -401,11 +401,11 @@ ContextSelector.prototype.setActiveStates = function(pValue) }; /** * sets the condition property of a ContextSelector-object - * @param {SqlBuilder} pSqlCondition condition as SqlBuilder-object + * @param {SqlBuilder} pSqlBuilder condition as SqlBuilder-object */ -ContextSelector.prototype.setCondition = function(pSqlCondition) +ContextSelector.prototype.setCondition = function(pSqlBuilder) { - this._condition = pSqlCondition; + this._condition = pSqlBuilder; return this; }; ContextSelector.prototype.setSubContexts = function(pContexts) diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js index 411ed083c550caaf88672ab7ec512f347960956c..14e27a6c77f155131d1ad6bda4ae6fdc75e61e01 100644 --- a/process/DuplicateScanner_lib/process.js +++ b/process/DuplicateScanner_lib/process.js @@ -162,11 +162,10 @@ DuplicateScannerUtils.CreateUnrelatedDuplicateRelation = function(pSourceContact */ DuplicateScannerUtils.GetClusterId = function(pDuplicateId) { - let duplicateIdsOfClusterWithoutUnrelated = SqlCondition.begin() - .and("DUPLICATECLUSTERS.DUPLICATEID = '" + pDuplicateId + "'") - .buildSql("select CLUSTERID from DUPLICATECLUSTERS"); - - return db.cell(duplicateIdsOfClusterWithoutUnrelated); + return newSelect("CLUSTERID") + .from("DUPLICATECLUSTERS") + .where("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId) + .cell(); } /* @@ -178,12 +177,9 @@ DuplicateScannerUtils.GetClusterId = function(pDuplicateId) */ DuplicateScannerUtils.DeleteUnrelatedDuplicateRelation = function(pSourceDuplicateId, pUnrelatedDuplicateId) { - var cond = new SqlCondition(); - cond.andPrepare("UNRELATEDDUPLICATES.SOURCEDUPLICATEID", pSourceDuplicateId) - cond.andPrepare("UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID", pUnrelatedDuplicateId) - let condition = db.translateCondition(cond.build()); - - return db.deleteData("UNRELATEDDUPLICATES", condition); + return newWhere("UNRELATEDDUPLICATES.SOURCEDUPLICATEID", pSourceDuplicateId) + .and("UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID", pUnrelatedDuplicateId) + .deleteData(true, "UNRELATEDDUPLICATES"); } /* @@ -194,13 +190,8 @@ DuplicateScannerUtils.DeleteUnrelatedDuplicateRelation = function(pSourceDuplica */ DuplicateScannerUtils.DeleteAllUnrelatedDuplicateRelations = function(pDuplicateId) { - var cond = new SqlCondition(); - cond.orPrepare("UNRELATEDDUPLICATES.SOURCEDUPLICATEID", pDuplicateId) - cond.orPrepare("UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID", pDuplicateId) - let condition = db.translateCondition(cond.build()); - - return db.deleteData("UNRELATEDDUPLICATES", condition); -} + DuplicateScannerUtils.DeleteUnrelatedDuplicateRelation(pDuplicateId, pDuplicateId) +} /* * Loads all other duplicates from the cluster in which the parameterized duplicate is located @@ -210,14 +201,22 @@ DuplicateScannerUtils.DeleteAllUnrelatedDuplicateRelations = function(pDuplicate */ DuplicateScannerUtils.GetCachedDuplicatesForDuplicateId = function(pDuplicateId) { - let querySelectDuplicateContactIds = "select DUPLICATEID from DUPLICATECLUSTERS" - + " where CLUSTERID in (select CLUSTERID from DUPLICATECLUSTERS" - + " where DUPLICATEID = '"+ pDuplicateId +"')" - + " and DUPLICATEID != '"+ pDuplicateId +"'" - + " and DUPLICATEID not in (select UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES where SOURCEDUPLICATEID = '"+ pDuplicateId +"')" - + " and DUPLICATEID not in (select SOURCEDUPLICATEID from UNRELATEDDUPLICATES where UNRELATEDDUPLICATEID = '"+ pDuplicateId +"')"; - - return db.array(db.COLUMN, querySelectDuplicateContactIds); + return newSelect("DUPLICATEID") + .from("DUPLICATECLUSTERS") + .where("DUPLICATECLUSTERS.CLUSTERID", newSelect("CLUSTERID") + .from("DUPLICATECLUSTERS") + .where("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId), + SqlBuilder.IN()) + .and("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId, "# != ?") + .and("DUPLICATECLUSTERS.DUPLICATEID", newSelect("UNRELATEDDUPLICATEID") + .from("UNRELATEDDUPLICATES") + .where("UNRELATEDDUPLICATES.SOURCEDUPLICATEID", pDuplicateId), + SqlBuilder.NOT_IN()) + .and("DUPLICATECLUSTERS.DUPLICATEID", newSelect("SOURCEDUPLICATEID") + .from("UNRELATEDDUPLICATES") + .where("UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID", pDuplicateId), + SqlBuilder.NOT_IN()) + .arrayColumn(); } /* @@ -228,15 +227,12 @@ DuplicateScannerUtils.GetCachedDuplicatesForDuplicateId = function(pDuplicateId) */ DuplicateScannerUtils.GetCachedDuplicatesForClusterId = function(pClusterId) { - let clusterIdRay = []; - clusterIdRay.push(pClusterId); - - let duplicateIdsOfClusterWithoutUnrelated = SqlCondition.begin() - .and("DUPLICATEID not in (select UNRELATEDDUPLICATES.UNRELATEDDUPLICATEID from UNRELATEDDUPLICATES)") - .and("DUPLICATECLUSTERS.CLUSTERID = '" + clusterIdRay + "'") - .buildSql("select DUPLICATEID from DUPLICATECLUSTERS"); - - return db.array(db.COLUMN, duplicateIdsOfClusterWithoutUnrelated); + return newSelect("DUPLICATEID") + .from("DUPLICATECLUSTERS") + .where("DUPLICATECLUSTERS.DUPLICATEID", newSelect("UNRELATEDDUPLICATEID").from("UNRELATEDDUPLICATES"), + SqlBuilder.NOT_IN()) + .and("DUPLICATECLUSTERS.CLUSTERID", clusterIdRay) + .arrayColumn(); } /* @@ -483,24 +479,25 @@ DuplicateScannerUtils.GetClusterWithIdenticalDuplicates = function(pDuplicateIds if(pDuplicateIds.length < 1) return RESULT_NO_CLUSTER_FOUND; - let clusterIdConditionBuilder = SqlCondition.begin(); + let clusterIdSelect = newSelect("distinct CLUSTERID") + .from("DUPLICATECLUSTERS") + .where(); for (let i = 0; i < pDuplicateIds.length; i++) { - clusterIdConditionBuilder.andSqlCondition("CLUSTERID in (select CLUSTERID from DUPLICATECLUSTERS where DUPLICATEID = '" + pDuplicateIds[i] + "')", "1=2") + clusterIdSelect.and("DUPLICATECLUSTERS.CLUSTERID", newSelect("CLUSTERID").from("DUPLICATECLUSTERS").where("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateIds[i]), + SqlBuilder.IN()); } - - clusterIdCondition = clusterIdConditionBuilder.buildSql("select distinct CLUSTERID from DUPLICATECLUSTERS", "1=2"); - let foundClusterId = db.cell(clusterIdCondition); + let foundClusterId = clusterIdSelect.cell(); //logging.log("clusterid des clusters der die gleichen ids enthält-> " + foundClusterId); if(foundClusterId == null || foundClusterId == "") return RESULT_NO_CLUSTER_FOUND; - let duplicatesInClusterCondition = SqlCondition.begin() - .andPrepare("DUPLICATECLUSTERS.CLUSTERID", foundClusterId) - .buildSql("select DUPLICATEID from DUPLICATECLUSTERS"); - let duplicatesInCluster = db.array(db.COLUMN, duplicatesInClusterCondition); + let duplicatesInCluster = newSelect("DUPLICATEID") + .from("DUPLICATECLUSTERS") + .where("DUPLICATECLUSTERS.CLUSTERID", foundClusterId) + .arrayColumn(); //logging.log("länge gefundener cluster -> " + duplicatesInCluster.length); //logging.log("länge der angefragten ids -> " + pDuplicateIds.length); /* @@ -533,13 +530,12 @@ DuplicateScannerUtils.LoadEntityRecords = function(pTargetEntity, pEntityFields, */ DuplicateScannerUtils.LoadResultFields = function(pFilterName, pTargetEntity) { - let duplicateResultFields = SqlCondition.begin() - .andPrepare("DUPLICATESCANNER.FILTER_NAME", pFilterName) - .andPrepare("DUPLICATESCANNER.ENTITY_TO_SCAN_NAME", pTargetEntity) - .buildSql("select dsrfc.ENTITY_FIELD_NAME from DUPLICATESCANNERRESULTFIELDCONFIG dsrfc join DUPLICATESCANNER on DUPLICATESCANNER.ID = dsrfc.DUPLICATESCANNER_ID" - , "1=2"); - - return db.array(db.COLUMN, duplicateResultFields); + return newSelect("dsrfc.ENTITY_FIELD_NAME") + .from("DUPLICATESCANNERRESULTFIELDCONFIG dsrfc") + .join("DUPLICATESCANNER", "DUPLICATESCANNER.ID = dsrfc.DUPLICATESCANNER_ID") + .where("DUPLICATESCANNER.FILTER_NAME", pFilterName) + .and("DUPLICATESCANNER.ENTITY_TO_SCAN_NAME", pTargetEntity) + .arrayColumn(); } /* @@ -555,13 +551,13 @@ DuplicateScannerUtils.LoadResultFields = function(pFilterName, pTargetEntity) */ DuplicateScannerUtils.LoadIndexFieldsConfiguration = function(pFilterName, pTargetEntity) { - let duplicateIndexFieldConfigurations = SqlCondition.begin() - .andPrepare("DUPLICATESCANNER.FILTER_NAME", pFilterName) - .andPrepare("DUPLICATESCANNER.ENTITY_TO_SCAN_NAME", pTargetEntity) - .buildSql("select dsic.ENTITY_FIELD_NAME, dsic.IS_ID_FIELD, dsic.USE_FOR_INDEX_DUPLICATE_SEARCH from DUPLICATESCANNERINDEXCONFIG dsic join DUPLICATESCANNER on DUPLICATESCANNER.ID = dsic.DUPLICATESCANNER_ID" - , "1=2", "order by dsic.IS_ID_FIELD desc"); - - return db.table(duplicateIndexFieldConfigurations); + return newSelect("dsic.ENTITY_FIELD_NAME, dsic.IS_ID_FIELD, dsic.USE_FOR_INDEX_DUPLICATE_SEARCH") + .from("DUPLICATESCANNERINDEXCONFIG dsic") + .join("DUPLICATESCANNER", "DUPLICATESCANNER.ID = dsic.DUPLICATESCANNER_ID") + .where("DUPLICATESCANNER.FILTER_NAME", pFilterName) + .and("DUPLICATESCANNER.ENTITY_TO_SCAN_NAME", pTargetEntity) + .orderBy("dsic.IS_ID_FIELD desc") + .table(); } /* @@ -765,10 +761,10 @@ DuplicateScannerUtils.MergeOrganisation = function(pSourceContactId, pTargetCont let updateStatementsSystemAlias = []; let deleteStatements = []; - let querySourceOrganisationId = SqlCondition.begin() - .and("CONTACTID = '" + pSourceContactId + "'") - .buildSql("select ORGANISATION_ID from CONTACT"); - var sourceOrganisationId = db.cell(querySourceOrganisationId); + var sourceOrganisationId = newSelect("ORGANISATION_ID") + .from("CONTACT") + .where("CONTACT.CONTACTID", pSourceContactId) + .cell(); var tableInfosCurrentAlias = _DuplicateScannerUtils._getMergeUpdateTableInfosCurrentAlias(); var tableInfosSystemAlias = _DuplicateScannerUtils._getMergeUpdateTableInfosSystemAlias(); @@ -948,13 +944,11 @@ pResultFields, pRecordIdFieldToIgnore, pRecordIdValueToIgnore, pFormatValuesCons */ _DuplicateScannerUtils._isUseExternalWebservice = function(pFilterName, pTargetEntity) { - let scannerUseExternalWebserviceQuery = SqlCondition.begin() - .andPrepare("DUPLICATESCANNER.FILTER_NAME", pFilterName) - .andPrepare("DUPLICATESCANNER.ENTITY_TO_SCAN_NAME", pTargetEntity) - .buildSql("select EXTERNAL_SERVICE_USAGE_ALLOWED from DUPLICATESCANNER" - , "1=2"); - - let isUseWebservice = db.cell(scannerUseExternalWebserviceQuery); + let isUseWebservice = newSelect("EXTERNAL_SERVICE_USAGE_ALLOWED") + .from("DUPLICATESCANNER") + .where("DUPLICATESCANNER.FILTER_NAME", pFilterName) + .and("DUPLICATESCANNER.ENTITY_TO_SCAN_NAME", pTargetEntity) + .cell(); return (isUseWebservice == 0) ? false : true; }