final PropagationContext context,
final InternalWorkingMemory workingMemory) {
final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
memory.getTupleMemory().remove( leftTuple );
final Activation activation = leftTuple.getActivation();
// activation can be null if the LeftTuple previous propagated into a no-loop
if ( activation == null ) {
return;
}
if ( activation.getLogicalDependencies() != null && !activation.getLogicalDependencies().isEmpty() ) {
context.addRetractedTuple( this.rule,
activation );
}
if ( activation.isActivated() ) {
if ( context.getType() == PropagationContext.MODIFICATION ) {
// during a modify if we have either isLockOnActive or the activation has logical dependencies
// then we need to track retractions, so we know which are exising activations and which are truly new
if ( this.rule.isLockOnActive() ) {
context.addRetractedTuple( this.rule,
activation );
}
}
// on fact expiration, we don't remove the activation, but let it fire
if( context.getType() == PropagationContext.EXPIRATION && context.getFactHandleOrigin() != null ) {
EventFactHandle efh = (EventFactHandle) context.getFactHandleOrigin();
efh.increaseActivationsCount();
} else {
activation.remove();
if ( activation.getActivationGroupNode() != null ) {
activation.getActivationGroupNode().getActivationGroup().removeActivation( activation );
}
if ( activation.getRuleFlowGroupNode() != null ) {
final InternalRuleFlowGroup ruleFlowGroup = activation.getRuleFlowGroupNode().getRuleFlowGroup();
ruleFlowGroup.removeActivation( activation );
}
((EventSupport) workingMemory).getAgendaEventSupport().fireActivationCancelled( activation,
workingMemory,