PropagationContext context,
InternalWorkingMemory workingMemory) {
QueryTerminalNode node = (QueryTerminalNode) resultLeftTuple.getLeftTupleSink();
Declaration[] decls = node.getDeclarations();
DroolsQuery dquery = (DroolsQuery) this.factHandle.getObject();
Object[] objects = new Object[dquery.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, dquery.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 dquery results
dquery.isOpen());
RightTupleList rightTuples = dquery.getResultInsertRightTupleList();
if (rightTuples == null) {
rightTuples = new RightTupleList();
dquery.setResultInsertRightTupleList(rightTuples);
QueryResultInsertAction evalAction = new QueryResultInsertAction(context,
this.factHandle,
leftTuple,
this.node);
context.getQueue2().addFirst(evalAction);