Package org.pentaho.reporting.engine.classic.core.modules.output.pageable.base

Examples of org.pentaho.reporting.engine.classic.core.modules.output.pageable.base.PageableReportProcessor


  /**
   * Exports the report into a plain text file.
   */
  public void run()
  {
    PageableReportProcessor proc = null;
    OutputStream out = null;
    File file = null;
    try
    {
      file = new File(fileName).getCanonicalFile();
      final File directory = file.getParentFile();
      if (directory != null)
      {
        if (directory.exists() == false)
        {
          if (directory.mkdirs() == false)
          {
            PlainTextExportTask.logger.warn("Can't create directories. Hoping and praying now.."); //$NON-NLS-1$
          }
        }
      }
      out = new BufferedOutputStream(new FileOutputStream(file));

      final PageableTextOutputProcessor outputProcessor = new PageableTextOutputProcessor
          (getPrinterCommandSet(out), report.getConfiguration());
      proc = new PageableReportProcessor(report, outputProcessor);

      if (progressDialog != null)
      {
        progressDialog.setModal(false);
        progressDialog.setVisible(true);
        proc.addReportProgressListener(progressDialog);
      }

      proc.processReport();

      if (statusListener != null)
      {
        statusListener.setStatus
            (StatusType.INFORMATION, messages.getString("PlainTextExportTask.USER_TASK_FINISHED"), null); //$NON-NLS-1$
      }
    }
    catch (ReportInterruptedException re)
    {
      if (statusListener != null)
      {
        statusListener.setStatus
            (StatusType.WARNING, messages.getString("PlainTextExportTask.USER_TASK_ABORTED"), null); //$NON-NLS-1$
      }
      try
      {
        out.close();
        out = null;
        if (file.delete() == false)
        {
          PlainTextExportTask.logger.warn("Unable to delete incomplete export:" + file); //$NON-NLS-1$
        }
      }
      catch (SecurityException se)
      {
        // ignore me
      }
      catch (IOException ioe)
      {
        // ignore me...
      }
    }
    catch (Exception re)
    {
      PlainTextExportTask.logger.error("PlainText export failed", re); //$NON-NLS-1$
      if (statusListener != null)
      {
        statusListener.setStatus
            (StatusType.ERROR, messages.getString("PlainTextExportTask.USER_TASK_FAILED"), re); //$NON-NLS-1$
      }
    }
    finally
    {
      try
      {
        if (out != null)
        {
          out.close();
        }
      }
      catch (Exception e)
      {
        PlainTextExportTask.logger.error("Unable to close the output stream.", e); //$NON-NLS-1$
        // if there is already another error, this exception is
        // just a minor obstactle. Something big crashed before ...
      }

      if (progressDialog != null)
      {
        proc.removeReportProgressListener(progressDialog);
      }

    }
    if (progressDialog != null)
    {
View Full Code Here


        final HtmlPrinter printer = new AllItemsHtmlPrinter(report.getResourceManager());
        printer.setContentWriter(targetRoot, new DefaultNameGenerator(targetRoot, filename, suffix));
        printer.setDataWriter(dataRoot, new DefaultNameGenerator(dataRoot, "content")); //$NON-NLS-1$
        printer.setUrlRewriter(new FileSystemURLRewriter());
        outputProcessor.setPrinter(printer);
        sp = new PageableReportProcessor(report, outputProcessor);
      }
      else
      {
        final HtmlOutputProcessor outputProcessor = createOutputProcessor();
        final HtmlPrinter printer = new AllItemsHtmlPrinter(report.getResourceManager());
View Full Code Here

   *
   * @see Thread#run()
   */
  public void run()
  {
    PageableReportProcessor proc = null;
    OutputStream fout = null;
    try
    {
      fout = new BufferedOutputStream(new FileOutputStream(targetFile));
      final PdfOutputProcessor outputProcessor = new PdfOutputProcessor(report.getConfiguration(), fout,
          report.getResourceManager());
      proc = new PageableReportProcessor(report, outputProcessor);
      if (progressListener != null)
      {
        proc.addReportProgressListener(progressListener);
        progressListener.setVisible(true);
      }
      proc.processReport();
      if (statusListener != null)
      {
        statusListener.setStatus
            (StatusType.INFORMATION, messages.getString("PdfExportTask.USER_EXPORT_COMPLETE"), null); //$NON-NLS-1$
      }
    }
    catch (Exception e)
    {
      if (statusListener != null)
      {
        statusListener.setStatus
            (StatusType.ERROR, messages.getString("PdfExportTask.USER_EXPORT_FAILED"), e); //$NON-NLS-1$
      }
      PdfExportTask.logger.error("Failed"); //$NON-NLS-1$
    }
    finally
    {
      if (proc != null)
      {
        if (progressListener != null)
        {
          proc.removeReportProgressListener(progressListener);
        }
        proc.close();
      }
      if (fout != null)
      {
        try
        {
View Full Code Here

    report.getReportHeader().addElement(topLabel);
    report.getReportHeader().addElement(bottomLabel);

    final PdfOutputProcessor outputProcessor =
        new TestPdfOutputProcessor(report.getConfiguration(), new NullOutputStream());
    final PageableReportProcessor reportProcessor = new PageableReportProcessor(report, outputProcessor);
    reportProcessor.processReport();
  }
View Full Code Here

        printer.setContentWriter(root, new DefaultNameGenerator(root, "report.html"));
        printer.setDataWriter(data, new DefaultNameGenerator(data, "content"));
        printer.setUrlRewriter(new NullURLRewriter());
        outputProcessor.setPrinter(printer);

        final PageableReportProcessor sp = new PageableReportProcessor(report, outputProcessor);
        sp.processReport();
        sp.close();
        zipRepository.close();
        return out.toString("UTF-8");
      }
      catch (IOException ioe)
      {
View Full Code Here

        final HtmlPrinter printer = new AllItemsHtmlPrinter(report.getResourceManager());
        printer.setContentWriter(root, new DefaultNameGenerator(root, "report.html")); //$NON-NLS-1$
        printer.setDataWriter(data, new DefaultNameGenerator(data, "content")); //$NON-NLS-1$
        printer.setUrlRewriter(new SingleRepositoryURLRewriter());
        outputProcessor.setPrinter(printer);
        sp = new PageableReportProcessor(report, outputProcessor);
      }
      else
      {
        final HtmlOutputProcessor outputProcessor = createOutputProcessor();
        final HtmlPrinter printer = new AllItemsHtmlPrinter(report.getResourceManager());
View Full Code Here

      {
        case PDF:
        {
          final PdfOutputProcessor outputProcessor =
              new PdfOutputProcessor(report.getConfiguration(), outputStream, report.getResourceManager());
          reportProcessor = new PageableReportProcessor(report, outputProcessor);
          break;
        }

        case EXCEL:
        {
View Full Code Here

          final float linesPerInch = StringUtil.parseFloat(report.getReportConfiguration().getConfigProperty
              (PlainTextPageableModule.LINES_PER_INCH), 6.0f);

          final PageableTextOutputProcessor outputProcessor = new PageableTextOutputProcessor
              (new TextFilePrinterDriver(bout, charPerInch, linesPerInch), report.getConfiguration());
          final PageableReportProcessor reportProcessor = new PageableReportProcessor(report, outputProcessor);

          reportProcessor.addReportProgressListener(progressDialog);
          progressDialog.setVisibleInEDT(true);

          reportProcessor.processReport();
          reportProcessor.close();
          bout.flush();
          reportProcessor.removeReportProgressListener(progressDialog);
        }
        finally
        {
          fout.close();
        }
View Full Code Here

        try
        {
          final BufferedOutputStream bout = new BufferedOutputStream(fout);
          final PdfOutputProcessor outputProcessor = new PdfOutputProcessor(report.getConfiguration(), bout,
              report.getResourceManager());
          final PageableReportProcessor reportProcessor = new PageableReportProcessor(report, outputProcessor);

          reportProcessor.addReportProgressListener(progressDialog);
          progressDialog.setVisibleInEDT(true);

          reportProcessor.processReport();
          reportProcessor.close();
          bout.flush();
          reportProcessor.removeReportProgressListener(progressDialog);
        }
        finally
        {
          fout.close();
        }
View Full Code Here

    }
    return result;
  }

  protected boolean writePdf( final MasterReport report, final OutputStream outputStream, final int yieldRate ) {
    PageableReportProcessor proc = null;
    boolean result = false;
    try {

      final PdfOutputProcessor outputProcessor = new PdfOutputProcessor( report.getConfiguration(), outputStream );
      proc = new PageableReportProcessor( report, outputProcessor );
      if ( yieldRate > 0 ) {
        proc.addReportProgressListener( new YieldReportListener( yieldRate ) );
      }
      proc.processReport();
      proc.close();
      proc = null;
      result = true;
    } catch ( Exception e ) {
      error( Messages.getInstance().getErrorString( "JFreeReportPdfComponent.ERROR_0001_WRITING_PDF_FAILED", //$NON-NLS-1$
          e.getLocalizedMessage() ), e );
    } finally {
      if ( proc != null ) {
        proc.close();
      }
    }
    return result;
  }
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.engine.classic.core.modules.output.pageable.base.PageableReportProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.