This commit is contained in:
Nicolas Héron 2016-05-20 14:16:10 +02:00
commit 474d3bf5b1
86 changed files with 675 additions and 529 deletions

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
<kbase name="lesson34" packages="lesson34">
<ksession name="lesson34-session"/>
</kbase>
</kmodule>

View file

@ -0,0 +1,42 @@
//#created on: 30 oct. 2010
package cours
//#list any import classes here.
import droolscours.Account;
import droolscours.AccountingPeriod;
import droolscours.CashFlow;
import droolscours.PrivateAccount;
import droolscours.Customer;
import droolscours.service.CustomerService;
import java.util.ArrayList;
import droolscours.util.OutputDisplay;
//#declare any global variables here
global OutputDisplay showResult;
global CustomerService serviceCustomer;
rule "More then 2 CashFlow Line"
when
$c : Account( $acc : accountno )
$p : AccountingPeriod ($sDate : startDate ,$eDate : endDate )
$number : ArrayList(size >= 2 )
from collect( CashFlow( mvtDate >= $sDate && mvtDate <= $eDate,accountNo == $acc ) )
then
showResult.showText("Found more than 2 CashFlow Lines");
showResult.showText("<<<<<<<<<<");
for (Object ff : $number){
showResult.showText(ff.toString());
}
showResult.showText(">>>>>>>>>>>>>>>>");
end
rule "Numbers of CashFlow Line"
when
$c : Account( $acc : accountno )
$p : AccountingPeriod ($sDate : startDate ,$eDate : endDate )
$number : ArrayList( )
from collect( CashFlow( mvtDate >= $sDate && mvtDate <= $eDate,accountNo == $acc ) )
then
showResult.showText("Found "+$number+" more than 2 CashFlow Lines");
end

View file

@ -0,0 +1,29 @@
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 Testlesson34 {
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 ?");
}
}