Search in sources :

Example 6 with JFreeReportAction

use of org.pentaho.actionsequence.dom.actions.JFreeReportAction 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;
}
Also used : JFreeReportAction(org.pentaho.actionsequence.dom.actions.JFreeReportAction) MasterReport(org.pentaho.reporting.engine.classic.core.MasterReport) IActionResource(org.pentaho.actionsequence.dom.IActionResource) ReportGenerator(org.pentaho.reporting.engine.classic.core.modules.parser.base.ReportGenerator) PrintException(javax.print.PrintException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ContentIOException(org.pentaho.reporting.libraries.repository.ContentIOException) ReportProcessingException(org.pentaho.reporting.engine.classic.core.ReportProcessingException) ResourceException(org.pentaho.reporting.libraries.resourceloader.ResourceException) IOException(java.io.IOException) URL(java.net.URL) IActionSequenceResource(org.pentaho.platform.api.engine.IActionSequenceResource)

Example 7 with JFreeReportAction

use of org.pentaho.actionsequence.dom.actions.JFreeReportAction in project pentaho-platform by pentaho.

the class JFreeReportComponent method getReport.

public MasterReport getReport() throws Exception {
    JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
    MasterReport report = getReportFromResource();
    if (report == null) {
        report = getReportFromInputParam();
        if (report == null) {
            report = getReportFromJar();
        }
    }
    if ((report != null) && jFreeReportAction.getCreatePrivateCopy().getBooleanValue(false)) {
        report = (MasterReport) report.clone();
    }
    return report;
}
Also used : JFreeReportAction(org.pentaho.actionsequence.dom.actions.JFreeReportAction) MasterReport(org.pentaho.reporting.engine.classic.core.MasterReport)

Example 8 with JFreeReportAction

use of org.pentaho.actionsequence.dom.actions.JFreeReportAction in project pentaho-platform by pentaho.

the class JFreeReportComponent method initReportInputs.

private boolean initReportInputs(final MasterReport report) throws CloneNotSupportedException {
    JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
    // Get input parameters, and set them as properties in the report
    // object.
    IActionInput[] actionInputs = jFreeReportAction.getInputs();
    for (IActionInput element : actionInputs) {
        String paramName = element.getName();
        Object paramValue = element.getValue();
        if ((paramValue == null) || "".equals(paramValue)) {
            // $NON-NLS-1$
            continue;
        }
        if (paramValue instanceof IPentahoResultSet) {
            continue;
        }
        if (paramValue instanceof TableModel) {
            continue;
        }
        if (AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_OBJINPUT.equals(paramName)) {
            continue;
        }
        if (AbstractJFreeReportComponent.DATACOMPONENT_REPORTTEMP_DATAINPUT.equals(paramName)) {
            continue;
        }
        if (AbstractJFreeReportComponent.DATACOMPONENT_DATAINPUT.equals(paramName)) {
            continue;
        }
        /*
       * WG: Commenting out because this change (SVN: 44880) breaks bi-developers / reporting / subreport.xaction we'll
       * need to revisit this when reving to the 4.0 reporting engine.
       * 
       * final ParameterDefinitionEntry[] parameterDefinitions =
       * report.getParameterDefinition().getParameterDefinitions(); boolean foundParameter = false; for (int j = 0; j <
       * parameterDefinitions.length; j++) { final ParameterDefinitionEntry definition = parameterDefinitions[j]; if
       * (paramName.equals(definition.getName())) { foundParameter = true; break; } } if (foundParameter == false) { if
       * (report.getParameterDefinition() instanceof ModifiableReportParameterDefinition) { final
       * ModifiableReportParameterDefinition parameterDefinition = (ModifiableReportParameterDefinition)
       * report.getParameterDefinition(); parameterDefinition.addParameterDefinition(new PlainParameter(paramName)); } }
       */
        if (paramValue instanceof Object[]) {
            Object[] values = (Object[]) paramValue;
            StringBuffer valuesBuffer = new StringBuffer();
            // TODO support non-string items
            for (int j = 0; j < values.length; j++) {
                if (j == 0) {
                    valuesBuffer.append(values[j].toString());
                } else {
                    valuesBuffer.append(',').append(values[j].toString());
                }
            }
            report.getParameterValues().put(paramName, valuesBuffer.toString());
        // report.setProperty(paramName, valuesBuffer.toString());
        } else {
            report.getParameterValues().put(paramName, paramValue);
        // report.setProperty(paramName, paramValue);
        }
    }
    return true;
}
Also used : JFreeReportAction(org.pentaho.actionsequence.dom.actions.JFreeReportAction) IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) IActionInput(org.pentaho.actionsequence.dom.IActionInput) TableModel(javax.swing.table.TableModel) PentahoTableModel(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableModel)

