[rules-users] Counting Number of Items in NESTED LIST

Wolfgang Laun wolfgang.laun at gmail.com
Fri Jul 20 06:30:18 EDT 2012


when
    $order: Order()
    not Item( measureList.size < 12 ) from $order.itemList;
then

Why is it *important* to use MVEL?

-W


On 20/07/2012, aliosha79 <alex_orl1079 at yahoo.it> wrote:
> I have this use case: an Order can contain one or more items... each item
> is
> characterized by one or more measures. They are described by this simple
> pojo class.
>
> public class Order{
>
>      protected List<Item> itemList;
>
>      public void   setItemList (List<Item> itemList) { ... }
>      public List<Item> getItemList() { ... }
> }
>
>
>
> public class Item {
>
>      protected List<Measure> measureList;
>
>      public void   setMeasureList (List<Measure> measureList) { ... }
>      public List<Measure> getMeasureList() { ... }
> }
>
>
> public class Measure {
>
>      protected int measure;
>
>      public    getMeasure() { ... }
>      public    setMeasure() { ... }
> }
>
>
> Supposing i have in my Working Memory an Order containing 2 items. The
> first
> item contains 5 measures, the second one instead contains 12 Measures.
> I'd like to write a rule using MVEL (for the assumptions), specifying
>
> WHEN each ITEM has more than 11 measures THEN system.out.println ("order is
> valid");
>
> How can i write the assumption? It's important to use MVEL ... (is it
> necessary to use accumulate? from? or what?)
> Really thanks.
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Counting-Number-of-Items-in-NESTED-LIST-tp4018794.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


More information about the rules-users mailing list