Thanks Steve,
Is contains in 3.0.5 - I can't find reference to it in the bundled
documentation?
Also, do you know whether Object's equals() and Object's hashCode() are
used for normal equality conditions:-
when
h : house()
p : person ( residence == ( h ) )
...
Do you also know how the greater than and less than operators are
implemented (can we provide a comparator instance)?
when
r : rank()
p : person (rank >= ( r ) )
...
(If this is even possible!?!? - I haven't got this far yet).
Thanks in advance.
Mike
________________________________
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Steven
Williams
Sent: 23 January 2007 23:00
To: Rules Users List
Subject: Re: [rules-users] Rules to detect states in an object
graph?!?
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
* the child object in the children collection to be the
same as the asserted child object or
* the equals/hashcode method to be implemented
appropriately in Child
cheers
Steve
On 1/24/07, Anstis, Michael (M.) <manstis1(a)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 <mailto:manstis1@ford.com>
_______________________________________________
rules-users mailing list
rules-users(a)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(a)objectconsulting.com.au
www.objectconsulting.com.au
consulting | development | training | support
our experience makes the difference