Ejemplo n.º 1
0
  public void clear() {
    // reset focus stack
    this.focusStack.clear();
    this.focusStack.add(getMainAgendaGroup());

    // reset scheduled activations
    if (!this.scheduledActivations.isEmpty()) {
      for (ScheduledAgendaItem item = this.scheduledActivations.removeFirst();
          item != null;
          item = this.scheduledActivations.removeFirst()) {
        item.setEnqueued(false);
        Scheduler.removeAgendaItem(item, this);
      }
    }

    // reset staged activations
    getStageActivationsGroup().clear();

    // reset all agenda groups
    for (InternalAgendaGroup group : this.agendaGroups.values()) {
      group.reset();
    }

    // reset all activation groups.
    for (InternalActivationGroup group : this.activationGroups.values()) {
      group.setTriggeredForRecency(this.workingMemory.getFactHandleFactory().getRecency());
      group.reset();
    }
  }
Ejemplo 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();
  }