use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoResourceBundleFactory in project pentaho-platform by pentaho.
the class JFreeReportComponent method generateReport.
private boolean generateReport(final MasterReport report, final PentahoTableDataFactory factory) throws IOException {
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
boolean result = false;
try {
applyThreadPriority();
// this might be invalid in case the action is contained in a sub-directory.
final String baseName = IOUtils.getInstance().stripFileExtension(getActionName());
final String path = getSolutionPath();
final PentahoResourceBundleFactory bundleFactory = new PentahoResourceBundleFactory(path, baseName, getSession());
report.setResourceBundleFactory(bundleFactory);
// set the default resourcebundle. This allows users to override the
// resource-bundle in case they want to keep common strings in a common
// collection.
report.getReportConfiguration().setConfigProperty(ResourceBundleFactory.DEFAULT_RESOURCE_BUNDLE_CONFIG_KEY, baseName);
if (factory != null) {
report.setDataFactory(factory);
}
String printerName = jFreeReportAction.getPrinterName().getStringValue();
String outputFormat = jFreeReportAction.getOutputType().getStringValue();
if (printerName != null) {
result = print(report, getActionTitle(), printerName);
} else if (AbstractJFreeReportComponent.REPORTALLCONTENT_OUTPUTTYPE_SWING.equals(outputFormat)) {
if (GraphicsEnvironment.isHeadless()) {
result = writeSwingPreview(report);
}
// $NON-NLS-1$
warn(Messages.getInstance().getString("JFreeReportAllContentComponent.WARN_HEADLESSMODE_ACTIVE"));
} else if (AbstractJFreeReportComponent.REPORTALLCONTENT_OUTPUTTYPE_HTML.equals(outputFormat) || AbstractJFreeReportComponent.REPORTALLCONTENT_OUTPUTTYPE_PDF.equals(outputFormat) || AbstractJFreeReportComponent.REPORTALLCONTENT_OUTPUTTYPE_XLS.equals(outputFormat) || AbstractJFreeReportComponent.REPORTALLCONTENT_OUTPUTTYPE_CSV.equals(outputFormat) || AbstractJFreeReportComponent.REPORTALLCONTENT_OUTPUTTYPE_RTF.equals(outputFormat) || AbstractJFreeReportComponent.REPORTALLCONTENT_OUTPUTTYPE_XML.equals(outputFormat)) {
String mimeType = getMimeType(outputFormat);
String fileExtention = getFileExtension(outputFormat);
IContentItem contentItem = getContentItem(mimeType, fileExtention);
OutputStream outputStream = null;
if (contentItem != null) {
outputStream = contentItem.getOutputStream(getActionName());
} else {
outputStream = getDefaultOutputStream(mimeType);
}
result = writeReport(outputFormat, report, outputStream, jFreeReportAction.getReportGenerationYieldRate().getIntValue(0), jFreeReportAction.getHtmlContentHandlerUrlPattern().getStringValue());
if (contentItem != null) {
contentItem.closeOutputStream();
}
} else {
// $NON-NLS-1$
warn(Messages.getInstance().getString("JFreeReportAllContentComponent.WARN_NO_PRINTER_GIVEN"));
}
} finally {
if (factory != null) {
// force close the factory
factory.closeTables();
}
}
return result;
}
use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoResourceBundleFactory in project pentaho-platform by pentaho.
the class AbstractGenerateContentComponent method executeAction.
@Override
protected boolean executeAction() throws Throwable {
MasterReport report = getReport();
if (report == null) {
warn(Messages.getInstance().getString(// $NON-NLS-1$
"AbstractGenerateContentComponent.JFreeReport.ERROR_0043_NO_REPORT_FOR_ACTION"));
return false;
}
applyThreadPriority();
final boolean privateCopy = getInputBooleanValue(AbstractJFreeReportComponent.REPORTPARAMCOMPONENT_PRIVATEREPORT_OUTPUT, false);
if (privateCopy && isDefinedOutput(AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_OBJINPUT)) {
report = (MasterReport) report.clone();
}
// this might be invalid in case the action is contained in a sub-directory.
final String baseName = IOUtils.getInstance().stripFileExtension(getActionName());
final String path = getSolutionName() + File.separator + getSolutionPath();
final PentahoResourceBundleFactory bundleFactory = new PentahoResourceBundleFactory(path, baseName, getSession());
report.setResourceBundleFactory(bundleFactory);
// set the default resourcebundle. This allows users to override the
// resource-bundle in case they want to keep common strings in a common
// collection.
report.getReportConfiguration().setConfigProperty(ResourceBundleFactory.DEFAULT_RESOURCE_BUNDLE_CONFIG_KEY, baseName);
return performExport(report);
}
Aggregations