Arjun,
I guess your questions are about 2 different subjects.
1. The non-existence of an object is handled by the NOT CE. So, if you want to say: there is no Bus asserted into working memory, you simply say:
not Bus()
If you want to say: there is no red bus asserted into working memory, you simply say:
not Bus( color == "red" )
In the above case, even if there is a blue bus asserted, but not a red one, the CE will evaluate to true.
If you want to say: there is a MyComposedObject whose active attribute is false or none MyComposedObject at all, you could say something like:
when
MyComposedObject(active == false) or
not MyComposedObject()
Then
//Action
End
http://labs.jboss.com/file-access/default/members/drools/freezone/docs/4.0.0.13773GA/html/ch06s05.html#d0e3622
2. The use of contains and memberOf constraints. They both work on collections and arrays. The "in" operator only works on explicit lists of values:
Composer( this contains "abc" ) // valid
Composer( this contains $anotherObject ) // valid
Component( this memberOf $composer.components ) // valid
Cheese( type in ( "stilton", $muzzarela, Cheese.PROVOLONE ) ) // valid
The negation of all of these operators works the same.
http://labs.jboss.com/file-access/default/members/drools/freezone/docs/4.0.0.13773GA/html/ch06s05.html#d0e2992
Please, read the docs and suggest improvements for everything that is not clear there.
Thanks,
Edson
2007/8/2, Arjun Dhar <
dhar_ar@yahoo.com>: <mark.mcnally <at> comcast.net
> writes:
>
> My rule now appears to be working after switching from the "excludes"
operator to the newer "not contains".
>
> This works:
> $ca:CandidateAssociation(
nurseDetails.stateLicensures not contains
patientDetails.state )
>
> This does not:
> $ca:CandidateAssociation(nurseDetails.stateLicensures excludes
patientDetails.state )
>
> Mark
I was just about to post a question and I think this may be the answer to my
problem as well. So let me confirm.
Question) I hvae a rule
When
obj: MyComposedObject(active == false)
Then
//Action
End
.. the problem is, if the above object was never asserted; I still want it to
execute. Luckily MyComposedObject is composend inside another object, so can i
use the technique above as>
When
obj: Composer( this not contains MyComposedObject)
End
or even obj: Composer( this not in MyComposedObject)
... My Composer simply composes the object and does not contain it in a list.
Q1) So would either or both "not contains" or "not in" work?
Q2) Or is "not contains" only for List or Collection type? what about HashMaps
then?
Q3) Stretching my actual use case to its limits; if I want to write conditions
over objects that were never asserted into the working memory (need to OR them
with existing) ones, how do I do that? I understand technically it does not
make sense to want conditions over objects one never asserted; ... but please
think a moment. A person asserts Objects and due to some external factor some
objects do not get asserted. Since he is aware of it, can he trap that
conidtion in the rule itself?
Example: Assertions --> (Object Type) A1, A2, A4
RULES: I never got Object type A3 so Do Notify Admin <-- How to write such a
rule?
I hope I'm able to express my use case.
_______________________________________________
rules-users mailing list
rules-users@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