I do not understand a few parts of this drl
code, but I'll just post one question here:
The full drl code is here:
package org.kie.kogito.queries;
unit LoanUnit;
import org.kie.kogito.queries.LoanApplication;
import org.kie.kogito.queries.AllAmounts;
rule SmallDepositApprove when
$l: /loanApplications[ applicant.age >= 20, deposit < 1000, amount <= 2000 ]
then
modify($l) { setApproved(true) };
end
rule SmallDepositReject when
$l: /loanApplications[ applicant.age >= 20, deposit < 1000, amount > 2000 ]
then
modify($l) { setApproved(false) };
end
rule LargeDepositApprove when
$l: /loanApplications[ applicant.age >= 20, deposit >= 1000, amount <= maxAmount ]
then
modify($l) { setApproved(true) };
end
rule LargeDepositReject when
$l: /loanApplications[ applicant.age >= 20, deposit >= 1000, amount > maxAmount ]
then
modify($l) { setApproved(false) };
end
rule NotAdultApplication when
$l: /loanApplications[ applicant.age < 20 ]
then
modify($l) { setApproved(false) };
end
query FindApproved
$l: /loanApplications[ approved ]
end
query FindNotApprovedIdAndAmount
/loanApplications[ !approved, $id: id, $amount : amount ]
end
rule AllAmounts
when
accumulate ( $a : /loanApplications ; $sum : sum($a.amount))
then
allAmounts.add(new AllAmounts($sum));
end
query FindAllApplicationAmounts
$a : /allAmounts
end
What is the difference between the usage of the variables $l
and $a
, given that they are both linked to /loanApplications
in some way? Are they considered local or instance variables?
I've extracted a couple of rules illustrating what I'm asking about here. What actually goes into $l
and $a
, given that they're supposed to be different?
rule NotAdultApplication when
$l: /loanApplications[ applicant.age < 20 ]
then
modify($l) { setApproved(false) };
end
rule AllAmounts
when
accumulate ( $a : /loanApplications ; $sum : sum($a.amount))
then
allAmounts.add(new AllAmounts($sum));
end