From 635e6b2fd7a29dfccb961fc704e5f5db0ddcaa42 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Fri, 23 Aug 2019 14:35:47 +0200 Subject: [PATCH] refactor Context_entity excludedContext params --- .../AttributeUsage_entity.aod | 10 +-- .../children/blacklist_param/valueProcess.js | 4 + .../exclusivecontexts_param/valueProcess.js | 16 ---- .../valueProcess.js | 0 entity/Attribute_entity/Attribute_entity.aod | 16 +++- .../children/blacklist_param/valueProcess.js | 4 + .../getallcontexts_param/valueProcess.js | 3 + .../invertblacklist_param/valueProcess.js | 3 + entity/Context_entity/Context_entity.aod | 80 +++++++------------ .../recordcontainers/jdito/contentProcess.js | 22 ++--- entity/Offer_entity/Offer_entity.aod | 10 ++- .../valueProcess.js | 6 +- .../invertblacklist_param/valueProcess.js | 3 + entity/Order_entity/Order_entity.aod | 10 ++- .../children/blacklist_param/valueProcess.js | 4 + .../invertblacklist_param/valueProcess.js | 3 + .../children/whitelist/valueProcess.js | 4 - process/Attribute_lib/process.js | 21 +++++ process/Context_lib/process.js | 26 +++--- 19 files changed, 134 insertions(+), 111 deletions(-) create mode 100644 entity/AttributeUsage_entity/entityfields/context/children/blacklist_param/valueProcess.js delete mode 100644 entity/AttributeUsage_entity/entityfields/context/children/exclusivecontexts_param/valueProcess.js rename entity/AttributeUsage_entity/entityfields/context/children/{useexclusives_param => invertblacklist_param}/valueProcess.js (100%) create mode 100644 entity/Attribute_entity/entityfields/contexts/children/blacklist_param/valueProcess.js create mode 100644 entity/Attribute_entity/entityfields/contexts/children/getallcontexts_param/valueProcess.js create mode 100644 entity/Attribute_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js rename entity/Offer_entity/entityfields/contexts/children/{whitelist => blacklist_param}/valueProcess.js (97%) create mode 100644 entity/Offer_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js create mode 100644 entity/Order_entity/entityfields/contexts/children/blacklist_param/valueProcess.js create mode 100644 entity/Order_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js delete mode 100644 entity/Order_entity/entityfields/contexts/children/whitelist/valueProcess.js diff --git a/entity/AttributeUsage_entity/AttributeUsage_entity.aod b/entity/AttributeUsage_entity/AttributeUsage_entity.aod index f585a185e5..606005be56 100644 --- a/entity/AttributeUsage_entity/AttributeUsage_entity.aod +++ b/entity/AttributeUsage_entity/AttributeUsage_entity.aod @@ -70,7 +70,7 @@ <dependency> <name>dependency</name> <entityName>Context_entity</entityName> - <fieldName>#PROVIDER</fieldName> + <fieldName>Exclusive</fieldName> </dependency> <children> <entityParameter> @@ -78,12 +78,12 @@ <valueProcess>%aditoprj%/entity/AttributeUsage_entity/entityfields/context/children/getallcontexts_param/valueProcess.js</valueProcess> </entityParameter> <entityParameter> - <name>UseExclusives_param</name> - <valueProcess>%aditoprj%/entity/AttributeUsage_entity/entityfields/context/children/useexclusives_param/valueProcess.js</valueProcess> + <name>Blacklist_param</name> + <valueProcess>%aditoprj%/entity/AttributeUsage_entity/entityfields/context/children/blacklist_param/valueProcess.js</valueProcess> </entityParameter> <entityParameter> - <name>ExclusiveContexts_param</name> - <valueProcess>%aditoprj%/entity/AttributeUsage_entity/entityfields/context/children/exclusivecontexts_param/valueProcess.js</valueProcess> + <name>InvertBlacklist_param</name> + <valueProcess>%aditoprj%/entity/AttributeUsage_entity/entityfields/context/children/invertblacklist_param/valueProcess.js</valueProcess> </entityParameter> </children> </entityConsumer> diff --git a/entity/AttributeUsage_entity/entityfields/context/children/blacklist_param/valueProcess.js b/entity/AttributeUsage_entity/entityfields/context/children/blacklist_param/valueProcess.js new file mode 100644 index 0000000000..3e85628ab0 --- /dev/null +++ b/entity/AttributeUsage_entity/entityfields/context/children/blacklist_param/valueProcess.js @@ -0,0 +1,4 @@ +import("Attribute_lib"); +import("system.result"); + +result.object(AttributeUtil.getPossibleUsageContexts()); \ No newline at end of file diff --git a/entity/AttributeUsage_entity/entityfields/context/children/exclusivecontexts_param/valueProcess.js b/entity/AttributeUsage_entity/entityfields/context/children/exclusivecontexts_param/valueProcess.js deleted file mode 100644 index a304ae4185..0000000000 --- a/entity/AttributeUsage_entity/entityfields/context/children/exclusivecontexts_param/valueProcess.js +++ /dev/null @@ -1,16 +0,0 @@ -import("system.result"); - -result.object([ - "Organisation", - "Person", - "Contract", - "Product", - "Activity", - "Offer", - "Order", - "Employee", - "Salesproject", - "Campaign", - "DocumentTemplate", - "SupportTicket" -]); \ No newline at end of file diff --git a/entity/AttributeUsage_entity/entityfields/context/children/useexclusives_param/valueProcess.js b/entity/AttributeUsage_entity/entityfields/context/children/invertblacklist_param/valueProcess.js similarity index 100% rename from entity/AttributeUsage_entity/entityfields/context/children/useexclusives_param/valueProcess.js rename to entity/AttributeUsage_entity/entityfields/context/children/invertblacklist_param/valueProcess.js diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod index 8752963e7b..ce9b1778aa 100644 --- a/entity/Attribute_entity/Attribute_entity.aod +++ b/entity/Attribute_entity/Attribute_entity.aod @@ -380,8 +380,22 @@ <dependency> <name>dependency</name> <entityName>Context_entity</entityName> - <fieldName>#PROVIDER</fieldName> + <fieldName>Exclusive</fieldName> </dependency> + <children> + <entityParameter> + <name>Blacklist_param</name> + <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/contexts/children/blacklist_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>GetAllContexts_param</name> + <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/contexts/children/getallcontexts_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>InvertBlacklist_param</name> + <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js</valueProcess> + </entityParameter> + </children> </entityConsumer> </entityFields> <recordContainers> diff --git a/entity/Attribute_entity/entityfields/contexts/children/blacklist_param/valueProcess.js b/entity/Attribute_entity/entityfields/contexts/children/blacklist_param/valueProcess.js new file mode 100644 index 0000000000..3e85628ab0 --- /dev/null +++ b/entity/Attribute_entity/entityfields/contexts/children/blacklist_param/valueProcess.js @@ -0,0 +1,4 @@ +import("Attribute_lib"); +import("system.result"); + +result.object(AttributeUtil.getPossibleUsageContexts()); \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/contexts/children/getallcontexts_param/valueProcess.js b/entity/Attribute_entity/entityfields/contexts/children/getallcontexts_param/valueProcess.js new file mode 100644 index 0000000000..40effa0178 --- /dev/null +++ b/entity/Attribute_entity/entityfields/contexts/children/getallcontexts_param/valueProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string(true); \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js b/entity/Attribute_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js new file mode 100644 index 0000000000..40effa0178 --- /dev/null +++ b/entity/Attribute_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string(true); \ No newline at end of file diff --git a/entity/Context_entity/Context_entity.aod b/entity/Context_entity/Context_entity.aod index efc6a9df14..04b6a36548 100644 --- a/entity/Context_entity/Context_entity.aod +++ b/entity/Context_entity/Context_entity.aod @@ -16,18 +16,6 @@ <fieldName>Context</fieldName> <isConsumer v="false" /> </entityDependency> - <entityDependency> - <name>f1eebe8c-93d2-4977-b619-b6315f843f7a</name> - <entityName>AttributeUsage_entity</entityName> - <fieldName>Context</fieldName> - <isConsumer v="false" /> - </entityDependency> - <entityDependency> - <name>68f79479-52e5-42b1-81f5-bb725e032382</name> - <entityName>Attribute_entity</entityName> - <fieldName>Contexts</fieldName> - <isConsumer v="false" /> - </entityDependency> </dependencies> </entityProvider> <entityField> @@ -65,32 +53,20 @@ <fieldName>Contexts</fieldName> <isConsumer v="false" /> </entityDependency> - <entityDependency> - <name>420468aa-c237-4e29-a24f-8851e56343b9</name> - <entityName>Offer_entity</entityName> - <fieldName>Contexts</fieldName> - <isConsumer v="false" /> - </entityDependency> - <entityDependency> - <name>98695ca8-7f46-489d-a479-f856f6d2b5ca</name> - <entityName>Order_entity</entityName> - <fieldName>Contexts</fieldName> - <isConsumer v="false" /> - </entityDependency> </dependencies> <children> <entityParameter> - <name>ExclusiveContexts_param</name> + <name>InvertBlacklist_param</name> <expose v="false" /> </entityParameter> <entityParameter> - <name>UseExclusives_param</name> + <name>Blacklist_param</name> <expose v="false" /> </entityParameter> </children> </entityProvider> <entityParameter> - <name>ExclusiveContexts_param</name> + <name>Blacklist_param</name> <expose v="true" /> <description>PARAMETER</description> </entityParameter> @@ -136,34 +112,38 @@ <description>PARAMETER</description> </entityParameter> <entityParameter> - <name>UseExclusives_param</name> + <name>InvertBlacklist_param</name> <expose v="true" /> <description>PARAMETER</description> </entityParameter> - <entityParameter> - <name>Whitelist</name> - <expose v="true" /> - </entityParameter> <entityProvider> <name>Exclusive</name> - <children> - <entityParameter> - <name>ExclusiveContexts_param</name> - <expose v="false" /> - </entityParameter> - <entityParameter> - <name>GetAllContexts_param</name> - <expose v="false" /> - </entityParameter> - <entityParameter> - <name>UseExclusives_param</name> - <expose v="false" /> - </entityParameter> - <entityParameter> - <name>Whitelist</name> - <expose v="false" /> - </entityParameter> - </children> + <dependencies> + <entityDependency> + <name>2fb3e0df-0372-4ba4-acde-210432517ee8</name> + <entityName>Offer_entity</entityName> + <fieldName>Contexts</fieldName> + <isConsumer v="false" /> + </entityDependency> + <entityDependency> + <name>66a69b09-d02a-4de6-a2dd-d11ce1467e01</name> + <entityName>Order_entity</entityName> + <fieldName>Contexts</fieldName> + <isConsumer v="false" /> + </entityDependency> + <entityDependency> + <name>b48df8c7-9d56-40f2-8269-b749afc92af5</name> + <entityName>Attribute_entity</entityName> + <fieldName>Contexts</fieldName> + <isConsumer v="false" /> + </entityDependency> + <entityDependency> + <name>9ad799f1-6303-4119-9bea-8e559850541b</name> + <entityName>AttributeUsage_entity</entityName> + <fieldName>Context</fieldName> + <isConsumer v="false" /> + </entityDependency> + </dependencies> </entityProvider> </entityFields> <recordContainers> diff --git a/entity/Context_entity/recordcontainers/jdito/contentProcess.js b/entity/Context_entity/recordcontainers/jdito/contentProcess.js index d061ec44ca..2568221255 100644 --- a/entity/Context_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Context_entity/recordcontainers/jdito/contentProcess.js @@ -2,21 +2,25 @@ import("system.vars"); import("system.result"); import("Context_lib"); -var excludeContexts = vars.getString("$param.ExclusiveContexts_param"); -if (excludeContexts) - excludeContexts = JSON.parse(excludeContexts); -var filterContexts = !(vars.exists("$param.GetAllContexts_param") && vars.get("$param.GetAllContexts_param") == "true"); -var useExclusives = vars.exists("$param.UseExclusives_param") && vars.get("$param.UseExclusives_param") == "true"; +var blacklist +var invertBlacklist +var filterContexts = vars.get("$param.GetAllContexts_param") != "true"; var whitelist; if (vars.get("$local.idvalues") && vars.get("$local.idvalues").length > 0) { - whitelist = vars.get("$local.idvalues") + blacklist = vars.get("$local.idvalues") + invertBlacklist = true; } else { - whitelist = vars.get("$param.Whitelist") ? JSON.parse(vars.get("$param.Whitelist")) : undefined; - + blacklist = vars.getString("$param.Blacklist_param"); + if (blacklist) + blacklist = JSON.parse(blacklist); + else + blacklist = undefined; + + invertBlacklist = vars.get("$param.InvertBlacklist_param") == "true"; } -result.object(ContextUtils.getContexts(filterContexts, excludeContexts, useExclusives, whitelist)); \ No newline at end of file +result.object(ContextUtils.getContexts(filterContexts, blacklist, invertBlacklist)); \ No newline at end of file diff --git a/entity/Offer_entity/Offer_entity.aod b/entity/Offer_entity/Offer_entity.aod index 62a2d841e5..c613c94c3c 100644 --- a/entity/Offer_entity/Offer_entity.aod +++ b/entity/Offer_entity/Offer_entity.aod @@ -690,12 +690,16 @@ <dependency> <name>dependency</name> <entityName>Context_entity</entityName> - <fieldName>Context</fieldName> + <fieldName>Exclusive</fieldName> </dependency> <children> <entityParameter> - <name>Whitelist</name> - <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/contexts/children/whitelist/valueProcess.js</valueProcess> + <name>Blacklist_param</name> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/contexts/children/blacklist_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>InvertBlacklist_param</name> + <valueProcess>%aditoprj%/entity/Offer_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js</valueProcess> </entityParameter> </children> </entityConsumer> diff --git a/entity/Offer_entity/entityfields/contexts/children/whitelist/valueProcess.js b/entity/Offer_entity/entityfields/contexts/children/blacklist_param/valueProcess.js similarity index 97% rename from entity/Offer_entity/entityfields/contexts/children/whitelist/valueProcess.js rename to entity/Offer_entity/entityfields/contexts/children/blacklist_param/valueProcess.js index 928bc6a94c..91cfc66201 100644 --- a/entity/Offer_entity/entityfields/contexts/children/whitelist/valueProcess.js +++ b/entity/Offer_entity/entityfields/contexts/children/blacklist_param/valueProcess.js @@ -1,4 +1,4 @@ -import("system.vars"); -import("system.result"); - +import("system.vars"); +import("system.result"); + result.string(vars.get("$param.PossibleConnectionTypes")) \ No newline at end of file diff --git a/entity/Offer_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js b/entity/Offer_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js new file mode 100644 index 0000000000..40effa0178 --- /dev/null +++ b/entity/Offer_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string(true); \ No newline at end of file diff --git a/entity/Order_entity/Order_entity.aod b/entity/Order_entity/Order_entity.aod index 80b6937c3c..0dcd4c1d48 100644 --- a/entity/Order_entity/Order_entity.aod +++ b/entity/Order_entity/Order_entity.aod @@ -607,12 +607,16 @@ <dependency> <name>dependency</name> <entityName>Context_entity</entityName> - <fieldName>Context</fieldName> + <fieldName>Exclusive</fieldName> </dependency> <children> <entityParameter> - <name>Whitelist</name> - <valueProcess>%aditoprj%/entity/Order_entity/entityfields/contexts/children/whitelist/valueProcess.js</valueProcess> + <name>Blacklist_param</name> + <valueProcess>%aditoprj%/entity/Order_entity/entityfields/contexts/children/blacklist_param/valueProcess.js</valueProcess> + </entityParameter> + <entityParameter> + <name>InvertBlacklist_param</name> + <valueProcess>%aditoprj%/entity/Order_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js</valueProcess> </entityParameter> </children> </entityConsumer> diff --git a/entity/Order_entity/entityfields/contexts/children/blacklist_param/valueProcess.js b/entity/Order_entity/entityfields/contexts/children/blacklist_param/valueProcess.js new file mode 100644 index 0000000000..767a3db63e --- /dev/null +++ b/entity/Order_entity/entityfields/contexts/children/blacklist_param/valueProcess.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.get("$param.PossibleConnectionTypes")); \ No newline at end of file diff --git a/entity/Order_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js b/entity/Order_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js new file mode 100644 index 0000000000..40effa0178 --- /dev/null +++ b/entity/Order_entity/entityfields/contexts/children/invertblacklist_param/valueProcess.js @@ -0,0 +1,3 @@ +import("system.result"); + +result.string(true); \ No newline at end of file diff --git a/entity/Order_entity/entityfields/contexts/children/whitelist/valueProcess.js b/entity/Order_entity/entityfields/contexts/children/whitelist/valueProcess.js deleted file mode 100644 index 928bc6a94c..0000000000 --- a/entity/Order_entity/entityfields/contexts/children/whitelist/valueProcess.js +++ /dev/null @@ -1,4 +0,0 @@ -import("system.vars"); -import("system.result"); - -result.string(vars.get("$param.PossibleConnectionTypes")) \ No newline at end of file diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index a2a93c3da0..d5e2fe99b1 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -21,6 +21,27 @@ import("Keyword_lib"); */ function AttributeUtil () {} +/** + * @return all Contexts (Object types) which can be the usage of attributes + */ +AttributeUtil.getPossibleUsageContexts = function() +{ + return [ + "Organisation", + "Person", + "Contract", + "Product", + "Activity", + "Offer", + "Order", + "Employee", + "Salesproject", + "Campaign", + "DocumentTemplate", + "SupportTicket" + ]; +} + /** * Gives an array of all available attributes for a context. This is used in the possibleItems * process for the attribute id in AttributeRelation diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js index 6d7b5c396d..aa417543da 100644 --- a/process/Context_lib/process.js +++ b/process/Context_lib/process.js @@ -88,47 +88,39 @@ ContextUtils.getContextConsumer = function(pContextId) /** * * @param {Boolean} [pFilter=false] filter only for contexts which have a mapping in ContextUtils.getSelectMap - * @param {String[]} [pExclusiveContexts] contextIds that shall not be included (so this is a additional filter to the pFilter param) - * @param {Boolean} [pUseExclusives=false] decides whether the items in pExclusiveContexts are excluded (false) or - * everything that is NOT in pExclusiveContexts is excluded (true) + * @param {String[]} [pBlacklist] contextIds that shall not be included (so this is a additional filter to the pFilter param) + * @param {Boolean} [pInvertBlacklist=false] decides whether the items in pBlacklist are excluded (false) or + * everything that is NOT in pBlacklist is excluded (true) * (-> if it is a whitelist or blacklist) - * @param {String[]} [pWhitelist=undefined] only allowed contexts * * @return {String[][]} the contexts [[contextId, contextName, contextTitle], [... ], ...] */ -ContextUtils.getContexts = function(pFilter, pExclusiveContexts, pUseExclusives, pWhitelist) +ContextUtils.getContexts = function(pFilter, pBlacklist, pInvertBlacklist) { if (pFilter == undefined) pFilter = false; - if (pUseExclusives == undefined) - pUseExclusives = false; + if (pInvertBlacklist == undefined) + pInvertBlacklist = false; var contexts = project.getDataModels(project.DATAMODEL_KIND_CONTEXT); if (pFilter) { contexts = contexts.filter(function(pContext) { - if (pExclusiveContexts && pExclusiveContexts.indexOf(pContext[0]) > -1 != pUseExclusives) + if (pBlacklist && pBlacklist.indexOf(pContext[0]) > -1 != pInvertBlacklist) return false; // filter only contexts which have defined mappings in Context_lib return ContextUtils.getSelectMap ()[pContext[0]] != undefined; }); } - else if (pExclusiveContexts) + else if (pBlacklist) { contexts = contexts.filter(function(pContext) { - if (pExclusiveContexts && pExclusiveContexts.indexOf(pContext[0]) > -1 != pUseExclusives) + if (pBlacklist && pBlacklist.indexOf(pContext[0]) > -1 != pInvertBlacklist) return false; return true; }); } - - if (pWhitelist) - { - contexts = contexts.filter(function(pContext) { - return (pWhitelist.indexOf(pContext[0]) >= 0); - }); - } return contexts.map(ContextUtils._contextDataMapping).sort(function(pContext1, pContext2) { -- GitLab