This commit is contained in:
Nicolas Héron 2016-05-17 14:49:41 +02:00
commit c9209dc9a5
105 changed files with 2390 additions and 839 deletions

View file

@ -0,0 +1,45 @@
package droolscours;
public class Account {
private long accountno;
private double balance;
public Account(long accountno, double balance) {
super();
this.accountno = accountno;
this.balance = balance;
}
public Account() {
super();
// TODO Auto-generated constructor stub
}
public long getAccountno() {
return accountno;
}
public void setAccountno(long accountno) {
this.accountno = accountno;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
@Override
public String toString() {
// TODO Auto-generated method stub
StringBuffer buff = new StringBuffer();
buff.append("-----Account-----)\n");
buff.append("Account no " + this.accountno + "\n");
buff.append("Balance " + this.balance + "\n");
buff.append("-----End Account-)");
return buff.toString();
}
}

View file

@ -0,0 +1,59 @@
package droolscours;
import java.text.DateFormat;
import java.util.Date;
public class AccountingPeriod {
private Date startDate;
private Date endDate;
public AccountingPeriod() {
super();
// TODO Auto-generated constructor stub
}
public AccountingPeriod(Date startDate, Date endDate) {
super();
this.startDate = startDate;
this.endDate = endDate;
}
public Date getStartDate() {
return startDate;
}
public void setStartDate(Date start) {
this.startDate = start;
}
public Date getEndDate() {
return endDate;
}
public void setEndDate(Date end) {
this.endDate = end;
}
@Override
public String toString() {
// TODO Auto-generated method stub
StringBuffer buff = new StringBuffer();
buff.append("-----AccountingPeriod-----)\n");
if (this.startDate != null) {
buff.append("StartDate "
+ DateFormat.getDateInstance().format(this.startDate)
+ "\n");
} else {
buff.append("No start date was set\n");
}
if (this.endDate != null) {
buff.append("EndDate "
+ DateFormat.getDateInstance().format(this.endDate) + "\n");
} else {
buff.append("No ens date was set\n");
}
buff.append("-----End AccountingPeriod -)");
return buff.toString();
}
}

View file

@ -0,0 +1,78 @@
package droolscours;
import java.text.DateFormat;
import java.util.Date;
public class CashFlow {
public static int CREDIT = 1;
public static int DEBIT = 2;
private Date mvtDate;
private double amount;
private int type;
private long accountNo;
public CashFlow(Date mvtDate, double amount, int type, long accountNo) {
super();
this.mvtDate = mvtDate;
this.amount = amount;
this.type = type;
this.accountNo = accountNo;
}
public CashFlow() {
super();
// TODO Auto-generated constructor stub
}
public Date getMvtDate() {
return mvtDate;
}
public void setMvtDate(Date date) {
this.mvtDate = date;
}
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public long getAccountNo() {
return accountNo;
}
public void setAccountNo(long accountNo) {
this.accountNo = accountNo;
}
@Override
public String toString() {
// TODO Auto-generated method stub
StringBuffer buff = new StringBuffer();
buff.append("-----CashFlow-----)\n");
buff.append("Account no=" + this.accountNo + "\n");
if (this.mvtDate != null) {
buff.append("Mouvement Date= "
+ DateFormat.getDateInstance().format(this.mvtDate)
+ "\n");
} else {
buff.append("No Mouvement date was set\n");
}
buff.append("Mouvement Amount=" + this.amount + "\n");
buff.append("-----CashFlow end--)");
return buff.toString();
}
}

View file

@ -0,0 +1,55 @@
package droolscours;
public class Customer {
private String name;
private String surname;
private String country;
public Customer(String name, String surname, String country) {
super();
this.name = name;
this.surname = surname;
this.country = country;
}
public Customer() {
super();
// TODO Auto-generated constructor stub
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
@Override
public String toString() {
StringBuffer buff = new StringBuffer();
buff.append("-----Customer-----)\n");
buff.append("Name=" + this.name + "\n");
buff.append("Surname Name=" + this.surname + "\n");
buff.append("Country=" + this.country + "\n");
buff.append("-----Customer end-)");
return buff.toString();
}
}

View file

@ -0,0 +1,25 @@
package droolscours;
public class PrivateAccount extends Account {
private Customer owner;
public Customer getOwner() {
return owner;
}
public void setOwner(Customer owner) {
this.owner = owner;
}
@Override
public String toString() {
StringBuffer buff = new StringBuffer();
buff.append("-----Private Account-)");
buff.append(super.toString());
if (this.owner != null) {
buff.append(this.owner.toString());
}
buff.append("-----Private Account end-)");
return buff.toString();
}
}

View file

@ -0,0 +1,18 @@
package droolscours.service;
import droolscours.Customer;
import java.util.ArrayList;
import java.util.List;
public class CustomerService {
public List<Customer> getListCustomer() {
List<Customer> result = new ArrayList<Customer>();
result.add(new Customer("Héron", "Nicolas", "Fr"));
result.add(new Customer("Héron", "James", "GB"));
result.add(new Customer("Héron", "Nicolas", "GB"));
return result;
}
}

View file

@ -0,0 +1,12 @@
package droolscours.util;
public class OutputDisplay {
public OutputDisplay() {
}
public void showText(String someText) {
long time = System.currentTimeMillis();
System.out.println("time=" + time + "-" + someText);
}
}

View file

@ -0,0 +1,19 @@
package util;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DateHelper {
public static String sFormat = "yyyy-MM-dd";
public static Date getDate(String sDate) throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat(sFormat);
return sdf.parse(sDate);
}
public static Date getDate(String sDate, String anotherFormat)
throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat(anotherFormat);
return sdf.parse(sDate);
}
}

