Class ScriptableDataFactory

  • All Implemented Interfaces:
    Serializable, Cloneable, org.pentaho.reporting.engine.classic.core.DataFactory, org.pentaho.reporting.engine.classic.core.DataFactoryDesignTimeSupport, org.pentaho.reporting.engine.classic.core.DataFactoryMetaProvider

    public class ScriptableDataFactory
    extends org.pentaho.reporting.engine.classic.core.AbstractDataFactory
    A datafactory that uses a bean-scripting framework script to produce a tablemodel.
    Author:
    Thomas Morgner
    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class org.pentaho.reporting.engine.classic.core.AbstractDataFactory

        org.pentaho.reporting.engine.classic.core.AbstractDataFactory.DataRowWrapper
    • Field Summary

      • Fields inherited from interface org.pentaho.reporting.engine.classic.core.DataFactory

        QUERY_LIMIT, QUERY_SORT, QUERY_TIMEOUT
      • Fields inherited from interface org.pentaho.reporting.engine.classic.core.DataFactoryDesignTimeSupport

        DESIGN_TIME
    • Constructor Detail

      • ScriptableDataFactory

        public ScriptableDataFactory()
    • Method Detail

      • getLanguage

        public String getLanguage()
      • setLanguage

        public void setLanguage​(String language)
      • setQuery

        public void setQuery​(String name,
                             String value)
      • getScript

        public String getScript()
      • setScript

        public void setScript​(String script)
      • getShutdownScript

        public String getShutdownScript()
      • setShutdownScript

        public void setShutdownScript​(String shutdownScript)
      • getQueryNames

        public String[] getQueryNames()
      • createInterpreter

        protected org.apache.bsf.BSFManager createInterpreter()
                                                       throws org.apache.bsf.BSFException
        Creates a new interpreter instance.
        Returns:
        the interpreter or null, if there was an error.
        Throws:
        org.apache.bsf.BSFException
      • initializeInterpreter

        protected void initializeInterpreter​(org.apache.bsf.BSFManager interpreter)
                                      throws org.apache.bsf.BSFException
        Initializes the Bean-Scripting Framework manager.
        Parameters:
        interpreter - the BSF-Manager that should be initialized.
        Throws:
        org.apache.bsf.BSFException - if an error occurred.
      • queryData

        public TableModel queryData​(String query,
                                    org.pentaho.reporting.engine.classic.core.DataRow parameters)
                             throws org.pentaho.reporting.engine.classic.core.ReportDataFactoryException
        Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain more data than actually needed for the query.

        The parameter-dataset may change between two calls, do not assume anything, and do not hold references to the parameter-dataset or the position of the columns in the dataset.

        Parameters:
        query - the query string
        parameters - the parameters for the query
        Returns:
        the result of the query as table model.
        Throws:
        org.pentaho.reporting.engine.classic.core.ReportDataFactoryException - if an error occurred while performing the query.
      • clone

        public ScriptableDataFactory clone()
        Specified by:
        clone in interface org.pentaho.reporting.engine.classic.core.DataFactory
        Overrides:
        clone in class org.pentaho.reporting.engine.classic.core.AbstractDataFactory
      • derive

        public org.pentaho.reporting.engine.classic.core.DataFactory derive()
        Returns a copy of the data factory that is not affected by its ancestor and holds no connection to the ancestor anymore. A data-factory will be derived at the beginning of the report processing.
        Specified by:
        derive in interface org.pentaho.reporting.engine.classic.core.DataFactory
        Overrides:
        derive in class org.pentaho.reporting.engine.classic.core.AbstractDataFactory
        Returns:
        a copy of the data factory.
      • close

        public void close()
        Closes the data factory and frees all resources held by this instance.
      • isQueryExecutable

        public boolean isQueryExecutable​(String query,
                                         org.pentaho.reporting.engine.classic.core.DataRow parameters)
        Checks whether the query would be executable by this datafactory. This performs a rough check, not a full query.
        Parameters:
        query -
        parameters -
        Returns:
      • cancelRunningQuery

        public void cancelRunningQuery()
        Specified by:
        cancelRunningQuery in interface org.pentaho.reporting.engine.classic.core.DataFactory
        Overrides:
        cancelRunningQuery in class org.pentaho.reporting.engine.classic.core.AbstractDataFactory