Charlie,
Can u explain more simply, without the function, what u are trying to do? Is it just to see if there exists a Person, whose tagList property contains a string that is the same as one of the engrTags from a TagCodes?
I'm fairly new to Drools so there may be an easier way to do this. I need to check to see if any one of a list of tags on an object are in another list of tags and am trying to do that with a function. the compiler tells me it can't compile my eval function:#list any import classes here.
import com.cp.services.rules.sources.Person;
import com.cp.services.rules.actions.PersonActions;
import com.cp.rules.TagCodes;
import java.util.List;
#declare any global variables here
global com.cp.services.rules.actions.PersonActions personActions;
function boolean hasOneOf(List list1, String[] list2){
for (Object obj : list1) {
String string = (String)obj;
for (int j = 0; j < list2.length; j++) {
if (string != null && string.equals(list2[j])) {
return true;
}
}
}
return false;
}
rule "Engineering"
dialect "mvel"
when
#conditions
Person( ageInYears >= 18 ) and
eval ( hasOneOf(Person(tagList), TagCodes(engrTags)) )
then
#actions
personActions.addAction("EngineeringGroup");
end
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users