From bbdcff0b0216fec6af274c87b3c78101f5efeb07 Mon Sep 17 00:00:00 2001 From: "j.goderbauer" <j.goderbauer@adito.de> Date: Wed, 30 Sep 2020 11:10:29 +0200 Subject: [PATCH] 360Degree_entity supports no the $local.idvalues variable --- .../recordcontainers/jdito/contentProcess.js | 39 +++++++++++++++++-- process/Context_lib/process.js | 5 ++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/entity/360Degree_entity/recordcontainers/jdito/contentProcess.js b/entity/360Degree_entity/recordcontainers/jdito/contentProcess.js index 60a8312eb2..3014803809 100644 --- a/entity/360Degree_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/360Degree_entity/recordcontainers/jdito/contentProcess.js @@ -25,7 +25,12 @@ if (vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param" var contextList = JSON.parse(vars.getString("$param.ObjectType_param")); var contactId = vars.get("$param.ObjectRowId_param"); - result.object(_get360Data(selectMap, contactId, contextList, active)); + var idValues; + if (vars.exists("$local.idvalues")) + idValues = vars.get("$local.idvalues"); + + var res = _get360Data(selectMap, contactId, contextList, active, idValues); + result.object(res); } else { @@ -38,15 +43,40 @@ else * @param {String[]} pContactId the Contactid the 360 Degree tree should be loaded for * @param {String[]} pContextList list of contexts to load. Note that subcontexts use their own list, defined in ContextUtils * @param {Boolean} [pActive=undefined] if not undefined: it select only for active / inactive state + * @param {Array} [pUids=undefined] uids of the 360° entity that are used for filtering, each rowId needs the format: + * {id: "«rowid»", type: "«context id»"} * * @return {String[][]} the resulting data */ -function _get360Data(pSelectMap, pContactId, pContextList, pActive) +function _get360Data(pSelectMap, pContactId, pContextList, pActive, pUids) { + //if there are uids for filtering, group them per context: + var uidContextMap = new Map();//Map where key is the type (contextname) and value is an array of the rowIds for that type + if (pUids) + { + pUids.forEach(function (uid){ + uid = JSON.parse(uid); + if (uidContextMap.has(uid.type)) + uidContextMap.get(uid.type).push(uid.id); + else + uidContextMap.set(uid.type, [uid.id]); + }); + } + var resultList = []; pContextList.forEach(function (context) { - var data = db.table(ContextUtils.getContextDataSql(context, JSON.parse(pContactId), true, pActive, true, true)); + var rowIds; + if (pUids) + { + //when a Uid-filter exists, but there is no context for filtering we can skip that context, + //otherwise we need to filter for the found row ids of that context + if (!uidContextMap.has(context)) + return; + else + rowIds = uidContextMap.get(context); + } + var data = db.table(ContextUtils.getContextDataSql(context, JSON.parse(pContactId), true, pActive, true, true, rowIds)); data.forEach(function (row) { var active; @@ -64,8 +94,9 @@ function _get360Data(pSelectMap, pContactId, pContextList, pActive) if(groupBy == "") groupBy = ContextUtils.getEntityTitle(context, true); + var uid = JSON.stringify({id: row[0], type: context}); resultList.push([ - util.getNewUUID(), // UID + uid, // UID row[0], // TARGET_ID context, // TARGET_CONTEXT row[1], // TITLE diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js index 38f64a6d9c..f65180f1d1 100644 --- a/process/Context_lib/process.js +++ b/process/Context_lib/process.js @@ -662,7 +662,7 @@ ContextUtils.getContactId = function(pContextId, pRowId) * nur 360 * */ -ContextUtils.getContextDataSql = function(pContextId, pContactId, pWithDate, pActive, pWithState, pWithGroupBy) +ContextUtils.getContextDataSql = function(pContextId, pContactId, pWithDate, pActive, pWithState, pWithGroupBy, pUidsForFiltering) { var selectMap = ContextUtils.getSelectMap(); var ownContextSelector = selectMap[pContextId]; @@ -689,7 +689,8 @@ ContextUtils.getContextDataSql = function(pContextId, pContactId, pWithDate, pAc var contextDataSelect = newSelect( columns.join(", ") ) .from(ownContextSelector.getFullFromClause()) - .where(ownContextSelector.getFullField(ownContextSelector.contactIdField), pContactId, SqlBuilder.IN()); + .where(ownContextSelector.getFullField(ownContextSelector.contactIdField), pContactId, SqlBuilder.IN()) + .andIfSet(ownContextSelector.getFullIdField(), pUidsForFiltering, SqlBuilder.IN()); if (pActive != undefined) { -- GitLab