示例#1
0
  /**
   * Gets the filtered notification tasks from all the post record task list.
   *
   * @return the filtered notification tasks
   */
  private List<RecordTask> getFilterNotificationTask() {
    List<RecordTask> events = new ArrayList<RecordTask>();
    for (int i = 0; i < recordList.size(); i++) {
      ActivityRecord record = recordList.get(i);
      if (record instanceof AbstractElementRecord)
        events.addAll(getNotificationTask(record.getPostTasks()));
      else if (record instanceof CompoundRecord) {
        // only collect those event will hold till the transaction stack
        // is empty; otherwise the notifications must already be send

        CompoundRecord cr = (CompoundRecord) record;

        if ((cr instanceof FilterEventsCompoundRecord) || (cr instanceof LayoutCompoundRecord)) {
          if (!((FilterEventsCompoundRecord) cr).isOutermostFilterTrans)
            events.addAll(cr.getFilterNotificationTask());
        } else {
          TransactionOption options = cr.getOptions();
          if (options != null
              && options.getSendTime() == TransactionOption.OUTMOST_TRANSACTION_SEND_TIME)
            events.addAll(cr.getFilterNotificationTask());
        }
      }
    }

    // filter all the collected events

    if (options != null) {
      IEventFilter filter = options.getEventFilter();
      if (filter != null) events = filter.filter(events);
    }
    return events;
  }
示例#2
0
  protected void performPostTasks(Stack<CompoundRecord> transStack) {
    List<RecordTask> simpleTasks = getPostTasks();
    List<RecordTask> validationTasks = new ArrayList<RecordTask>();
    for (int i = 0; i < simpleTasks.size(); i++) {
      RecordTask task = simpleTasks.get(i);
      if (task instanceof ValidationRecordTask) validationTasks.add(task);
    }

    // if this record is FilterEventsCompoundRecord and stack is empty, we
    // can do the filter operation by the event filter directly, not need
    // recusively call getFilterNotificationTask like the following 'else
    // if'; it is a special case

    if (this instanceof FilterEventsCompoundRecord && transStack.isEmpty()) {
      // filter events

      assert options != null;
      IEventFilter filter = options.getEventFilter();
      assert filter != null;
      doTasks(transStack, filter.filter(getNotificationTask(simpleTasks)));

    } else if (options != null
        && options.getSendTime() != TransactionOption.INSTANTANEOUS_SEND_TIME) {
      // filter notification tasks and do them second

      doTasks(transStack, getFilterNotificationTask());
    } else if (options == null) {
      // if options is not set, then hold the notification till
      // transaction stack is empty
      if (transStack == null || transStack.isEmpty())
        doTasks(transStack, getNotificationTask(simpleTasks));
    }

    // do the validation task in the end

    if (!validationTasks.isEmpty()) (validationTasks.get(0)).doTask(this, transStack);
  }