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 : (List<String>) $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 : (List<String>) $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 : (List<String>) $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