use of org.drools.core.common.ActivationsManager in project drools by kiegroup.
the class ModifyPreviousTuples method doDeleteObject.
public void doDeleteObject(PropagationContext pctx, ReteEvaluator reteEvaluator, LeftTuple leftTuple) {
LeftInputAdapterNode liaNode = leftTuple.getTupleSource();
LeftInputAdapterNode.LiaNodeMemory lm = reteEvaluator.getNodeMemory(liaNode);
SegmentMemory sm = lm.getSegmentMemory();
if (sm != null) {
LeftInputAdapterNode.doDeleteObject(leftTuple, pctx, sm, reteEvaluator, liaNode, true, lm);
} else {
ActivationsManager activationsManager = reteEvaluator.getActivationsManager();
TerminalNode rtn = leftTuple.getTupleSink();
PathMemory pathMemory = reteEvaluator.getNodeMemory(rtn);
PhreakRuleTerminalNode.doLeftDelete(activationsManager, pathMemory.getRuleAgendaItem().getRuleExecutor(), leftTuple);
}
}
use of org.drools.core.common.ActivationsManager in project drools by kiegroup.
the class AlphaTerminalNode method assertObject.
@Override
public void assertObject(InternalFactHandle factHandle, PropagationContext propagationContext, ReteEvaluator reteEvaluator) {
ActivationsManager activationsManager = reteEvaluator.getActivationsManager();
Sink[] sinks = getSinks();
for (int i = 0; i < sinks.length; i++) {
TerminalNode rtn = (TerminalNode) getSinks()[i];
RuleAgendaItem agendaItem = getRuleAgendaItem(reteEvaluator, activationsManager, rtn, true);
LeftTuple leftTuple = rtn.createLeftTuple(factHandle, true);
leftTuple.setPropagationContext(propagationContext);
if (rtn.getRule().getAutoFocus() && !agendaItem.getAgendaGroup().isActive()) {
activationsManager.getAgendaGroupsManager().setFocus(agendaItem.getAgendaGroup());
}
PhreakRuleTerminalNode.doLeftTupleInsert(rtn, agendaItem.getRuleExecutor(), activationsManager, agendaItem, leftTuple);
}
}
use of org.drools.core.common.ActivationsManager in project drools by kiegroup.
the class AddRemoveRule method forceFlushLeftTuple.
public static void forceFlushLeftTuple(PathMemory pmem, SegmentMemory sm, ReteEvaluator reteEvaluator, TupleSets<LeftTuple> leftTupleSets) {
SegmentMemory[] smems = pmem.getSegmentMemories();
LeftTupleNode node;
Memory mem;
long bit = 1;
if (sm.getRootNode().getType() == NodeTypeEnums.LeftInputAdapterNode && sm.getTipNode().getType() != NodeTypeEnums.LeftInputAdapterNode) {
// The segment is the first and it has the lian shared with other nodes, the lian must be skipped, so adjust the bit and sink
node = sm.getRootNode().getSinkPropagator().getFirstLeftTupleSink();
mem = sm.getNodeMemories().get(1);
// adjust bit to point to next node
bit = 2;
} else {
node = sm.getRootNode();
mem = sm.getNodeMemories().get(0);
}
PathMemory rtnPmem = NodeTypeEnums.isTerminalNode(pmem.getPathEndNode()) ? pmem : reteEvaluator.getNodeMemory((AbstractTerminalNode) pmem.getPathEndNode().getPathEndNodes()[0]);
ActivationsManager activationsManager = pmem.getActualActivationsManager(reteEvaluator);
RuleNetworkEvaluator.INSTANCE.outerEval(pmem, node, bit, mem, smems, sm.getPos(), leftTupleSets, activationsManager, new LinkedList<>(), true, rtnPmem.getOrCreateRuleAgendaItem(activationsManager).getRuleExecutor());
}
use of org.drools.core.common.ActivationsManager in project drools by kiegroup.
the class AlphaTerminalNode method modifyObject.
@Override
public void modifyObject(InternalFactHandle factHandle, ModifyPreviousTuples modifyPreviousTuples, PropagationContext context, ReteEvaluator reteEvaluator) {
ActivationsManager activationsManager = reteEvaluator.getActivationsManager();
Sink[] sinks = getSinks();
for (int i = 0; i < sinks.length; i++) {
TerminalNode rtn = (TerminalNode) getSinks()[i];
ObjectTypeNode.Id otnId = rtn.getLeftInputOtnId();
LeftTuple leftTuple = processDeletesFromModify(modifyPreviousTuples, context, reteEvaluator, otnId);
RuleAgendaItem agendaItem = getRuleAgendaItem(reteEvaluator, activationsManager, rtn, true);
RuleExecutor executor = agendaItem.getRuleExecutor();
if (leftTuple != null && leftTuple.getInputOtnId().equals(otnId)) {
modifyPreviousTuples.removeLeftTuple(partitionId);
leftTuple.reAdd();
if (context.getModificationMask().intersects(rtn.getLeftInferredMask())) {
leftTuple.setPropagationContext(context);
PhreakRuleTerminalNode.doLeftTupleUpdate(rtn, executor, activationsManager, leftTuple);
if (leftTuple instanceof Activation) {
((Activation) leftTuple).setActive(true);
}
}
} else {
if (context.getModificationMask().intersects(rtn.getLeftInferredMask())) {
leftTuple = rtn.createLeftTuple(factHandle, true);
leftTuple.setPropagationContext(context);
PhreakRuleTerminalNode.doLeftTupleInsert(rtn, executor, activationsManager, agendaItem, leftTuple);
}
}
}
}
use of org.drools.core.common.ActivationsManager in project drools by kiegroup.
the class AlphaTerminalNode method retractLeftTuple.
@Override
public void retractLeftTuple(LeftTuple leftTuple, PropagationContext context, ReteEvaluator reteEvaluator) {
ActivationsManager activationsManager = reteEvaluator.getActivationsManager();
leftTuple.setPropagationContext(context);
TerminalNode rtn = (TerminalNode) leftTuple.getTupleSink();
PhreakRuleTerminalNode.doLeftDelete(activationsManager, getRuleAgendaItem(reteEvaluator, activationsManager, rtn, false).getRuleExecutor(), leftTuple);
}
Aggregations