<br> If you want the "engine to see" your changes, in a way you affect other rules, you must call update( object ) for the object you are changing. Otherwise, the change will happen to the original object, but not to the shadow proxy that the engine uses to ensure consistency.
<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>Ok, I'm still working on that, I'll publish my solution asap. In the 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 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 has<br>been added to the two items! The problem seems to be related to extracting<br>items from the list. Apparently, every time we get an item from the list, it
<br>looses its link with the original item (I don't know if it's a copy of the<br>original item or whatever), so that every update doesn't affect the 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 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 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 like a<br>>> > good feature idea for a future release, open a jira and I'll look 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 support
<br>>> >> something like that. So, how to do that, if needed? I tried this, 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 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>>> <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: <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></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>