Example 9 with JFreeReportAction

use of org.pentaho.actionsequence.dom.actions.JFreeReportAction in project pentaho-platform by pentaho.

the class JFreeReportComponent method initReportParams.

private int initReportParams() {
    JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
    int result = JFreeReportComponent.INIT_REPORT_PARAMS_STATUS_PASSED;
    // $NON-NLS-1$
    final String defaultValue = "";
    IActionInput[] actionInputs = jFreeReportAction.getInputs();
    for (IActionInput element : actionInputs) {
        Object paramValue = element.getValue();
        String inputName = element.getName();
        if (// $NON-NLS-1$
        (paramValue == null) || ("".equals(paramValue))) {
            IActionParameter paramParameter = getInputParameter(inputName);
            if (paramParameter.getPromptStatus() == IActionParameter.PROMPT_PENDING) {
                result = JFreeReportComponent.INIT_REPORT_PARAMS_STATUS_PROMPT_PENDING;
                continue;
            }
            if (isParameterUIAvailable()) {
                // The parameter value was not provided, and we are allowed
                // to
                // create user interface forms
                // $NON-NLS-1$
                createFeedbackParameter(inputName, inputName, "", defaultValue, true);
                result = JFreeReportComponent.INIT_REPORT_PARAMS_STATUS_PROMPT_PENDING;
            } else {
                result = JFreeReportComponent.INIT_REPORT_PARAMS_STATUS_FAILED;
            }
        }
    }
    return result;
}
Also used : JFreeReportAction(org.pentaho.actionsequence.dom.actions.JFreeReportAction) IActionInput(org.pentaho.actionsequence.dom.IActionInput) IActionParameter(org.pentaho.platform.api.engine.IActionParameter)

Example 10 with JFreeReportAction

use of org.pentaho.actionsequence.dom.actions.JFreeReportAction in project pentaho-platform by pentaho.

the class ReportWizardSpecComponent method getReportSpec.

@SuppressWarnings("deprecation")
public ReportSpec getReportSpec() throws IOException {
    JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
    DataSource dataSource = new ActivationHelper.PentahoStreamSourceWrapper(jFreeReportAction.getReportDefinitionDataSource());
    ReportSpec reportSpec = null;
    reportSpec = loadFromZip(dataSource.getInputStream());
    if (reportSpec == null) {
        dataSource = new ActivationHelper.PentahoStreamSourceWrapper(jFreeReportAction.getReportDefinitionDataSource());
        reportSpec = (ReportSpec) CastorUtility.getInstance().readCastorObject(dataSource.getInputStream(), ReportSpec.class);
    }
    return reportSpec;
}
Also used : JFreeReportAction(org.pentaho.actionsequence.dom.actions.JFreeReportAction) ReportSpec(org.pentaho.jfreereport.castormodel.reportspec.ReportSpec) ActivationHelper(org.pentaho.commons.connection.ActivationHelper) DataSource(javax.activation.DataSource)

Aggregations

JFreeReportAction (org.pentaho.actionsequence.dom.actions.JFreeReportAction)14 IActionInput (org.pentaho.actionsequence.dom.IActionInput)5 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)4 PentahoTableModel (org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableModel)4 MasterReport (org.pentaho.reporting.engine.classic.core.MasterReport)4 TableModel (javax.swing.table.TableModel)3 IActionResource (org.pentaho.actionsequence.dom.IActionResource)3 PentahoTableDataFactory (org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 DataSource (javax.activation.DataSource)2 PrintException (javax.print.PrintException)2 ActionInput (org.pentaho.actionsequence.dom.ActionInput)2 IActionSequenceResource (org.pentaho.platform.api.engine.IActionSequenceResource)2 IContentItem (org.pentaho.platform.api.repository.IContentItem)2 ReportProcessingException (org.pentaho.reporting.engine.classic.core.ReportProcessingException)2 ReportGenerator (org.pentaho.reporting.engine.classic.core.modules.parser.base.ReportGenerator)2 ContentIOException (org.pentaho.reporting.libraries.repository.ContentIOException)2