Search in sources :

Example 1 with ActivationsManager

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);
    }
}
Also used : ActivationsManager(org.drools.core.common.ActivationsManager) PhreakRuleTerminalNode(org.drools.core.phreak.PhreakRuleTerminalNode)

Example 2 with ActivationsManager

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);
    }
}
Also used : RuleAgendaItem(org.drools.core.phreak.RuleAgendaItem) ActivationsManager(org.drools.core.common.ActivationsManager) PhreakRuleTerminalNode(org.drools.core.phreak.PhreakRuleTerminalNode)

Example 3 with ActivationsManager

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());
}
Also used : AbstractTerminalNode(org.drools.core.reteoo.AbstractTerminalNode) SegmentMemory(org.drools.core.reteoo.SegmentMemory) Memory(org.drools.core.common.Memory) PathMemory(org.drools.core.reteoo.PathMemory) InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) SegmentNodeMemory(org.drools.core.reteoo.SegmentNodeMemory) ObjectTypeNodeMemory(org.drools.core.reteoo.ObjectTypeNode.ObjectTypeNodeMemory) RiaNodeMemory(org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory) AccumulateMemory(org.drools.core.reteoo.AccumulateNode.AccumulateMemory) TupleMemory(org.drools.core.reteoo.TupleMemory) BetaMemory(org.drools.core.reteoo.BetaMemory) SegmentMemory(org.drools.core.reteoo.SegmentMemory) FromMemory(org.drools.core.reteoo.FromNode.FromMemory) ActivationsManager(org.drools.core.common.ActivationsManager) LeftTupleNode(org.drools.core.reteoo.LeftTupleNode) PathMemory(org.drools.core.reteoo.PathMemory)

Example 4 with ActivationsManager

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);
            }
        }
    }
}
Also used : RuleAgendaItem(org.drools.core.phreak.RuleAgendaItem) ActivationsManager(org.drools.core.common.ActivationsManager) RuleExecutor(org.drools.core.phreak.RuleExecutor) Activation(org.drools.core.spi.Activation) PhreakRuleTerminalNode(org.drools.core.phreak.PhreakRuleTerminalNode)

Example 5 with ActivationsManager

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);
}
Also used : ActivationsManager(org.drools.core.common.ActivationsManager) PhreakRuleTerminalNode(org.drools.core.phreak.PhreakRuleTerminalNode)

Aggregations

ActivationsManager (org.drools.core.common.ActivationsManager)5 PhreakRuleTerminalNode (org.drools.core.phreak.PhreakRuleTerminalNode)4 RuleAgendaItem (org.drools.core.phreak.RuleAgendaItem)2 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)1 Memory (org.drools.core.common.Memory)1 RuleExecutor (org.drools.core.phreak.RuleExecutor)1 AbstractTerminalNode (org.drools.core.reteoo.AbstractTerminalNode)1 AccumulateMemory (org.drools.core.reteoo.AccumulateNode.AccumulateMemory)1 BetaMemory (org.drools.core.reteoo.BetaMemory)1 FromMemory (org.drools.core.reteoo.FromNode.FromMemory)1 LeftTupleNode (org.drools.core.reteoo.LeftTupleNode)1 ObjectTypeNodeMemory (org.drools.core.reteoo.ObjectTypeNode.ObjectTypeNodeMemory)1 PathMemory (org.drools.core.reteoo.PathMemory)1 RiaNodeMemory (org.drools.core.reteoo.RightInputAdapterNode.RiaNodeMemory)1 SegmentMemory (org.drools.core.reteoo.SegmentMemory)1 SegmentNodeMemory (org.drools.core.reteoo.SegmentNodeMemory)1 TupleMemory (org.drools.core.reteoo.TupleMemory)1 Activation (org.drools.core.spi.Activation)1