diff --git a/entity/360Degree_entity/documentation.adoc b/entity/360Degree_entity/documentation.adoc index b2ad150c07864327f864c6c179b28caf1a37d285..b07c00500ceb7ed1fc24f01140cf046eb2f41251 100644 --- a/entity/360Degree_entity/documentation.adoc +++ b/entity/360Degree_entity/documentation.adoc @@ -16,21 +16,21 @@ Heres is a list of what you need to do whenever you want to do this: - At first you have to fill/add certain Fields/Processes in your new Context. - Add (These have to be written exactly like that, if not already existing): - - CONTACT_ID, this Field has to contain a CONTACTID. That will be used to find the Connection to your Person or your Organisation. - DATE_NEW, this Field has to contain a Date as a Long Value. That will be used as the Date Value you can see in the Timeline View-Template. - ACTIVE, in this Field you can specify which Datasets are active or not. You have to declare that in the Value Expression as a Case-When due to the Filter - Fill (these can be filled in the specific Entity as a Process) - #CONTENTTITLE, this will be the main display Text and the blue Link - #CONTENTDESCRIPTION, this will be the smaller, mostly longer, Text beneath the #CONTENTTITLE -- Add an elemnt (with the name of the context you want to add) in the process of the `ObjectType_param` in the *corresponding provider* which is located in the `360Degree_entity`. _We would extend the JSON-Object which is returned in the `PersonObjects`-provider by the name of our t-shirt-context: "TShirt" in our example -- -- In that JSON-Object can also add some Configuration Elements to change the results. +- Add an element (with the name of the context you want to add) in the process of the `ObjectType_param` in the *corresponding provider* which is located in the `360Degree_entity`. _We would extend the JSON-Object which is returned in the `PersonObjects`-provider by the name of our t-shirt-context: "TShirt" in our example + +- In that JSON-Object you can/have to add some Configuration Elements to change the results. + - connectionField, here you have to declare a Field that writes exactly like the one in your Entity (Standard is CONTACT_ID!!!). The Value of this Field will be used to compare it with the Object_Rowid. - setGroupBy: here you can declare a DB-Column that will be used as the new group by of that context. A good example is Order. We want to group by the Ordertype so we have to declare ORDERTYPE as our groupBy. - If your DB-Value is related to a Keyword you also have to use groupByKeyword and add the Container as Value -- If you have a Connection of 1:N in your Database Schema (like Activity and ActivityLink) you have to add specific Properties in your Context Object. Lets take ActivityLink as a Example. - - subContext: the Name of the "Link"-Context -> ActivityLink - - childField: The Field where the LinkID to your Parent is stored -> ACTIVITY_ID - - parentField: The field in your Parent Context where your Connection to your Child is stored -> ACTIVITYID +- If you have a Connection of 1:N in your Database Schema (like Task and TaskLink) you have to add specific Properties in your Context Object. Lets take TaskLink as a Example. + - subContext: the Name of the "Link"-Context -> TaskLink + - childField: The Field where the LinkID to your Parent is stored -> TASK_ID + - parentField: The field in your Parent Context where your Connection to your Child is stored -> TASKID - contactIdField: The Field in the Link Context where your Contactid is stored -> OBJECT_ROWID \ No newline at end of file diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js index b7bf2e8a17ab57f3b798bdb5ffaf388b678ca982..40e6e00d4c2d686986fa22bb843da5b35d29c01f 100644 --- a/process/Context_lib/process.js +++ b/process/Context_lib/process.js @@ -355,10 +355,15 @@ ContextUtils.getTitleByContext = function(pContextId, pRowId) * @param {Object} [pFilterObj] prepeared Filter Object * @param {String[]} [pContactId] Array of all the Contactids you want to search through * - * @return {String[][]} An Array of Fields (["#UID", "#TITLE", "#MAPPING", "#CONTENTDESCRIPTION", "#CONTENTTITLE", "CONTACT_ID", "DATE_NEW"]) for a certain Context + * @return {String[][]} An Array of Fields (["#UID", "#TITLE", "#MAPPING", "#CONTENTDESCRIPTION", "#CONTENTTITLE", CONNECTIONFIELD, "DATE_NEW"]) for a certain Context */ ContextUtils.getContextDataViaReadEntity = function(pContextId, pContextConfig, pFilterObj, pContactId) { + + var connectionField = "CONTACT_ID"; + if(pContextConfig.connectionField) + connectionField = pContextConfig.connectionField; + if(pContextConfig.childField && pContextConfig.parentField && pContextConfig.contactIdField && pContextConfig.subContext) { var prefilter = Utils.buildFilterObj({}, pContextConfig.contactIdField, "IN", "TEXT", JSON.stringify(pContactId), JSON.stringify(pContactId), "OR"); @@ -377,10 +382,10 @@ ContextUtils.getContextDataViaReadEntity = function(pContextId, pContextConfig, } else { - pFilterObj = Utils.buildFilterObj(pFilterObj, "CONTACT_ID", "IN", "TEXT", JSON.stringify(pContactId), JSON.stringify(pContactId), "AND"); + pFilterObj = Utils.buildFilterObj(pFilterObj, connectionField, "IN", "TEXT", JSON.stringify(pContactId), JSON.stringify(pContactId), "AND"); } - var fields = ["#UID", "#TITLE", "#MAPPING", "#CONTENTDESCRIPTION", "#CONTENTTITLE", "CONTACT_ID", "DATE_NEW", "ACTIVE"]; + var fields = ["#UID", "#TITLE", "#MAPPING", "#CONTENTDESCRIPTION", "#CONTENTTITLE", connectionField, "DATE_NEW", "ACTIVE"]; if(pContextConfig.setGroupBy) fields.push(pContextConfig.setGroupBy); @@ -410,8 +415,8 @@ ContextUtils.getContextDataViaReadEntity = function(pContextId, pContextConfig, throw new Error(translate.text("Some prereserved EntityFields which are necessary fot 360° are not available. Context: "+pContextId +" Data: "+JSON.stringify(res))); } - else if(res[0]["CONTACT_ID"] == undefined) - throw new Error(translate.text("CONTACT_ID is not defined! Context: "+pContextId)); + else if(res[0][connectionField] == undefined) + throw new Error(translate.text(connectionField+" is not defined! Context: "+pContextId)); } return res; }