コード例 #1
0
  /** {@inheritDoc} */
  @Override
  public void run(
      ReportParameters parameters,
      ReportMode mode,
      DeliveryOptions deliveryOptions,
      String reportId) {

    if (!deliveryOptions.getPersist()) {
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      BufferedOutputStream bout = new BufferedOutputStream(out);
      try {
        getReportService(reportId)
            .runAndRender(
                parameters.getReportParms(mode), reportId, deliveryOptions.getFormat(), bout);
      } catch (ReportException reportException) {
        log.error("failed to run or render report: " + reportId, reportException);
      }
      mailReport(deliveryOptions, out);
    } else {
      String outputPath;
      try {
        outputPath = getReportService(reportId).run(parameters.getReportParms(mode), reportId);
        ReportCatalogEntry catalogEntry = new ReportCatalogEntry();
        catalogEntry.setReportId(reportId);
        catalogEntry.setTitle(deliveryOptions.getInstanceId());
        catalogEntry.setLocation(outputPath);
        catalogEntry.setDate(new Date());
        m_reportStoreService.save(catalogEntry);
        if (deliveryOptions.getMailTo().length() != 0) {
          ByteArrayOutputStream out = new ByteArrayOutputStream();
          BufferedOutputStream bout = new BufferedOutputStream(out);
          getReportService(reportId)
              .render(reportId, outputPath, deliveryOptions.getFormat(), bout);
          mailReport(deliveryOptions, out);
        }
      } catch (ReportException reportException) {
        log.error("failed to run or render report: " + reportId, reportException);
      }
    }
  }