[rules-users] Re: Drools 4.0 problem: insert (drl) not reflected StatefulSession.

Michael Waluk mwaluk at gmail.com
Fri Aug 17 15:58:54 EDT 2007


I found my problem, in case anyone else has this same issue (until
4.0.1which may have this fixed):

The ClassObjectFilter's accept method works like this:

    public boolean accept(Object object) {
        return object.getClass().isAssignableFrom( this.clazz );
    }

which is opposite of what I expected.  I want to find all the objects in
working memory that implement a particular interface.  So I created my own
ObjectFilter that works like you'd expect:

    public boolean accept(Object object) {
        return this.clazz.isAssignableFrom(object.getClass());
    }

Hope it helps someone,
Michael


On 8/16/07, Michael Waluk <mwaluk at gmail.com> wrote:
>
> The log file also shows that the BenefitsProgramEvent was inserted
> properly.  So why wouldn't it appear in the working memory?  Do I need to do
> something special or is somehow inserted in another working memory?
>
> Thanks for any suggestions,
> Michael
>
> <object-stream>
>   <list>
>     <org.drools.audit.event.ActivationLogEvent>
>       <activationId>RecognizeBenefitsProgramEvent [1]</activationId>
>       <rule>RecognizeBenefitsProgramEvent</rule>
>       <declarations>$edit=
> com.workscape.oba.model.editor.benefits.BenefitsProgramModelEdit at 12d91d5
> (1)</declarations>
>       <type>6</type>
>     </org.drools.audit.event.ActivationLogEvent>
>     <org.drools.audit.event.ObjectLogEvent>
>       <factId>84</factId>
>       <objectToString>
> com.workscape.oba.model.events.BenefitsProgramEvent at 9b6713
> []</objectToString>
>       <type>1</type>
>     </org.drools.audit.event.ObjectLogEvent>
>     <org.drools.audit.event.ActivationLogEvent>
>       <activationId>RecognizeBenefitsProgramEvent [1]</activationId>
>       <rule>RecognizeBenefitsProgramEvent</rule>
>       <declarations>$edit=
> com.workscape.oba.model.editor.benefits.BenefitsProgramModelEdit at 12d91d5
> (1)</declarations>
>       <type>7</type>
>     </org.drools.audit.event.ActivationLogEvent>
>   </list>
> </object-stream>
>
>
>
>
> On 8/15/07, Michael Waluk <mwaluk at gmail.com> wrote:
> >
> > I just upgraded to Drools 4.0 and changed my assertObject calls to
> > insert.  I also switched from WorkingMemory to StatefulSession.  The rules
> > seem to be fine, but I am not able to retrieve any inserted objects from the
> > working memory for some reason.  Here is what I'm doing.  I'd appreciate any
> > suggestions...
> >
> > StatefulSession *workingMemory* = getActiveWorkingMemories(id);
> > *workingMemory*.fireAllRules();
> >
> > // Here is the rule that fires:
> > *
> >
> > rule
> > *"RecognizeBenefitsProgramEvent" *
> > **  when* $edit: BenefitsProgramModelEdit()
> > *  then*
> > *    insert* (*new* *BenefitsProgramEvent*("BenefitsProgramEvent",
> > $edit.getValidFrom(), "AnnualEnrollmentEvent")); *
> > **    System*.out.println("Rule RecognizeBenefitsProgramEvent fired " );
> > *
> > **end*
> >
> > I see the print statement in the console but the inserted object is not
> > actually in the working memory.  I look using this:
> >
> > Iterator events = *workingMemory*.iterateObjects(new ClassObjectFilter(
> > BenefitsProgramEvent.class));
> >
> > This iterator is empty.  I also debug and look at the assetMap inside
> > workingMemory and it never changes.
> >
> > Thanks,
> >
> > Michael
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070817/89cfdc73/attachment.html 


More information about the rules-users mailing list