PropagationContext pctx = leftTuple.getPropagationContext();
pctx = RuleTerminalNode.findMostRecentPropagationContext(leftTuple,
pctx);
boolean blocked = false;
RuleTerminalNodeLeftTuple rtnLeftTuple = (RuleTerminalNodeLeftTuple) leftTuple;
if( executor.isDeclarativeAgendaEnabled() ) {
if ( rtnLeftTuple.getBlockers() != null && !rtnLeftTuple.getBlockers().isEmpty() ) {
blocked = true; // declarativeAgenda still blocking LeftTuple, so don't add back ot list
}
} else {
blocked = rtnNode.getRule().isNoLoop() && rtnNode.equals(pctx.getTerminalNodeOrigin());
}
if ( salience != null ) {
salienceInt = salience.getValue( new DefaultKnowledgeHelper(rtnLeftTuple, wm),
rtnNode.getRule(), wm);
}
if (agenda.getActivationsFilter() != null && !agenda.getActivationsFilter().accept( rtnLeftTuple, wm, rtnNode)) {
// only relevant for serialization, to not re-fire Matches already fired
return;
}
if ( !blocked ) {
boolean addToExector = true;
if ( rtnNode.getRule().isLockOnActive() &&
pctx.getType() != org.kie.api.runtime.rule.PropagationContext.RULE_ADDITION ) {
long handleRecency = ((InternalFactHandle) pctx.getFactHandle()).getRecency();
InternalAgendaGroup agendaGroup = executor.getRuleAgendaItem().getAgendaGroup();
if (blockedByLockOnActive(rtnNode.getRule(), agenda, pctx, handleRecency, agendaGroup)) {
addToExector = false;
}
}
if ( addToExector ) {
if (!rtnLeftTuple.isQueued() ) {
// not queued, so already fired, so it's effectively recreated
EventSupport es = (EventSupport) wm;
es.getAgendaEventSupport().fireActivationCreated(rtnLeftTuple, wm);
rtnLeftTuple.update(salienceInt, pctx);
executor.addLeftTuple(leftTuple);
}
}
} else {
// LeftTuple is blocked, and thus not queued, so just update it's values
rtnLeftTuple.update(salienceInt, pctx);
}
if( !rtnNode.isFireDirect() && executor.isDeclarativeAgendaEnabled()) {
agenda.modifyActivation(rtnLeftTuple, rtnLeftTuple.isQueued());
}
}