Search in sources :

Example 1 with ActionResource

use of org.pentaho.actionsequence.dom.ActionResource 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;
}
Also used : JFreeReportAction(org.pentaho.actionsequence.dom.actions.JFreeReportAction) MasterReport(org.pentaho.reporting.engine.classic.core.MasterReport) ReportGenerator(org.pentaho.reporting.engine.classic.core.modules.parser.base.ReportGenerator) InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) IActionResource(org.pentaho.actionsequence.dom.IActionResource) ActionResource(org.pentaho.actionsequence.dom.ActionResource) IActionSequenceResource(org.pentaho.platform.api.engine.IActionSequenceResource)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 ActionResource (org.pentaho.actionsequence.dom.ActionResource)1 IActionResource (org.pentaho.actionsequence.dom.IActionResource)1 JFreeReportAction (org.pentaho.actionsequence.dom.actions.JFreeReportAction)1 IActionSequenceResource (org.pentaho.platform.api.engine.IActionSequenceResource)1 MasterReport (org.pentaho.reporting.engine.classic.core.MasterReport)1 ReportGenerator (org.pentaho.reporting.engine.classic.core.modules.parser.base.ReportGenerator)1 InputSource (org.xml.sax.InputSource)1