[rules-users] forall/from/eval/contains: odd DRL syntax error

Wolfgang Laun wolfgang.laun at gmail.com
Wed Sep 2 10:58:05 EDT 2009


A rule has to ascertain that all elements in a List<ElemBoxStatus>in a
Collector occur in the matching BoxResponse's  Set<ElemBoxStatus>. There is
just one BoxResponse per Collector.

This here works fine:

rule matchCollectorResponse
 when
        $c : Collector( $ebsList : elemBoxStatusList, $gsSet :
globalStatusSet )
        $b : BoxResponse( collector == $c, globalStatusSet == $gsSet,
$ebsSet : elemBoxStatusSet  )
        forall( $ebs : ElemBoxStatus() from $ebsList
                BoxResponse( collector == $c, elemBoxStatusSet contains $ebs
) )
    then
...
end

Thinking that $ebs is already available from the second pattern ($b:...), I
tried

rule matchCollectorResponse
    when
        $c : Collector( $ms : message, $ebsList : elemBoxStatusList, $gsSet
: globalStatusSet )
        $b : BoxResponse( collector == $c, globalStatusSet == $gsSet,
$ebsSet : elemBoxStatusSet  )
        forall( $ebs : ElemBoxStatus() from $ebsList
                   eval( $ebsSet.contains( $ebs ) ) )
    then
...
end

but the compiler came back with

Line ...:55 no viable alternative at input '$ebs' in rule
matchCollectorResponse in pattern eval

Defining a suitable function isIn(...) and using this within eval() produces
the same result. This
and other experiments seems to indicate that bindings in the first pattern
of forall() are not
passed in to an eval() later in the forall.

JIRA?

-W
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20090902/fe1452ee/attachment.html 


More information about the rules-users mailing list