Newer
Older
import("system.datetime");
import("system.logging");
import("Util_lib");
import("system.translate");
import("system.vars");
import("Keyword_lib");
if (vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param")
&& vars.exists("$param.ObjectRowId_param") && vars.get("$param.ObjectRowId_param"))
{
var contextList = JSON.parse(vars.get("$param.ObjectType_param"));
var contactId = JSON.parse(vars.get("$param.ObjectRowId_param"));
var data = _get360Data(contactId, contextList);
result.object(data);
}
else
{
result.object([]);
}
/**
* collects all data for the 360Degree tree.
* @param {String} pContactId, the main Contactid that will be used for the Connections
* @param {String[]} pContextList, a list of Contexts that should be displayed
*
* @return {String[][]} the resulting data
function _get360Data(pContactId, pContextList)
var filter = vars.get("$sys.filter");
for(var context in pContextList)
var group = ContextUtils.getTitle(context, true);
if(pContextList[context].hasOwnProperty("setGroupBy") && pContextList[context].hasOwnProperty("groupByKeyword"))
var groupKeyword = Utils.objectFromMap(new Map(KeywordUtils.getEntryNamesAndIdsByContainer(pContextList[context]["groupByKeyword"])));
var res = ContextUtils.getContextDataViaReadEntity(context, pContextList[context], filter, pContactId);
if(res.length > 0)
res.forEach(function (row)
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var uid = JSON.stringify({
"id": row["#UID"],
"type": context
});
var targetid = row["#UID"];
var title = row["#CONTENTTITLE"];
var description = row["#CONTENTDESCRIPTION"];
var dataDate = row["DATE_NEW"];
var active = row["ACTIVE"];
if(pContextList[context].hasOwnProperty("setGroupBy"))
group = row[pContextList[context]["setGroupBy"]]
if(pContextList[context].hasOwnProperty("setGroupBy"))
{
if( pContextList[context].hasOwnProperty("groupByKeyword") && groupKeyword)
group = groupKeyword[row[pContextList[context]["setGroupBy"]]]
else
group = row[pContextList[context]["setGroupBy"]]
}
resultList.push([
uid, // UID
targetid, // TARGET_ID
context, // TARGET_CONTEXT
translate.text(pContextList[context]), // TARGET_CONTEXT.displayValue
title, // TITLE
description, // DESCRIPTION
dataDate, // DATE
datetime.toDate(dataDate, "yyyy"), // YEAR
ContextUtils.getEntity(context), // ENTITY_NAME
translate.text(group), // GROUP
active // ACTIVE
]);
});
}
}
var sortArr = [9, false]
resultList = ArrayUtils.sortMulti(resultList, sortArr)