Why not assert all Products into WM as opposed to the array list?? If you insist on just the array list, something along these lines should do the trick<br><br>rule "Find Product"<br> when <br> <br> $list : ArrayList()<br>
Product(productType == "foo") from $list<br> then <br>...<br><br><br><div class="gmail_quote">2009/6/10 prasad raju sagi <span dir="ltr"><<a href="mailto:prasadrajusagi@yahoo.com">prasadrajusagi@yahoo.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div style="font-family: verdana,helvetica,sans-serif; font-size: 10pt;"><div></div>
<div>Hi ,</div>
<div> </div>
<div>I am trying to insert fact as arraylist and then i wanted to get the objects from the arraylist based on some condition.</div>
<div> </div>
<div>like Arryalist<Product> fact was inserted into working memory, I want to get some product from the arrylist based on condition ( productType==??).</div>
<div> </div>
<div>Is there any solution for this .</div>
<div><br> </div>Thanks<br>Prasad Raju Sagi<br>Mobile: 847-644-4103
<div><br></div>
<div style="font-size: 10pt; font-family: verdana,helvetica,sans-serif;"><br>
<div style="font-size: 13px; font-family: arial,helvetica,sans-serif;"><font size="2" face="Tahoma">
<hr size="1">
<b><span style="font-weight: bold;">From:</span></b> Greg Barton <<a href="mailto:greg_barton@yahoo.com" target="_blank">greg_barton@yahoo.com</a>><br><b><span style="font-weight: bold;">To:</span></b> Rules Users List <<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>><br>
<b><span style="font-weight: bold;">Sent:</span></b> Wednesday, June 10, 2009 3:25:39 PM<br><b><span style="font-weight: bold;">Subject:</span></b> RE: [rules-users] Constaint evaluation<br></font><br><br>Correct. When there are no more instantiations (a rule plus a set of objects that match the rule's conditions) on the agenda, then rule firing ceases. With version 5 of drools they added the ability to keep the session ready and available to react even when there are no instantiations on the agenda, but you must make a separate method call to do that. (StatefulSession.fireUntilHalt() instead of fireAllRules())<br>
<br>--- On Wed, 6/10/09, Malenfant, Andre <<a href="mailto:andre.malenfant@cgi.com" target="_blank">andre.malenfant@cgi.com</a>> wrote:<br><br>> From: Malenfant, Andre <<a href="mailto:andre.malenfant@cgi.com" target="_blank">andre.malenfant@cgi.com</a>><br>
> Subject: RE: [rules-users] Constaint evaluation<br>> To: "Rules Users List" <<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>><br>> Date: Wednesday, June 10, 2009, 2:55 PM<br>
> Ok, so now I understand that the<br>> "immutable" is really a concept but not necessarily<br>> "enforced". So, the rule conditions get evaluated each time<br>> the working memory is updated (and not globals) and rules<br>
> for which the conditions are true at each evaluation will<br>> fire. The execution of the rules will end when there is no<br>> more rules for which the conditions are true. Am I correct?<br>> <br>> Thanks<br>
>
<br>> -----Original Message-----<br>> From: <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a><br>> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>]<br>
> On Behalf Of Greg Barton<br>> Sent: Wednesday, June 10, 2009 3:49 PM<br>> To: Rules Users List<br>> Subject: RE: [rules-users] Constaint evaluation<br>> <br>> <br>> The ideas is that objects in working memory are those that<br>
> meant to be tracked: their changes are made visible to the<br>> rules via the insert/update/retract methods. A global<br>> is not in working memory, so it's changes cannot be<br>> tracked. You can change the contents of a global all<br>
> day long and the rules would never be notified.<br>> <br>> It's a similar concept
to threads and<br>> synchronization. You can have unsynchronized access to<br>> member variables in a class when in a multithreaded<br>> environment, but the results are unpredictable. <br>> Likewise, you can use globals in conditions, and change the<br>
> value of the global as you go, but the results are<br>> unpredictable. <br>> <br>> --- On Wed, 6/10/09, Malenfant, Andre <<a href="mailto:andre.malenfant@cgi.com" target="_blank">andre.malenfant@cgi.com</a>><br>
> wrote:<br>> <br>> > From: Malenfant, Andre <<a href="mailto:andre.malenfant@cgi.com" target="_blank">andre.malenfant@cgi.com</a>><br>> > Subject: RE: [rules-users] Constaint evaluation<br>> > To: "Kris Verlaenen" <<a href="mailto:Kris.Verlaenen@cs.kuleuven.be" target="_blank">Kris.Verlaenen@cs.kuleuven.be</a>><br>
> > Cc:
"Rules Users List" <<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>><br>> > Date: Wednesday, June 10, 2009, 2:20 PM<br>> > Thanks Kris,<br>> > <br>
> > I will try with code constraints.<br>> > <br>> > But on the globals subject, I read in the<br>> documentation<br>> > that one should not use a global in a rule. I have<br>> trouble<br>> > understanding why. I don't think drools clones the<br>
> global<br>> > object (might not be possible anyway). If my rule<br>> > consequences change the state of a global (this usage<br>> is<br>> > considered valid as per the documentation as well)<br>> then what<br>
> > is the harm of using it in a condition? I could<br>> understand<br>> > with immutable objects like String but...<br>> > <br>> > I can change my code to insert that global
in the<br>> working<br>> > memory but I would like to understand why I should do<br>> so...<br>> > And if I do and the state of that object is changed by<br>> a<br>> > consequence of my rules, I have to call update? For<br>
> the same<br>> > reason? I guess I am trying to understand the<br>> underlying<br>> > mechanism.<br>> > <br>> > Thanks<br>> > <br>> > <br>> > -----Original Message-----<br>
> > From: Kris Verlaenen [mailto:<a href="mailto:Kris.Verlaenen@cs.kuleuven.be" target="_blank">Kris.Verlaenen@cs.kuleuven.be</a>]<br>> > <br>> > Sent: Wednesday, June 10, 2009 11:38 AM<br>> > To: Rules Users List; Malenfant, Andre<br>
> > Cc: Rules Users List<br>> > Subject: Re: [rules-users] Constaint evaluation<br>> > <br>> > It depends on what type of constraint you are using.<br>> > <br>> > If you
are using a rule constraint, that constraint<br>> will be<br>> > evaluated<br>> > just the same as normal rules. This means that the<br>> > constraints are<br>> > evaluated when data is inserted / updated /<br>
> removed. <br>> > Note that, if you<br>> > want to make sure the engine is using up-to-date<br>> > information, you must<br>> > notify the engine (using update) when you change the<br>> data<br>
> > in the working<br>> > memory. Also note that globals are considered<br>> > immutable. You should<br>> > never write rules that depend on the state of a global<br>> and<br>> > where the<br>
> > global can be changed.<br>> > <br>> > If you are using code constraints, the constraint is<br>> > evaluated at the<br>> > point the code constraint is reached.<br>> > <br>> > Kris<br>
> > <br>> >
Quoting "Malenfant, Andre" <<a href="mailto:andre.malenfant@cgi.com" target="_blank">andre.malenfant@cgi.com</a>>:<br>> > <br>> > > I have some trouble understanding how conditions<br>> and<br>
> > constraints are<br>> > > evaluated:<br>> > > <br>> > > I have a rule flow split node with constraints on<br>> a<br>> > global object.<br>> > > The split node always takes the same path like if<br>
> the<br>> > constraints are<br>> > > evaluated at the beginning of the execution of<br>> the<br>> > process and not<br>> > > when the process flow reaches that split node.<br>> What I<br>
> > would expect is<br>> > > that the split node constraints takes into<br>> account the<br>> > state of the<br>> > > global object as modified by previous rules in<br>> the<br>> > flow.<br>
> > >
<br>> > > Am I right to think that rules conditions and<br>> split<br>> > nodes constraints<br>> > > are evaluated only when inserting/updating<br>> objects in<br>> > the working<br>> > > memory? The documentation is not really useful<br>
> (unless<br>> > I haven't<br>> > > found the appropriate one).<br>> > > <br>> > > Thanks<br>> > > <br>> > > André<br>> > > <br>> > > -----Original Message-----<br>
> > > From: <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a><br>> > > [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>]<br>
> > On Behalf Of Malenfant,<br>> > > Andre<br>> > > Sent: Wednesday, June 10,
2009 11:07 AM<br>> > > To: Kris Verlaenen<br>> > > Cc: Rules Users List<br>> > > Subject: RE: [rules-users] Globals in ruleflow<br>> > > <br>> > > Thanks for trying this for me...<br>
> > > <br>> > > As it turns out, while I was creating a test<br>> sample<br>> > for you I<br>> > > realized<br>> > > that my ruleflow was not loading properly and I<br>> forgot<br>
> > to check for<br>> > > errors on the builder. Now it works.<br>> > > <br>> > > Still, the behavior is strange. If my rule<br>> doesn't<br>> > load and even<br>> > > though<br>
> > > my DRL loaded, my globals were not available.<br>> Since<br>> > the DRL declared<br>> > > the<br>> > > same globals it should not have given me that<br>> error.<br>> > > <br>
> > > Thanks<br>> > > <br>> >
> -----Original Message-----<br>> > > From: Kris Verlaenen [mailto:<a href="mailto:Kris.Verlaenen@cs.kuleuven.be" target="_blank">Kris.Verlaenen@cs.kuleuven.be</a>]<br>> > <br>> > > Sent: Tuesday, June 09, 2009 5:51 PM<br>
> > > To: Rules Users List; Malenfant, Andre<br>> > > Cc: Rules Users List<br>> > > Subject: Re: [rules-users] Globals in ruleflow<br>> > > <br>> > > Andre,<br>> > > <br>
> > > There should be no problem in using the same<br>> global in<br>> > both your<br>> > > rules<br>> > > and processes.<br>> > > <br>> > > I have tried a simple example as you described<br>
> but<br>> > have not been able<br>> > > to<br>> > > reproduce the problem. Could you send me a<br>> > self-contained example<br>> > > that<br>> > > shows the
issue?<br>> > > <br>> > > Kris<br>> > > <br>> > > Quoting "Malenfant, Andre" <<a href="mailto:andre.malenfant@cgi.com" target="_blank">andre.malenfant@cgi.com</a>>:<br>
> > > <br>> > > > I am experimenting with rule flows and I get<br>> the<br>> > following error:<br>> > > > <br>> > > > Unexpected global [myglobal]<br>> > > > <br>
> > > > When calling setGlobal on the session.<br>> > > > <br>> > > > This code works without the workflow<br>> (globals<br>> > declared in the drl)<br>> > > > but<br>
> > > > fails when I include the rule flow. I<br>> declared<br>> > the same globals in<br>> > > > the<br>> > > > rule flow in the header section.<br>> > > > <br>> > > ><br>
>
_______________________________________________<br>> > > > rules-users mailing list<br>> > > > <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>> > > > <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
> > > > <br>> > > <br>> > > <br>> > > <br>> > > <br>> > > Disclaimer: <a href="http://www.kuleuven.be/cwis/email_disclaimer.htm" target="_blank">http://www.kuleuven.be/cwis/email_disclaimer.htm</a><br>
> > > <br>> > > _______________________________________________<br>> > > rules-users mailing list<br>> > > <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
> > > <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>> > > <br>> > > _______________________________________________<br>
> > > rules-users mailing list<br>> > > <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>> > > <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
> > > <br>> > <br>> > <br>> > <br>> > <br>> > Disclaimer: <a href="http://www.kuleuven.be/cwis/email_disclaimer.htm" target="_blank">http://www.kuleuven.be/cwis/email_disclaimer.htm</a><br>
> > <br>> > _______________________________________________<br>> > rules-users mailing list<br>> > <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>> > <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
> > <br>> <br>> <br>> <br>> <br>> _______________________________________________<br>> rules-users mailing list<br>> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>> <br>> _______________________________________________<br>> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
> <br><br><br> <br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></div><br>
</div><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>