Syntactically speaking, I don't think the eval is necessary:

  $response : Response( $question : question, question.ID == "XYZ" ) 

   Behind the scenes Drools will still generate an eval to resolve the nested property constraint, but the rule stays simple to read and maintain.

   Edson

2010/6/2 Wolfgang Laun <wolfgang.laun@gmail.com>
The "inline eval" constraint is what you want: a boolean expression,
within parentheses.

  $response : Response( $question : question, eval(question.getID().equals( "XYZ" ) ) )

See the Drools Expert manual, section on "Left Hand Side..."

-W


On 1 June 2010 23:54, Laird Nelson <ljnelson@gmail.com> wrote:
I have a fact that is inserted into my rule base.  It is a Response.

A Response has a Question that it is a response to.  At the moment,
the Question itself is not separately inserted into the knowledge
base.  I would ideally like to keep it this way.

What's the best approach for binding variables to both the Response
and its associated Question?

That is, if the Question were inserted, it would be relatively easy:

when
 $question : Question( )
 $response : Response( question == $question )

...but I'm finding myself somewhat confused how to "extract" a
Question out of a Response, particularly when, say, I want to "select"
only Responses whose associated Question IDs are "XYZ":

when
 $response : Response( $question : question.ID == "XYZ" ) // boy
howdy does this seem wrong

Is the easiest thing to do here to add a second rule that just inserts
the questions:

when
 $response : Response
then
 insert($response.getQuestion())
end

...?  I would love to stay away from this if I could.

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


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




--
 Edson Tirelli
 JBoss Drools Core Development
 JBoss by Red Hat @ www.jboss.com