Sudhir,
As I said in my previous e-mail, in case 1, it is the expected behavior.
http://en.wikipedia.org/wiki/First-order_logic
If you want to ensure that there is at least one Vehicle AND for all
Vehicles the model is bmw, write your rule as:
when
exists( Vehicle() )
forall( Vehicle( model == "bmw" ) )
then
// do something...
end
[]s
Edson
2009/2/3 Sudhir M <sudhir.cse(a)gmail.com>
Hi Edson,
Thanks for a quick reply.
Regarding the second second point I will open an issue in JIRA.
Regarding the first one is that a bug as well? since I haven't assert any
of the vehicle instances I suppose the rule shouldn't fire right? But the
rule is firing always.
Thanks,
sudhir.
On Tue, Feb 3, 2009 at 6:49 PM, Edson Tirelli <tirelli(a)post.com> wrote:
>
> 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(a)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(a)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
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>
_______________________________________________
rules-users mailing list
rules-users(a)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