Hi All,
I have attached the Guvnor repository and the java code that I am using to run a
ruleflow.
The two tables 'MasterHud' and 'FeeCalc' are decision tables made in
Guvnor.
* MasterHud decision table is used to get the hudLineNumber based on lienPosition and
productType.
* FeeCalc table is used to get the fee based on hudLineNumber.
I have created a ruleflow 'Fee.rf' which connects these two tables.
Below is the code I use to call Fee.rf:
public static void main(String args[]){
try{
KnowledgeBase kbase = readKnowledgeBase();
StatefulKnowledgeSession ksession =
kbase.newStatefulKnowledgeSession();
LoanDetail l = new LoanDetail();
l.setLienPosition("Second Lien");
l.setProductType("ABC");
ksession.insert(l);
ksession.startProcess("hudRule");
ksession.fireAllRules();
System.out.println("Hud Line Number: "
+l.getHudLineNumber());
System.out.println("Fee: " +l.getFee());
ksession.dispose();
}catch(Throwable t){
t.printStackTrace();
}
}
private static KnowledgeBase readKnowledgeBase()throws Exception{
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(
ResourceFactory.newUrlResource("http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/com.example/LATEST"),ResourceType.PKG);
kbuilder.add(ResourceFactory.newClassPathResource("Fee.rf", Test.class),
ResourceType.DRF);
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;
}
When I run this code, I get the Hud Line Number as 801 but the fee displayed is 0.0
The expected output is Hud Line Number as 801 but the fee displayed as 450.
There is no exception but I don't get the desired output.
________________________________
From: Ambika Goel
Sent: Monday, October 12, 2009 1:09 PM
To: 'rules-users(a)lists.jboss.org'
Subject: Implementaion of Rule Flow in Guvnor
I am using the following code to add to knowledge builder and run it:
knowledgeBuilder.add(ResourceFactory.newClassPathResource("QueueFlow.rf",
GuvnorTest.class), ResourceType.DRF) // ruleflow
knowledgeBuilder.add(ResourceFactory.newUrlResource("http://..."),
ResourceType.PKG) // guvnor package
My rule flow is connection of two tables. I set a property in action of one decision
table and use it as a condition in another decision table to get the desired result.
If I run the above code, I don't get any exception but the output is 'null'.