[id="ref-kogito-migrate-example-loan-application-project_{context}"]
= Example loan application project

[role="_abstract"]
In the following sections, a loan application project is used as an example to migrate a DRL project to {KOGITO} deployments. The domain model of the loan application project is made of two classes, the `LoanApplication` class and the `Applicant` class:

.Example `LoanApplication` class
[source,java]
----
public class LoanApplication {

   private String id;
   private Applicant applicant;
   private int amount;
   private int deposit;
   private boolean approved = false;

   public LoanApplication(String id, Applicant applicant,
                      	int amount, int deposit) {
   	this.id = id;
   	this.applicant = applicant;
   	this.amount = amount;
   	this.deposit = deposit;
   }
}
----

.Example `Applicant` class
[source,java]
----
public class Applicant {

   private String name;
   private int age;

   public Applicant(String name, int age) {
   	this.name = name;
   	this.age = age;
   }
}
----

The rule set is created using business decisions to approve or reject an application, along with the last rule of collecting all the approved applications in a list.

.Example rule set in loan application
[source]
----
global Integer maxAmount;
global java.util.List approvedApplications;

rule LargeDepositApprove when
   $l: LoanApplication( applicant.age >= 20, deposit >= 1000, amount <= maxAmount )
then
   modify($l) { setApproved(true) }; // loan is approved
end

rule LargeDepositReject when
   $l: LoanApplication( applicant.age >= 20, deposit >= 1000, amount > maxAmount )
then
   modify($l) { setApproved(false) }; // loan is rejected
end

// ... more loans approval/rejections business rules ...

rule CollectApprovedApplication when
   $l: LoanApplication( approved )
then
   approvedApplications.add($l); // collect all approved loan applications
end
----
