From c1f6b6d3d76f5f5bc58ddc9f84da363d0abd0a8b Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Thu, 30 May 2024 18:05:12 +0530 Subject: [PATCH 1/2] Improved: Handled the case to perform operations on all the facilities/channels of the associated product store (#1). --- drl/ProductFacilityRuleTemplate.drl.ftl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drl/ProductFacilityRuleTemplate.drl.ftl b/drl/ProductFacilityRuleTemplate.drl.ftl index a69d14a..3e858ff 100644 --- a/drl/ProductFacilityRuleTemplate.drl.ftl +++ b/drl/ProductFacilityRuleTemplate.drl.ftl @@ -1,3 +1,5 @@ +<#assign ruleGroup = ec.entity.find("co.hotwax.rule.RuleGroup").condition("ruleGroupId", ruleGroupId).condition("statusId", "ATP_RG_ACTIVE").one()!> +<#if ruleGroup?has_content> <#assign decisionRules = ec.entity.find("co.hotwax.rule.DecisionRule").condition("ruleGroupId", ruleGroupId).condition("statusId", "ATP_RULE_ACTIVE").orderBy("sequenceNum asc").list()!> <#if decisionRules?has_content> @@ -26,6 +28,16 @@ <#assign facilityIds = []/> <#if facilityConditions?has_content> <#assign facilityCondition = facilityConditions?first/> + <#if "ALL" == facilityCondition.fieldValue!> + <#assign allConfigFacilities = ec.entity.find("co.hotwax.product.store.ProductStoreFacilityDetail").selectField("facilityId").condition("productStoreId", ruleGroup.productStoreId, "facilityTypeId", "CONFIGURATION").list()!> + <#if allConfigFacilities?has_content> + <#list allConfigFacilities as configFacility> + <#assign facilityIds = facilityIds + [configFacility.facilityId]> + + + <#else> + <#assign facilityIds = Static["co.hotwax.common.DecisionRuleHelper"].valueToCollection(facilityCondition.fieldValue)/> + <#assign facilityIds = Static["co.hotwax.common.DecisionRuleHelper"].valueToCollection(facilityCondition.fieldValue)/> <#if !facilityIds?has_content> @@ -33,6 +45,16 @@ <#assign includedFacilityGroupIds = []> <#assign excludedFacilityGroupIds = []> <#if facilityGroupConditions?has_content> + <#assign facilityGroupCondition = facilityGroupConditions?first/> + <#if "ALL" == facilityGroupCondition.fieldValue!> + <#assign allFacilities = ec.entity.find("co.hotwax.product.store.ProductStoreFacilityDetail").selectField("facilityId").condition("productStoreId", ruleGroup.productStoreId).condition("facilityTypeId", "not-equals", "VIRTUAL_FACILITY").condition("parentFacilityTypeId", "not-equals", "VIRTUAL_FACILITY").list()!> + <#if allFacilities?has_content> + <#list allFacilities as facility> + <#assign facilityIds = facilityIds + [facility.facilityId]> + + + + <#if !facilityIds?has_content> <#list facilityGroupConditions as facilityGroupCondition> <#if "in" == facilityGroupCondition.operator> <#assign includedFacilityGroupIds = includedFacilityGroupIds + Static["co.hotwax.common.DecisionRuleHelper"].valueToCollection(facilityGroupCondition.fieldValue)/> @@ -57,6 +79,7 @@ <#assign facilityIds = facilityIds + [includedFacilityId]> + <#if facilityIds?has_content> @@ -79,4 +102,5 @@ <#assign ruleCount = ruleCount - 1> + \ No newline at end of file From bd80443a890bd02c8f9ee38db6d3ac7e09400040 Mon Sep 17 00:00:00 2001 From: Ravi Lodhi Date: Fri, 31 May 2024 11:25:12 +0530 Subject: [PATCH 2/2] Fixed: Removed unwanted code (#1). --- drl/ProductFacilityRuleTemplate.drl.ftl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drl/ProductFacilityRuleTemplate.drl.ftl b/drl/ProductFacilityRuleTemplate.drl.ftl index 3e858ff..978cecd 100644 --- a/drl/ProductFacilityRuleTemplate.drl.ftl +++ b/drl/ProductFacilityRuleTemplate.drl.ftl @@ -29,7 +29,7 @@ <#if facilityConditions?has_content> <#assign facilityCondition = facilityConditions?first/> <#if "ALL" == facilityCondition.fieldValue!> - <#assign allConfigFacilities = ec.entity.find("co.hotwax.product.store.ProductStoreFacilityDetail").selectField("facilityId").condition("productStoreId", ruleGroup.productStoreId, "facilityTypeId", "CONFIGURATION").list()!> + <#assign allConfigFacilities = ec.entity.find("co.hotwax.product.store.ProductStoreFacilityDetail").selectField("facilityId").condition("productStoreId", ruleGroup.productStoreId).condition("facilityTypeId", "CONFIGURATION").list()!> <#if allConfigFacilities?has_content> <#list allConfigFacilities as configFacility> <#assign facilityIds = facilityIds + [configFacility.facilityId]> @@ -38,7 +38,6 @@ <#else> <#assign facilityIds = Static["co.hotwax.common.DecisionRuleHelper"].valueToCollection(facilityCondition.fieldValue)/> - <#assign facilityIds = Static["co.hotwax.common.DecisionRuleHelper"].valueToCollection(facilityCondition.fieldValue)/> <#if !facilityIds?has_content> <#assign facilityGroupConditions = ec.entity.find("co.hotwax.rule.RuleCondition").condition("ruleId", decisionRule.ruleId).condition("conditionTypeEnumId", "ENTCT_ATP_FAC_GROUPS").list()!>