Hi Michael,

To do the opposite approach (where the relationship is navigable from the parent only) you can use the following:

when
        c : Child ( age > 18 )
        Parent ( children contains c, type == "SMURF" )

Of course this requires either
cheers
Steve

On 1/24/07, Anstis, Michael (M.) <manstis1@ford.com> wrote:

Sorry, me again,

I'm putting together some prototype rules that operate on related objects in a graph of objects.

I'm adding all objects individually to working memory and then checking the objects are related in the rule to ensure only valid combinations are selected; for example:-

//Java code
parent.addChild(child)
wm.assertObject(parent);
wm.assertObject(child);

//Rule
rule "Adult smurfs"
when
        c : Child ( age > 18, p : parent )
        Parent ( parentId == ( p.parentId ) , type == "SMURF" )
then
        System.out.println("Smurf " + p.getName() + " is " + c.getAge() + " years old."
end

rule "Adult clangers"
when
        c : Child ( age > 18, p : parent )
        Parent ( parentId == ( p.parentId ) , type == "CLANGER" )
then
        System.out.println("Clanger " + p.getName() + " is " + c.getAge() + " years old."
end

This requires that the parent-child relationship is navigable from the child end of the relationship -- child.getParent() .

What other approaches does anyone else use to implement rules that span related objects?

With kind regards,

Michael Anstis
-------------------------------------------
Next Generation Estimating System
( Trafford House (Int) 8 718 2239
( Trafford House (Ext) +44 (0)1268 702239
* < mailto:manstis1@ford.com>


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users





--
Steven Williams

Supervising Consultant

Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
stevenw@objectconsulting.com.au
www.objectconsulting.com.au

consulting | development | training | support
our experience makes the difference