Search in sources :

Example 21 with IActionSequenceResource

use of org.pentaho.platform.api.engine.IActionSequenceResource in project pentaho-platform by pentaho.

the class ActionSequenceParameterMgr method getString.

public String getString(final IActionResource actionResource) throws IOException {
    String resourceString = null;
    IActionSequenceResource resource = runtimeContext.getResourceDefintion(actionResource.getName());
    if (resource != null) {
        resourceString = runtimeContext.getResourceAsString(resource);
    }
    return resourceString;
}
Also used : IActionSequenceResource(org.pentaho.platform.api.engine.IActionSequenceResource)

Example 22 with IActionSequenceResource

use of org.pentaho.platform.api.engine.IActionSequenceResource in project pentaho-platform by pentaho.

the class ActionSequenceParameterMgr method getInputStream.

public InputStream getInputStream(final IActionResource actionResource) throws FileNotFoundException {
    InputStream inputStream = null;
    IActionSequenceResource resource = runtimeContext.getResourceDefintion(actionResource.getName());
    if (resource != null) {
        inputStream = resource.getInputStream(RepositoryFilePermission.READ, LocaleHelper.getLocale());
    }
    return inputStream;
}
Also used : InputStream(java.io.InputStream) IActionSequenceResource(org.pentaho.platform.api.engine.IActionSequenceResource)

Example 23 with IActionSequenceResource

use of org.pentaho.platform.api.engine.IActionSequenceResource in project pentaho-platform by pentaho.

the class HQLBaseComponent method getCatalog.

/*
   * Utility function to get the catalog info from hibernate config.
   */
private String getCatalog() {
    IActionResource hibernateConfigRes = ((HQLConnectionAction) getActionDefinition()).getHibernateConfigResource();
    String catalog = null;
    String resAddress = null;
    if (hibernateConfigRes != null) {
        String resName = this.applyInputsToFormat(hibernateConfigRes.getName());
        IActionSequenceResource resource = getResource(resName);
        resAddress = resource.getAddress();
        if (resAddress != null) {
            catalog = this.applyInputsToFormat(resAddress);
        }
    }
    return catalog;
}
Also used : IActionResource(org.pentaho.actionsequence.dom.IActionResource) HQLConnectionAction(org.pentaho.actionsequence.dom.actions.HQLConnectionAction) IActionSequenceResource(org.pentaho.platform.api.engine.IActionSequenceResource)

Example 24 with IActionSequenceResource

use of org.pentaho.platform.api.engine.IActionSequenceResource in project pentaho-platform by pentaho.

the class JFreeReportDataComponent method getJarDataFactory.

