Esempio n. 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());
  }
Esempio n. 2
0
  /*
   * (non-Javadoc)
   *
   * @see org.kie.common.AgendaI#clearActivationGroup(org.kie.spi.ActivationGroup)
   */
  public void clearAndCancelActivationGroup(final InternalActivationGroup activationGroup) {
    final EventSupport eventsupport = (EventSupport) this.workingMemory;

    activationGroup.setTriggeredForRecency(this.workingMemory.getFactHandleFactory().getRecency());

    for (final Iterator it = activationGroup.iterator(); it.hasNext(); ) {
      final ActivationGroupNode node = (ActivationGroupNode) it.next();
      final Activation activation = node.getActivation();
      activation.setActivationGroupNode(null);

      if (activation.isQueued()) {
        activation.setQueued(false);
        activation.remove();

        eventsupport
            .getAgendaEventSupport()
            .fireActivationCancelled(activation, this.workingMemory, MatchCancelledCause.CLEAR);
      }
    }
    activationGroup.reset();
  }