Torsten,

If the container is asserted in the working memory, just add it to the rule:

rule "Item handling"
When $item : Item(uniqueId)
       $container: Container( values contains $item )
Then
        if(mustBeDeleted($item)) {
                retract($item);
               $container.remove( $item );
        } else {
                doSomethingElse();
                modify($item);
        }
End


   Otherwise, you can set the container as a global:

global my.package.Container container;

rule "Item handling"
When $item : Item(uniqueId)
Then
        if(mustBeDeleted($item)) {
                retract($item);
               container.remove( $item );
        } else {
                doSomethingElse();
                modify($item);
        }
End

You can access workingMemory through a special variable named "drools", but for your case, I think best approach is one of the above.

   []s
   Edson


Geise, Thorsten (ext) wrote:

Is it possible to access the working memory from within a rule or
function?
Example: I have two container objects that refer to another object
(item). Both container have this item in a list.
A rules decides to delete the item and therefore retracts it from the
working memory. But I need to delete the item from the two containers as
well. How to do?

rule "Item handling"
When $item : Item(uniqueId)
Then
        if(mustBeDeleted($item)) {
                retract($item);
        } else {
                doSomethingElse();
                modify($item);
        }
End

Thanks,
Torsten.

---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email




--
 ---
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com

 IT executives: Red Hat still #1 for value
http://www.redhat.com/promo/vendor/

---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to