Search in sources :

Example 1 with PentahoTableDataFactory

use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory in project pentaho-platform by pentaho.

the class JFreeReportComponent method getDataFactory.

protected PentahoTableDataFactory getDataFactory() throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
    PentahoTableDataFactory factory = null;
    factory = getQueryComponentDataFactory();
    if (factory == null) {
        factory = getInputParamDataFactory();
    }
    if (factory == null) {
        factory = getJarDataFactory();
    }
    if (factory == null) {
        // $NON-NLS-1$
        throw new Exception(Messages.getInstance().getString("JFreeReport.ERROR_0022_DATA_INPUT_INVALID_OBJECT"));
    }
    return factory;
}
Also used : PentahoTableDataFactory(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory) 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)

Example 2 with PentahoTableDataFactory

use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory in project pentaho-platform by pentaho.

the class JFreeReportComponent method getInputParamDataFactory.

private PentahoTableDataFactory getInputParamDataFactory() {
    PentahoTableDataFactory factory = null;
    JFreeReportAction jFreeReportAction = (JFreeReportAction) getActionDefinition();
    ActionInput reportDataParam = (ActionInput) jFreeReportAction.getData();
    Object dataObject = reportDataParam != null ? reportDataParam.getValue() : null;
    if ((dataObject instanceof IPentahoResultSet) || (dataObject instanceof TableModel)) {
        factory = new PentahoTableDataFactory();
        if (dataObject instanceof IPentahoResultSet) {
            IPentahoResultSet resultset = (IPentahoResultSet) dataObject;
            if (resultset.isScrollable()) {
                resultset.beforeFirst();
            } else {
                // $NON-NLS-1$
                debug("ResultSet is not scrollable. Copying into memory");
                IPentahoResultSet memSet = resultset.memoryCopy();
                resultset.close();
                resultset = memSet;
            }
            factory.addTable(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, new PentahoTableModel(resultset));
        } else if (dataObject instanceof TableModel) {
            factory.addTable(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, (TableModel) dataObject);
        }
        IActionInput[] subreportQueries = jFreeReportAction.getSubreportQueryParams();
        for (IActionInput element : subreportQueries) {
            dataObject = element.getValue();
            if (dataObject instanceof IPreparedComponent) {
                factory.addPreparedComponent(element.getName(), (IPreparedComponent) dataObject);
            } else if (dataObject instanceof IPentahoResultSet) {
                final IPentahoResultSet resultset = (IPentahoResultSet) dataObject;
                resultset.beforeFirst();
                factory.addTable(element.getName(), new PentahoTableModel(resultset));
            } else if (dataObject instanceof TableModel) {
                factory.addTable(element.getName(), (TableModel) dataObject);
            }
        }
    }
    return factory;
}
Also used : JFreeReportAction(org.pentaho.actionsequence.dom.actions.JFreeReportAction) PentahoTableModel(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableModel) IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) ActionInput(org.pentaho.actionsequence.dom.ActionInput) IActionInput(org.pentaho.actionsequence.dom.IActionInput) IActionInput(org.pentaho.actionsequence.dom.IActionInput) PentahoTableDataFactory(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory) TableModel(javax.swing.table.TableModel) PentahoTableModel(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableModel) IPreparedComponent(org.pentaho.platform.api.data.IPreparedComponent)

Example 3 with PentahoTableDataFactory

use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory in project pentaho-platform by pentaho.

the class ReportWizardSpecComponent method getDataFactory.

@Override
protected PentahoTableDataFactory getDataFactory() throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
    PentahoTableDataFactory factory = null;
    if (reportSpec != null) {
        if (!isDefinedInput(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTTEMP_PERFQRY) || "true".equals(getInputParameter(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTTEMP_PERFQRY))) {
            // $NON-NLS-1$
            IPentahoResultSet pentahoResultSet = getResultSet(getReportSpec());
            factory = new PentahoTableDataFactory();
            pentahoResultSet.beforeFirst();
            factory.addTable(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, new PentahoTableModel(pentahoResultSet));
        } else {
            factory = super.getDataFactory();
        }
    } else {
        factory = super.getDataFactory();
    }
    return factory;
}
Also used : PentahoTableModel(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableModel) IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) PentahoTableDataFactory(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory)

Example 4 with PentahoTableDataFactory

use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory in project pentaho-platform by pentaho.

the class JFreeReportDataComponent method getInputParamDataFactory.

