[rules-users] Guvnor and collections.

Jane James jane6210 at yahoo.com
Tue Oct 6 17:49:16 EDT 2009


Hi, All,
     I have a similar questions to Jame's question. 
     I have a list of Strings which is wrapped in a class called Names, and what I want to get is to find all the elements that's equal to "targetStringname". 
     How do I create a rule using guided rule editor in Guvnor to create a rule which looks like the following? (Our system requires  users to be able to create their own rules and I doubt that the users will know how to write rules like the following).

when
   $name: Names( )
   $foundThese: ArrayList (size >0) from collect (String (this matches "targetname" ) from $name.names)

then
   System.out.println("something happened here");

public class Names {
      private List <String> name = new ArrayList<String>();
}

Thanks a bunch!



________________________________
From: "Nord, James" <JNord at nds.com>
To: rules-users at lists.jboss.org
Sent: Tue, October 6, 2009 8:48:46 AM
Subject: [rules-users] Guvnor test scenarios and collections.


Hi 
all,
 
One of our facts has 
a collection which the rules add to.
 
I'm trying to write 
a test scenrio to cover the simple case where the fact with an empty collection 
runs through and ends up containing a value "default".
 
However I can't work 
out how to get Guvnor to do this.  I am presented with fact.blah and then 
"equals" or "does not equal" but no contains or does not 
contain.
I have tried the 
MVEL syntax of [default] but this complains that the expectation fails as: 
"[myFact] field [myCollection] was 
[[DEFAULT]] expected [[DEFAULT]]."
 
Is there any any way to do 
this?
 
Regards,
 
    
/James
**************************************************************************************
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmaster at nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00
**************************************************************************************


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


More information about the rules-users mailing list