Skip to content

Instantly share code, notes, and snippets.

@tkobayas
Last active January 6, 2020 05:10
Show Gist options
  • Save tkobayas/48b15f7c6a6ffac5aaf4b88ffd893ff9 to your computer and use it in GitHub Desktop.
Save tkobayas/48b15f7c6a6ffac5aaf4b88ffd893ff9 to your computer and use it in GitHub Desktop.
package org.kie.kogito.queries;
unit LoanUnit;
import org.kie.kogito.queries.LoanApplication
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment