Class NamedStaticDataFactory
- java.lang.Object
-
- org.pentaho.reporting.engine.classic.core.AbstractDataFactory
-
- org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.StaticDataFactory
-
- org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.NamedStaticDataFactory
-
- All Implemented Interfaces:
Serializable
,Cloneable
,DataFactory
,DataFactoryDesignTimeSupport
,DataFactoryMetaProvider
public class NamedStaticDataFactory extends StaticDataFactory
A NamedStaticDataFactory provides an query-aliasing facility to decouple the report definitions from the underlying datasource implentation. The reports no longer need to specify the raw-query (which is in fact just an implementation detail) and can use a symbolic name in the report definition instead.- Author:
- Thomas Morgner
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.pentaho.reporting.engine.classic.core.AbstractDataFactory
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 Summary
Constructors Constructor Description NamedStaticDataFactory()
Defaultconstructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NamedStaticDataFactory
clone()
Returns a clone of the factory.DataFactory
derive()
Derives the factory.String
getQuery(String name)
Returns the query for the given alias-name or null, if there is no such alias defined.String[]
getQueryNames()
Returns all known alias-names.boolean
isQueryExecutable(String query, DataRow parameters)
Checks whether the query would be executable by this datafactory.TableModel
queryData(String query, DataRow parameters)
Queries a datasource.void
setQuery(String alias, String queryString)
Adds an query-alias to this factory.String
translateQuery(String queryName)
-
Methods inherited from class org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.StaticDataFactory
close, getClassLoader, getParameterFields
-
Methods inherited from class org.pentaho.reporting.engine.classic.core.AbstractDataFactory
calculateQueryLimit, calculateQueryTimeOut, cancelRunningQuery, getConfiguration, getContextKey, getDataFactoryContext, getDisplayConnectionName, getLocale, getMetaData, getQueryHash, getReferencedFields, getResourceBundleFactory, getResourceManager, initialize, queryDesignTimeStructure
-
-
-
-
Method Detail
-
isQueryExecutable
public boolean isQueryExecutable(String query, 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 interfaceDataFactory
- Overrides:
isQueryExecutable
in classStaticDataFactory
- Parameters:
query
-parameters
-- Returns:
-
setQuery
public void setQuery(String alias, String queryString)
Adds an query-alias to this factory.- Parameters:
alias
- the aliasqueryString
- the real query string that should be used when the alias is specified as query.
-
derive
public DataFactory derive()
Derives the factory. The derived factory does no longer share properties with its parent and changes to either factory will not be reflected in the other factory.- Specified by:
derive
in interfaceDataFactory
- Overrides:
derive
in classStaticDataFactory
- Returns:
- the derived factory.
-
clone
public NamedStaticDataFactory clone()
Returns a clone of the factory.- Specified by:
clone
in interfaceDataFactory
- Overrides:
clone
in classAbstractDataFactory
- Returns:
- the clone.
-
queryData
public TableModel queryData(String query, DataRow parameters) throws ReportDataFactoryException
Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain more data than actually needed. The dataset may change between two calls, do not assume anything!- Specified by:
queryData
in interfaceDataFactory
- Overrides:
queryData
in classStaticDataFactory
- Parameters:
query
- the alias-name of the query.parameters
- the set of parameters.- Returns:
- the tablemodel.
- Throws:
ReportDataFactoryException
- if an error occured while performing the query.
-
getQuery
public String getQuery(String name)
Returns the query for the given alias-name or null, if there is no such alias defined.- Parameters:
name
- the alias name.- Returns:
- the real query or null.
-
getQueryNames
public String[] getQueryNames()
Returns all known alias-names.- Specified by:
getQueryNames
in interfaceDataFactory
- Overrides:
getQueryNames
in classStaticDataFactory
- Returns:
- all alias-names as string-array.
-
translateQuery
public String translateQuery(String queryName)
- Overrides:
translateQuery
in classStaticDataFactory
-
-