<br> Well, it must work. Can you open a JIRA with a self contained test case please? I will investigate.<br><br> []s<br> Edson<br><br><div><span class="gmail_quote">2007/8/22, pentarious <<a href="mailto:cristiano.giuffrida@gmail.com">
cristiano.giuffrida@gmail.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>I know. Actually I didn't put any update or insert statement in the code just
<br>to make it simpler. The actual code looks like:<br>when<br> $itemList : ArrayList() from collect( Item( category == "VIDEO" ) )<br>then<br> ItemDiscount disc = new ItemDiscount(10);<br> insert(disc);
<br> $myFirstItem = (Item)$itemList.get(0);<br> $mySecondItem = (Item)$itemList.get(1);<br> $myFirstItem.addDiscount(disc);<br> $mySecondItem.addDiscount(disc);<br> update($myFirstItem);<br> update($mySecondItem);
<br>Now, why this doesn't work at all? It does work if I write a rule for each<br>item using in the when clause $item : Item from $itemList, but as I said I<br>need to write a list-oriented rule.<br><br>Regards,<br><br>
CG<br><br><br>Edson Tirelli-3 wrote:<br>><br>> If you want the "engine to see" your changes, in a way you affect other<br>> rules, you must call update( object ) for the object you are changing.<br>> Otherwise, the change will happen to the original object, but not to the
<br>> shadow proxy that the engine uses to ensure consistency.<br>><br>> []s<br>> Edson<br>><br>> 2007/8/22, pentarious <<a href="mailto:cristiano.giuffrida@gmail.com">cristiano.giuffrida@gmail.com
</a>>:<br>>><br>>><br>>> Ok, I'm still working on that, I'll publish my solution asap. In the<br>>> meantime<br>>> it turns out our requirements need something more than that. We have an
<br>>> ordered list of beans (items) and we have to be able to modify a specific<br>>> subset of the list (adding a discount). Now I tried to solve this problem<br>>> by<br>>> working directly on the list of items. But I can't understand why this
<br>>> doesn't work:<br>>> when<br>>> $itemList : ArrayList() from collect( Item( category == "VIDEO" ) )<br>>> then<br>>> ItemDiscount disc = new ItemDiscount(10);<br>
>> $myFirstItem = (Item)$itemList.get(0);<br>>> $mySecondItem = (Item)$itemList.get(1);<br>>> $myFirstItem.addDiscount(disc);<br>>> $mySecondItem.addDiscount(disc);<br>>><br>
>> After executing this rule it's like nothing happened! I mean no discount<br>>> has<br>>> been added to the two items! The problem seems to be related to<br>>> extracting<br>>> items from the list. Apparently, every time we get an item from the list,
<br>>> it<br>>> looses its link with the original item (I don't know if it's a copy of<br>>> the<br>>> original item or whatever), so that every update doesn't affect the<br>>> original
<br>>> item any more. But of course that's what we're interested in! We want to<br>>> modify original items in the rule session. Am I missing something? Or Is<br>>> it<br>>> a bug?<br>>>
<br>>> Regards,<br>>><br>>> CG<br>>><br>>><br>>><br>>> Edson Tirelli-3 wrote:<br>>> ><br>>> > Please, share with us! Send to the list!<br>>> ><br>>> > Edson
<br>>> ><br>>> > 2007/8/21, pentarious <<a href="mailto:cristiano.giuffrida@gmail.com">cristiano.giuffrida@gmail.com</a>>:<br>>> >><br>>> >><br>>> >> I found an interesting implementation to do that. If anyone is
<br>>> interested<br>>> >> I<br>>> >> could share my solution.<br>>> >><br>>> >> Regards,<br>>> >><br>>> >> CG<br>>> >><br>>> >>
<br>>> >> Mark Proctor wrote:<br>>> >> ><br>>> >> > There is no supported way to do this. You could use an inline-eval<br>>> >> > against a global, but that is very clunkey. However it does seem
<br>>> like<br>>> a<br>>> >> > good feature idea for a future release, open a jira and I'll look<br>>> into<br>>> >> > getting it included.<br>>> >> ><br>
>> >> > Mark<br>>> >> > pentarious wrote:<br>>> >> >> Does anyone know a method to limit the number of results from a<br>>> >> collect<br>>> >> >> statement? I was just wondering how to do something like this:
<br>>> >> >> $myList : List() from collect( MyObject(myField == "something") )<br>>> >> limit<br>>> >> 3<br>>> >> >> //it should put in $myList just the first 3 objects retrieved
<br>>> >> >> I'm quite sure there is nothing in Drools which can natively<br>>> support<br>>> >> >> something like that. So, how to do that, if needed? I tried this,<br>>> but
<br>>> >> it<br>>> >> >> seems not to be working (I can't understand why, though):<br>>> >> >> $myList : List() from collect( MyObject(myField == "something") )
<br>>> >> >> $myObject : MyObject() from $myList<br>>> >> >> eval( $myList.indexOf($myObject) < 3 )<br>>> >> >> Indeed, it doesn't work because the link beetween $myList and
<br>>> >> $myObject<br>>> >> >> seems to be released during any execution of the rule (In fact<br>>> >> >> $myList.contains($myObject) returns false! Again, I can't<br>>> understand
<br>>> >> >> why...)<br>>> >> >><br>>> >> >> Any advice would be really appreciated!<br>>> >> >><br>>> >> >> Regards,<br>>> >> >>
<br>>> >> >> CG<br>>> >> >><br>>> >> ><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">https://lists.jboss.org/mailman/listinfo/rules-users</a>
<br>>> >> ><br>>> >> ><br>>> >><br>>> >> --<br>>> >> View this message in context:<br>>> >><br>>> <a href="http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12249025">
http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12249025</a><br>>> >> Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>>> >>
<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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>> >><br>>> ><br>>> ><br>>> ><br>>> > --<br>>> > Edson Tirelli
<br>>> > Software Engineer - JBoss Rules Core Developer<br>>> > Office: +55 11 3529-6000<br>>> > Mobile: +55 11 9287-5646<br>>> > JBoss, a division of Red Hat @ <a href="http://www.jboss.com">
www.jboss.com</a><br>>> ><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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>> ><br>>> ><br>>><br>>> --<br>>> View this message in context:
<br>>> <a href="http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12270505">http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12270505</a><br>>> Sent from the drools - user mailing list archive at
<a href="http://Nabble.com">Nabble.com</a>.<br>>><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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>>><br>><br>><br>><br>> --<br>> Edson Tirelli<br>> Software Engineer - JBoss Rules Core Developer
<br>> Office: +55 11 3529-6000<br>> Mobile: +55 11 9287-5646<br>> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>><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">https://lists.jboss.org/mailman/listinfo/rules-users
</a><br>><br>><br><br>--<br>View this message in context: <a href="http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12272536">http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12272536
</a><br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br><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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli
<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>