Beispiel #1
0
  public void cancelActivation(
      final LeftTuple leftTuple,
      final PropagationContext context,
      final InternalWorkingMemory workingMemory,
      final Activation activation,
      final TerminalNode rtn) {
    AgendaItem item = (AgendaItem) activation;
    item.removeAllBlockersAndBlocked(this);

    if (isDeclarativeAgenda() && activation.getFactHandle() == null) {
      // This a control rule activation, nothing to do except update counters. As control rules are
      // not in agenda-groups etc.
      return;
    } else {
      // we are retracting an actual Activation, so also remove it and it's handle from the WM.
      removeActivation(item);
    }

    if (activation.isQueued()) {
      // on fact expiration, we don't remove the activation, but let it fire
      if (context.getType() == PropagationContext.EXPIRATION
          && context.getFactHandleOrigin() != null) {
      } else {
        activation.remove();

        if (activation.getActivationGroupNode() != null) {
          activation.getActivationGroupNode().getActivationGroup().removeActivation(activation);
        }
        leftTuple.decreaseActivationCountForEvents();

        ((EventSupport) workingMemory)
            .getAgendaEventSupport()
            .fireActivationCancelled(activation, workingMemory, MatchCancelledCause.WME_MODIFY);
      }
    }

    if (item.getActivationUnMatchListener() != null) {
      item.getActivationUnMatchListener().unMatch(workingMemory.getKnowledgeRuntime(), item);
    }

    TruthMaintenanceSystemHelper.removeLogicalDependencies(activation, context, rtn.getRule());
  }