Search in sources :

Example 11 with ReportProcessingException

use of org.pentaho.reporting.engine.classic.core.ReportProcessingException in project pentaho-platform by pentaho.

the class JFreeReportComponent method writeRtf.

protected boolean writeRtf(final MasterReport report, final OutputStream outputStream, final int yieldRate) {
    boolean result = false;
    try {
        final StreamRTFOutputProcessor target = new StreamRTFOutputProcessor(report.getConfiguration(), outputStream, report.getResourceManager());
        final StreamReportProcessor proc = new StreamReportProcessor(report, target);
        if (yieldRate > 0) {
            proc.addReportProgressListener(new YieldReportListener(yieldRate));
        }
        proc.processReport();
        proc.close();
        outputStream.close();
        result = true;
    } catch (ReportProcessingException e) {
    // ignore
    } catch (IOException e) {
    // ignore
    }
    return result;
}
Also used : ReportProcessingException(org.pentaho.reporting.engine.classic.core.ReportProcessingException) YieldReportListener(org.pentaho.reporting.engine.classic.core.layout.output.YieldReportListener) StreamReportProcessor(org.pentaho.reporting.engine.classic.core.modules.output.table.base.StreamReportProcessor) ContentIOException(org.pentaho.reporting.libraries.repository.ContentIOException) IOException(java.io.IOException) StreamRTFOutputProcessor(org.pentaho.reporting.engine.classic.core.modules.output.table.rtf.StreamRTFOutputProcessor)

Example 12 with ReportProcessingException

use of org.pentaho.reporting.engine.classic.core.ReportProcessingException in project pentaho-platform by pentaho.

the class JFreeReportComponent method print.

public boolean print(final MasterReport report, final String jobName, final String printerName) {
    boolean result = false;
    if (jobName != null) {
        report.getReportConfiguration().setConfigProperty(PrintUtil.PRINTER_JOB_NAME_KEY, String.valueOf(jobName));
    }
    PrintService printer = null;
    PrintService[] services = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
    for (final PrintService service : services) {
        if (service.getName().equals(printerName)) {
            printer = service;
        }
    }
    if ((printer == null) && (services.length > 0)) {
        printer = services[0];
    }
    try {
        Java14PrintUtil.printDirectly(report, printer);
        result = true;
    } catch (PrintException e) {
    // ignore
    } catch (ReportProcessingException e) {
    // ignore
    }
    return result;
}
Also used : PrintException(javax.print.PrintException) ReportProcessingException(org.pentaho.reporting.engine.classic.core.ReportProcessingException) PrintService(javax.print.PrintService)

Example 13 with ReportProcessingException

use of org.pentaho.reporting.engine.classic.core.ReportProcessingException in project pentaho-platform by pentaho.

the class JFreeReportComponent method writeCsv.

protected boolean writeCsv(final MasterReport report, final OutputStream outputStream, final int yieldRate) {
    boolean result = false;
    try {
        final StreamCSVOutputProcessor target = new StreamCSVOutputProcessor(outputStream);
        final StreamReportProcessor reportProcessor = new StreamReportProcessor(report, target);
        if (yieldRate > 0) {
            reportProcessor.addReportProgressListener(new YieldReportListener(yieldRate));
        }
        reportProcessor.processReport();
        reportProcessor.close();
        outputStream.flush();
        result = true;
    } catch (ReportProcessingException e) {
    // ignore
    } catch (IOException e) {
    // ignore
    }
    return result;
}
Also used : StreamCSVOutputProcessor(org.pentaho.reporting.engine.classic.core.modules.output.table.csv.StreamCSVOutputProcessor) ReportProcessingException(org.pentaho.reporting.engine.classic.core.ReportProcessingException) YieldReportListener(org.pentaho.reporting.engine.classic.core.layout.output.YieldReportListener) StreamReportProcessor(org.pentaho.reporting.engine.classic.core.modules.output.table.base.StreamReportProcessor) ContentIOException(org.pentaho.reporting.libraries.repository.ContentIOException) IOException(java.io.IOException)

Example 14 with ReportProcessingException

use of org.pentaho.reporting.engine.classic.core.ReportProcessingException in project pentaho-platform by pentaho.

the class JFreeReportZipHtmlComponent method performExport.

