[rules-users] get inserted facts

Wolfgang Laun wolfgang.laun at gmail.com
Wed Jul 6 03:02:30 EDT 2011


Without changing the rules: you might also use a WorkingMemoryEventListener
to collect the inserted new Fact objects.

A StatefulKnowledgeSession provides the method getObjects(), with or without
a filter, so you might consider using that.

-W


2011/7/6 Nathan Bell <Nathan.Bell at pharmacyonesource.com>

> Without knowing your use cases, or what you intended to do with the facts
> once you retrieve them, I’d suggest that you could simply add them to a
> global list and examine the list contents after rule processing. For
> example:****
>
> ** **
>
> import java.util.List;****
>
> ** **
>
> global List results;****
>
> ** **
>
> rule "IWantToTrackMyConsequenceFacts"****
>
> when ****
>
>                 Type1(filter1 =1) ****
>
> then****
>
>                 Fact someFact = new Fact();****
>
>                 insert(someFact);****
>
>                 results.add(someFact);****
>
> end****
>
> ** **
>
> ** **
>
> Prior to executing the rule(s) you will have to set that global variable to
> a valid list object with something like this:****
>
> ** **
>
> knowledgeSession.setGlobal(“results”, new ArrayList());****
>
> ** **
>
> ** **
>
> ** **
>
> *From:* rules-users-bounces at lists.jboss.org [mailto:
> rules-users-bounces at lists.jboss.org] *On Behalf Of *Ruault Gaetan
> *Sent:* Tuesday, July 05, 2011 5:13 PM
> *To:* Rules Users List
> *Subject:* [rules-users] get inserted facts****
>
> ** **
>
> Hi,****
>
> ** **
>
> I use drools in stateless Session  like this :****
>
> ** **
>
> session.execute( my_facts_list) ;****
>
> ** **
>
> and i have many rules like this****
>
> ** **
>
> when ****
>
>                                 Type1(filter1 =1) ****
>
> Then****
>
>                                 Insert( new Fact()) ;****
>
> ** **
>
> ** **
>
> Could you explain how it’s possible to retrieve my new facts in java code ?
> ****
>
> ** **
>
> ** **
>
> Thanks.****
>
> ** **
>
> Gaetan****
>
> ** **
>
> ** **
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110706/554271e8/attachment.html 


More information about the rules-users mailing list