use of org.drools.core.base.DroolsQuery in project drools by kiegroup.
the class PhreakQueryTerminalNode method doLeftDeletes.
public void doLeftDeletes(QueryTerminalNode qtnNode, InternalAgenda agenda, TupleSets<LeftTuple> srcLeftTuples, LinkedList<StackEntry> stack) {
for (LeftTuple leftTuple = srcLeftTuples.getDeleteFirst(); leftTuple != null; ) {
LeftTuple next = leftTuple.getStagedNext();
// qtnNode.retractLeftTuple( leftTuple, leftTuple.getPropagationContext(), wm );
PropagationContext pCtx = RuleTerminalNode.findMostRecentPropagationContext(leftTuple, leftTuple.getPropagationContext());
LeftTuple rootEntry = leftTuple;
// find the DroolsQuery object
while (rootEntry.getParent() != null) {
rootEntry = rootEntry.getParent();
}
DroolsQuery dquery = (DroolsQuery) rootEntry.getFactHandle().getObject();
dquery.setQuery(qtnNode.getQuery());
if (dquery.getStackEntry() != null) {
checkAndTriggerQueryReevaluation(agenda, stack, rootEntry, dquery);
}
// Add results to the adapter
dquery.getQueryResultCollector().rowRemoved(qtnNode.getQuery(), leftTuple, pCtx, agenda.getWorkingMemory());
leftTuple.clearStaged();
leftTuple = next;
}
}
use of org.drools.core.base.DroolsQuery in project drools by kiegroup.
the class QueryElementNode method createDroolsQuery.
public DroolsQuery createDroolsQuery(LeftTuple leftTuple, InternalFactHandle handle, StackEntry stackEntry, final List<PathMemory> pmems, QueryElementNodeMemory qmem, LeftTupleSink sink, InternalWorkingMemory workingMemory) {
UnificationNodeViewChangedEventListener collector = createCollector(leftTuple, queryElement.getVariableIndexes(), this.tupleMemoryEnabled);
boolean executeAsOpenQuery = openQuery;
if (executeAsOpenQuery) {
// There is no point in doing an open query if the caller is a non-open query.
Object object = leftTuple.get(0).getObject();
if (object instanceof DroolsQuery && !((DroolsQuery) object).isOpen()) {
executeAsOpenQuery = false;
}
}
DroolsQuery queryObject = new DroolsQuery(this.queryElement.getQueryName(), getActualArguments(leftTuple, workingMemory), collector, executeAsOpenQuery, stackEntry, pmems, qmem != null ? qmem.getResultLeftTuples() : null, qmem, sink);
collector.setFactHandle(handle);
handle.setObject(queryObject);
// so it can be retracted later and destroyed
leftTuple.setContextObject(handle);
return queryObject;
}
Aggregations