use of org.drools.core.base.NonCloningQueryViewListener in project drools by kiegroup.
the class RuleUnitExecutorImpl method getQueryResults.
@Override
public QueryResults getQueryResults(String queryName, Object... arguments) {
activationsManager.flushPropagations();
DroolsQuery queryObject = new DroolsQuery(queryName, arguments, new NonCloningQueryViewListener(), false);
InternalFactHandle handle = this.handleFactory.newFactHandle(queryObject, null, this, getDefaultEntryPoint());
final PropagationContext pCtx = new PhreakPropagationContext(getNextPropagationIdCounter(), PropagationContext.Type.INSERTION, null, null, handle, getDefaultEntryPointId());
PropagationEntry.ExecuteQuery executeQuery = new PropagationEntry.ExecuteQuery(queryName, queryObject, handle, pCtx, false);
addPropagation(executeQuery);
TerminalNode[] terminalNodes = executeQuery.getResult();
List<Map<String, Declaration>> decls = new ArrayList<>();
if (terminalNodes != null) {
for (TerminalNode node : terminalNodes) {
decls.add(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]);
}
Aggregations