@SuppressWarnings("unused")
private PentahoTableDataFactory getInputParamDataFactory() {
    PentahoTableDataFactory factory = null;
    if (isDefinedInput(AbstractJFreeReportComponent.DATACOMPONENT_DATAINPUT) || isDefinedInput(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT)) {
        factory = new PentahoTableDataFactory();
        final Iterator iter = getInputNames().iterator();
        while (iter.hasNext()) {
            String name = (String) iter.next();
            final Object dataObject = getInputValue(name);
            // if input name is "data", rename to "default" which is the name that jfreereport is expecting.
            if (name.equals(AbstractJFreeReportComponent.DATACOMPONENT_DATAINPUT)) {
                name = AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT;
            }
            if (dataObject instanceof IPreparedComponent) {
                final IPreparedComponent comp = (IPreparedComponent) dataObject;
                factory.addPreparedComponent(name, comp);
            } else if (dataObject instanceof IPentahoResultSet) {
                final IPentahoResultSet resultset = (IPentahoResultSet) dataObject;
                resultset.beforeFirst();
                factory.addTable(name, new PentahoTableModel(resultset));
            } else if (dataObject instanceof TableModel) {
                final TableModel model = (TableModel) dataObject;
                factory.addTable(name, model);
            }
        }
    }
    return factory;
}
Also used : PentahoTableModel(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableModel) IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) PentahoTableDataFactory(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory) Iterator(java.util.Iterator) IPreparedComponent(org.pentaho.platform.api.data.IPreparedComponent) PentahoTableModel(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableModel) TableModel(javax.swing.table.TableModel)

Example 5 with PentahoTableDataFactory

use of org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory in project pentaho-platform by pentaho.

the class JFreeReportDataComponent method getQueryComponentDataFactory.

@SuppressWarnings("unused")
private PentahoTableDataFactory getQueryComponentDataFactory() throws ClassNotFoundException, InstantiationException, IllegalAccessException, Exception {
    PentahoTableDataFactory factory = null;
    dataComponent = null;
    final Node sourceNode = getComponentDefinition().selectSingleNode(AbstractJFreeReportComponent.DATACOMPONENT_SOURCE);
    if (sourceNode != null) {
        String dataComponentClass = sourceNode.getText();
        if (AbstractJFreeReportComponent.DATACOMPONENT_SQLSOURCE.equalsIgnoreCase(dataComponentClass)) {
            dataComponentClass = AbstractJFreeReportComponent.DATACOMPONENT_SQLCLASS;
        } else if (AbstractJFreeReportComponent.DATACOMPONENT_MDXSOURCE.equalsIgnoreCase(dataComponentClass)) {
            dataComponentClass = AbstractJFreeReportComponent.DATACOMPONENT_MDXCLASS;
        }
        if (dataComponentClass != null) {
            try {
                final Class componentClass = Class.forName(dataComponentClass);
                dataComponent = (IDataComponent) componentClass.newInstance();
                dataComponent.setInstanceId(getInstanceId());
                dataComponent.setActionName(getActionName());
                dataComponent.setProcessId(getProcessId());
                dataComponent.setComponentDefinition(getComponentDefinition());
                dataComponent.setRuntimeContext(getRuntimeContext());
                dataComponent.setSession(getSession());
                dataComponent.setLoggingLevel(getLoggingLevel());
                dataComponent.setMessages(getMessages());
                // Abort, we cant continue anyway.
                if ((dataComponent.validate() == IRuntimeContext.RUNTIME_CONTEXT_VALIDATE_OK) && dataComponent.init() && (dataComponent.execute() == IRuntimeContext.RUNTIME_STATUS_SUCCESS)) {
                    final IPentahoResultSet resultset = dataComponent.getResultSet();
                    factory = new PentahoTableDataFactory(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, new PentahoTableModel(resultset));
                } else {
                    throw new IllegalArgumentException(Messages.getInstance().getErrorString(// $NON-NLS-1$
                    "JFreeReport.ERROR_0021_DATA_COMPONENT_FAILED"));
                }
            } catch (ClassNotFoundException e) {
            // ignore
            } catch (InstantiationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    return factory;
}
Also used : PentahoTableModel(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableModel) IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) PentahoTableDataFactory(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory) Node(org.dom4j.Node)

Aggregations

PentahoTableDataFactory (org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory)8 PentahoTableModel (org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableModel)7 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)6 TableModel (javax.swing.table.TableModel)4 FileNotFoundException (java.io.FileNotFoundException)3 JFreeReportAction (org.pentaho.actionsequence.dom.actions.JFreeReportAction)3 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Iterator (java.util.Iterator)2 PrintException (javax.print.PrintException)2 IActionInput (org.pentaho.actionsequence.dom.IActionInput)2 IPreparedComponent (org.pentaho.platform.api.data.IPreparedComponent)2 PentahoDataFactory (org.pentaho.platform.plugin.action.jfreereport.helper.PentahoDataFactory)2 DataFactory (org.pentaho.reporting.engine.classic.core.DataFactory)2 ParameterDataRow (org.pentaho.reporting.engine.classic.core.ParameterDataRow)2 ReportProcessingException (org.pentaho.reporting.engine.classic.core.ReportProcessingException)2 ReportParameterValues (org.pentaho.reporting.engine.classic.core.util.ReportParameterValues)2 ContentIOException (org.pentaho.reporting.libraries.repository.ContentIOException)2 ResourceException (org.pentaho.reporting.libraries.resourceloader.ResourceException)2