|
Hi Kris, I hope you can help me. Here you have the whole code: public class RuleFlowTest { 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"); // start a new process instance ksession.startProcess("com.sample.ruleflow"); System.out.println("Waiting..."); Person person = new Person(); person.setName("Kevin"); person.setSurname("Alonso"); ksession.insert(person); logger.close(); } catch (Throwable t) { t.printStackTrace(); } } private static KnowledgeBase readKnowledgeBase() throws Exception { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newClassPathResource("ruleflow.rf"), 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; } } Person Class: public class Person { String name; String surname; 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; } } And rf file. <?xml version="1.0" encoding="UTF-8"?> <process xmlns="http://drools.org/drools-5.0/process" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd" type="RuleFlow" name="ruleflow" id="com.sample.ruleflow" package-name="com.sample" > <header> <imports> <import name="com.sample.Person" /> </imports> </header> <nodes> <start id="1" name="Start" x="16" y="16" /> <end id="3" name="End" x="480" y="277" width="80" height="40" /> <milestone id="4" name="Event Wait" x="130" y="17" width="80" height="40" > <constraint type="rule" dialect="mvel" >Person()</constraint> </milestone> <end id="5" name="End" x="312" y="275" width="80" height="40" /> <split id="6" name="Split" x="354" y="18" width="80" height="40" type="2" > <constraints> <constraint toNodeId="8" toType="DROOLS_DEFAULT" name="Not Person" priority="1" type="rule" dialect="mvel" >not Person()</constraint> <constraint toNodeId="7" toType="DROOLS_DEFAULT" name="Person" priority="1" type="rule" dialect="mvel" >Person()</constraint> </constraints> </split> <actionNode id="7" name="Action" x="482" y="185" width="80" height="40" > <action type="_expression_" dialect="java" >System.out.println("Person");</action> </actionNode> <actionNode id="8" name="Action" x="310" y="185" width="80" height="40" > <action type="_expression_" dialect="mvel" >System.out.println("No Person");</action> </actionNode> </nodes> <connections> <connection from="7" to="3" /> <connection from="1" to="4" /> <connection from="8" to="5" /> <connection from="4" to="6" /> <connection from="6" to="7" /> <connection from="6" to="8" /> </connections> </process> Kevin. Kris Verlaenen escribió: Kevin, Could you also post your process, so I can take a look and if necessary try it out locally to see what is going on?Kris Quoting Kevin Alonso <[email protected]>:Hello, I´m working with a simple flow that has a Event Wait node. This node has the following condition: - Person() Being Person a class that is not inserted into the session yet. When the flow arrives to the event wait node its execution stops and the test main class execution continues. Here I insert a Person object to the session, so now, the flow can continue. After wait node I have a Split node, which has the followings constraints: - Person() - not Person() The flow always take the not Person() way. But now a Person instance is into the session. Why is happening this? Could anyone help me? Thank you, Kevin _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-usersDisclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm |
_______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
