Work
This commit is contained in:
parent
ce0f351c9d
commit
c9209dc9a5
105 changed files with 2390 additions and 839 deletions
|
|
@ -1,34 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:5.6.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:5.6.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:knowledge-api:5.6.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:knowledge-internal-api:5.6.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr:3.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:stringtemplate:3.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.1.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.6.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:5.5.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:5.5.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:5.5.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.5.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
33
AccountProject/drools-lesson-pojo/drools-lesson-pojo.iml
Normal file
33
AccountProject/drools-lesson-pojo/drools-lesson-pojo.iml
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
38
AccountProject/drools-lesson-pojo/pom.xml
Normal file
38
AccountProject/drools-lesson-pojo/pom.xml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-lesson-pojo</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
35
AccountProject/drools-lesson1/drools-lesson1.iml
Normal file
35
AccountProject/drools-lesson1/drools-lesson1.iml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/../../drools-lesson1/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
<orderEntry type="module" module-name="drools-lesson-pojo" />
|
||||
</component>
|
||||
</module>
|
||||
43
AccountProject/drools-lesson1/pom.xml
Normal file
43
AccountProject/drools-lesson1/pom.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-lesson1</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<artifactId>drools-lesson-pojo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="lesson1" packages="lesson1">
|
||||
<ksession name="lesson1-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
//#created on: 30 oct. 2010
|
||||
package cours
|
||||
|
||||
//list any import classes here.
|
||||
import droolscours.Account;
|
||||
import droolscours.Customer;
|
||||
import droolscours.AccountingPeriod;
|
||||
import droolscours.PrivateAccount;
|
||||
import droolscours.CashFlow;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Your First Rule"
|
||||
|
||||
when
|
||||
Account( )
|
||||
then
|
||||
System.out.println("The bank account exists");
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
rule "Your First Rule revisited with Global"
|
||||
|
||||
when
|
||||
Customer()
|
||||
then
|
||||
showResult.showText("A customer exists");
|
||||
|
||||
end
|
||||
|
||||
rule "Your First Rule revisited AccountingPeriod"
|
||||
|
||||
when
|
||||
CashFlow( )
|
||||
then
|
||||
showResult.showText("The CashFlow exists, inserting an accounting Period");
|
||||
AccountingPeriod newPeriod = new AccountingPeriod();
|
||||
insert (newPeriod);
|
||||
end
|
||||
|
||||
rule "Rule on AccountingPeriod that are inserting"
|
||||
when
|
||||
AccountingPeriod ()
|
||||
then
|
||||
showResult.showText("Accounting period exists");
|
||||
end
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
package droolscours;
|
||||
|
||||
import droolscours.util.OutputDisplay;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.event.rule.ObjectDeletedEvent;
|
||||
import org.kie.api.event.rule.ObjectInsertedEvent;
|
||||
import org.kie.api.event.rule.ObjectUpdatedEvent;
|
||||
import org.kie.api.event.rule.RuleRuntimeEventListener;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.StatelessKieSession;
|
||||
import org.kie.api.runtime.rule.FactHandle;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
|
||||
public class Testlesson1 {
|
||||
static KieContainer kieContainer;
|
||||
StatelessKieSession sessionStateless = null;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
kieContainer = KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRuleOneFactWithoutFact() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer, "lesson1-session");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Did you see something ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRuleOneFactWithFact() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer, "lesson1-session");
|
||||
Account a = new Account();
|
||||
sessionStatefull.insert(a);
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("So you saw something ;)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRuleOneFactWithFactAndUsageOfGlobal() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer, "lesson1-session");
|
||||
Customer a = new Customer();
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
sessionStatefull.insert(a);
|
||||
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("So you saw something ;)");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testRuleOneFactWithFactAndUsageOfGlobalAndCallBack() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer, "lesson1-session");
|
||||
sessionStatefull.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());
|
||||
}
|
||||
});
|
||||
Customer a = new Customer();
|
||||
a.setName("Heron");
|
||||
FactHandle handlea = sessionStatefull.insert(a);
|
||||
a.setSurname("Nicolas");
|
||||
sessionStatefull.update(handlea, a);
|
||||
sessionStatefull.delete(handlea);
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("So you saw something ;)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRuleOneFactFireConditionStep1() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer, "lesson1-session");
|
||||
Account a = new Account();
|
||||
FactHandle handlea = sessionStatefull.insert(a);
|
||||
System.out.println("First fireAllRules");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Second fireAllRules");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Did A rule be fired");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRuleOneFactFireConditionStep2() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer, "lesson1-session");
|
||||
Account a = new Account();
|
||||
FactHandle handlea = sessionStatefull.insert(a);
|
||||
System.out.println("First fireAllRules");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Updating fact");
|
||||
sessionStatefull.update(handlea, a);
|
||||
System.out.println("Second fireAllRules");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Did A rule be fired");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRuleOneFactThatInsertObject() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer, "lesson1-session");
|
||||
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
|
||||
sessionStatefull.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());
|
||||
}
|
||||
});
|
||||
CashFlow a = new CashFlow();
|
||||
FactHandle handlea = sessionStatefull.insert(a);
|
||||
sessionStatefull.fireAllRules();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRuleOneFactWithFactAndAllCallbacks() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "lesson1-session");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
sessionStatefull.insert(a);
|
||||
sessionStatefull.fireAllRules();
|
||||
CashFlow b = new CashFlow();
|
||||
FactHandle handlea = sessionStatefull.insert(b);
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("So you saw something ;)");
|
||||
}
|
||||
|
||||
}
|
||||
34
AccountProject/drools-lesson2/drools-lesson2.iml
Normal file
34
AccountProject/drools-lesson2/drools-lesson2.iml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
<orderEntry type="module" module-name="drools-lesson-pojo" />
|
||||
</component>
|
||||
</module>
|
||||
43
AccountProject/drools-lesson2/pom.xml
Normal file
43
AccountProject/drools-lesson2/pom.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-lesson2</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<artifactId>drools-lesson-pojo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="lesson2" packages="lesson2">
|
||||
<ksession name="lesson2-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
//#created on: 30 oct. 2010
|
||||
package cours
|
||||
|
||||
//#list any import classes here.
|
||||
import droolscours.Account;
|
||||
import droolscours.AccountingPeriod;
|
||||
import droolscours.CashFlow;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay showResult;
|
||||
|
||||
|
||||
rule "Account and accounting period both exist"
|
||||
|
||||
when
|
||||
Account( )
|
||||
AccountingPeriod( )
|
||||
then
|
||||
showResult.showText("Un compte est un accountingperiod existe");
|
||||
|
||||
end
|
||||
rule "Credit rule"
|
||||
|
||||
when
|
||||
$cash :CashFlow( $no : accountNo ,type == CashFlow.CREDIT )
|
||||
$acc : Account(accountno ==$no )
|
||||
then
|
||||
$acc.setBalance($acc.getBalance()+$cash.getAmount());
|
||||
showResult.showText("le compte no "+$no+ " a maintenant une valeur de "+$acc.getBalance());
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
package droolscours;
|
||||
|
||||
import droolscours.util.OutputDisplay;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.StatelessKieSession;
|
||||
import util.DateHelper;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
|
||||
public class Testlesson2 {
|
||||
static KieContainer kieContainer;
|
||||
StatelessKieSession sessionStateless = null;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass(){
|
||||
kieContainer=KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testdeuxFait1() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer,"lesson2-session");
|
||||
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
sessionStatefull.insert(a);
|
||||
AccountingPeriod period = new AccountingPeriod();
|
||||
sessionStatefull.insert(period);
|
||||
sessionStatefull.fireAllRules();
|
||||
}
|
||||
@Test
|
||||
public void testdeuxFait2() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer,"lesson2-session");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
a.setAccountno(1);
|
||||
a.setBalance(0);
|
||||
sessionStatefull.insert(a);
|
||||
CashFlow cash1 = new CashFlow();
|
||||
cash1.setAccountNo(1);
|
||||
cash1.setAmount(1000);
|
||||
cash1.setMvtDate(DateHelper.getDate("2010-01-15"));
|
||||
cash1.setType(CashFlow.CREDIT);
|
||||
sessionStatefull.insert(cash1);
|
||||
sessionStatefull.fireAllRules();
|
||||
junit.framework.Assert.assertTrue(a.getBalance()==1000);
|
||||
}
|
||||
@Test
|
||||
public void testdeuxFait3() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer,"lesson2-session");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
a.setAccountno(1);
|
||||
a.setBalance(0);
|
||||
sessionStatefull.insert(a);
|
||||
CashFlow cash1 = new CashFlow();
|
||||
cash1.setAccountNo(1);
|
||||
cash1.setAmount(1000);
|
||||
cash1.setMvtDate(DateHelper.getDate("2010-01-15"));
|
||||
cash1.setType(CashFlow.CREDIT);
|
||||
sessionStatefull.insert(cash1);
|
||||
CashFlow cash2 = new CashFlow();
|
||||
cash2.setAccountNo(2);
|
||||
cash2.setAmount(1000);
|
||||
cash2.setMvtDate(DateHelper.getDate("2010-01-15"));
|
||||
cash2.setType(CashFlow.CREDIT);
|
||||
sessionStatefull.insert(cash2);
|
||||
sessionStatefull.fireAllRules();
|
||||
junit.framework.Assert.assertTrue(a.getBalance()==1000);
|
||||
}
|
||||
}
|
||||
34
AccountProject/drools-lesson3/drools-lesson3.iml
Normal file
34
AccountProject/drools-lesson3/drools-lesson3.iml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
<orderEntry type="module" module-name="drools-lesson-pojo" />
|
||||
</component>
|
||||
</module>
|
||||
43
AccountProject/drools-lesson3/pom.xml
Normal file
43
AccountProject/drools-lesson3/pom.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-lesson3</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<artifactId>drools-lesson-pojo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="lesson3" packages="lesson3">
|
||||
<ksession name="lesson3-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//#created on: 30 oct. 2010
|
||||
package cours
|
||||
|
||||
//list any import classes here.
|
||||
import droolscours.Account;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Your First Rule revisited"
|
||||
|
||||
when
|
||||
Account( )
|
||||
then
|
||||
showResult.showText("Le compte existe donc déjà");
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package droolscours;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.StatelessKieSession;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
|
||||
public class Testlesson3 {
|
||||
static KieContainer kieContainer;
|
||||
StatelessKieSession sessionStateless = null;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass(){
|
||||
kieContainer=KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
@Test
|
||||
public void testUnFaitSansFait() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer,"lesson3-session");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Did you see something ?");
|
||||
}
|
||||
|
||||
}
|
||||
34
AccountProject/drools-lesson4/drools-lesson4.iml
Normal file
34
AccountProject/drools-lesson4/drools-lesson4.iml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
<orderEntry type="module" module-name="drools-lesson-pojo" />
|
||||
</component>
|
||||
</module>
|
||||
43
AccountProject/drools-lesson4/pom.xml
Normal file
43
AccountProject/drools-lesson4/pom.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-lesson4</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<artifactId>drools-lesson-pojo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="lesson2" packages="lesson2">
|
||||
<ksession name="lesson2-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//#created on: 30 oct. 2010
|
||||
package cours
|
||||
|
||||
//list any import classes here.
|
||||
import droolscours.Account;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Your First Rule revisited"
|
||||
|
||||
when
|
||||
Account( )
|
||||
then
|
||||
showResult.showText("Le compte existe donc déjà");
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package droolscours;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.StatelessKieSession;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
|
||||
public class Testlesson4 {
|
||||
static KieContainer kieContainer;
|
||||
StatelessKieSession sessionStateless = null;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass(){
|
||||
kieContainer=KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
@Test
|
||||
public void testUnFaitSansFait() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer,"lesson1-session");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Did you see something ?");
|
||||
}
|
||||
|
||||
}
|
||||
34
AccountProject/drools-lesson5/drools-lesson5.iml
Normal file
34
AccountProject/drools-lesson5/drools-lesson5.iml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
<orderEntry type="module" module-name="drools-lesson-pojo" />
|
||||
</component>
|
||||
</module>
|
||||
43
AccountProject/drools-lesson5/pom.xml
Normal file
43
AccountProject/drools-lesson5/pom.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-lesson5</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<artifactId>drools-lesson-pojo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="lesson5" packages="lesson5">
|
||||
<ksession name="lesson5-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//#created on: 30 oct. 2010
|
||||
package cours
|
||||
|
||||
//list any import classes here.
|
||||
import droolscours.Account;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Your First Rule revisited"
|
||||
|
||||
when
|
||||
Account( )
|
||||
then
|
||||
showResult.showText("Le compte existe donc déjà");
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package droolscours;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.StatelessKieSession;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
|
||||
public class Testlesson5 {
|
||||
static KieContainer kieContainer;
|
||||
StatelessKieSession sessionStateless = null;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass(){
|
||||
kieContainer=KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
@Test
|
||||
public void testUnFaitSansFait() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer,"lesson1-session");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Did you see something ?");
|
||||
}
|
||||
|
||||
}
|
||||
34
AccountProject/drools-lesson6/drools-lesson6.iml
Normal file
34
AccountProject/drools-lesson6/drools-lesson6.iml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
<orderEntry type="module" module-name="drools-lesson-pojo" />
|
||||
</component>
|
||||
</module>
|
||||
43
AccountProject/drools-lesson6/pom.xml
Normal file
43
AccountProject/drools-lesson6/pom.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-lesson6</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<artifactId>drools-lesson-pojo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="lesson6" packages="lesson6">
|
||||
<ksession name="lesson6-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//#created on: 30 oct. 2010
|
||||
package cours
|
||||
|
||||
//list any import classes here.
|
||||
import droolscours.Account;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Your First Rule revisited"
|
||||
|
||||
when
|
||||
Account( )
|
||||
then
|
||||
showResult.showText("Le compte existe donc déjà");
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package droolscours;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.StatelessKieSession;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
|
||||
public class Testlesson6 {
|
||||
static KieContainer kieContainer;
|
||||
StatelessKieSession sessionStateless = null;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass(){
|
||||
kieContainer=KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
@Test
|
||||
public void testUnFaitSansFait() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer,"lesson1-session");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Did you see something ?");
|
||||
}
|
||||
|
||||
}
|
||||
34
AccountProject/drools-lesson7/drools-lesson7.iml
Normal file
34
AccountProject/drools-lesson7/drools-lesson7.iml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
<orderEntry type="module" module-name="drools-lesson-pojo" />
|
||||
</component>
|
||||
</module>
|
||||
43
AccountProject/drools-lesson7/pom.xml
Normal file
43
AccountProject/drools-lesson7/pom.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-lesson7</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<artifactId>drools-lesson-pojo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="lesson7" packages="lesson7">
|
||||
<ksession name="lesson7-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//#created on: 30 oct. 2010
|
||||
package cours
|
||||
|
||||
//list any import classes here.
|
||||
import droolscours.Account;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Your First Rule revisited"
|
||||
|
||||
when
|
||||
Account( )
|
||||
then
|
||||
showResult.showText("Le compte existe donc déjà");
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package droolscours;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.StatelessKieSession;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
|
||||
public class Testlesson7 {
|
||||
static KieContainer kieContainer;
|
||||
StatelessKieSession sessionStateless = null;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass(){
|
||||
kieContainer=KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
@Test
|
||||
public void testUnFaitSansFait() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer,"lesson1-session");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Did you see something ?");
|
||||
}
|
||||
|
||||
}
|
||||
34
AccountProject/drools-lesson8/drools-lesson8.iml
Normal file
34
AccountProject/drools-lesson8/drools-lesson8.iml
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
<orderEntry type="module" module-name="drools-lesson-pojo" />
|
||||
</component>
|
||||
</module>
|
||||
43
AccountProject/drools-lesson8/pom.xml
Normal file
43
AccountProject/drools-lesson8/pom.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-lesson8</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<artifactId>drools-lesson-pojo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="lesson8" packages="lesson8">
|
||||
<ksession name="lesson8-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//#created on: 30 oct. 2010
|
||||
package cours
|
||||
|
||||
//list any import classes here.
|
||||
import droolscours.Account;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Your First Rule revisited"
|
||||
|
||||
when
|
||||
Account( )
|
||||
then
|
||||
showResult.showText("Le compte existe donc déjà");
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package droolscours;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.StatelessKieSession;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
|
||||
public class Testlesson8 {
|
||||
static KieContainer kieContainer;
|
||||
StatelessKieSession sessionStateless = null;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass(){
|
||||
kieContainer=KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
@Test
|
||||
public void testUnFaitSansFait() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer,"lesson1-session");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Did you see something ?");
|
||||
}
|
||||
|
||||
}
|
||||
35
AccountProject/drools-lessonxx/drools-lesson1.iml
Normal file
35
AccountProject/drools-lessonxx/drools-lesson1.iml
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/../../drools-lesson1/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-compiler:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.drools:drools-core:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-internal:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.mvel:mvel2:2.2.8.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.google.protobuf:protobuf-java:2.6.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.eclipse.jdt.core.compiler:ecj:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-bpmn2:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow-builder:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jbpm:jbpm-flow:6.4.0.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.kie:kie-api:6.4.0.Final" level="project" />
|
||||
<orderEntry type="module" module-name="drools-lesson-pojo" />
|
||||
</component>
|
||||
</module>
|
||||
43
AccountProject/drools-lessonxx/pom.xml
Normal file
43
AccountProject/drools-lessonxx/pom.xml
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>drools-lesson1</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.drools</groupId>
|
||||
<artifactId>drools-compiler</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jdt.core.compiler</groupId>
|
||||
<artifactId>ecj</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbpm</groupId>
|
||||
<artifactId>jbpm-bpmn2</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pymma-software.droolscourse</groupId>
|
||||
<artifactId>drools-lesson-pojo</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="simplesample" packages="simplesample">
|
||||
<ksession name="simplesample-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package simplesample
|
||||
|
||||
import droolscours.Account;
|
||||
import droolscours.AccountingPeriod;
|
||||
import droolscours.CashFlow;
|
||||
import droolscours.util.OutputDisplay;
|
||||
global OutputDisplay showResults;
|
||||
rule "Credit Rule"
|
||||
when
|
||||
acco: Account( no : accountno )
|
||||
period : AccountingPeriod(s : startDate , e: endDate )
|
||||
act : CashFlow( type == CashFlow.CREDIT ,mvtDate >= s && mvtDate <=e ,accountNo ==no)
|
||||
then
|
||||
acco.setBalance(acco.getBalance()+act.getAmount());
|
||||
showResults.showText("The new balance is now "+acco.getBalance());
|
||||
end
|
||||
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package droolscours;
|
||||
|
||||
import droolscours.util.OutputDisplay;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.event.rule.ObjectDeletedEvent;
|
||||
import org.kie.api.event.rule.ObjectInsertedEvent;
|
||||
import org.kie.api.event.rule.ObjectUpdatedEvent;
|
||||
import org.kie.api.event.rule.RuleRuntimeEventListener;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.StatelessKieSession;
|
||||
import org.omg.CORBA.portable.OutputStream;
|
||||
import util.DateHelper;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
|
||||
public class PremierEssai {
|
||||
StatelessKieSession sessionStateless = null;
|
||||
KieSession sessionStatefull = null;
|
||||
static KieContainer kieContainer;
|
||||
@BeforeClass
|
||||
public static void beforeClass(){
|
||||
kieContainer=KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimple() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession(kieContainer,"simplesample-session");
|
||||
sessionStatefull.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());
|
||||
}
|
||||
});
|
||||
OutputDisplay showResult = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("showResults",showResult);
|
||||
Account account = new Account();
|
||||
account.setAccountno(1);
|
||||
sessionStatefull.insert(account);
|
||||
AccountingPeriod period = new AccountingPeriod();
|
||||
period.setStartDate(DateHelper.getDate("2010-01-01"));
|
||||
period.setEndDate(DateHelper.getDate("2010-03-31"));
|
||||
sessionStatefull.insert(period);
|
||||
CashFlow action1 = new CashFlow();
|
||||
action1.setAccountNo(1);
|
||||
action1.setAmount(1000);
|
||||
action1.setType(CashFlow.CREDIT);
|
||||
action1.setMvtDate(DateHelper.getDate("2010-01-02"));
|
||||
sessionStatefull.insert(action1);
|
||||
sessionStatefull.fireAllRules();
|
||||
Assert.assertTrue(account.getBalance() == 1000);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="simplesample" packages="simplesample">
|
||||
<ksession name="simplesample-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package simplesample
|
||||
|
||||
import droolscours.Account;
|
||||
import droolscours.AccountingPeriod;
|
||||
import droolscours.CashFlow;
|
||||
import droolscours.util.OutputDisplay;
|
||||
global OutputDisplay showResults;
|
||||
rule "Credit Rule"
|
||||
when
|
||||
acco: Account( no : accountno )
|
||||
period : AccountingPeriod(s : startDate , e: endDate )
|
||||
act : CashFlow( type == CashFlow.CREDIT ,mvtDate >= s && mvtDate <=e ,accountNo ==no)
|
||||
then
|
||||
acco.setBalance(acco.getBalance()+act.getAmount());
|
||||
showResults.showText("The new balance is now "+acco.getBalance());
|
||||
end
|
||||
|
||||
Binary file not shown.
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<javadocOptions>
|
||||
<docletArtifacts>
|
||||
<docletArtifact/>
|
||||
</docletArtifacts>
|
||||
<tagletArtifacts>
|
||||
<tagletArtifact/>
|
||||
</tagletArtifacts>
|
||||
<javadocResourcesDirectory>src/main/javadoc</javadocResourcesDirectory>
|
||||
</javadocOptions>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#Generated by Maven
|
||||
#Thu May 12 17:05:58 CEST 2016
|
||||
version=2.0-SNAPSHOT
|
||||
groupId=com.pymma-software.droolscourse
|
||||
artifactId=drools-lesson1
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
droolscours/PremierEssai.class
|
||||
droolscours/PremierEssai$1.class
|
||||
|
|
@ -0,0 +1 @@
|
|||
/Users/nheron/workspace-chtiJBUG/chtijbug-6.3/droolscourse/AccountProject/drools-lesson1/src/test/java/droolscours/PremierEssai.java
|
||||
Binary file not shown.
Binary file not shown.
|
|
@ -1,4 +1,4 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
|
@ -8,7 +8,19 @@
|
|||
</parent>
|
||||
<artifactId>AccountProject</artifactId>
|
||||
<name>Accounting project</name>
|
||||
<packaging>pom</packaging>
|
||||
<description>Accounting project</description>
|
||||
<modules>
|
||||
<module>drools-lesson1</module>
|
||||
<module>drools-lesson2</module>
|
||||
<module>drools-lesson3</module>
|
||||
<module>drools-lesson4</module>
|
||||
<module>drools-lesson5</module>
|
||||
<module>drools-lesson6</module>
|
||||
<module>drools-lesson7</module>
|
||||
<module>drools-lesson8</module>
|
||||
<module>drools-lesson-pojo</module>
|
||||
</modules>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
@ -26,8 +38,45 @@
|
|||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.2</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
</plugin>
|
||||
|
||||
<!--plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin-->
|
||||
</plugins>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.18.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
|
@ -48,6 +97,10 @@
|
|||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kie</groupId>
|
||||
<artifactId>kie-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
package com.sample;
|
||||
|
||||
import org.drools.KnowledgeBase;
|
||||
import org.drools.KnowledgeBaseFactory;
|
||||
import org.drools.builder.KnowledgeBuilder;
|
||||
import org.drools.builder.KnowledgeBuilderError;
|
||||
import org.drools.builder.KnowledgeBuilderErrors;
|
||||
import org.drools.builder.KnowledgeBuilderFactory;
|
||||
import org.drools.builder.ResourceType;
|
||||
import org.drools.io.ResourceFactory;
|
||||
import org.drools.logger.KnowledgeRuntimeLogger;
|
||||
import org.drools.logger.KnowledgeRuntimeLoggerFactory;
|
||||
import org.drools.runtime.StatefulKnowledgeSession;
|
||||
|
||||
/**
|
||||
* This is a sample class to launch a rule.
|
||||
*/
|
||||
public class DroolsTest {
|
||||
|
||||
public static final void main(String[] args) {
|
||||
try {
|
||||
// load up the knowledge base
|
||||
KnowledgeBase kbase = readKnowledgeBase();
|
||||
StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
|
||||
KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");
|
||||
// go !
|
||||
Message message = new Message();
|
||||
message.setMessage("Hello World");
|
||||
message.setStatus(Message.HELLO);
|
||||
ksession.insert(message);
|
||||
ksession.fireAllRules();
|
||||
logger.close();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static KnowledgeBase readKnowledgeBase() throws Exception {
|
||||
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
|
||||
kbuilder.add(ResourceFactory.newClassPathResource("Sample.drl"), ResourceType.DRL);
|
||||
KnowledgeBuilderErrors errors = kbuilder.getErrors();
|
||||
if (errors.size() > 0) {
|
||||
for (KnowledgeBuilderError error: errors) {
|
||||
System.err.println(error);
|
||||
}
|
||||
throw new IllegalArgumentException("Could not parse knowledge.");
|
||||
}
|
||||
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
|
||||
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
|
||||
return kbase;
|
||||
}
|
||||
|
||||
public static class Message {
|
||||
|
||||
public static final int HELLO = 0;
|
||||
public static final int GOODBYE = 1;
|
||||
|
||||
private String message;
|
||||
|
||||
private int status;
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package droolscours;
|
||||
|
||||
public class Account {
|
||||
private long accountno;
|
||||
private double balance;
|
||||
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();
|
||||
}
|
||||
|
||||
public Account(long accountno, double balance) {
|
||||
super();
|
||||
this.accountno = accountno;
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public Account() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
package droolscours;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class AccountingPeriod {
|
||||
private Date startDate;
|
||||
private Date 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;
|
||||
}
|
||||
|
||||
public AccountingPeriod() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
public AccountingPeriod(Date startDate, Date endDate) {
|
||||
super();
|
||||
this.startDate = startDate;
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
package droolscours;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class CashFlow {
|
||||
private Date mvtDate;
|
||||
private double amount;
|
||||
private int type;
|
||||
private long accountNo;
|
||||
public static int CREDIT = 1;
|
||||
public static int DEBIT = 2;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
package droolscours;
|
||||
|
||||
public class Customer {
|
||||
private String name;
|
||||
private String surname;
|
||||
private String country;
|
||||
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();
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
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());
|
||||
buff.append(this.owner.toString());
|
||||
buff.append("-----Private Account end-)");
|
||||
return buff.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
package droolscours.service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import droolscours.Customer;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
package util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
package util;
|
||||
|
||||
import org.drools.KnowledgeBase;
|
||||
import org.drools.KnowledgeBaseFactory;
|
||||
import org.drools.builder.KnowledgeBuilder;
|
||||
import org.drools.builder.KnowledgeBuilderError;
|
||||
import org.drools.builder.KnowledgeBuilderErrors;
|
||||
import org.drools.builder.KnowledgeBuilderFactory;
|
||||
import org.drools.builder.ResourceType;
|
||||
import org.drools.event.rule.DefaultAgendaEventListener;
|
||||
import org.drools.event.rule.ActivationCancelledEvent;
|
||||
import org.drools.event.rule.ActivationCreatedEvent;
|
||||
import org.drools.event.rule.AfterActivationFiredEvent;
|
||||
import org.drools.event.rule.AgendaGroupPoppedEvent;
|
||||
import org.drools.event.rule.AgendaGroupPushedEvent;
|
||||
import org.drools.event.rule.BeforeActivationFiredEvent;
|
||||
import org.drools.event.rule.ObjectInsertedEvent;
|
||||
import org.drools.event.rule.ObjectRetractedEvent;
|
||||
import org.drools.event.rule.ObjectUpdatedEvent;
|
||||
import org.drools.event.rule.WorkingMemoryEventListener;
|
||||
import org.drools.io.ResourceFactory;
|
||||
import org.drools.runtime.StatefulKnowledgeSession;
|
||||
import org.drools.runtime.StatelessKnowledgeSession;
|
||||
|
||||
public class KnowledgeSessionHelper {
|
||||
|
||||
private static KnowledgeBase createRuleBase(String drlFile) {
|
||||
KnowledgeBase ruleBase = null;
|
||||
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
|
||||
.newKnowledgeBuilder();
|
||||
kbuilder.add(ResourceFactory.newClassPathResource(drlFile),
|
||||
ResourceType.DRL);
|
||||
KnowledgeBuilderErrors errors = kbuilder.getErrors();
|
||||
if (errors.size() > 0) {
|
||||
for (KnowledgeBuilderError error : errors) {
|
||||
System.err.println(error);
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"Probleme a la lecture du fichier.");
|
||||
}
|
||||
ruleBase = KnowledgeBaseFactory.newKnowledgeBase();
|
||||
ruleBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
|
||||
return ruleBase;
|
||||
}
|
||||
|
||||
public static StatelessKnowledgeSession getStatelessKnowledgeSession(
|
||||
String drlFile) {
|
||||
KnowledgeBase ruleBase = createRuleBase(drlFile);
|
||||
return ruleBase.newStatelessKnowledgeSession();
|
||||
}
|
||||
|
||||
public static StatefulKnowledgeSession getStatefulKnowledgeSession(
|
||||
String drlFile) {
|
||||
KnowledgeBase ruleBase = createRuleBase(drlFile);
|
||||
return ruleBase.newStatefulKnowledgeSession();
|
||||
}
|
||||
|
||||
public static StatefulKnowledgeSession getStatefulKnowledgeSessionWithCallback(
|
||||
String drlFile) {
|
||||
StatefulKnowledgeSession session = getStatefulKnowledgeSession(drlFile);
|
||||
session.addEventListener(new WorkingMemoryEventListener() {
|
||||
//@Override
|
||||
public void objectUpdated(ObjectUpdatedEvent arg0) {
|
||||
System.out.println("Object mise à jour \n"
|
||||
+ "Nouvelles valeurs \n" + arg0.getObject().toString());
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void objectRetracted(ObjectRetractedEvent arg0) {
|
||||
System.out.println("Object retiré \n"
|
||||
+ arg0.getOldObject().toString());
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void objectInserted(ObjectInsertedEvent arg0) {
|
||||
System.out.println("Object inséré \n"
|
||||
+ arg0.getObject().toString());
|
||||
}
|
||||
});
|
||||
session.addEventListener(new DefaultAgendaEventListener() {
|
||||
@Override
|
||||
public void beforeActivationFired(BeforeActivationFiredEvent arg0) {
|
||||
System.out.println("La règle "
|
||||
+ arg0.getActivation().getRule().getName()
|
||||
+ " va être déclenchée");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agendaGroupPushed(AgendaGroupPushedEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void agendaGroupPopped(AgendaGroupPoppedEvent arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterActivationFired(AfterActivationFiredEvent arg0) {
|
||||
System.out.println("La règle "
|
||||
+ arg0.getActivation().getRule().getName()
|
||||
+ " a êté déclenchée");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activationCreated(ActivationCreatedEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void activationCancelled(ActivationCancelledEvent arg0) {
|
||||
}
|
||||
});
|
||||
return session;
|
||||
}
|
||||
|
||||
public static StatefulKnowledgeSession getStatefulKnowledgeSession(
|
||||
String drlFile,String rfFile) {
|
||||
KnowledgeBase ruleBase = null;
|
||||
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory
|
||||
.newKnowledgeBuilder();
|
||||
kbuilder.add(ResourceFactory.newClassPathResource(drlFile),
|
||||
ResourceType.DRL);
|
||||
kbuilder.add(ResourceFactory.newClassPathResource(rfFile),
|
||||
ResourceType.DRF);
|
||||
KnowledgeBuilderErrors errors = kbuilder.getErrors();
|
||||
if (errors.size() > 0) {
|
||||
for (KnowledgeBuilderError error : errors) {
|
||||
System.err.println(error);
|
||||
}
|
||||
throw new IllegalArgumentException(
|
||||
"Probleme a la lecture du fichier.");
|
||||
}
|
||||
ruleBase = KnowledgeBaseFactory.newKnowledgeBase();
|
||||
ruleBase.addKnowledgePackages(kbuilder.getKnowledgePackages());
|
||||
return ruleBase.newStatefulKnowledgeSession();
|
||||
}
|
||||
|
||||
}
|
||||
48
AccountProject/src/main/resources/META-INF/kmodule.xml
Normal file
48
AccountProject/src/main/resources/META-INF/kmodule.xml
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
<kbase name="sample" packages="sample">
|
||||
<ksession name="sample-session"/>
|
||||
</kbase>
|
||||
<kbase name="simplesample" packages="simplesample">
|
||||
<ksession name="simplesample-session"/>
|
||||
</kbase>
|
||||
<kbase name="part1" packages="part1">
|
||||
<ksession name="part1-rules"/>
|
||||
</kbase>
|
||||
<kbase name="part2" packages="part2">
|
||||
<ksession name="part2-rules"/>
|
||||
</kbase>
|
||||
<kbase name="part3" packages="part3">
|
||||
<ksession name="part3-rules"/>
|
||||
</kbase>
|
||||
<kbase name="part4" packages="part4">
|
||||
<ksession name="part4-rules"/>
|
||||
</kbase>
|
||||
<kbase name="part5" packages="part5">
|
||||
<ksession name="part5-rules"/>
|
||||
</kbase>
|
||||
<kbase name="part6" packages="part6">
|
||||
<ksession name="part6-rules"/>
|
||||
</kbase>
|
||||
<kbase name="part7" packages="part7">
|
||||
<ksession name="part7-rules"/>
|
||||
</kbase>
|
||||
<kbase name="demo" packages="demo">
|
||||
<ksession name="demo-rules"/>
|
||||
</kbase>
|
||||
<kbase name="demo-global" packages="demo-global">
|
||||
<ksession name="demo-global-rules"/>
|
||||
</kbase>
|
||||
<kbase name="demo-insertupdatedelete" packages="demo-insertupdatedelete">
|
||||
<ksession name="demo-insertupdatedelete-rules"/>
|
||||
</kbase>
|
||||
<kbase name="demo-ruleflow1" packages="demo-ruleflow1">
|
||||
<ksession name="demo-ruleflow1-rules"/>
|
||||
</kbase>
|
||||
<kbase name="demo-ruleflow2" packages="demo-ruleflow2">
|
||||
<ksession name="demo-ruleflow2-rules"/>
|
||||
</kbase>
|
||||
<kbase name="demo-ruleflow3" packages="demo-ruleflow3">
|
||||
<ksession name="demo-ruleflow3-rules"/>
|
||||
</kbase>
|
||||
</kmodule>
|
||||
|
|
@ -1,51 +1,48 @@
|
|||
package droolscours;
|
||||
|
||||
import org.drools.event.rule.ObjectInsertedEvent;
|
||||
import org.drools.event.rule.ObjectRetractedEvent;
|
||||
import org.drools.event.rule.ObjectUpdatedEvent;
|
||||
import org.drools.event.rule.WorkingMemoryEventListener;
|
||||
import org.drools.runtime.StatefulKnowledgeSession;
|
||||
import org.drools.runtime.StatelessKnowledgeSession;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.kie.api.event.rule.ObjectDeletedEvent;
|
||||
import org.kie.api.event.rule.ObjectInsertedEvent;
|
||||
import org.kie.api.event.rule.ObjectUpdatedEvent;
|
||||
import org.kie.api.event.rule.RuleRuntimeEventListener;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.StatelessKieSession;
|
||||
import util.DateHelper;
|
||||
import util.KnowledgeSessionHelper;
|
||||
|
||||
|
||||
|
||||
public class PremierEssai {
|
||||
StatelessKnowledgeSession sessionStateless = null;
|
||||
StatefulKnowledgeSession sessionStatefull = null;
|
||||
static KieContainer kieContainer;
|
||||
StatelessKieSession sessionStateless = null;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
sessionStateless = KnowledgeSessionHelper
|
||||
.getStatelessKnowledgeSession("Sample.drl");
|
||||
sessionStateless.execute(new String("Hello"));
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
kieContainer = KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimple() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("SimpleSample.drl");
|
||||
sessionStatefull.addEventListener(new WorkingMemoryEventListener() {
|
||||
//@Override
|
||||
public void objectUpdated(ObjectUpdatedEvent arg0) {
|
||||
System.out.println("Object mise à jour \n"
|
||||
+ "Nouvelles valeurs \n" + arg0.getObject().toString());
|
||||
.getStatefulKnowledgeSession(kieContainer, "simplesample-session");
|
||||
sessionStatefull.addEventListener(new RuleRuntimeEventListener() {
|
||||
public void objectInserted(ObjectInsertedEvent event) {
|
||||
System.out.println("Object inserted \n"
|
||||
+ event.getObject().toString());
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void objectRetracted(ObjectRetractedEvent arg0) {
|
||||
System.out.println("Object retiré \n"
|
||||
+ arg0.getOldObject().toString());
|
||||
public void objectUpdated(ObjectUpdatedEvent event) {
|
||||
System.out.println("Object was updated \n"
|
||||
+ "new Content \n" + event.getObject().toString());
|
||||
}
|
||||
|
||||
//Override
|
||||
public void objectInserted(ObjectInsertedEvent arg0) {
|
||||
System.out.println("Object inséré \n"
|
||||
+ arg0.getObject().toString());
|
||||
public void objectDeleted(ObjectDeletedEvent event) {
|
||||
System.out.println("Object retracted \n"
|
||||
+ event.getOldObject().toString());
|
||||
}
|
||||
});
|
||||
Account account = new Account();
|
||||
|
|
|
|||
|
|
@ -1,16 +1,23 @@
|
|||
package droolscours;
|
||||
|
||||
import org.drools.runtime.StatefulKnowledgeSession;
|
||||
import droolscours.util.OutputDisplay;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import util.KnowledgeSessionHelper;
|
||||
import util.OutputDisplay;
|
||||
|
||||
|
||||
public class TestRuleFlow {
|
||||
StatefulKnowledgeSession sessionStatefull = null;
|
||||
static KieContainer kieContainer;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
kieContainer = KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
|
|
@ -25,9 +32,9 @@ public class TestRuleFlow {
|
|||
@Test
|
||||
public void testdeuxFait1() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("demo-ruleflow.drl","RuleFlow1.rf");
|
||||
.getStatefulKnowledgeSession(kieContainer, "demo-ruleflow1-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
sessionStatefull.insert(a);
|
||||
AccountingPeriod period = new AccountingPeriod();
|
||||
|
|
@ -38,9 +45,9 @@ public class TestRuleFlow {
|
|||
@Test
|
||||
public void testdeuxFait2() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("demo-ruleflow2.drl","RuleFlow2.rf");
|
||||
.getStatefulKnowledgeSession(kieContainer, "demo-ruleflow2-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
sessionStatefull.insert(a);
|
||||
AccountingPeriod period = new AccountingPeriod();
|
||||
|
|
@ -50,9 +57,9 @@ public class TestRuleFlow {
|
|||
@Test
|
||||
public void testdeuxFait3() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("demo-ruleflow3.drl","RuleFlow3.rf");
|
||||
.getStatefulKnowledgeSession(kieContainer, "demo-ruleflow3-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
a.setBalance(1500);
|
||||
sessionStatefull.insert(a);
|
||||
|
|
|
|||
|
|
@ -1,138 +0,0 @@
|
|||
package droolscours;
|
||||
|
||||
import org.drools.event.rule.ObjectInsertedEvent;
|
||||
import org.drools.event.rule.ObjectRetractedEvent;
|
||||
import org.drools.event.rule.ObjectUpdatedEvent;
|
||||
import org.drools.event.rule.WorkingMemoryEventListener;
|
||||
import org.drools.runtime.StatefulKnowledgeSession;
|
||||
import org.drools.runtime.rule.FactHandle;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import util.KnowledgeSessionHelper;
|
||||
import util.OutputDisplay;
|
||||
|
||||
public class TestUnFait {
|
||||
StatefulKnowledgeSession sessionStatefull = null;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
System.out.println("------------Before------------");
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
System.out.println("------------Après ------------");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnFaitSansFait() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("demo.drl");
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Avez-vous vu quelquechose ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnFaitAvecAccountCommeFait() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("demo.drl");
|
||||
Account a = new Account();
|
||||
sessionStatefull.insert(a);
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Vous avez donc vu quelquechose ;)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnFaitAvecAccountCommeFaitGlobal() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("demo-global.drl");
|
||||
Account a = new Account();
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.insert(a);
|
||||
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Vous avez donc vu quelquechose ;)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnFaitAvecAccountCommeFaitGlobalEtAvecCallBack() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("demo.drl");
|
||||
sessionStatefull.addEventListener(new WorkingMemoryEventListener() {
|
||||
//@Override
|
||||
public void objectUpdated(ObjectUpdatedEvent arg0) {
|
||||
System.out.println("Object mise à jour \n"
|
||||
+ "Nouvelles valeurs \n" + arg0.getObject().toString());
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void objectRetracted(ObjectRetractedEvent arg0) {
|
||||
System.out.println("Object retiré \n"
|
||||
+ arg0.getOldObject().toString());
|
||||
}
|
||||
|
||||
//@Override
|
||||
public void objectInserted(ObjectInsertedEvent arg0) {
|
||||
System.out.println("Object inséré \n"
|
||||
+ arg0.getObject().toString());
|
||||
}
|
||||
});
|
||||
Account a = new Account();
|
||||
a.setAccountno(0);
|
||||
FactHandle handlea = sessionStatefull.insert(a);
|
||||
a.setAccountno(100);
|
||||
sessionStatefull.update(handlea, a);
|
||||
sessionStatefull.retract(handlea);
|
||||
sessionStatefull.fireAllRules();
|
||||
System.out.println("Vous avez donc vu quelquechose ;)");
|
||||
}
|
||||
@Test
|
||||
public void testUnFaitAvecAccountRDGDeclenchement1() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("demo.drl");
|
||||
Account a = new Account();
|
||||
FactHandle handlea = sessionStatefull.insert(a);
|
||||
sessionStatefull.fireAllRules();
|
||||
sessionStatefull.fireAllRules();
|
||||
}
|
||||
@Test
|
||||
public void testUnFaitAvecAccountRDGDeclenchement2() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("demo.drl");
|
||||
Account a = new Account();
|
||||
FactHandle handlea = sessionStatefull.insert(a);
|
||||
sessionStatefull.fireAllRules();
|
||||
sessionStatefull.update(handlea, a);
|
||||
sessionStatefull.fireAllRules();
|
||||
}
|
||||
@Test
|
||||
public void testUnFaitAvecAccountInsert() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSession("demo-insertupdatedelete.drl");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
|
||||
sessionStatefull.addEventListener(new WorkingMemoryEventListener() {
|
||||
//@Override
|
||||
public void objectUpdated(ObjectUpdatedEvent arg0) {
|
||||
System.out.println("Object mise à jour \n"
|
||||
+ "Nouvelles valeurs \n" + arg0.getObject().toString());
|
||||
}
|
||||
//@Override
|
||||
public void objectRetracted(ObjectRetractedEvent arg0) {
|
||||
System.out.println("Object retiré \n"
|
||||
+ arg0.getOldObject().toString());
|
||||
}
|
||||
//@Override
|
||||
public void objectInserted(ObjectInsertedEvent arg0) {
|
||||
System.out.println("Object inséré \n"
|
||||
+ arg0.getObject().toString());
|
||||
}
|
||||
});
|
||||
Account a = new Account();
|
||||
FactHandle handlea = sessionStatefull.insert(a);
|
||||
sessionStatefull.fireAllRules();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +1,27 @@
|
|||
package droolscours;
|
||||
|
||||
import droolscours.service.CustomerService;
|
||||
import droolscours.util.OutputDisplay;
|
||||
import junit.framework.Assert;
|
||||
import org.drools.runtime.StatefulKnowledgeSession;
|
||||
import org.drools.runtime.rule.FactHandle;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.kie.api.runtime.KieContainer;
|
||||
import org.kie.api.runtime.KieSession;
|
||||
import org.kie.api.runtime.rule.FactHandle;
|
||||
import util.DateHelper;
|
||||
import util.KnowledgeSessionHelper;
|
||||
import util.OutputDisplay;
|
||||
|
||||
|
||||
public class Testlanguage {
|
||||
StatefulKnowledgeSession sessionStatefull = null;
|
||||
static KieContainer kieContainer;
|
||||
KieSession sessionStatefull = null;
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() {
|
||||
kieContainer = KnowledgeSessionHelper.createRuleBase();
|
||||
}
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
System.out.println("------------Before------------");
|
||||
|
|
@ -28,10 +35,10 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait1() {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part1-rules");
|
||||
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
sessionStatefull.insert(a);
|
||||
AccountingPeriod period = new AccountingPeriod();
|
||||
|
|
@ -42,9 +49,9 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait2() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part1-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
a.setAccountno(1);
|
||||
a.setBalance(0);
|
||||
|
|
@ -61,9 +68,9 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait3() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part1-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
a.setAccountno(1);
|
||||
a.setBalance(0);
|
||||
|
|
@ -86,9 +93,9 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait4() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language2.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part2-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
a.setAccountno(1);
|
||||
a.setBalance(0);
|
||||
|
|
@ -121,9 +128,9 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait5() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language3.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part3-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Customer customer = new Customer();
|
||||
customer.setName("Héron");
|
||||
customer.setSurname("Nicolas");
|
||||
|
|
@ -135,9 +142,9 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait6() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language3.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part3-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Customer customer = new Customer();
|
||||
customer.setName("Héron");
|
||||
customer.setSurname("Nicolas");
|
||||
|
|
@ -151,9 +158,9 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait7() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language3.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part3-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account pAccount = new Account();
|
||||
sessionStatefull.insert(pAccount);
|
||||
sessionStatefull.fireAllRules();
|
||||
|
|
@ -161,9 +168,9 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait8() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language3.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part3-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account pAccount = new Account();
|
||||
sessionStatefull.insert(pAccount);
|
||||
sessionStatefull.fireAllRules();
|
||||
|
|
@ -171,9 +178,9 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait9() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language4.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part4-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
a.setAccountno(1);
|
||||
a.setBalance(0);
|
||||
|
|
@ -206,9 +213,9 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait10() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language5.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part5-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
sessionStatefull.setGlobal("serviceCustomer", new CustomerService());
|
||||
Customer c = new Customer("Héron","Nicolas","A");
|
||||
sessionStatefull.insert(c);
|
||||
|
|
@ -217,9 +224,9 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait11() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language6.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part6-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
Account a = new Account();
|
||||
a.setAccountno(1);
|
||||
a.setBalance(0);
|
||||
|
|
@ -233,16 +240,17 @@ public class Testlanguage {
|
|||
@Test
|
||||
public void testdeuxFait12() throws Exception {
|
||||
sessionStatefull = KnowledgeSessionHelper
|
||||
.getStatefulKnowledgeSessionWithCallback("demo-Language7.drl");
|
||||
.getStatefulKnowledgeSessionWithCallback(kieContainer, "part7-rules");
|
||||
OutputDisplay display = new OutputDisplay();
|
||||
sessionStatefull.setGlobal("result", display);
|
||||
sessionStatefull.setGlobal("showResult", display);
|
||||
sessionStatefull.insert(new Account(1,0));
|
||||
|
||||
FactHandle fa = sessionStatefull.insert(new CashFlow(DateHelper.getDate("2010-01-15"), 1000, CashFlow.CREDIT, 1));
|
||||
sessionStatefull.insert(new CashFlow(DateHelper.getDate("2010-02-15"),500,CashFlow.DEBIT,1));
|
||||
sessionStatefull.insert(new CashFlow(DateHelper.getDate("2010-04-15"),1000,CashFlow.CREDIT,1));
|
||||
sessionStatefull.insert(new AccountingPeriod(DateHelper.getDate("2010-01-01"),DateHelper.getDate("2010-12-31")));
|
||||
sessionStatefull.fireAllRules();
|
||||
sessionStatefull.retract(fa);
|
||||
sessionStatefull.delete(fa);
|
||||
sessionStatefull.fireAllRules();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
package com.sample
|
||||
|
||||
import com.sample.DroolsTest.Message;
|
||||
|
||||
rule "Hello World"
|
||||
when
|
||||
m : Message( status == Message.HELLO, myMessage : message )
|
||||
then
|
||||
System.out.println( m.getMessage() );
|
||||
m.setMessage( "Goodbye cruel world" );
|
||||
m.setStatus( Message.GOODBYE );
|
||||
update( m );
|
||||
end
|
||||
|
||||
rule "GoodBye"
|
||||
when
|
||||
Message( status == Message.GOODBYE, myMessage : message )
|
||||
then
|
||||
System.out.println( myMessage );
|
||||
end
|
||||
|
|
@ -3,20 +3,19 @@ package cours
|
|||
|
||||
//list any import classes here.
|
||||
import droolscours.Account;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay result;
|
||||
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Your First Rule revisited"
|
||||
|
||||
when
|
||||
Account( )
|
||||
then
|
||||
result.showText("Le compte existe donc déjà");
|
||||
showResult.showText("Le compte existe donc déjà");
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -3,15 +3,15 @@ package cours
|
|||
//#list any import classes here.
|
||||
import droolscours.Account;
|
||||
import droolscours.AccountingPeriod;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
//#declare any global variables here
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
rule "Your First Rule revisited"
|
||||
|
||||
when
|
||||
Account( )
|
||||
then
|
||||
result.showText("Le compte existe donc déjà");
|
||||
showResult.showText("Le compte existe donc déjà");
|
||||
AccountingPeriod newPeriod = new AccountingPeriod();
|
||||
insert (newPeriod);
|
||||
end
|
||||
|
|
@ -19,5 +19,5 @@ rule "Rule on Period"
|
|||
when
|
||||
AccountingPeriod ()
|
||||
then
|
||||
result.showText("Période de compte existe");
|
||||
showResult.showText("Période de compte existe");
|
||||
end
|
||||
|
|
@ -5,12 +5,12 @@ package cours
|
|||
import droolscours.Account;
|
||||
import droolscours.AccountingPeriod;
|
||||
import droolscours.CashFlow;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
|
||||
|
||||
rule "Account group1"
|
||||
|
|
@ -18,7 +18,7 @@ rule "Account group1"
|
|||
when
|
||||
Account( )
|
||||
then
|
||||
result.showText("Account in Group1");
|
||||
showResult.showText("Account in Group1");
|
||||
|
||||
end
|
||||
rule "Account group2"
|
||||
|
|
@ -26,7 +26,7 @@ rule "Account group2"
|
|||
when
|
||||
Account( )
|
||||
then
|
||||
result.showText("Account in Group2");
|
||||
showResult.showText("Account in Group2");
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -5,17 +5,18 @@ package cours
|
|||
import droolscours.Account;
|
||||
import droolscours.AccountingPeriod;
|
||||
import droolscours.CashFlow;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "start process"
|
||||
when
|
||||
then
|
||||
kcontext.getKnowledgeRuntime().startProcess("RF2");
|
||||
kcontext.getKieRuntime().startProcess("RF2");
|
||||
|
||||
end
|
||||
|
||||
rule "Account group1"
|
||||
|
|
@ -23,7 +24,7 @@ rule "Account group1"
|
|||
when
|
||||
Account( )
|
||||
then
|
||||
result.showText("Account in Group1");
|
||||
showResult.showText("Account in Group1");
|
||||
|
||||
end
|
||||
rule "Account group2"
|
||||
|
|
@ -31,7 +32,7 @@ rule "Account group2"
|
|||
when
|
||||
Account( )
|
||||
then
|
||||
result.showText("Account in Group2");
|
||||
showResult.showText("Account in Group2");
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -5,17 +5,17 @@ package cours
|
|||
import droolscours.Account;
|
||||
import droolscours.AccountingPeriod;
|
||||
import droolscours.CashFlow;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "start process"
|
||||
when
|
||||
then
|
||||
kcontext.getKnowledgeRuntime().startProcess("RF3");
|
||||
kcontext.getKieRuntime().startProcess("RF3");
|
||||
end
|
||||
|
||||
rule "Account group1"
|
||||
|
|
@ -23,7 +23,7 @@ rule "Account group1"
|
|||
when
|
||||
Account(balance > 0 )
|
||||
then
|
||||
result.showText("Account in Group1 > 1000 ");
|
||||
showResult.showText("Account in Group1 > 1000 ");
|
||||
|
||||
end
|
||||
rule "Account group2"
|
||||
|
|
@ -31,7 +31,7 @@ rule "Account group2"
|
|||
when
|
||||
Account( )
|
||||
then
|
||||
result.showText("Account in Group2 < 1000");
|
||||
showResult.showText("Account in Group2 < 1000");
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -3,12 +3,12 @@ package cours
|
|||
|
||||
//list any import classes here.
|
||||
import droolscours.Account;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Your First Rule"
|
||||
|
||||
|
|
@ -5,12 +5,12 @@ package cours
|
|||
import droolscours.Account;
|
||||
import droolscours.AccountingPeriod;
|
||||
import droolscours.CashFlow;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
//#declare any global variables here
|
||||
|
||||
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
|
||||
|
||||
rule "Account and accounting period both exist"
|
||||
|
|
@ -19,7 +19,7 @@ rule "Account and accounting period both exist"
|
|||
Account( )
|
||||
AccountingPeriod( )
|
||||
then
|
||||
result.showText("Un compte est un accountingperiod existe");
|
||||
showResult.showText("Un compte est un accountingperiod existe");
|
||||
|
||||
end
|
||||
rule "Credit rule"
|
||||
|
|
@ -29,6 +29,6 @@ rule "Credit rule"
|
|||
$acc : Account(accountno ==$no )
|
||||
then
|
||||
$acc.setBalance($acc.getBalance()+$cash.getAmount());
|
||||
result.showText("le compte no "+$no+ " a maintenant une valeur de "+$acc.getBalance());
|
||||
showResult.showText("le compte no "+$no+ " a maintenant une valeur de "+$acc.getBalance());
|
||||
end
|
||||
|
||||
|
|
@ -5,9 +5,9 @@ package cours
|
|||
import droolscours.Account;
|
||||
import droolscours.AccountingPeriod;
|
||||
import droolscours.CashFlow;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Credit rule"
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ rule "Credit rule"
|
|||
$period : AccountingPeriod( startDate <= $aDate && endDate >= $aDate)
|
||||
then
|
||||
$acc.setBalance($acc.getBalance()+$cash.getAmount());
|
||||
result.showText("le compte no "+$no+ " a maintenant une valeur de "+$acc.getBalance());
|
||||
showResult.showText("le compte no "+$no+ " a maintenant une valeur de "+$acc.getBalance());
|
||||
end
|
||||
rule "Debit rule"
|
||||
|
||||
|
|
@ -27,6 +27,6 @@ rule "Debit rule"
|
|||
$period : AccountingPeriod( startDate <= $aDate && endDate >= $aDate)
|
||||
then
|
||||
$acc.setBalance($acc.getBalance()-$cash.getAmount());
|
||||
result.showText("le compte no "+$no+ " a maintenant une valeur de "+$acc.getBalance());
|
||||
showResult.showText("le compte no "+$no+ " a maintenant une valeur de "+$acc.getBalance());
|
||||
end
|
||||
|
||||
|
|
@ -7,9 +7,9 @@ import droolscours.AccountingPeriod;
|
|||
import droolscours.CashFlow;
|
||||
import droolscours.PrivateAccount;
|
||||
import droolscours.Customer;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
//#declare any global variables here
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
|
||||
rule "Le cashFlow est du crédit ou du débit"
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ rule "Le cashFlow est du crédit ou du débit"
|
|||
$cash :CashFlow(type in ( CashFlow.DEBIT,CashFlow.CREDIT) )
|
||||
|
||||
then
|
||||
result.showText("Cash Flow est un crédit ou un débit");
|
||||
showResult.showText("Cash Flow est un crédit ou un débit");
|
||||
end
|
||||
rule "Accessor"
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ rule "Accessor"
|
|||
$cash :PrivateAccount( owner.name =="Héron" )
|
||||
|
||||
then
|
||||
result.showText("Account is owned by Héron");
|
||||
showResult.showText("Account is owned by Héron");
|
||||
end
|
||||
rule "infixAnd"
|
||||
when
|
||||
|
|
@ -35,17 +35,17 @@ rule "infixAnd"
|
|||
|
||||
|
||||
then
|
||||
result.showText("Person lives in GB or US");
|
||||
showResult.showText("Person lives in GB or US");
|
||||
end
|
||||
rule "no customer"
|
||||
when
|
||||
not Customer( )
|
||||
then
|
||||
result.showText("No customer");
|
||||
showResult.showText("No customer");
|
||||
end
|
||||
rule "Exists"
|
||||
when
|
||||
exists Account( )
|
||||
then
|
||||
result.showText("Account exists");
|
||||
showResult.showText("Account exists");
|
||||
end
|
||||
|
|
@ -7,9 +7,9 @@ import droolscours.AccountingPeriod;
|
|||
import droolscours.CashFlow;
|
||||
import droolscours.PrivateAccount;
|
||||
import droolscours.Customer;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
//#declare any global variables here
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
|
||||
|
||||
rule "ForAll"
|
||||
|
|
@ -19,7 +19,7 @@ rule "ForAll"
|
|||
CashFlow( accountNo == $no)
|
||||
)
|
||||
then
|
||||
result.showText("All mouvements concerns all account ");
|
||||
showResult.showText("All mouvements concerns all account ");
|
||||
end
|
||||
rule "ForAll2"
|
||||
when
|
||||
|
|
@ -28,5 +28,5 @@ rule "ForAll2"
|
|||
CashFlow( accountNo == $no)
|
||||
|
||||
then
|
||||
result.showText("All mouvements concerns only one account ");
|
||||
showResult.showText("All mouvements concerns only one account ");
|
||||
end
|
||||
|
|
@ -8,9 +8,9 @@ import droolscours.CashFlow;
|
|||
import droolscours.PrivateAccount;
|
||||
import droolscours.Customer;
|
||||
import droolscours.service.CustomerService;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
//#declare any global variables here
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
global CustomerService serviceCustomer;
|
||||
|
||||
rule "ForAll"
|
||||
|
|
@ -18,5 +18,5 @@ rule "ForAll"
|
|||
$c : Customer()
|
||||
$cc : Customer(name ==$c.name,surname==$c.surname,country !=$c.country) from serviceCustomer.getListCustomer();
|
||||
then
|
||||
result.showText("Found same customer in 2 countries");
|
||||
showResult.showText("Found same customer in 2 countries");
|
||||
end
|
||||
|
|
@ -9,9 +9,9 @@ import droolscours.PrivateAccount;
|
|||
import droolscours.Customer;
|
||||
import droolscours.service.CustomerService;
|
||||
import java.util.ArrayList;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
//#declare any global variables here
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
global CustomerService serviceCustomer;
|
||||
|
||||
rule "More then 2 CashFlow Line"
|
||||
|
|
@ -22,12 +22,12 @@ rule "More then 2 CashFlow Line"
|
|||
from collect( CashFlow( mvtDate >= $sDate && mvtDate <= $eDate,accountNo == $acc ) )
|
||||
|
||||
then
|
||||
result.showText("Found more than 2 CashFlow Lines");
|
||||
result.showText("<<<<<<<<<<");
|
||||
showResult.showText("Found more than 2 CashFlow Lines");
|
||||
showResult.showText("<<<<<<<<<<");
|
||||
for (Object ff : $number){
|
||||
result.showText(ff.toString());
|
||||
showResult.showText(ff.toString());
|
||||
}
|
||||
result.showText(">>>>>>>>>>>>>>>>");
|
||||
showResult.showText(">>>>>>>>>>>>>>>>");
|
||||
end
|
||||
|
||||
rule "Numbers of CashFlow Line"
|
||||
|
|
@ -38,5 +38,5 @@ rule "Numbers of CashFlow Line"
|
|||
from collect( CashFlow( mvtDate >= $sDate && mvtDate <= $eDate,accountNo == $acc ) )
|
||||
|
||||
then
|
||||
result.showText("Found "+$number+" more than 2 CashFlow Lines");
|
||||
showResult.showText("Found "+$number+" more than 2 CashFlow Lines");
|
||||
end
|
||||
|
|
@ -9,9 +9,9 @@ import droolscours.PrivateAccount;
|
|||
import droolscours.Customer;
|
||||
import droolscours.service.CustomerService;
|
||||
import java.util.ArrayList;
|
||||
import util.OutputDisplay;
|
||||
import droolscours.util.OutputDisplay;
|
||||
//#declare any global variables here
|
||||
global OutputDisplay result;
|
||||
global OutputDisplay showResult;
|
||||
global CustomerService serviceCustomer;
|
||||
|
||||
|
||||
|
|
@ -33,6 +33,6 @@ rule "Credit and Debit Rule"
|
|||
result( total ) )
|
||||
|
||||
then
|
||||
result.showText(" Found "+$totalCredit+" as a credit");
|
||||
result.showText(" Found "+$totalDebit+" as a debit");
|
||||
showResult.showText(" Found "+$totalCredit+" as a credit");
|
||||
showResult.showText(" Found "+$totalDebit+" as a debit");
|
||||
end
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package com.sample
|
||||
|
||||
import com.sample.DroolsTest.Message;
|
||||
|
||||
import droolscours.Account;
|
||||
import droolscours.AccountingPeriod;
|
||||
import droolscours.CashFlow;
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
editor.link_modal.header
Reference in a new issue