diff --git a/drl/ProductFacilityRuleTemplate.drl.ftl b/drl/ProductFacilityRuleTemplate.drl.ftl index a69d14a..978cecd 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,13 +28,32 @@ <#assign facilityIds = []/> <#if facilityConditions?has_content> <#assign facilityCondition = facilityConditions?first/> - <#assign facilityIds = Static["co.hotwax.common.DecisionRuleHelper"].valueToCollection(facilityCondition.fieldValue)/> + <#if "ALL" == facilityCondition.fieldValue!> + <#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]> + + + <#else> + <#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()!> <#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 +78,7 @@ <#assign facilityIds = facilityIds + [includedFacilityId]> + <#if facilityIds?has_content> @@ -79,4 +101,5 @@ <#assign ruleCount = ruleCount - 1> + \ No newline at end of file