Search in sources :

Example 6 with RuleTerminalNodeLeftTuple

use of org.drools.core.reteoo.RuleTerminalNodeLeftTuple in project drools by kiegroup.

the class PhreakRuleTerminalNode method doLeftTupleInsert.

public static void doLeftTupleInsert(TerminalNode rtnNode, RuleExecutor executor, InternalAgenda agenda, RuleAgendaItem ruleAgendaItem, int salienceInt, Salience salience, LeftTuple leftTuple) {
    PropagationContext pctx = leftTuple.getPropagationContext();
    pctx = RuleTerminalNode.findMostRecentPropagationContext(leftTuple, pctx);
    if (rtnNode.getRule().isNoLoop() && rtnNode.equals(pctx.getTerminalNodeOrigin())) {
        return;
    }
    InternalWorkingMemory wm = agenda.getWorkingMemory();
    if (salience != null) {
        salienceInt = salience.getValue(new DefaultKnowledgeHelper((AgendaItem) leftTuple, wm), rtnNode.getRule(), wm);
    }
    RuleTerminalNodeLeftTuple rtnLeftTuple = (RuleTerminalNodeLeftTuple) leftTuple;
    agenda.createAgendaItem(rtnLeftTuple, salienceInt, pctx, ruleAgendaItem, ruleAgendaItem.getAgendaGroup());
    EventSupport es = (EventSupport) wm;
    es.getAgendaEventSupport().fireActivationCreated(rtnLeftTuple, wm);
    if (rtnNode.getRule().isLockOnActive() && leftTuple.getPropagationContext().getType() != PropagationContext.Type.RULE_ADDITION) {
        long handleRecency = pctx.getFactHandle().getRecency();
        InternalAgendaGroup agendaGroup = executor.getRuleAgendaItem().getAgendaGroup();
        if (blockedByLockOnActive(rtnNode.getRule(), pctx, handleRecency, agendaGroup)) {
            es.getAgendaEventSupport().fireActivationCancelled(rtnLeftTuple, wm, MatchCancelledCause.FILTER);
            return;
        }
    }
    if (agenda.getActivationsFilter() != null && !agenda.getActivationsFilter().accept(rtnLeftTuple, wm, rtnNode)) {
        // only relevant for seralization, to not refire Matches already fired
        return;
    }
    agenda.addItemToActivationGroup(rtnLeftTuple);
    executor.addLeftTuple(leftTuple);
    // increased here, decreased in Agenda's cancelActivation and fireActivation
    leftTuple.increaseActivationCountForEvents();
    if (!rtnNode.isFireDirect() && executor.isDeclarativeAgendaEnabled()) {
        agenda.insertAndStageActivation(rtnLeftTuple);
    }
}
Also used : InternalWorkingMemory(org.drools.core.common.InternalWorkingMemory) InternalAgendaGroup(org.drools.core.common.InternalAgendaGroup) PropagationContext(org.drools.core.spi.PropagationContext) EventSupport(org.drools.core.common.EventSupport) DefaultKnowledgeHelper(org.drools.core.base.DefaultKnowledgeHelper) RuleTerminalNodeLeftTuple(org.drools.core.reteoo.RuleTerminalNodeLeftTuple)

Aggregations

RuleTerminalNodeLeftTuple (org.drools.core.reteoo.RuleTerminalNodeLeftTuple)6 PropagationContext (org.drools.core.spi.PropagationContext)3 DefaultKnowledgeHelper (org.drools.core.base.DefaultKnowledgeHelper)2 EventSupport (org.drools.core.common.EventSupport)2 InternalAgendaGroup (org.drools.core.common.InternalAgendaGroup)2 InternalWorkingMemory (org.drools.core.common.InternalWorkingMemory)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ObjectFilter (org.drools.core.ObjectFilter)1 InternalFactHandle (org.drools.core.common.InternalFactHandle)1 Entity (org.drools.core.factmodel.traits.Entity)1 RuleAgendaItem (org.drools.core.phreak.RuleAgendaItem)1 RuleExecutor (org.drools.core.phreak.RuleExecutor)1 LeftTuple (org.drools.core.reteoo.LeftTuple)1 Activation (org.drools.core.spi.Activation)1 RuleFlowGroup (org.drools.core.spi.RuleFlowGroup)1 TupleList (org.drools.core.util.index.TupleList)1 Test (org.junit.Test)1 KieBase (org.kie.api.KieBase)1 ClassObjectFilter (org.kie.api.runtime.ClassObjectFilter)1