use of org.drools.core.base.QueryRowWithSubruleIndex in project drools by kiegroup.
the class StatefulKnowledgeSessionImpl method internalGetQueryResult.
protected QueryResultsImpl internalGetQueryResult(boolean calledFromRHS, String queryName, Object... arguments) {
try {
startOperation();
this.lock.lock();
this.kBase.executeQueuedActions();
// eventually enqueued by events that have been inserted when already expired
if (calledFromRHS) {
flushPropagations();
flushPropagations();
} else {
agenda.executeFlush();
agenda.executeFlush();
}
DroolsQuery queryObject = new DroolsQuery(queryName, arguments, getQueryListenerInstance(), false, null, null, null, null, null);
InternalFactHandle handle = this.handleFactory.newFactHandle(queryObject, null, this, this);
final PropagationContext pCtx = pctxFactory.createPropagationContext(getNextPropagationIdCounter(), PropagationContext.Type.INSERTION, null, null, handle, getEntryPoint());
BaseNode[] tnodes = evalQuery(queryName, queryObject, handle, pCtx, calledFromRHS);
List<Map<String, Declaration>> decls = new ArrayList<Map<String, Declaration>>();
if (tnodes != null) {
for (BaseNode node : tnodes) {
decls.add(((QueryTerminalNode) node).getSubRule().getOuterDeclarations());
}
}
this.handleFactory.destroyFactHandle(handle);
return new QueryResultsImpl((List<QueryRowWithSubruleIndex>) queryObject.getQueryResultCollector().getResults(), decls.toArray(new Map[decls.size()]), this, (queryObject.getQuery() != null) ? queryObject.getQuery().getParameters() : new Declaration[0]);
} finally {
this.lock.unlock();
endOperation();
}
}
Aggregations