Re: [rules-users] get inserted facts
Hi, Finaly in my cases i stay in stateless session And i've addeda result list.and get this list in out. Thanks Gaetan De : rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] De la part de Swindells, Thomas Envoyé : mercredi 6 juillet 2011 09:41 À : Rules Users List Objet : Re: [rules-users] get inserted facts Option 1 is to just use a stateful session - from my understanding there is pretty much no difference in terms of overhead. The other option is to insert a 'ResultsAccumulator' object containing a resultList. I If you don't need to reason over your new Facts than rather than inserting them just add them to the result list. Alternatively have a low salience rule which will only run at the end which accumulates up all the facts and adds them to the result list (either with accumulate or one by one). Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Ruault Gaetan Sent: 06 July 2011 01:13 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 ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com<mailto:postmas...@nds.com> and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] get inserted facts
Option 1 is to just use a stateful session - from my understanding there is pretty much no difference in terms of overhead. The other option is to insert a 'ResultsAccumulator' object containing a resultList. I If you don't need to reason over your new Facts than rather than inserting them just add them to the result list. Alternatively have a low salience rule which will only run at the end which accumulates up all the facts and adds them to the result list (either with accumulate or one by one). Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Ruault Gaetan Sent: 06 July 2011 01:13 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 ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] get inserted facts
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 > 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-boun...@lists.jboss.org [mailto: > rules-users-boun...@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@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] get inserted facts
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-boun...@lists.jboss.org [mailto:rules-users-boun...@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@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[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@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users