示例#1
0
  /**
   * If the item belongs to an activation group, add it
   *
   * @param item
   */
  public void addItemToActivationGroup(final AgendaItem item) {
    String group = item.getRule().getActivationGroup();
    if (group != null && group.length() > 0) {
      InternalActivationGroup actgroup = getActivationGroup(group);

      actgroup.addActivation(item);
    }
  }
示例#2
0
  public void modifyActivation(final AgendaItem activation, boolean previouslyActive) {
    if (declarativeAgenda) {
      InternalFactHandle factHandle = activation.getFactHandle();
      workingMemory
          .getEntryPointNode()
          .modifyActivation(factHandle, activation.getPropagationContext(), workingMemory);

      if (previouslyActive) {
        // already activated
        return;
      }

      if (activation.isCanceled()
          || (activation.getBlockers() != null && activation.getBlockers().size() > 0)) {
        // it's blocked so do nothing
        return;
      }

      // All activations started off staged, they are unstaged if they are blocked or
      // allowed to move onto the actual agenda for firing.
      InternalActivationGroup activationGroup = getStageActivationsGroup();
      if (activation.getActivationGroupNode() != null
          && activation.getActivationGroupNode().getActivationGroup() == activationGroup) {
        // already staged, so return
        return;
      }

      activationGroup.addActivation(activation);
    } else {
      if (!previouslyActive) {
        addActivation(activation, true);
      } else {
        Timer timer = activation.getRule().getTimer();
        if (timer != null && timer instanceof ExpressionIntervalTimer) {
          ScheduledAgendaItem schItem = (ScheduledAgendaItem) activation;
          removeScheduleItem(schItem);

          scheduleItem(schItem, workingMemory);
        }
      }
    }
  }