@SuppressWarnings("unused")
private PentahoTableDataFactory getJarDataFactory() throws Exception {
    PentahoTableDataFactory factory = null;
    if (isDefinedResource(AbstractJFreeReportComponent.DATACOMPONENT_JARINPUT)) {
        final IActionSequenceResource resource = getResource(AbstractJFreeReportComponent.DATACOMPONENT_JARINPUT);
        final InputStream in;
        try {
            in = resource.getInputStream(RepositoryFilePermission.READ, LocaleHelper.getLocale());
            try {
                // not being able to read a single char is definitly a big boo ..
                if (in.read() == -1) {
                    // $NON-NLS-1$
                    throw new Exception(Messages.getInstance().getErrorString("JFreeReport.ERROR_0009_REPORT_JAR_UNREADABLE"));
                } else {
                    final ClassLoader loader = ReportUtils.createJarLoader(getSession(), resource);
                    if (loader == null) {
                        throw new Exception(Messages.getInstance().getString(// $NON-NLS-1$
                        "JFreeReportDataComponent.ERROR_0035_COULD_NOT_CREATE_CLASSLOADER"));
                    } else if (!isDefinedInput(AbstractJFreeReportComponent.DATACOMPONENT_CLASSLOCINPUT)) {
                        throw new Exception(Messages.getInstance().getErrorString(// $NON-NLS-1$
                        "JFreeReport.ERROR_0012_CLASS_LOCATION_MISSING"));
                    } else {
                        final String classLocation = getInputStringValue(AbstractJFreeReportComponent.DATACOMPONENT_CLASSLOCINPUT);
                        // Get input parameters, and set them as properties in the report
                        // object.
                        final ReportParameterValues reportProperties = new ReportParameterValues();
                        final Set paramNames = getInputNames();
                        final Iterator it = paramNames.iterator();
                        while (it.hasNext()) {
                            final String paramName = (String) it.next();
                            final Object paramValue = getInputValue(paramName);
                            if (paramValue instanceof Object[]) {
                                final Object[] values = (Object[]) paramValue;
                                final StringBuffer valuesBuffer = new StringBuffer();
                                // TODO support non-string items
                                for (int i = 0; i < values.length; i++) {
                                    if (i == 0) {
                                        valuesBuffer.append(values[i].toString());
                                    } else {
                                        valuesBuffer.append(',').append(values[i].toString());
                                    }
                                }
                                reportProperties.put(paramName, valuesBuffer.toString());
                            } else {
                                reportProperties.put(paramName, paramValue);
                            }
                        }
                        final DataFactory dataFactory = new PentahoDataFactory(loader);
                        final TableModel model = dataFactory.queryData(classLocation, new ParameterDataRow(reportProperties));
                        factory = new PentahoTableDataFactory(AbstractJFreeReportComponent.DATACOMPONENT_DEFAULTINPUT, model);
                    }
                }
            } catch (Exception e) {
                // $NON-NLS-1$
                throw new Exception(Messages.getInstance().getErrorString("JFreeReport.ERROR_0009_REPORT_JAR_UNREADABLE"));
            }
        } catch (FileNotFoundException e1) {
            throw new Exception(Messages.getInstance().getErrorString("JFreeReport.ERROR_0010_REPORT_JAR_MISSING", // $NON-NLS-1$
            resource.getAddress()));
        }
    }
    return factory;
}
Also used : Set(java.util.Set) IPentahoResultSet(org.pentaho.commons.connection.IPentahoResultSet) PentahoTableDataFactory(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) PentahoTableDataFactory(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableDataFactory) DataFactory(org.pentaho.reporting.engine.classic.core.DataFactory) PentahoDataFactory(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoDataFactory) ParameterDataRow(org.pentaho.reporting.engine.classic.core.ParameterDataRow) FileNotFoundException(java.io.FileNotFoundException) IActionSequenceResource(org.pentaho.platform.api.engine.IActionSequenceResource) Iterator(java.util.Iterator) PentahoDataFactory(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoDataFactory) PentahoTableModel(org.pentaho.platform.plugin.action.jfreereport.helper.PentahoTableModel) TableModel(javax.swing.table.TableModel) ReportParameterValues(org.pentaho.reporting.engine.classic.core.util.ReportParameterValues)

Example 25 with IActionSequenceResource

use of org.pentaho.platform.api.engine.IActionSequenceResource in project pentaho-platform by pentaho.

the class JFreeReportGenerateDefinitionComponent method getReportSpec.

public ReportSpec getReportSpec() throws FileNotFoundException {
    ReportSpec reportSpec = null;
    if (isDefinedResource(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTSPECINPUT)) {
        IActionSequenceResource resource = getResource(AbstractJFreeReportComponent.REPORTGENERATEDEFN_REPORTSPECINPUT);
        reportSpec = loadFromZip(resource);
        if (reportSpec == null) {
            InputStream reportSpecInputStream = resource.getInputStream(RepositoryFilePermission.READ, LocaleHelper.getLocale());
            reportSpec = (ReportSpec) CastorUtility.getInstance().readCastorObject(reportSpecInputStream, ReportSpec.class);
        }
    }
    return reportSpec;
}
Also used : ReportSpec(org.pentaho.jfreereport.castormodel.reportspec.ReportSpec) ZipInputStream(java.util.zip.ZipInputStream) InputStream(java.io.InputStream) IActionSequenceResource(org.pentaho.platform.api.engine.IActionSequenceResource)

Aggregations

IActionSequenceResource (org.pentaho.platform.api.engine.IActionSequenceResource)28 InputStream (java.io.InputStream)10 IOException (java.io.IOException)9 ActionSequenceResource (org.pentaho.platform.engine.services.actionsequence.ActionSequenceResource)7 OutputStream (java.io.OutputStream)5 FileInputStream (java.io.FileInputStream)4 Set (java.util.Set)4 Document (org.dom4j.Document)4 Node (org.dom4j.Node)4 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)4 IActionParameter (org.pentaho.platform.api.engine.IActionParameter)4 MasterReport (org.pentaho.reporting.engine.classic.core.MasterReport)4 ReportGenerator (org.pentaho.reporting.engine.classic.core.modules.parser.base.ReportGenerator)4 BufferedInputStream (java.io.BufferedInputStream)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 File (java.io.File)3 FileNotFoundException (java.io.FileNotFoundException)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 URL (java.net.URL)3 Iterator (java.util.Iterator)3