|
|
|
Ambika Goel
|
Some javascript/style in this post has been disabled (why?)
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.
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 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’. _______________________________________________ rules-users mailing list [hidden email] https://lists.jboss.org/mailman/listinfo/rules-users |
||||||||||||||||
|
Jaroslaw Kijanowski-3
|
Hi Ambika,
your rules in the first rule flow group "MasterHud" set a new value on a fact's field. Then you expect that your rules in the second rule flow group fire. The rule engine has no idea that some facts' fields changed until you let the engine know via update(); Open your MasterHud decision table and edit the action column (check the 'Update engine with changes:' check box), build the package and enjoy. Cheers, Jarek Ambika Goel wrote: > 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:* '[hidden email]' > *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’. > > > ------------------------------------------------------------------------ > > _______________________________________________ > rules-users mailing list > [hidden email] > https://lists.jboss.org/mailman/listinfo/rules-users rules-users mailing list [hidden email] https://lists.jboss.org/mailman/listinfo/rules-users |
||||||||||||||||
| Free Embeddable Forum Powered by Nabble | Help |