[rules-users] Re: assertLogical only retracted once

Edson Tirelli tirelli at post.com
Fri May 25 08:35:16 EDT 2007


   Alexandre,

   Thanks for letting us know.

   Regards,
     Edson

2007/5/25, A Gattiker <agattik at gmail.com>:
>
> Hello,
>
> I have given it a try with JBoss Rules 4.0.0 and this time, both facts
> are retracted! Congratulations for this exciting new version.
>
> Regards,
> Alexandre
>
> On 5/24/07, A Gattiker <agattik at gmail.com> wrote:
> > Hello,
> >
> > I am trying to use assertLogical in combination with a
> > WorkingMemoryEventListener in order to have business rules drive my
> > application: if conditions, then do something; if conditions not true
> > anymore, then do something else.
> >
> > However, it seems that if the rule is activated multiple times, then
> > becomes unsupported, only one of the assertLogical'ed facts is
> > retracted, as illustrated in the example below.
> >
> > Does anyone know how to get around that problem? I thought
> > assertLogical would be an elegant solution but maybe there is a better
> > way?
> >
> > Kind regards
> > Alexandre
> >
> >
> > To reproduce the problem: With the JBoss Rules 3.0.6 IDE, I have
> > started with a test project with the Eclipse Wizard and modified it as
> > listed below. "Date" facts are used simply to ensure unequality.
> >
> > DRL:
> >
> > import com.sample.DroolsTest.Message;
> > import java.util.Date;
> >
> > rule "Hello World"
> >         when
> >                 $i : Message ( status > 4 )
> >         then
> >                 assertLogical(new Date());
> > end
> >
> > Java:
> >             workingMemory.addEventListener(new
> > DebugWorkingMemoryEventListener());
> >
> >             Message message = new Message();
> >             message.setStatus( 10 );
> >             FactHandle fh = workingMemory.assertObject( message );
> >             workingMemory.fireAllRules();
> >             Thread.sleep(2000);
> >
> >             message.setStatus( 6 );
> >             workingMemory.modifyObject(fh, message);
> >             workingMemory.fireAllRules();
> >
> >             Thread.sleep(2000);
> >             message.setStatus( 2 );
> >             workingMemory.modifyObject(fh, message);
> >             workingMemory.fireAllRules();
> >
> > Output:
> > [ObjectAsserted: handle=[fid:1:1];
> > object=com.sample.DroolsTest$Message at 629da7ee]
> > [ObjectAsserted: handle=[fid:2:2]; object=Thu May 24 19:19:01 CEST 2007]
> > [ObjectModified: handle=[fid:1:3];
> > old_object=com.sample.DroolsTest$Message at 629da7ee;
> > new_object=com.sample.DroolsTest$Message at 629da7ee]
> > [ObjectAsserted: handle=[fid:3:4]; object=Thu May 24 19:19:03 CEST 2007]
> > [ObjectModified: handle=[fid:1:5];
> > old_object=com.sample.DroolsTest$Message at 629da7ee;
> > new_object=com.sample.DroolsTest$Message at 629da7ee]
> > [ObjectRetracted: handle=[fid:3:4]; old_object=Thu May 24 19:19:03 CEST
> 2007]
> >
> _______________________________________________
> 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/20070525/8b71131d/attachment.html 


More information about the rules-users mailing list