use of org.drools.core.base.DroolsQuery in project drools by kiegroup.
the class PhreakQueryNode method doLeftDeletes.
public void doLeftDeletes(QueryElementNodeMemory qmem, ReteEvaluator reteEvaluator, TupleSets<LeftTuple> srcLeftTuples, TupleSets<LeftTuple> trgLeftTuples, TupleSets<LeftTuple> stagedLeftTuples) {
for (LeftTuple leftTuple = srcLeftTuples.getDeleteFirst(); leftTuple != null; ) {
LeftTuple next = leftTuple.getStagedNext();
InternalFactHandle fh = (InternalFactHandle) leftTuple.getContextObject();
DroolsQuery dquery = (DroolsQuery) fh.getObject();
if (dquery.isOpen()) {
LeftInputAdapterNode lian = (LeftInputAdapterNode) qmem.getQuerySegmentMemory().getRootNode();
LiaNodeMemory lm = (LiaNodeMemory) qmem.getQuerySegmentMemory().getNodeMemories().get(0);
// there is only one, all other LTs are peers
LeftTuple childLeftTuple = fh.getFirstLeftTuple();
LeftInputAdapterNode.doDeleteObject(childLeftTuple, childLeftTuple.getPropagationContext(), qmem.getQuerySegmentMemory(), reteEvaluator, lian, false, lm);
} else {
LeftTuple childLeftTuple = leftTuple.getFirstChild();
while (childLeftTuple != null) {
LeftTuple nextChild = childLeftTuple.getHandleNext();
RuleNetworkEvaluator.unlinkAndDeleteChildLeftTuple(childLeftTuple, trgLeftTuples, stagedLeftTuples);
childLeftTuple = nextChild;
}
}
leftTuple.clearStaged();
leftTuple = next;
}
}
use of org.drools.core.base.DroolsQuery in project drools by kiegroup.
the class UnificationConstraint method evaluateUnification.
private boolean evaluateUnification(InternalFactHandle handle, Tuple tuple, ReteEvaluator reteEvaluator) {
if (!unification) {
return evaluator.evaluate(handle, tuple, reteEvaluator);
}
DroolsQuery query = (DroolsQuery) tuple.getObject(0);
if (query.getVariables()[indexingDeclaration.getExtractor().getIndex()] != null) {
return true;
}
if (evaluator != null) {
return evaluator.evaluate(handle, tuple, reteEvaluator);
}
Object argument = indexingDeclaration.getValue(null, query);
return handle.getObject().equals(argument);
}
use of org.drools.core.base.DroolsQuery in project drools by kiegroup.
the class MVELConstraint method isAllowedCachedRight.
public boolean isAllowedCachedRight(Tuple tuple, ContextEntry context) {
if (isUnification) {
DroolsQuery query = (DroolsQuery) tuple.get(0).getObject();
Variable v = query.getVariables()[((UnificationContextEntry) context).getReader().getIndex()];
if (v != null) {
return true;
}
context = ((UnificationContextEntry) context).getContextEntry();
}
MvelContextEntry mvelContextEntry = (MvelContextEntry) context;
return evaluate(mvelContextEntry.rightHandle, mvelContextEntry.reteEvaluator, tuple);
}
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, ReteEvaluator reteEvaluator) {
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, reteEvaluator), 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