diff --git a/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js b/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js index 6ed5a08a2366f64ef2fadc14976b411edb6d210e..c17d8835a8583f79cebbeda7a3f9a3ed5b7ed113 100644 --- a/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js @@ -1,4 +1,3 @@ -import("system.logging"); import("system.db"); import("system.translate"); import("system.result"); @@ -44,12 +43,12 @@ else if(vars.exists("$local.idvalues") && vars.get("$local.idvalues") && vars.ge if (uidParam && uidParam.includes("[")) // "[" -> is JSON { // Load one by uid. Basically the data to return is also encoded in the uid itself -> no extra data loading is needed. - let uid = JSON.parse(uidParam); + var uid = JSON.parse(uidParam); // if objectRelationTypeId is a string it is a relation node and no Grouping if (uid != null && typeof uid[UID.objectRelationTypeId] == "string") { - let relationTypeData = ObjectRelationUtils.getRelationType(uid[UID.objectRelationTypeId]); + var relationTypeData = ObjectRelationUtils.getRelationType(uid[UID.objectRelationTypeId]); _insertEntry(tree, _getEntryData(uid[UID.objectId], relationTypeData[3], relationTypeData[7], relationTypeData[8], undefined, false, uid[UID.objectRelationId]), "", 0, uid[UID.otherObjectType], relationTypeData[10], relationTypeData[12], relationTypeData[4]); } diff --git a/entity/Person_entity/entityfields/duplicateactions/children/integrateselectedintocurrentaction/onActionProcess.js b/entity/Person_entity/entityfields/duplicateactions/children/integrateselectedintocurrentaction/onActionProcess.js index 851ada0af360d8e89cc23cbfbda7b997ca4bde56..651c632fb2984ebc04e2c764444545bf75f02562 100644 --- a/entity/Person_entity/entityfields/duplicateactions/children/integrateselectedintocurrentaction/onActionProcess.js +++ b/entity/Person_entity/entityfields/duplicateactions/children/integrateselectedintocurrentaction/onActionProcess.js @@ -2,24 +2,24 @@ import("system.db"); import("Employee_lib"); import("KeywordRegistry_basic"); import("ActivityTask_lib"); -import("system.logging"); import("system.vars"); import("system.neon"); import("DuplicateScanner_lib"); -let targetContactId = vars.get("$param.DuplicateCurrentContactId_param"); -let sourceContactId = vars.get("$sys.selection"); -logging.log("targetContactId -> " + targetContactId); -logging.log("sourceContactId -> "+ sourceContactId); +var targetContactId = vars.get("$param.DuplicateCurrentContactId_param"); +var sourceContactIdArray = vars.get("$sys.selection"); +var sourceContactId = sourceContactIdArray[0]; + //todo the actual merge ought to happen in a separate view where the contact infos can be merged manually by the user. -let mergeSuccess = DuplicateScannerUtils.MergePerson(sourceContactId, targetContactId); +var mergeSuccess = DuplicateScannerUtils.MergePerson(sourceContactId, targetContactId); if(mergeSuccess) { - let currentContactId = EmployeeUtils.getCurrentContactId(); + var currentContactId = EmployeeUtils.getCurrentContactId(); if(currentContactId == null) currentContactId = ""; DuplicateScannerUtils.CreateMergeSuccessActivity(sourceContactId, targetContactId, currentContactId, "Person"); - - neon.refreshAll(); +// openContext due to the fact, that openContext will lead to an error 'due'cause it's trying to load the already opened preview +// of the duplicateContact which just got deleted = nullpointException + neon.openContext("Person", null, [targetContactId], neon.OPERATINGSTATE_VIEW, null, null); } \ No newline at end of file diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index 7d3794c3adde49b3ad78259a7da03916aa7e7ba4..1442c2565230f4982d7a7d741f7216c56be7691f 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -468,6 +468,8 @@ AttributeRelationUtils.selectAttributeValue = function (pAttributeId, pValueMap, type[0] = type[0].trim(); var field = AttributeTypeUtil.getDatabaseField(type[0]); var value = pValueMap[field]; + if(value == undefined) + return ""; if (pGetViewValue && type[0] == $AttributeTypes.COMBO) { value = newSelect("ATTRIBUTE_NAME") diff --git a/process/DuplicateScanner_lib/process.js b/process/DuplicateScanner_lib/process.js index 6d263c439dac568a3559fd626368f9d722b981ce..91239d93d19cb53e4fa9d19a08f67a8af4f285ce 100644 --- a/process/DuplicateScanner_lib/process.js +++ b/process/DuplicateScanner_lib/process.js @@ -50,18 +50,20 @@ DuplicateScannerUtils.loadFilters = function(pFilterName, pTargetEntity) */ DuplicateScannerUtils.DeleteCachedDuplicate = function(pDuplicateId) { - let query = newSelect("count(ID), CLUSTERID from DUPLICATECLUSTERS") + + + var query = newSelect("count(ID), CLUSTERID") .from("DUPLICATECLUSTERS") .where("DUPLICATECLUSTERS.CLUSTERID", newSelect("CLUSTERID") .from("DUPLICATECLUSTERS") - .where("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId), + .where("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId).build(), SqlBuilder.IN()) .and("DUPLICATECLUSTERS.DUPLICATEID", pDuplicateId, SqlBuilder.NOT_EQUAL()) .groupBy("CLUSTERID"); - let coundAndClusterId = db.array(db.ROW, query); - let countDuplicatesInClusterWithoutParameterId = coundAndClusterId[0]; - let clusterId = coundAndClusterId[1]; + var countAndClusterId = query.arrayRow(); + let countDuplicatesInClusterWithoutParameterId = countAndClusterId[0]; + let clusterId = countAndClusterId[1]; //If only one duplicate would be remaining, //the whole cluster has to be deleted because there are no more duplicates. @@ -635,9 +637,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") @@ -650,15 +652,15 @@ DuplicateScannerUtils.MergePerson = function(pSourceContactId, pTargetContactId) updateStatementsCurrentAlias = updateStatementsCurrentAlias.concat(_DuplicateScannerUtils._buildUpdateContactIdStatements(tableInfosCurrentAlias, pSourceContactId, pTargetContactId)); updateStatementsCurrentAlias = updateStatementsCurrentAlias.concat(_DuplicateScannerUtils._buildUpdateAttachParticipantsToNewContactQuery("CAMPAIGNPARTICIPANT", "CONTACT_ID", "CAMPAIGN_ID", pSourceContactId, pTargetContactId)); - updateStatementsSystemAlias = updateStatementsSystemAlias.concat(_DuplicateScannerUtils._buildUpdateContactIdStatements(tableInfosSystemAlias, pSourceContactId, pTargetContactId)); + updateStatementsSystemAlias = updateStatementsSystemAlias.concat(_DuplicateScannerUtils._buildUpdateContactIdStatements(tableInfosSystemAlias, pSourceContactId, pTargetContactId, SqlUtils.getSystemAlias())); 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)); - 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); @@ -1124,26 +1126,26 @@ _DuplicateScannerUtils._getIgnoreSourceRecordPattern = function(pRecordIdValueTo return "( +( -" + indexsearch.FIELD_ID + ":(" + pRecordIdValueToIgnore + ") ) "; } -_DuplicateScannerUtils._buildUpdateContactIdStatements = function(pTableInfos, pSourceContactId, pTargetContactId) +_DuplicateScannerUtils._buildUpdateContactIdStatements = function(pTableInfos, pSourceContactId, pTargetContactId, pAlias) { let statements = []; for (let i = 0; i < pTableInfos.length; i++) { let tableInfo = pTableInfos[i]; - let updateStatement = _DuplicateScannerUtils._buildStatement(tableInfo, pSourceContactId, pTargetContactId); + let updateStatement = _DuplicateScannerUtils._buildStatement(tableInfo, pSourceContactId, pTargetContactId, pAlias); statements.push(updateStatement); } return statements; } -_DuplicateScannerUtils._buildStatement = function(pTableinfos, pSourceContactId, pTargetContactId) +_DuplicateScannerUtils._buildStatement = function(pTableinfos, pSourceContactId, pTargetContactId, pAlias) { let tableName = pTableinfos[INDEX_TABLE_NAME]; let columnName = pTableinfos[INDEX_COLUMN_NAME]; let additionalCondition = pTableinfos[INDEX_CONDITION]; - let condition = newWhere([tableName, columnName], pSourceContactId); + let condition = newWhere([tableName, columnName], pSourceContactId, undefined, undefined, pAlias); if(additionalCondition != "") condition.and(additionalCondition);