[rules-users] Rules firing with an update of another object

Edson Tirelli tirelli at post.com
Tue Oct 23 19:57:55 EDT 2007


   Hi Fabrice,

   That is how it is supposed to work... no "automatic" way of doing it in
another way.

   []s
   Edson

2007/10/23, Fabrice Granzotto <granz at mit.edu>:
>
> 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071023/6d6bc946/attachment.html 


More information about the rules-users mailing list