PropagationContext context,
InternalWorkingMemory workingMemory) {
QueryTerminalNode node = (QueryTerminalNode) resultLeftTuple.getLeftTupleSink();
Declaration[] decls = node.getDeclarations();
DroolsQuery query = (DroolsQuery) this.factHandle.getObject();
Object[] objects = new Object[query.getElements().length];
Declaration decl;
for ( int i = 0, length = this.variables.length; i < length; i++ ) {
decl = decls[this.variables[i]];
objects[this.variables[i]] = decl.getValue( workingMemory,
resultLeftTuple.get( decl ).getObject() );
}
QueryElementFactHandle resultHandle = createQueryResultHandle( context,
workingMemory,
objects );
RightTuple rightTuple = createResultRightTuple( resultHandle, resultLeftTuple, query.isOpen() );
this.node.getSinkPropagator().createChildLeftTuplesforQuery( this.leftTuple,
rightTuple,
true, // this must always be true, otherwise we can't
// find the child tuples to iterate for evaluating the query results
query.isOpen() );
RightTupleList rightTuples = query.getResultInsertRightTupleList();
if ( rightTuples == null ) {
rightTuples = new RightTupleList();
query.setResultInsertRightTupleList( rightTuples );
QueryResultInsertAction evalAction = new QueryResultInsertAction( context,
this.factHandle,
leftTuple,
this.node );
context.getQueue2().addFirst( evalAction );