For modifying a fact object you have in Working Memory, check out
the documentation on "modify" in the Expert manual's section on
"The Right Hand Side (then)"
-W
On 04/12/2012, Mister Nono <noel.maurice(a)univ-jfc.fr> wrote:
Hi,
I have the drools rule (made in guvnor server) :
1. | rule "driverRule"
2. | salience 10
3. | dialect "mvel"
4. | when
5. | Driver( driverAge : age > 18 && < 65 )
6. | then
7. | Driver fact0 = new Driver();
8. | fact0.setName( "TOTO" );
9. | insert( fact0 );
10. | end
... and the java code source :
KnowledgeAgent agent =
KnowledgeAgentFactory.newKnowledgeAgent("/Guvnor.properties");
KnowledgeBase ruleBase = agent.getKnowledgeBase();
StatefulKnowledgeSession workingMemory =
ruleBase.newStatefulKnowledgeSession();
Driver d = new Driver("Jack", 28, null);
workingMemory.insert(d);
workingMemory.fireAllRules();
for(Iterator i = workingMemory.getObjects().iterator(); i.hasNext();)
{
Object obj = i.next();
System.out.println(obj.getClass().getCanonicalName());
if (obj instanceof Driver)
{
System.out.println("Driver name => " + ((Driver)obj).getName());
System.out.println("Driver age => " + ((Driver)obj).getAge());
}
}
But the drools rule changes the driver name "Jack" by "TOTO", but in
the
console the initial name "Jack" is always displayed.
How to access at the objet who is in knowledge base (the modified objet) ?
Thank. ;)
--
View this message in context:
http://drools.46999.n3.nabble.com/To-access-at-the-fact-object-tp4021064....
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users