[rules-users] Arrays help

Bhattacharya, Sougata sougata.bhattacharya at capgemini.com
Wed Oct 3 09:25:58 EDT 2007


Your assumption is correct, but how do I iterate throw the array

 

________________________________

From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Anstis,
Michael (M.)
Sent: Wednesday, October 03, 2007 6:52 PM
To: Rules Users List
Subject: RE: [rules-users] Arrays help

 

Do you mean you cannot insert NameValue facts into working memory?

 

If this is the case, then you might have to use eval or MVEL dialect.
Based upon your model below I assumed you could insert NameValues:-

 

LineItem-->getParameters() returns Parameter[]

Parameter->getNameValueArray() return NameValue[]

Each NameValue has name and value attribute

	 

	
________________________________


	From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Bhattacharya,
Sougata
	Sent: 03 October 2007 13:23
	To: Rules Users List
	Subject: RE: [rules-users] Arrays help

	Yes that's the simple one, but I can't send the NameValue, I
will send only the LineItem

	 

	
________________________________


	From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of Anstis,
Michael (M.)
	Sent: Wednesday, October 03, 2007 5:36 PM
	To: Rules Users List
	Subject: RE: [rules-users] Arrays help

	 

	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-us
ing-it

		    then

		        ...

		end

		 

			 

			
________________________________


			From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at 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.

			 

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.

	 



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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20071003/85c629c8/attachment.html 


More information about the rules-users mailing list