throws ProviderException
{
Report report = input.getReport();
Map<String,Object> parameters = input.getParameters();
ReportEngineOutput output = new ReportEngineOutput();
ByteArrayOutputStream out = new ByteArrayOutputStream();
IReportEngine engine = BirtProvider
.getBirtEngine(directoryProvider.getReportDirectory() + "platform");
// Set options for task
HTMLRenderOption renderOption = new HTMLRenderOption();
renderOption.setOutputStream(out);
renderOption.setImageDirectory(directoryProvider.getTempDirectory());
renderOption.setBaseImageURL("report-images");
try
{
String designFile = directoryProvider.getReportDirectory() + report.getFile();
log.info("Loading BIRT report design: " + report.getFile());
IReportRunnable design = engine.openReportDesign(designFile);
handleDataSourceOverrides(design);
if (input.getExportType() == ExportType.PDF)
{
output.setContentType(ReportEngineOutput.CONTENT_TYPE_PDF);
renderOption.setOutputFormat(IRenderOption.OUTPUT_FORMAT_PDF);
}
else if (input.getExportType() == ExportType.HTML || input.getExportType() == ExportType.HTML_EMBEDDED)
{
output.setContentType(ReportEngineOutput.CONTENT_TYPE_HTML);
renderOption.setOutputFormat(IRenderOption.OUTPUT_FORMAT_HTML);
if (input.getExportType() == ExportType.HTML_EMBEDDED)
{
renderOption.setEmbeddable(true);
}
}
else if (input.getExportType() == ExportType.XLS)
{
output.setContentType(ReportEngineOutput.CONTENT_TYPE_XLS);
renderOption.setOutputFormat("xls");
}
else
{
log.error("Export type not yet implemented: " + input.getExportType());
}
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
task.setRenderOption(renderOption);
task.setParameterValues(parameters);
task.validateParameters();
if (input.getLocale() != null)
{
task.setLocale(input.getLocale());
}
if (input.getXmlInput() != null)
{
ByteArrayInputStream stream = new ByteArrayInputStream(input.getXmlInput().getBytes());
task.getAppContext().put("org.eclipse.datatools.enablement.oda.xml.inputStream", stream);
}
log.info("Generating BIRT report: " + report.getName());
task.run();
task.close();
log.info("Finished Generating BIRT report: " + report.getName());
output.setContent(out.toByteArray());
}
catch (Throwable e)
{
log.error("generateReport Exception", e);
throw new ProviderException(e.toString());