Work
This commit is contained in:
parent
c9209dc9a5
commit
474d3bf5b1
86 changed files with 675 additions and 529 deletions
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
|
||||
|
||||
<kbase name="lesson35" packages="lesson35">
|
||||
<ksession name="lesson35-session"/>
|
||||
</kbase>
|
||||
|
||||
</kmodule>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
//#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 "Credit and Debit Rule"
|
||||
when
|
||||
$c : Account( $acc : accountno )
|
||||
$p : AccountingPeriod ($sDate : startDate ,$eDate : endDate )
|
||||
$totalCredit : Number( doubleValue > 100 )
|
||||
from accumulate( CashFlow( type ==CashFlow.CREDIT,$value : amount, mvtDate >= $sDate && mvtDate <= $eDate,accountNo == $acc ),
|
||||
init( double total = 0; ),
|
||||
action( total += $value; ),
|
||||
reverse( total -= $value; ),
|
||||
result( total ) )
|
||||
$totalDebit : Number( doubleValue > 100 )
|
||||
from accumulate( CashFlow( type ==CashFlow.DEBIT,$value : amount, mvtDate >= $sDate && mvtDate <= $eDate,accountNo == $acc ),
|
||||
init( double total = 0; ),
|
||||
action( total += $value; ),
|
||||
reverse( total -= $value; ),
|
||||
result( total ) )
|
||||
|
||||
then
|
||||
showResult.showText(" Found "+$totalCredit+" as a credit");
|
||||
showResult.showText(" Found "+$totalDebit+" as a debit");
|
||||
end
|
||||
|
|
@ -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 Testlesson35 {
|
||||
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 ?");
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue