Skip to content

Commit

Permalink
Merge pull request #21 from hotwax/1_rule_groups
Browse files Browse the repository at this point in the history
Improved: Handled the case to perform operations on all the facilities/channels of the associated product store
  • Loading branch information
dixitdeepak authored May 31, 2024
2 parents 922a680 + bd80443 commit b0e4f14
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion drl/ProductFacilityRuleTemplate.drl.ftl
Original file line number Diff line number Diff line change
@@ -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>

Expand Down Expand Up @@ -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]>
</#list>
</#if>
<#else>
<#assign facilityIds = Static["co.hotwax.common.DecisionRuleHelper"].valueToCollection(facilityCondition.fieldValue)/>
</#if>
</#if>
<#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]>
</#list>
</#if>
</#if>
<#if !facilityIds?has_content>
<#list facilityGroupConditions as facilityGroupCondition>
<#if "in" == facilityGroupCondition.operator>
<#assign includedFacilityGroupIds = includedFacilityGroupIds + Static["co.hotwax.common.DecisionRuleHelper"].valueToCollection(facilityGroupCondition.fieldValue)/>
Expand All @@ -57,6 +78,7 @@
<#assign facilityIds = facilityIds + [includedFacilityId]>
</#if>
</#list>
</#if>
</#if>
</#if>
<#if facilityIds?has_content>
Expand All @@ -79,4 +101,5 @@
</#if>
<#assign ruleCount = ruleCount - 1>
</#list>
</#if>
</#if>

0 comments on commit b0e4f14

Please sign in to comment.