Hi everybody!

Here is my code and my rule. The problem is that the rule doesn?t detect that
my item ?chocolate? contained in the container has moved to the
?office?.

I know that if I update the item instead the container it?s working, but I was
wondering if there is a solution to detect this movement by this way? Do you
have a solution?

Thanks!

*******CODE *******
session = ruleBase.newStatefulSession();
Location kitchen=new Location("kitchen");
Location office=new Location("office");
Container container1=new Container("container1",kitchen);
session.insert(container1);
Item chocolate=new Item("chocolate", container1);
session.insert(chocolate);
session.fireAllRules();
//No rules fired => OK
container1.setLocation(office);
session.update(session.getFactHandle(container1), container1);
session.fireAllRules();
//Once again, no rules fired => Not OK... I want detect this movement

*******RULE *******
rule "An item is in the office"
        salience 0
        when
                $itemA : Item($cont : container, $cont.location.name=="office")
        then
        System.out.println("item in office");
end
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to