Exemple #1
0
  /** @param data */
  private void filterDurationAndName(List<JobReportData> data) {
    if (!StringUtils.isEmpty(jobReportOptions.getDurationStart())) {
      try {
        int duration = findDuration(jobReportOptions.getDurationStart());
        for (Iterator<JobReportData> iter = data.iterator(); iter.hasNext(); ) {
          JobReportData job = iter.next();
          if (duration > job.getDuration()) {
            iter.remove();
          }
        }
      } catch (Exception e) {
        LOG.warn("Error with min duration value of " + jobReportOptions.getDurationStart());
      }
    }
    if (!StringUtils.isEmpty(jobReportOptions.getDurationEnd())) {
      try {
        int duration = findDuration(jobReportOptions.getDurationEnd());
        for (Iterator<JobReportData> iter = data.iterator(); iter.hasNext(); ) {
          JobReportData job = iter.next();
          if (duration < job.getDuration()) {
            iter.remove();
          }
        }
      } catch (Exception e) {
        LOG.warn("Error with max duration value of " + jobReportOptions.getDurationEnd());
      }
    }
    if (!StringUtils.isEmpty(jobReportOptions.getProjectNameMatch())) {
      try {

        String match =
            jobReportOptions
                .getProjectNameMatch()
                .toLowerCase()
                .replace(".", "\\.")
                .replace("\\", "\\\\")
                .replace("*", ".*");
        for (Iterator<JobReportData> iter = data.iterator(); iter.hasNext(); ) {
          JobReportData job = iter.next();
          if (!job.getProjectName().toLowerCase().matches(match)) {
            iter.remove();
          }
        }
      } catch (Exception e) {
        LOG.warn("Error with max duration value of " + jobReportOptions.getDurationEnd());
      }
    }
  }