[rules-users] Rules to detect states in an object graph?!?

Anstis, Michael (M.) manstis1 at ford.com
Tue Jan 23 09:48:22 EST 2007


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 at ford.com>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070123/7b88fffd/attachment.html 


More information about the rules-users mailing list