We’re upgrading from drools version 5.x to 8.x
While trying to compile traditional DRT syntax, condition based templates are not parsed as expected.
Below is the scenario.
template header
NOT_NULL_INDICATOR:Boolean
NULL_INDICATOR:Boolean
package xyz
import xyz
dialect 'mvel'
template "rule with all indicator false"
NOT_NULL_INDICATOR==false
NULL_INDICATOR==false
rule "Rule_@{RULE_GRP_ID}"
agenda-group "@{RULE_GRP_ID}"
auto-focus @{AUTO_FOCUS}
lock-on-active true
when
xyz
then
xyz
template "rule with all indicator true"
NOT_NULL_INDICATOR==true
NULL_INDICATOR==true
rule "Rule_@{RULE_GRP_ID}"
agenda-group "@{RULE_GRP_ID}"
auto-focus @{AUTO_FOCUS}
lock-on-active true
when
xyz
then
xyz
Below is the java code and input Java object to generate DRL.
PRDataProvider prDataProvider = new PRDataProvider(ruleSet.getPRList());
final DataProviderCompiler converter = new DataProviderCompiler();
InputStream inputStream = InterchangeRuleExecutorImpl.class.getResourceAsStream(drt);
String drl = converter.compile(prDataProvider, inputStream);
PR [dataElement=XYZ, value=RDX, operation=EQUALS, ruleGrpId=500_28518_3722, autoFocus=true, mathOperationIndicator=false, feeCalculationPriority=0, fraud_fee=0.0, overridePriorityFlag=false, notNullIndicator=false, nullIndicator=false]
PR [dataElement=PQR, value=500, operation=EQUALS, ruleGrpId=500_28518_3724, autoFocus=false, mathOperationIndicator=false, feeCalculationPriority=0, fraud_fee=0.0, overridePriorityFlag=false, notNullIndicator=true, nullIndicator=true]
We have multiple templates defined in a single DRT file and each template needs to be parsed only when the condition given to the template is satisfied. Expected DRL is template needs to be parsed based on the condition input (NOT_NULL_INDICATOR
and NULL_INDICATOR
) given before defining rule.
Currently, after drools upgrade we can see that conditions for that template are not considered and we are getting all templates parsed for every java object.
How do I handle this scenario?
Pavithra is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.