I forgot to mention, this assumes you want to maintain the relationships. If
you're not interested in these but merely want to process all NameValue
objects then a simple rule works fine:-
rule "don't worry about preserving relationships"
when
$n : NameValue ( )
then
...
end
Simply assert all NameValue objects.
_____
From: Anstis, Michael (M.)
Sent: 03 October 2007 12:48
To: 'Rules Users List'
Subject: RE: [rules-users] Arrays help
There are a number of ways...
Java dialect [requires LineItem, Parameter and NameValue to be asserted into
working memory]
rule "a - requires object model change for parent property"
when
$l : LineItem( )
$p : Parameter ( parent == $l )
$n : NameValue( parent == $p )
then
...
end
rule "b"
when
$n : NameValue( )
$p : Parameter ( nameValues contains $n )
$l : LineItem( parameters contains $p )
then
...
end
MVEL dialect
rule "c"
dialect mvel
when
$n :
my-mvel-syntax-lets-me-down-but-I-know-you-can-traverse-object-graphs-using-
it
then
...
end
_____
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Bhattacharya,
Sougata
Sent: 03 October 2007 12:37
To: Rules Users List
Subject: [rules-users] Arrays help
Hi All,
I have a object graph like this
LineItem has array of Parameter and each Parameter has array of NameValue
and Namevalue object has name and value.
Now I have LineItem object in working memory, how to test the value of each
value of NameValue object.
LineItem-->getParameters() returns Parameter[]
Parameter->getNameValueArray() return NameValue[]
Each NameValue has name and value attribute
Any help?
Ta
Sougata
This message contains information that may be privileged or confidential and
is the property of the Capgemini Group. It is intended only for the person
to whom it is addressed. If you are not the intended recipient, you are not
authorized to read, print, retain, copy, disseminate, distribute, or use
this message or any part thereof. If you receive this message in error,
please notify the sender immediately and delete all copies of this message.