Skip to content
Snippets Groups Projects
Commit bbdcff0b authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

360Degree_entity supports no the $local.idvalues variable

parent 210bed44
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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)
{
......
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