public IDataExtractionTask createDataExtractionTask(IReportDocument reportDoc) { try { return new DataExtractionTask(engine, reportDoc); } catch (EngineException ex) { logger.log(Level.SEVERE, ex.getMessage(), ex); // $NON-NLS-1$ } return null; }
public static void createReport(int reportType, String date) { BirtIntegration bi = new BirtIntegration(); try { bi.runTasks(reportType, date); // bi.shutdown(); } catch (EngineException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
/** Test passing reportContext */ @SuppressWarnings("unchecked") @Test public void testExecute1() { try { final IReportEngine reportEngine = ReportEngine.getReportEngine(); final InputStream is = this.getClass().getResourceAsStream("/reports/test_display_parameters.rptdesign"); final IReportRunnable design = reportEngine.openReportDesign(is); final IGetParameterDefinitionTask paramTask = reportEngine.createGetParameterDefinitionTask(design); List<EngineException> errors = null; try { final IRunAndRenderTask rrTask = reportEngine.createRunAndRenderTask(design); final Map<String, Object> appContext = rrTask.getAppContext(); final ClassLoader classLoader = getClass().getClassLoader(); appContext.put(EngineConstants.APPCONTEXT_CLASSLOADER_KEY, classLoader); // rrTask.setAppContext(appContext); try { final ByteArrayOutputStream os = new ByteArrayOutputStream(); final RenderOption options = new HTMLRenderOption(); options.setOutputFormat("HTML"); options.setOutputStream(os); rrTask.setRenderOption(options); rrTask.run(); errors = rrTask.getErrors(); String output = os.toString("utf-8"); System.out.println(output); Assert.assertTrue(output.indexOf("Australian Collectors, Co.") >= 0); Assert.assertTrue(output.indexOf("NewParameter") >= 0); Assert.assertTrue(output.indexOf("abc") >= 0); } finally { rrTask.close(); } } finally { paramTask.close(); } if (errors != null) { Iterator<EngineException> iterator = errors.iterator(); if (iterator.hasNext()) { EngineException error = iterator.next(); Assert.fail("Engine exception: " + error.getMessage()); } } } catch (UnsupportedEncodingException e) { e.printStackTrace(); Assert.fail(e.toString()); } catch (BirtException e) { e.printStackTrace(); Assert.fail(e.toString()); } }
/** Заполнение отчёта */ private void fillReport(RptMain report, RptProperties properties) { String reportDoc = generateReportFileName(report, properties); IReportDocument rd = null; byte[] reportResult = null; try { IRunTask runTask = engine.createRunTask(design); setupEngineTask(runTask, properties); try { runTask.run(reportDoc); } finally { runTask.close(); } rd = engine.openReportDocument(reportDoc); IRenderTask rendTask = engine.createRenderTask(rd); setupRenderTask(rendTask, properties); try { rendTask.render(); reportResult = ((ByteArrayOutputStream) rendTask.getRenderOption().getOutputStream()).toByteArray(); } finally { rendTask.close(); } } catch (EngineException e) { if (e.getCause() instanceof ApplicationException) throw (ApplicationException) e.getCause(); else throw new ReportException(Messages.getInstance().getMessage(Messages.BIRT_ERROR), e); } finally { if (rd != null) rd.close(); File f = new File(reportDoc); f.delete(); f = null; } showReport(report, reportResult, properties); }