I've got two classes:

public class Resource {
}

public class Group {
   public List<Resource> resources = new ArrayList<Resource>();
}

I want to test whether there is a resource which is contained by a group. In 2.5, the test looked like:

<rule name="Authorized resources" >
       <parameter identifier="group">
           <class>model.Group</class>
       </parameter>
       <parameter identifier="res">
           <class>model.Resource</class>
       </parameter>
       <g:condition>
           group.resources.contains(res)
       </g:condition>
       <g:consequence>
           // do something
       </g:consequence>
   </rule>

In 3.0, I tried this:

rule "Authorize Resources"
   when
       $r : Resource()
       $g : Group($resources : resources -> ($resources.contains($r)))
   then
       # do something
end

Doesn't work though. I get a "Unable to create field extractor: $resources" error. So:

1. Am I allowed to use a fact binding inside the predicate condition?
2. How come the $resources field binding doesn't work?
3. Would I be allowed to use the == operator with a fact binding? For example, assume class Group had an attribute "resource" of type Resource: "$g : Group(resource == $r)" 4. If 3 wouldn't work, can I use the return value predicate when the expression returns an object, as in: "$g: Group(resource == ($r))"?

Generally, it seems the predicates are designed to work with boxed primitives. But my fact database is a map of pojos, many with attributes which are collections of other pojos. Seems like I won't be able to use the simple operators at all. Are there plans in 3.1 to make the operators (like == and contains) work with pojos?

Thanks.



Reply via email to