我是 Kogito 和 Drools 的新手。我不明白这段drl
代码的一些部分,但我将在这里发布一个问题:
完整的 drl 代码在这里:
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
/loanApplications
和是什么/allAmounts
意思?它们是否链接到其他文件? /loanApplications
出现在代码的许多部分中,我提取了 2 个特定部分作为示例。其中一个使用/loanApplications
而不将其附加到变量。这是如何运作的?
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