use of org.pentaho.reporting.engine.classic.core.modules.parser.base.ReportGenerator in project pentaho-platform by pentaho.
the class JFreeReportComponent method getReportFromResource.
private MasterReport getReportFromResource() throws ResourceException, IOException {
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
MasterReport report = null;
Object reportDefinition = jFreeReportAction.getReportDefinition();
IActionSequenceResource resource = null;
if (reportDefinition instanceof ActionResource) {
resource = getResource(((ActionResource) reportDefinition).getName());
}
if (resource != null) {
if (resource.getSourceType() == IActionResource.XML) {
String repDef = resource.getAddress();
ReportGenerator generator = ReportGenerator.createInstance();
// add the runtime context so that PentahoResourceData class can get access to the solution repo
// generator.setObject(PentahoResourceData.PENTAHO_RUNTIME_CONTEXT_KEY, getRuntimeContext());
// Read the encoding from the XML file - see BISERVER-895
final String encoding = XmlHelper.getEncoding(repDef, null);
ByteArrayInputStream inStream = new ByteArrayInputStream(repDef.getBytes(encoding));
InputSource repDefInputSource = new InputSource(inStream);
repDefInputSource.setEncoding(encoding);
report = generator.parseReport(repDefInputSource, getDefinedResourceURL(null));
} else {
report = parseReport(resource);
}
}
return report;
}
use of org.pentaho.reporting.engine.classic.core.modules.parser.base.ReportGenerator in project pentaho-platform by pentaho.
the class JFreeReportComponent method getReportFromJar.
private MasterReport getReportFromJar() throws Exception {
JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
MasterReport report;
org.pentaho.actionsequence.dom.IActionResource reportJar = jFreeReportAction.getReportDefinitionJar().getJar();
final IActionSequenceResource resource = getResource(reportJar.getName());
final ClassLoader loader = ReportUtils.createJarLoader(getSession(), resource);
if (loader == null) {
throw new Exception(Messages.getInstance().getString(// $NON-NLS-1$
"JFreeReportLoadComponent.ERROR_0035_COULD_NOT_CREATE_CLASSLOADER"));
}
String reportLocation = jFreeReportAction.getReportDefinitionJar().getReportLocation();
URL resourceUrl = loader.getResource(reportLocation);
if (resourceUrl == null) {
throw new Exception(// $NON-NLS-1$
Messages.getInstance().getErrorString(// $NON-NLS-1$
"JFreeReport.ERROR_0016_REPORT_RESOURCE_INVALID", reportLocation, resource.getAddress()));
}
try {
ReportGenerator generator = ReportGenerator.getInstance();
// add the runtime context so that PentahoResourceData class can get access to the solution repo
// generator.setObject(PentahoResourceData.PENTAHO_RUNTIME_CONTEXT_KEY, getRuntimeContext());
report = generator.parseReport(resourceUrl, getDefinedResourceURL(resourceUrl));
} catch (Exception ex) {
throw new Exception(Messages.getInstance().getErrorString("JFreeReport.ERROR_0007_COULD_NOT_PARSE", reportLocation), // $NON-NLS-1$
ex);
}
return report;
}
use of org.pentaho.reporting.engine.classic.core.modules.parser.base.ReportGenerator in project pentaho-platform by pentaho.
the class JFreeReportComponent method createReport.
protected MasterReport createReport(final String reportDefinition) throws ResourceException, IOException {
ReportGenerator generator = ReportGenerator.createInstance();
// add the runtime context so that PentahoResourceData class can get access to the solution repo
// generator.setObject(PentahoResourceData.PENTAHO_RUNTIME_CONTEXT_KEY, getRuntimeContext());
URL url = null;
IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
try {
// $NON-NLS-1$ //$NON-NLS-2$
url = new URL(requestContext.getContextPath());
} catch (Exception e) {
// a null URL is ok
// $NON-NLS-1$
warn(Messages.getInstance().getString("JFreeReportLoadComponent.WARN_COULD_NOT_CREATE_URL"));
}
// Read the encoding from the XML file - see BISERVER-895
final String encoding = XmlHelper.getEncoding(reportDefinition, null);
ByteArrayInputStream inStream = new ByteArrayInputStream(reportDefinition.getBytes(encoding));
InputSource reportDefinitionInputSource = new InputSource(inStream);
reportDefinitionInputSource.setEncoding(encoding);
return generator.parseReport(reportDefinitionInputSource, getDefinedResourceURL(url));
}
use of org.pentaho.reporting.engine.classic.core.modules.parser.base.ReportGenerator in project pentaho-platform by pentaho.
the class JFreeReportLoadComponent method getReportFromResource.
private MasterReport getReportFromResource() throws ResourceException, IOException {
MasterReport report = null;
if (isDefinedResource(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN)) {
final IActionSequenceResource resource = getResource(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN);
if (resource.getSourceType() == IActionResource.XML) {
String repDef = resource.getAddress();
ReportGenerator generator = ReportGenerator.getInstance();
report = generator.parseReport(new InputSource(new ByteArrayInputStream(repDef.getBytes())), getDefinedResourceURL(null));
}
report = parseReport(resource);
} else if (isDefinedInput(AbstractJFreeReportComponent.REPORTLOAD_RESOURCENAME)) {
final String resName = getInputStringValue(AbstractJFreeReportComponent.REPORTLOAD_RESOURCENAME);
if (isDefinedResource(resName)) {
final IActionSequenceResource resource = getResource(resName);
report = parseReport(resource);
}
}
return report;
}
use of org.pentaho.reporting.engine.classic.core.modules.parser.base.ReportGenerator in project pentaho-platform by pentaho.
the class JFreeReportLoadComponent method getReportFromInputParam.
private MasterReport getReportFromInputParam() throws ResourceException, UnsupportedEncodingException, IOException {
MasterReport report = null;
if (isDefinedInput(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN)) {
IActionParameter o = getInputParameter(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTDEFN);
if (o != null) {
String repDef = o.getStringValue();
ReportGenerator generator = ReportGenerator.getInstance();
IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
URL url = null;
try {
url = new URL(requestContext.getContextPath());
} catch (Exception e) {
// a null URL is ok
// $NON-NLS-1$
warn(Messages.getInstance().getString("JFreeReportLoadComponent.WARN_COULD_NOT_CREATE_URL"));
}
report = generator.parseReport(new InputSource(new ByteArrayInputStream(repDef.getBytes("UTF-8"))), // $NON-NLS-1$
getDefinedResourceURL(url));
}
}
return report;
}
Aggregations