From b0a37e2d56e90f3ed8d0fa4a7eb6b1a5983a895b Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Fri, 23 Aug 2019 13:34:01 +0200 Subject: [PATCH] filter attributes for usage --- entity/Attribute_entity/Attribute_entity.aod | 17 ++++++++++ .../recordcontainers/jdito/contentProcess.js | 22 ++++++++++++- entity/Context_entity/Context_entity.aod | 31 +++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod index e016d3d087..8752963e7b 100644 --- a/entity/Attribute_entity/Attribute_entity.aod +++ b/entity/Attribute_entity/Attribute_entity.aod @@ -370,6 +370,19 @@ <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/objectrowid_param/valueProcess.js</valueProcess> <expose v="true" /> </entityParameter> + <entityField> + <name>USAGE_FILTER</name> + <title>Usage</title> + <consumer>Contexts</consumer> + </entityField> + <entityConsumer> + <name>Contexts</name> + <dependency> + <name>dependency</name> + <entityName>Context_entity</entityName> + <fieldName>#PROVIDER</fieldName> + </dependency> + </entityConsumer> </entityFields> <recordContainers> <jDitoRecordContainer> @@ -422,6 +435,10 @@ <jDitoRecordFieldMapping> <name>FULL_ATTRIBUTE_NAME.value</name> </jDitoRecordFieldMapping> + <jDitoRecordFieldMapping> + <name>USAGE_FILTER.value</name> + <isFilterable v="true" /> + </jDitoRecordFieldMapping> </recordFieldMappings> </jDitoRecordContainer> </recordContainers> diff --git a/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js b/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js index e4fd9e63f9..80d83fad22 100644 --- a/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js @@ -86,7 +86,26 @@ if (vars.exists("$local.filter") && vars.get("$local.filter")) { var filter = vars.get("$local.filter"); if (filter.filter) - condition.andSqlCondition(JditoFilterUtils.getSqlCondition(filter.filter, "AB_ATTRIBUTE")); + condition.andSqlCondition(JditoFilterUtils.getSqlCondition(filter.filter, "AB_ATTRIBUTE", undefined, { + // special filter for usage + USAGE_FILTER : function (pValue, pOperator) + { + var cond = new SqlCondition(); + + switch (pOperator) + { + case "EQUAL": + return cond.andPrepare(["AB_ATTRIBUTEUSAGE", "OBJECT_TYPE", "attrUse"], pValue, "exists (select 1 from AB_ATTRIBUTEUSAGE attrUse where attrUse.AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID and # = ?)"); + case "NOT_EQUAL": + return cond.andPrepare(["AB_ATTRIBUTEUSAGE", "OBJECT_TYPE", "attrUse"], pValue, "not exists (select 1 from AB_ATTRIBUTEUSAGE attrUse where attrUse.AB_ATTRIBUTE_ID = AB_ATTRIBUTE.AB_ATTRIBUTEID and # = ?)"); + case "ISNULL": + return cond.and("not exists (select 1 from AB_ATTRIBUTEUSAGE attrUse where attrUse.AB_ATTRIBUTE_ID = AB_ATTRIBUTEID)"); + case "ISNOTNULL": + return cond.and("exists (select 1 from AB_ATTRIBUTEUSAGE attrUse where attrUse.AB_ATTRIBUTE_ID = AB_ATTRIBUTEID)"); + } + return cond; + } + })); } var usages; @@ -163,6 +182,7 @@ function _buildAttributeTable (pAttributes, pUsages) } rowData[10] = _getFullName(rowData[1]); //parent full name rowData[11] = _getFullName(rowData[0], displaySimpleName); + rowData[12] = "dummy" sortedArray[rows[i].index] = rowData; } diff --git a/entity/Context_entity/Context_entity.aod b/entity/Context_entity/Context_entity.aod index 95285692f1..efc6a9df14 100644 --- a/entity/Context_entity/Context_entity.aod +++ b/entity/Context_entity/Context_entity.aod @@ -22,6 +22,12 @@ <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> @@ -77,6 +83,10 @@ <name>ExclusiveContexts_param</name> <expose v="false" /> </entityParameter> + <entityParameter> + <name>UseExclusives_param</name> + <expose v="false" /> + </entityParameter> </children> </entityProvider> <entityParameter> @@ -134,6 +144,27 @@ <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> + </entityProvider> </entityFields> <recordContainers> <jDitoRecordContainer> -- GitLab