View file

@ -0,0 +1,105 @@
package util;
import org.kie.api.KieServices;
import org.kie.api.event.rule.*;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.StatelessKieSession;
public class KnowledgeSessionHelper {
public static KieContainer createRuleBase() {
KieServices ks = KieServices.Factory.get();
KieContainer kieContainer = ks.getKieClasspathContainer();
return kieContainer;
}
public static StatelessKieSession getStatelessKnowledgeSession(KieContainer kieContainer, String sessionName) {
StatelessKieSession kSession = kieContainer.newStatelessKieSession(sessionName);
return kSession;
}
public static KieSession getStatefulKnowledgeSession(KieContainer kieContainer, String sessionName) {
KieSession kSession = kieContainer.newKieSession(sessionName);
return kSession;
}
public static KieSession getStatefulKnowledgeSessionWithCallback(
KieContainer kieContainer, String sessionName) {
KieSession session = getStatefulKnowledgeSession(kieContainer, sessionName);
session.addEventListener(new RuleRuntimeEventListener() {
public void objectInserted(ObjectInsertedEvent event) {
System.out.println("Object inserted \n"
+ event.getObject().toString());
}
public void objectUpdated(ObjectUpdatedEvent event) {
System.out.println("Object was updated \n"
+ "new Content \n" + event.getObject().toString());
}
public void objectDeleted(ObjectDeletedEvent event) {
System.out.println("Object retracted \n"
+ event.getOldObject().toString());
}
});
session.addEventListener(new AgendaEventListener() {
public void matchCreated(MatchCreatedEvent event) {
System.out.println("The rule "
+ event.getMatch().getRule().getName()
+ " can be fired in agenda");
}
public void matchCancelled(MatchCancelledEvent event) {
System.out.println("The rule "
+ event.getMatch().getRule().getName()
+ " cannot b in agenda");
}
public void beforeMatchFired(BeforeMatchFiredEvent event) {
System.out.println("The rule "
+ event.getMatch().getRule().getName()
+ " will be fired");
}
public void afterMatchFired(AfterMatchFiredEvent event) {
System.out.println("The rule "
+ event.getMatch().getRule().getName()
+ " has be fired");
}
public void agendaGroupPopped(AgendaGroupPoppedEvent event) {
}
public void agendaGroupPushed(AgendaGroupPushedEvent event) {
}
public void beforeRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event) {
}
public void afterRuleFlowGroupActivated(RuleFlowGroupActivatedEvent event) {
}
public void beforeRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event) {
}
public void afterRuleFlowGroupDeactivated(RuleFlowGroupDeactivatedEvent event) {
}
});
return session;
}
}