@Override
protected boolean performExport(final MasterReport report, final OutputStream outputStream) {
    try {
        String dataDirectory = getInputStringValue(AbstractJFreeReportComponent.REPORTDIRECTORYHTML_DATADIR);
        if (dataDirectory == null) {
            // $NON-NLS-1$
            dataDirectory = "data";
        }
        final ZipRepository zipRepository = new ZipRepository();
        final ContentLocation root = zipRepository.getRoot();
        final ContentLocation data = // $NON-NLS-1$
        RepositoryUtilities.createLocation(zipRepository, RepositoryUtilities.split(dataDirectory, "/"));
        final FlowHtmlOutputProcessor outputProcessor = new FlowHtmlOutputProcessor();
        final HtmlPrinter printer = new AllItemsHtmlPrinter(report.getResourceManager());
        // $NON-NLS-1$
        printer.setContentWriter(root, new DefaultNameGenerator(root, "report.html"));
        // $NON-NLS-1$
        printer.setDataWriter(data, new DefaultNameGenerator(data, "content"));
        printer.setUrlRewriter(new SingleRepositoryURLRewriter());
        outputProcessor.setPrinter(printer);
        final FlowReportProcessor sp = new FlowReportProcessor(report, outputProcessor);
        final int yieldRate = getYieldRate();
        if (yieldRate > 0) {
            sp.addReportProgressListener(new YieldReportListener(yieldRate));
        }
        sp.processReport();
        zipRepository.write(outputStream);
        close();
        return true;
    } catch (ReportProcessingException e) {
        // $NON-NLS-1$
        error(Messages.getInstance().getString("JFreeReportZipHtmlComponent.ERROR_0046_FAILED_TO_PROCESS_REPORT"), e);
        return false;
    } catch (IOException e) {
        // $NON-NLS-1$
        error(Messages.getInstance().getString("JFreeReportZipHtmlComponent.ERROR_0046_FAILED_TO_PROCESS_REPORT"), e);
        return false;
    } catch (ContentIOException e) {
        // $NON-NLS-1$
        error(Messages.getInstance().getString("JFreeReportZipHtmlComponent.ERROR_0046_FAILED_TO_PROCESS_REPORT"), e);
        return false;
    }
}
Also used : DefaultNameGenerator(org.pentaho.reporting.libraries.repository.DefaultNameGenerator) FlowHtmlOutputProcessor(org.pentaho.reporting.engine.classic.core.modules.output.table.html.FlowHtmlOutputProcessor) ContentIOException(org.pentaho.reporting.libraries.repository.ContentIOException) IOException(java.io.IOException) SingleRepositoryURLRewriter(org.pentaho.reporting.engine.classic.core.modules.output.table.html.SingleRepositoryURLRewriter) ContentIOException(org.pentaho.reporting.libraries.repository.ContentIOException) ReportProcessingException(org.pentaho.reporting.engine.classic.core.ReportProcessingException) YieldReportListener(org.pentaho.reporting.engine.classic.core.layout.output.YieldReportListener) AllItemsHtmlPrinter(org.pentaho.reporting.engine.classic.core.modules.output.table.html.AllItemsHtmlPrinter) ContentLocation(org.pentaho.reporting.libraries.repository.ContentLocation) FlowReportProcessor(org.pentaho.reporting.engine.classic.core.modules.output.table.base.FlowReportProcessor) AllItemsHtmlPrinter(org.pentaho.reporting.engine.classic.core.modules.output.table.html.AllItemsHtmlPrinter) HtmlPrinter(org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlPrinter) ZipRepository(org.pentaho.reporting.libraries.repository.zip.ZipRepository)

Example 15 with ReportProcessingException

use of org.pentaho.reporting.engine.classic.core.ReportProcessingException in project pentaho-platform by pentaho.

the class JFreeReportPrintComponent method performExport.

@Override
protected boolean performExport(final MasterReport report) {
    final String printerName = getInputStringValue(StandardSettings.PRINTER_NAME);
    final Object jobName = getActionTitle();
    if (jobName instanceof String) {
        report.getReportConfiguration().setConfigProperty(PrintUtil.PRINTER_JOB_NAME_KEY, String.valueOf(jobName));
    }
    final PrintService printer = findPrintService(printerName);
    try {
        Java14PrintUtil.printDirectly(report, printer);
    } catch (PrintException e) {
        return false;
    } catch (ReportProcessingException e) {
        return false;
    }
    return true;
}
Also used : PrintException(javax.print.PrintException) ReportProcessingException(org.pentaho.reporting.engine.classic.core.ReportProcessingException) PrintService(javax.print.PrintService)

Aggregations

ReportProcessingException (org.pentaho.reporting.engine.classic.core.ReportProcessingException)15 IOException (java.io.IOException)11 YieldReportListener (org.pentaho.reporting.engine.classic.core.layout.output.YieldReportListener)10 StreamReportProcessor (org.pentaho.reporting.engine.classic.core.modules.output.table.base.StreamReportProcessor)7 ContentIOException (org.pentaho.reporting.libraries.repository.ContentIOException)7 AllItemsHtmlPrinter (org.pentaho.reporting.engine.classic.core.modules.output.table.html.AllItemsHtmlPrinter)5 HtmlPrinter (org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlPrinter)5 ContentLocation (org.pentaho.reporting.libraries.repository.ContentLocation)5 DefaultNameGenerator (org.pentaho.reporting.libraries.repository.DefaultNameGenerator)5 File (java.io.File)3 FlowReportProcessor (org.pentaho.reporting.engine.classic.core.modules.output.table.base.FlowReportProcessor)3 HtmlOutputProcessor (org.pentaho.reporting.engine.classic.core.modules.output.table.html.HtmlOutputProcessor)3 StreamHtmlOutputProcessor (org.pentaho.reporting.engine.classic.core.modules.output.table.html.StreamHtmlOutputProcessor)3 FileRepository (org.pentaho.reporting.libraries.repository.file.FileRepository)3 StreamRepository (org.pentaho.reporting.libraries.repository.stream.StreamRepository)3 OutputStreamWriter (java.io.OutputStreamWriter)2 PrintException (javax.print.PrintException)2 PrintService (javax.print.PrintService)2 IApplicationContext (org.pentaho.platform.api.engine.IApplicationContext)2 PentahoURLRewriter (org.pentaho.platform.plugin.action.jfreereport.helper.PentahoURLRewriter)2