Esempio n. 1
0
  public void executeReport(Locale locale) throws MavenReportException {
    // Validate parameters
    List<Integer> columnIds =
        IssuesReportHelper.getColumnIds(
            columnNames, TRAC_COLUMNS, DEPRECATED_TRAC_COLUMNS, getLog());
    if (columnIds.size() == 0) {
      // This can happen if the user has configured column names and they are all invalid
      throw new MavenReportException(
          "maven-changes-plugin: None of the configured columnNames '"
              + columnNames
              + "' are valid.");
    }

    try {
      // Download issues
      TracDownloader issueDownloader = new TracDownloader();
      configureIssueDownloader(issueDownloader);

      List<Issue> issueList = issueDownloader.getIssueList();

      // Generate the report
      IssuesReportGenerator report =
          new IssuesReportGenerator(IssuesReportHelper.toIntArray(columnIds));

      if (issueList.isEmpty()) {
        report.doGenerateEmptyReport(getBundle(locale), getSink());
        getLog().warn("No ticket has matched.");
      } else {
        report.doGenerateReport(getBundle(locale), getSink(), issueList);
      }
    } catch (MalformedURLException e) {
      // Rethrow this error so that the build fails
      throw new MavenReportException("The Trac URL is incorrect.");
    } catch (XmlRpcException e) {
      // Rethrow this error so that the build fails
      throw new MavenReportException("XmlRpc Error.", e);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  private void constructDetailRows(
      Sink sink, List issueList, ResourceBundle bundle, Locale locale) {
    if (issueList == null) {
      return;
    }

    for (int idx = 0; idx < issueList.size(); idx++) {
      // Use a DateFormat based on the Locale
      DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);

      Issue issue = (Issue) issueList.get(idx);

      sink.tableRow();

      for (int columnIndex = 0; columnIndex < columns.length; columnIndex++) {
        switch (columns[columnIndex]) {
          case IssuesReportHelper.COLUMN_ASSIGNEE:
            sinkCell(sink, issue.getAssignee());
            break;

          case IssuesReportHelper.COLUMN_COMPONENT:
            sinkCell(sink, IssuesReportHelper.printValues(issue.getComponents()));
            break;

          case IssuesReportHelper.COLUMN_CREATED:
            String created = NOT_AVAILABLE;
            if (issue.getCreated() != null) {
              created = df.format(issue.getCreated());
            }
            sinkCell(sink, created);
            break;

          case IssuesReportHelper.COLUMN_FIX_VERSION:
            sinkCell(sink, IssuesReportHelper.printValues(issue.getFixVersions()));
            break;

          case IssuesReportHelper.COLUMN_ID:
            sink.tableCell();
            sink.link(issue.getLink());
            sink.text(issue.getId());
            sink.link_();
            sink.tableCell_();
            break;

          case IssuesReportHelper.COLUMN_KEY:
            sink.tableCell();
            sink.link(issue.getLink());
            sink.text(issue.getKey());
            sink.link_();
            sink.tableCell_();
            break;

          case IssuesReportHelper.COLUMN_PRIORITY:
            sinkCell(sink, issue.getPriority());
            break;

          case IssuesReportHelper.COLUMN_REPORTER:
            sinkCell(sink, issue.getReporter());
            break;

          case IssuesReportHelper.COLUMN_RESOLUTION:
            sinkCell(sink, issue.getResolution());
            break;

          case IssuesReportHelper.COLUMN_STATUS:
            sinkCell(sink, issue.getStatus());
            break;

          case IssuesReportHelper.COLUMN_SUMMARY:
            sinkCell(sink, issue.getSummary());
            break;

          case IssuesReportHelper.COLUMN_TYPE:
            sinkCell(sink, issue.getType());
            break;

          case IssuesReportHelper.COLUMN_UPDATED:
            String updated = NOT_AVAILABLE;
            if (issue.getUpdated() != null) {
              updated = df.format(issue.getUpdated());
            }
            sinkCell(sink, updated);
            break;

          case IssuesReportHelper.COLUMN_VERSION:
            sinkCell(sink, issue.getVersion());
            break;

          default:
            // Do not add this column
            break;
        }
      }

      sink.tableRow_();
    }

    sink.table_();
  }