You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working in migrating IBM ODM rule to Drools and I'm starting to hit some issues on larger rules. I'm using Drools version 9.44.0.Final and RuleUnit. I'm writing automation to facilitate the migration effort which means that the output is not necessarily the ideal approach for the rules in Drools so you may see for example a mix of OOPath as well as usages of from in migrated rules.
I've hit two flavors of hitting the limits of the number of arguments supported by existing interfaces.
One is in the code generated for from
ule "Sb And P S Combination Not Valid for A (P C) - Validate Ver2"
when
$response: /ruleResponse
$ac: /ac
$p: P() from BindingUtils.getPoliciesUnder($ac)
$rule: Rule(ruleIsInScope("Sb And P S Combination Not Valid for A (P C) - Validate Ver2")) from $p.rules
Optional($p_s_prefix: ((String)this.orElse(null)), $p_s_prefix != null) from Optional.ofNullable(JavaStringUtils.subString($ac.selectedPType, 0, 2))
$pACStatPlanCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pACStatPlanCCodes"))
$pNonOwnedCStatPlanCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pNonOwnedCStatPlanCCodes"))
$pNonOwnedVolunteerCStatPlanCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pNonOwnedVolunteerCStatPlanCCodes"))
$pDocCStatPlanCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pDocCStatPlanCoveargeCodes"))
$pAMiscellaneousCStatPlanCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pAMiscellaneousCStatPlanCoveargeCodes"))
$pHACStatPlanCoveargeCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pHACStatPlanCoveargeCodes"))
// problem statement
$c: C() from CUtils.getCByCCodeA($pACStatPlanCCodes, $p.aC, $pNonOwnedCStatPlanCCodes, $p.nonOwnedEmployeesC, $pNonOwnedVolunteerCStatPlanCCodes, $p.nonOwnedVolunteersC, $pDocCStatPlanCCodes, $p.docC, $pAMiscellaneousCStatPlanCCodes, $p.aMiscellaneousC, $pHACStatPlanCoveargeCodes, $p.hAC)
$pr_bl: PrBl(statisticalPSbCode != null, OperatorOverride.IsNot(statisticalPSbCode, "000")) from $c.prBl
$validSbPSDataTable: DataTable() from $rule.findVariableAsDataTable("validSbPSDataTable")
$validSbPSDataTable_criteria: Criteria($validSbPSDataTable.firstMatching(this) == null) from $validSbPSDataTable.newCriteria("PSPrefix", $p_s_prefix, "StatSbCode", $pr_bl.statisticalPSbCode)
then
...
end
It fails to compile because D.from is only overloaded to take up to 4 binding variables.
The generated LambdaExtractor referenced above also has issues. It generates the following
The problem is there is no interface for a Function7, it only goes up to Function6. I've looked at those classes and was able to create the proper implementations for From5, From6, From7 as well as Function7` but I'm not aware of any process being present that would allow me to inject those.
I also noticed another issue with another extreme case where there are too many bindings for the rule below.
rule "Sr Balancing A - Validate"
when
$response: /ruleResponse
$ac: /ac
$p: P() from BindingUtils.getPUnder($ac)
$st: St() from BindingUtils.getStsUnder($p)
$rule: Rule(ruleIsInScope("Sr Balancing A - Validate")) from $st.rules
$pACLevelCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pACLevelCCodes"))
$pNonOwnedEmployeeCLevelCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pNonOwnedEmployeeCLevelCCodes"))
$pNonOwnedVolunteerCLevelCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pNonOwnedVolunteerCLevelCCodes"))
$pDocCLevelCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pDocCLevelCCodes"))
$pAMiscellaneousCLevelCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pAMiscellaneousCLevelCCodes"))
$pHACLevelCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("pHACLevelCCodes"))
$stACLevelCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("stACLevelCCodes"))
$vACLevelCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("vACLevelCCodes"))
$lACLevelCCodes: List() from collect (String() from $rule.findVariableAsListFromCommaSeparatedString("lACLevelCCodes"))
$created_object:
CreatedObjects() from
CreatedObjects.createdObjects($rule)
Optional($st_level_sr: ((BigDecimal)this.orElse(null))) from Optional.ofNullable(PrBlUtils.sumStLevel($ac, GeneralConstants.Sr, $st.stCode + GeneralConstants.Sr, $created_object.blPrBlList))
Optional($p_a_c_sr_level_balances: ((BigDecimal)this.orElse(null))) from Optional.ofNullable(PrBlUtils.sumPACTaxOrSrs($ac, $st, $pACLevelCCodes, GeneralConstants.Sr, $created_object.blPrBlList))
Optional($p_non_owned_employee_sr_level_balances: ((BigDecimal)this.orElse(null))) from Optional.ofNullable(PrBlUtils.sumPNonOwnedEmployeesTaxOrSrs($ac, $st, $pNonOwnedEmployeeCLevelCCodes, GeneralConstants.Sr, $created_object.blPrBlList))
Optional($p_non_owned_volunteer_sr_level_balances: ((BigDecimal)this.orElse(null))) from Optional.ofNullable(PrBlUtils.sumPNonOwnedVoluteersTaxOrSrs($ac, $st, $pNonOwnedVolunteerCLevelCCodes, GeneralConstants.Sr, $created_object.blPrBlList))
Optional($p_doc_c_sr_level_balances: ((BigDecimal)this.orElse(null))) from Optional.ofNullable(PrBlUtils.sumPDocCTaxOrSrs($ac, $st, $pDocCLevelCCodes, GeneralConstants.Sr, $created_object.blPrBlList))
Optional($p_a_misc_c_sr_level_balances: ((BigDecimal)this.orElse(null))) from Optional.ofNullable(PrBlUtils.sumAMiscellaneousCTaxOrSrs($ac, $st, $pAMiscellaneousCLevelCCodes, GeneralConstants.Sr, $created_object.blPrBlList))
Optional($p_h_a_c_sr_level_balances: ((BigDecimal)this.orElse(null))) from Optional.ofNullable(PrBlUtils.sumhACTaxOrSrs($ac, $st, $pHACLevelCCodes, GeneralConstants.Sr, $created_object.blPrBlList))
Optional($st_a_c_sr_level_balances: ((BigDecimal)this.orElse(null))) from Optional.ofNullable(PrBlUtils.sumStACTaxOrSrs($st, $stACLevelCCodes, GeneralConstants.Sr, $created_object.blPrBlList))
Optional($v_pr_sr_level_balances: ((BigDecimal)this.orElse(null))) from Optional.ofNullable(PrBlUtils.sumvAC($st, $vACLevelCCodes, GeneralConstants.Sr, $created_object.blPrBlList))
Optional($l_a_c_sr_level_balances: ((BigDecimal)this.orElse(null)), OperatorOverride.DoesNotEqual($st_level_sr, MathUtils.plus(MathUtils.plus(MathUtils.plus(MathUtils.plus(MathUtils.plus(MathUtils.plus(MathUtils.plus(MathUtils.plus($p_a_c_sr_level_balances, $v_pr_sr_level_balances), $p_non_owned_employee_sr_level_balances), $p_non_owned_volunteer_sr_level_balances), $l_a_c_sr_level_balances), $p_doc_c_sr_level_balances), $p_a_misc_c_sr_level_balances), $p_h_a_c_sr_level_balances), $st_a_c_sr_level_balances))) from Optional.ofNullable(PrBlUtils.sumlAC($st, $lACLevelCCodes, GeneralConstants.Sr, $created_object.blPrBlList))
then
for(PrBl var$_$0 : $created_object.getBlPrBlList()){
$created_object.addToValidationParameters(
ValidationParameter.create(var$_$0,
new NVPType[]{
NVPType.createNewNVPType("blAmount", var$_$0.getBlAmount())
}));
}
Outcome.generate($response, $p, $rule, (ValidationParameter[])$created_object.getValidationParameters().toArray(
new ValidationParameter[$created_object.getValidationParameters().size()]),
new RuleParameter[]{
RuleParameter.create("sumPACLevelSrs", $p_a_c_sr_level_balances),
RuleParameter.create("sumvLevelSrs", $v_pr_sr_level_balances),
RuleParameter.create("sumPNonOwnedEmployeeLevelSrs", $p_non_owned_employee_sr_level_balances),
RuleParameter.create("sumPNonOwnedVolunteerLevelSrs", $p_non_owned_volunteer_sr_level_balances),
RuleParameter.create("sumlACLevelSrs", $l_a_c_sr_level_balances),
RuleParameter.create("sumPDocCLevelSrs", $p_doc_c_sr_level_balances),
RuleParameter.create("sumAMiscCLevelSrs", $p_a_misc_c_sr_level_balances),
RuleParameter.create("sumPHACLevelSrs", $p_h_a_c_sr_level_balances),
RuleParameter.create("sumStACLevelSrs", $st_a_c_sr_level_balances),
RuleParameter.create("sumStLevelSrs", "St Sr Total", $st_level_sr),
RuleParameter.create("pACLevelCCodes", (String[])$pACLevelCCodes.toArray(
new String[$pACLevelCCodes.size()])),
RuleParameter.create("vACLevelCCodes", (String[])$vACLevelCCodes.toArray(
new String[$vACLevelCCodes.size()])),
RuleParameter.create("pNonOwnedEmployeeCLevelCCodes", (String[])$pNonOwnedEmployeeCLevelCCodes.toArray(
new String[$pNonOwnedEmployeeCLevelCCodes.size()])),
RuleParameter.create("pNonOwnedVolunteerCLevelCCodes", (String[])$pNonOwnedVolunteerCLevelCCodes.toArray(
new String[$pNonOwnedVolunteerCLevelCCodes.size()])),
RuleParameter.create("lACLevelCCodes", (String[])$lACLevelCCodes.toArray(
new String[$lACLevelCCodes.size()])),
RuleParameter.create("pDocCLevelCCodes", (String[])$pDocCLevelCCodes.toArray(
new String[$pDocCLevelCCodes.size()])),
RuleParameter.create("pAMiscellaneousCLevelCCodes", (String[])$pAMiscellaneousCLevelCCodes.toArray(
new String[$pAMiscellaneousCLevelCCodes.size()])),
RuleParameter.create("pHACLevelCCodes", (String[])$pHACLevelCCodes.toArray(
new String[$pHACLevelCCodes.size()])),
RuleParameter.create("stACLevelCCodes", (String[])$stACLevelCCodes.toArray(
new String[$stACLevelCCodes.size()])),
RuleParameter.create("St.stcode", "st code", $st.getStCode()),
RuleParameter.create("assessment", $st.getStCode() + GeneralConstants.Sr()),
RuleParameter.create("Ac.primaryRiskSt", "primary risk st", $ac.getPrimaryRiskSt()),
RuleParameter.create("Sr sums", "SOC Sr Total", MathUtils.plus(MathUtils.plus(MathUtils.plus(MathUtils.plus(MathUtils.plus(MathUtils.plus(MathUtils.plus(MathUtils.plus($p_a_c_sr_level_balances, $v_pr_sr_level_balances), $p_non_owned_employee_sr_level_balances), $p_non_owned_volunteer_sr_level_balances), $l_a_c_sr_level_balances), $p_doc_c_sr_level_balances), $p_a_misc_c_sr_level_balances), $p_h_a_c_sr_level_balances), $st_a_c_sr_level_balances))
});
end
This rules ends up with two problems. It generates a broken from provider and a Consequence that is unable to execute
The above format was edited to fit better here
The problem above is the order of parameters var_$st, var_$created_object, var_$ac does not follow the order of parameters expected by the lambda which is var_$st, var_$ac, var_$created_object (last two are reversed) so it throws a compilation error.
The execute method call above doesn't exist so it throws a compilation error. For these many arguments it generates a ConsequenceBuilder._N which only has an executeScript method. Similar to the problem above, even if I were to implement something higher than ConsequenceBuilder._24 (which is the highest implementation, one short of the number of parameters above), I have no way to inject that implementation into the process.
The text was updated successfully, but these errors were encountered:
I'm working in migrating IBM ODM rule to Drools and I'm starting to hit some issues on larger rules. I'm using Drools version 9.44.0.Final and RuleUnit. I'm writing automation to facilitate the migration effort which means that the output is not necessarily the ideal approach for the rules in Drools so you may see for example a mix of OOPath as well as usages of
from
in migrated rules.I've hit two flavors of hitting the limits of the number of arguments supported by existing interfaces.
One is in the code generated for from
This rule generates the code below:
It fails to compile because D.from is only overloaded to take up to 4 binding variables.
The generated LambdaExtractor referenced above also has issues. It generates the following
The problem is there is no interface for a
Function7
, it only goes up toFunction6
. I've looked at those classes and was able to create the proper implementations forFrom5
,From6
,From7
as well as Function7` but I'm not aware of any process being present that would allow me to inject those.I also noticed another issue with another extreme case where there are too many bindings for the rule below.
This rules ends up with two problems. It generates a broken
from
provider and a Consequence that is unable to executeThe above format was edited to fit better here
The problem above is the order of parameters
var_$st, var_$created_object, var_$ac
does not follow the order of parameters expected by the lambda which isvar_$st, var_$ac, var_$created_object
(last two are reversed) so it throws a compilation error.The
execute
method call above doesn't exist so it throws a compilation error. For these many arguments it generates aConsequenceBuilder._N
which only has anexecuteScript
method. Similar to the problem above, even if I were to implement something higher thanConsequenceBuilder._24
(which is the highest implementation, one short of the number of parameters above), I have no way to inject that implementation into the process.The text was updated successfully, but these errors were encountered: