[rules-users] RE: Help with syntax for detecting when an object exists, none of whose children match a pattern

Vikrant Yagnick VikrantY at mastek.com
Sat Sep 6 03:12:32 EDT 2008


I am a bit of a newbie myself, but I assume the following would work:

When
 $p: ParentFactObject()
$c: childFactObject(TestMe==false) from $p.ChildFactObjectList
Then
//do something
End

Another way is to simply assert the ChildFactObjectList as separate facts into the working memory and then pattern match just them.

Cheers,
Vikrant


From: rules-users-bounces at lists.jboss.org [mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Tom.E.Murphy at wellsfargo.com
Sent: Saturday, September 06, 2008 2:49 AM
To: rules-users at lists.jboss.org
Subject: [rules-users] Help with syntax for detecting when an object exists, none of whose children match a pattern


As a newbie to Drools (using v4.0.7), I'm struggling a bit with the right way to express the following concept

I have a ParentFactObject with an array of ChildFactObjects.

The ChildFactObjects have a boolean attribute "TestMe"

I want to pattern match all ParentFactObjects for whom all ChildFactObjects have false for TestMe

Here's what I've tried:

rule "NoTestChildren"

        when

                $parentFactObject : ParentFactObject // parent exists

                (

                )

                not ChildFactObject     // no child exists that has TestMe true

                (

                        TestMe == true

                ) from $parentFactObject.childFactObjects

        then

                log("Rule NoTestChildren fired.");

end

I get the following:

org.drools.rule.InvalidRulePackage: [66,4]: unknown:66:4 mismatched token: [@1085,4469:4472='from',<38>,66:4]; expecting type THEN

Also tried this:

rule " NoTestChildren "

        when

                $parentFactObject : Borrower // parent exists

                (

                )

                forall ($childFactObject : ChildFactObject      // no child exists that has TestMe true

                (

                        TestMe == true

                ) )from $parentFactObject. childFactObjects

        then

                log("Rule NoTestChildren fired.");

end

I've tried a series of variations with similar results.

Can anyone provide any guidance on how to do this?

Thanks in advance.

Tom Murphy

This message may contain confidential and/or privileged information.  If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein.  If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message.  Thank you for your cooperation.





MASTEK LTD.
Mastek in NASSCOM's 'India Top 20' Software Service Exporters List.
In the US, we're called MAJESCOMASTEK

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20080906/717da466/attachment.html 


More information about the rules-users mailing list