[rules-users] doubt regarding FORALL and contains operator...

Edson Tirelli tirelli at post.com
Tue Feb 3 08:19:51 EST 2009


    Regarding 1, it is the expected behavior, since there is no vehicle in
the wm whose model is not "bmw".

    Regarding 2, probably a bug. Can you please open a JIRA with a test
case?

    []s
    Edson

2009/2/3 Sudhir M <sudhir.cse at gmail.com>

> Hi ALL,
> We are using drools 4.0.7  for one of our projects. We encountered some
> issues which I thought are strange.
>
> 1. When using FORALL on an entity for which we haven't asserted any of the
> instances in the working memory the rule always fires. I thought this rule
> should be evaluted to true only if all the asserted instances satisfy the
> condition and if we don't insert any of the instances in the working memory
> it should no fire the rule. Is this the expected behaviour or am I wrong?
>
>   ex: rule "rule1"
>  when
> forall (
>  Vehicle( model == "bmw" )
>  )
>
>  then
>                 System.out.println("in forall");end
>
> 2. When using 'contains' operator on array or collection of strings its
> working fine. But when we use it for an array of primitive type double it
> gives a classcastexception . Is auto boxing not supported? May be this is
> fine as it mentioned in the documentation that it works only on Objects. I
> tried using the array of Double objects, here it doesn't throw an excpetion
> but the rule wasn't firing. The behaviour was same even if I use a
> collection of Double objects. Is this a bug or am I missing something?
>
>  ex:
> using Array
>
>      rule "OrderArray"
>  when
>
>  Order(valueArray contains 0)
>
>  then
>              System.out.println("OrderArray");
> end.
>
> using Collection
>
>
>  rule "OrderList"
>  when
>
>  Order(valueList contains 0)
>
>  then
>              System.out.println("OrderList");
> end.
>
> May be for collections I can write it as below
>
>
> rule "OrderList"
>  when
>
> $order : Order( $val:valueList)
>               Double(doubleValue   ==0) from $val
>
>  then
>        System.out.println("OrderList");
> end.   but this working but not intuitive as these rules were maintained
> later by a business user it will be easy for him if we contains and also if
> we can directly use array instead of collections it would be a great as
> current BOM uses arrays everywhere.
>
> Thanks,
> sudhir.
>
>
>
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
 Edson Tirelli
 JBoss Drools Core Development
 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/20090203/c352a56b/attachment.html 


More information about the rules-users mailing list