[rules-users] Guvnor does not like my rule?

2011-08-26 Thread Perrin John - jperri
Noob alert, first post.



I have a rule that works fine when I run it in a JUnit test.  I've imported it 
into Guvnor (along with all my referenced pojos and functions) and it will not 
build there.  Here is the error:



Unable to Analyse Expression for (String curr : (ListString) $validList) { 
ValidValue aValidVal = new ValidValue(curr); drools.insert(aValidVal); }; for 
(int i=0; i$validList.size(); i++) { String curr = (String)$validList.get(i); 
ValidValue aValidVal = new ValidValue(curr); drools.insert(aValidVal); };: 
[Error: unexpected token: $validList] [Near : {... rr : (ListString) 
$validList) { }] ^ [Line: 1, Column: 35]



What the rules is trying to do is run values from a set of records through a 
validation function and then add each of the valid values as individual facts.  
Guvnor apparently doesn't like the way the iteration of the list is being done. 
 I've tried a few different ways of iteration.  Thanks in advance for any 
advice.



Here is the rule:



   when

  $validList : List()

 from accumulate(

InRecord($value : 
value != ),

   
ListValid($value))

   then

  for (String curr : (ListString) $validList) {

 ValidValue aValidVal = new 
ValidValue(curr);

 insert(aValidVal);

  }

  for (int i=0; i$validList.size(); i++) {

 String curr = 
(String)$validList.get(i);

 ValidValue aValidVal = new 
ValidValue(curr);

 insert(aValidVal);

  }



Regards,

John Perrin

***
The information contained in this communication is confidential, is
intended only for the use of the recipient named above, and may be legally
privileged.

If the reader of this message is not the intended recipient, you are
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited.

If you have received this communication in error, please resend this
communication to the sender and delete the original message or any copy
of it from your computer system.

Thank You.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Guvnor does not like my rule?

2011-08-26 Thread JohnPerrin
Thanks folks.  I did end up finding something that works.  I guess
Guvnor5.2.0.Final still has some quirks.  Even this has to be written just
so for the package to build.  Everything has to be cast, using typing didn't
seem to work.

when
$validList : List()
from accumulate(
InRecord($value : value != ),
ListValid($value))
then
java.util.Iterator iter = 
(java.util.Iterator)$validList.iterator();
while (iter.hasNext()) {
String curr = (String)iter.next();
ValidValue aValidVal = new ValidValue(curr);
insert(aValidVal);
}




--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-Guvnor-does-not-like-my-rule-tp3287587p3287898.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Guvnor does not like my rule?

2011-08-26 Thread Michael Anstis
Did you add java.util.Iterator to the packages import section in Guvnor?


On 26 August 2011 21:18, JohnPerrin john.per...@acxiom.com wrote:

 Thanks folks.  I did end up finding something that works.  I guess
 Guvnor5.2.0.Final still has some quirks.  Even this has to be written just
 so for the package to build.  Everything has to be cast, using typing
 didn't
 seem to work.

when
$validList : List()
from accumulate(
InRecord($value : value != ),
ListValid($value))
then
 java.util.Iterator iter =
 (java.util.Iterator)$validList.iterator();
while (iter.hasNext()) {
String curr = (String)iter.next();
 ValidValue aValidVal = new ValidValue(curr);
insert(aValidVal);
}




 --
 View this message in context:
 http://drools.46999.n3.nabble.com/rules-users-Guvnor-does-not-like-my-rule-tp3287587p3287898.html
 Sent from the Drools: User forum mailing list archive at Nabble.com.
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users