Beispiel #1
0
  /**
   * Apply all the given filters and rules to this
   *
   * @return
   * @throws UnableToInitializeEntityException
   * @throws UnableToListBaselinesException
   */
  public BaselineList apply()
      throws UnableToInitializeEntityException, UnableToListBaselinesException {

    /* Printing info for debug */
    logger.fine(" --- Get baselines information --- ");
    logger.fine("Component: " + component.getNormalizedName());
    logger.fine("Stream   : " + stream.getNormalizedName());
    logger.fine("Level    : " + level);
    logger.fine("Limit    : " + limit);
    logger.fine("Filters  : " + filters);
    logger.fine("Multisite: " + multisitePolling);
    logger.finest("Requiring: " + required);

    if (stream.hasPostedDelivery()) {
      if (multisitePolling) {
        this.addAll(stream.getPostedBaselines(component, level));
      }
    } else {
      this.addAll(_get());
    }

    logger.fine("Pre filter steps");
    for (BaselineFilter filter : filters) {
      filter.preFilter(this);
    }

    if (required.size() > 0) {
      for (Baseline b : required) {
        if (!this.contains(b)) {
          this.add(b);
        }
      }
    }

    /* Sort the baselines */
    if (sorter != null) {
      Collections.sort(this, sorter);
    }

    logger.fine(" --- Bare retrieval --- ");
    logger.fine("Baselines: " + this);

    /* Do the filtering */
    int pruned = 0;
    for (BaselineFilter filter : filters) {
      logger.fine("Filter: " + filter.getName());
      pruned += filter.filter(this);
      logger.fine("Baselines: " + this);
    }

    /* Load em? */
    if (load) {
      Iterator<Baseline> it = this.iterator();
      while (it.hasNext()) {
        Baseline baseline = it.next();
        try {
          baseline.load();
        } catch (Exception e) {
          logger.warning(
              "[ClearCase] Unable to load " + baseline.getNormalizedName() + ": " + e.getMessage());
          it.remove();
          pruned++;
          continue;
          /* Just continue */
        }
      }
    }

    if (pruned > 0) {
      logger.config("[ClearCase] Pruned " + pruned + " baselines");
    }

    /* Limit? 0 = unlimited */
    if (limit > 0 && this.size() > 0) {
      BaselineList n = new BaselineList();
      n.addAll(this.subList(0, limit));
      logger.fine("Final list of baselines: " + n);
      return n;
    } else {
      logger.fine("Final list of baselines: " + this);
      return this;
    }
  }
Beispiel #2
0
  /**
   * Apply a single filter to the {@link BaselineList} after the list has been generated.
   *
   * @param filter
   * @return
   */
  public BaselineList applyFilter(BaselineFilter filter) {
    logger.fine("Filter: " + filter.getName());
    filter.filter(this);

    return this;
  }