This looks like a bug. Can you please open a JIRA and attach a self contained test you are using to reproduce the problem? This helps us to speed up getting the solution.

   Thanks,
    Edson

2007/11/7, Adrian Cowham <adrian.cowham@gmail.com>:
I'm running into an issue where the || operator embedded in a collect isn't working as expected. My collect statement is as follows...
       
        $request : AccessRequest($name : username, $ID : sessionID, $loc : accessLocation, $day : dayOfAccess)
        $locationRules : ArrayList(size > 0) from 
            collect (AccessRule((allowedLocation == "ANY" || allowedLocation == $loc))
            from $group.getRules())

I don't get comilation or runtime errors but I don't the expected behavior either. That is, I don't get the intersection of AccessRules that have allowedLocation equal to ANY or allowedLocation equal to the bound $loc variable. Instead, the empty set is returned.

When I modify the rule to look like

        $request : AccessRequest($name : username, $ID : sessionID, $loc : accessLocation, $day : dayOfAccess)
        $locationRules : ArrayList(size > 0) from 
            collect (AccessRule(allowedLocation == $loc))
            from $group.getRules())

I get the expected output.

However, when I modify the rule to look like

        $request : AccessRequest($name : username, $ID : sessionID, $loc : accessLocation, $day : dayOfAccess)
        $locationRules : ArrayList(size > 0) from 
            collect (AccessRule((allowedLocation == "ANY"))
            from $group.getRules())

...it returns the empty set even though there are rules that have allowedLocation set to "ANY" (i confirmed this by debugging my java code). I haven't seen any documentation that uses the collect statement this way but according to my understanding of the grammer this should work. For some reason the allowedLocation == "ANY" embedded in the collect isn't working. What's interesting to note is that the following rule works flawlessly (notice the absence of the collect statement)...

rule "test"
    when
        # does the user that just requested access exist in a group
        $request : AccessRequest($name : username, $ID : sessionID, $loc : accessLocation, $day : dayOfAccess) 
        $rule : AccessRule(allowedLocation == "ANY" || allowedLocation == $loc, allowAccess == "true")     
    then
        System.out.println("Test passed");
end

Any help on the matter would be greatly appreciated. Thanks.

a

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




--
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com