[rules-users] How to limit results from a collect statement

Edson Tirelli tirelli at post.com
Tue Aug 21 09:21:36 EDT 2007


    Please, share with us! Send to the list!

    Edson

2007/8/21, pentarious <cristiano.giuffrida at gmail.com>:
>
>
> I found an interesting implementation to do that. If anyone is interested
> I
> could share my solution.
>
> Regards,
>
> CG
>
>
> Mark Proctor wrote:
> >
> > There is no supported way to do this. You could use an inline-eval
> > against a global, but that is very clunkey. However it does seem like a
> > good feature idea for a future release, open a jira and I'll look into
> > getting it included.
> >
> > Mark
> > pentarious wrote:
> >> Does anyone know a method to limit the number of results from a collect
> >> statement? I was just wondering how to do something like this:
> >> $myList : List() from collect( MyObject(myField == "something") ) limit
> 3
> >> //it should put in $myList just the first 3 objects retrieved
> >> I'm quite sure there is nothing in Drools which can natively support
> >> something like that. So, how to do that, if needed? I tried this, but
> it
> >> seems not to be working (I can't understand why, though):
> >> $myList : List() from collect( MyObject(myField == "something") )
> >> $myObject : MyObject() from $myList
> >> eval( $myList.indexOf($myObject) < 3 )
> >> Indeed, it doesn't work because the link beetween $myList and $myObject
> >> seems to be released during any execution of the rule (In fact
> >> $myList.contains($myObject) returns false! Again, I can't understand
> >> why...)
> >>
> >> Any advice would be really appreciated!
> >>
> >> Regards,
> >>
> >> CG
> >>
> >
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-limit-results-from-a-collect-statement-tf4235669.html#a12249025
> Sent from the drools - user mailing list archive at Nabble.com.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070821/eb5929c2/attachment.html 


More information about the rules-users mailing list