Class PmdDataFactory

  • 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 PmdDataFactory
    extends SimplePmdDataFactory
    Performs MQL queries. A MQL-query usually contains all information needed to connect to the database. However the platform also allows to override the connection-information and to provide an own connection instead.

    We mirror that case by allowing to provide a connection provider. If no connection provider is given, we use whatever connection information is stored in the MQL data itself.

    Author:
    Thomas Morgner
    See Also:
    Serialized Form
    • Constructor Detail

      • PmdDataFactory

        public PmdDataFactory()
    • Method Detail

      • 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.
        Specified by:
        isQueryExecutable in interface org.pentaho.reporting.engine.classic.core.DataFactory
        Overrides:
        isQueryExecutable in class SimplePmdDataFactory
        Parameters:
        query - the query.
        parameters - the parameters.
        Returns:
        true, if the query would be executable, false if the query is not recognized.
      • setQuery

        public void setQuery​(String name,
                             String queryString)
        Parameters:
        name -
        queryString -
      • setQuery

        public void setQuery​(String name,
                             String queryString,
                             String queryScriptLanguage,
                             String queryScript)
      • remove

        public void remove​(String name)
      • getGlobalScriptLanguage

        public String getGlobalScriptLanguage()
      • setGlobalScriptLanguage

        public void setGlobalScriptLanguage​(String scriptLanguage)
      • getGlobalScript

        public String getGlobalScript()
      • setGlobalScript

        public void setGlobalScript​(String globalScript)
      • getScriptingLanguage

        public String getScriptingLanguage​(String name)
      • getQueryNames

        public String[] getQueryNames()
        Specified by:
        getQueryNames in interface org.pentaho.reporting.engine.classic.core.DataFactory
        Overrides:
        getQueryNames in class SimplePmdDataFactory
      • initialize

        public void initialize​(org.pentaho.reporting.engine.classic.core.DataFactoryContext dataFactoryContext)
                        throws org.pentaho.reporting.engine.classic.core.ReportDataFactoryException
        Specified by:
        initialize in interface org.pentaho.reporting.engine.classic.core.DataFactory
        Overrides:
        initialize in class org.pentaho.reporting.engine.classic.core.AbstractDataFactory
        Throws:
        org.pentaho.reporting.engine.classic.core.ReportDataFactoryException
      • queryData

        public TableModel queryData​(String queryName,
                                    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.

        Specified by:
        queryData in interface org.pentaho.reporting.engine.classic.core.DataFactory
        Overrides:
        queryData in class SimplePmdDataFactory
        Parameters:
        queryName - the query name
        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 occured while performing the query.
      • queryDesignTimeStructure

        public TableModel queryDesignTimeStructure​(String queryName,
                                                   org.pentaho.reporting.engine.classic.core.DataRow parameters)
                                            throws org.pentaho.reporting.engine.classic.core.ReportDataFactoryException
        Specified by:
        queryDesignTimeStructure in interface org.pentaho.reporting.engine.classic.core.DataFactoryDesignTimeSupport
        Overrides:
        queryDesignTimeStructure in class SimplePmdDataFactory
        Throws:
        org.pentaho.reporting.engine.classic.core.ReportDataFactoryException
      • computedQuery

        protected String computedQuery​(String queryName,
                                       org.pentaho.reporting.engine.classic.core.DataRow parameters)
                                throws org.pentaho.reporting.engine.classic.core.ReportDataFactoryException
        Overrides:
        computedQuery in class SimplePmdDataFactory
        Throws:
        org.pentaho.reporting.engine.classic.core.ReportDataFactoryException
      • getReferencedFields

        public String[] getReferencedFields​(String query,
                                            org.pentaho.reporting.engine.classic.core.DataRow parameter)
                                     throws org.pentaho.reporting.engine.classic.core.ReportDataFactoryException
        Specified by:
        getReferencedFields in interface org.pentaho.reporting.engine.classic.core.DataFactoryMetaProvider
        Overrides:
        getReferencedFields in class SimplePmdDataFactory
        Throws:
        org.pentaho.reporting.engine.classic.core.ReportDataFactoryException
      • getQueryHash

        public ArrayList<Object> getQueryHash​(String queryName,
                                              org.pentaho.reporting.engine.classic.core.DataRow parameters)
        Specified by:
        getQueryHash in interface org.pentaho.reporting.engine.classic.core.DataFactoryMetaProvider
        Overrides:
        getQueryHash in class SimplePmdDataFactory
      • clone

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

        public void close()
        Description copied from class: SimplePmdDataFactory
        Closes the data factory and frees all resources held by this instance.
        Specified by:
        close in interface org.pentaho.reporting.engine.classic.core.DataFactory
        Overrides:
        close in class SimplePmdDataFactory