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

Anstis, Michael (M.) manstis1 at ford.com
Wed Oct 24 02:51:08 EDT 2007


Could you not change your rule?
 
rule "An item is in the office" 
        salience 0
        when
                $item : Item( )
                $container : Container(location.name = "office", items
contains $item)
        then
        System.out.println("item in office");
end

[I think] this would only require an update to the Container.
 
If a object represented by a patten changes you always need to update the
working memory's knowledge of the object.
 
The above requires that Container exposes an Items collection.


  _____  

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Edson Tirelli
Sent: 24 October 2007 00:58
To: Rules Users List
Subject: Re: [rules-users] Rules firing with an update of another object



   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
<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/20071024/afe29c7e/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4159 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20071024/afe29c7e/attachment.bin 


More information about the rules-users mailing list