Thanks, I'll do that. In the meantime I still need to get the job done asap. Can you provide me an example to implement such a logic using an inline-eval and global (which variable should be global?)? And just out of curiosity can you explain me why this code doesn't work (basically why, after the second line, $myList.contains($myObject) would return false):
<br>> $myList : List() from collect( MyObject(myField == "something") )<br>> $myObject : MyObject() from $myList<br>> eval( $myList.indexOf($myObject) < 3 )<br>To me, this code seems to be just fine (in real Java it would be), so I can't understand why it doesn't work here. Maybe I am missing something or the DRL-Java code mapping done by a rule compiler is not so simple to figure out.
<br><br>Regards,<br><br>CG<br><br><div><span class="gmail_quote">On 8/8/07, <b class="gmail_sendername">Mark Proctor</b> <<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
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 collect<br>> statement? I was just wondering how to do something like this:<br>> $myList : List() from collect( MyObject(myField == "something") ) limit 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 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 $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 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></blockquote></div><br>