Class TableDataFactory
- java.lang.Object
-
- org.pentaho.reporting.engine.classic.core.AbstractDataFactory
-
- org.pentaho.reporting.engine.classic.core.TableDataFactory
-
- All Implemented Interfaces:
Serializable
,Cloneable
,DataFactory
,DataFactoryDesignTimeSupport
,DataFactoryMetaProvider
public class TableDataFactory extends AbstractDataFactory
The TableDataFactory provides keyed access to predefined tablemodels. The factory does not accept parameters and therefore cannot be used for parametrized queries. The queryname is used to lookup the table by its previously registered name.- 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 TableDataFactory()
Default Constructor.TableDataFactory(String name, TableModel tableModel)
Creates a new TableDataFactory and registers the tablemodel with the given name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addTable(String name, TableModel tableModel)
Registers a tablemodel with the given name.TableDataFactory
clone()
Creates a copy of this data-factory.void
close()
Closes the data factory.DataFactory
derive()
Returns a copy of the data factory that is not affected by its anchestor and holds no connection to the anchestor anymore.String[]
getQueryNames()
Returns all known query-names.TableModel
getTable(String name)
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
removeTable(String name)
Removes the table that has been registered by the given name.-
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
-
-
-
-
Constructor Detail
-
TableDataFactory
public TableDataFactory()
Default Constructor.
-
TableDataFactory
public TableDataFactory(String name, TableModel tableModel)
Creates a new TableDataFactory and registers the tablemodel with the given name.- Parameters:
name
- the name of the table.tableModel
- the tablemodel.
-
-
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.- Parameters:
query
-parameters
-- Returns:
-
addTable
public void addTable(String name, TableModel tableModel)
Registers a tablemodel with the given name. If a different tablemodel has been previously registered with the same name, this table will replace the existing one.- Parameters:
name
- the name of the table.tableModel
- the tablemodel that should be registered.
-
removeTable
public void removeTable(String name)
Removes the table that has been registered by the given name.- Parameters:
name
- the name of the table to be removed.
-
getTable
public TableModel getTable(String name)
-
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!- Parameters:
query
- the name of the table.parameters
- are ignored for this factory.- Returns:
- the report data or null.
- Throws:
ReportDataFactoryException
- if an error occured while performing the query.
-
close
public void close()
Closes the data factory. Actually, this one does nothing at all.
-
derive
public DataFactory derive()
Returns a copy of the data factory that is not affected by its anchestor and holds no connection to the anchestor anymore. A data-factory will be derived at the beginning of the report processing.- Specified by:
derive
in interfaceDataFactory
- Overrides:
derive
in classAbstractDataFactory
- Returns:
- a copy of the data factory.
-
clone
public TableDataFactory clone()
Creates a copy of this data-factory.- Specified by:
clone
in interfaceDataFactory
- Overrides:
clone
in classAbstractDataFactory
- Returns:
- the copy of the data-factory, never null.
-
getQueryNames
public String[] getQueryNames()
Description copied from interface:DataFactory
Returns all known query-names. A data-factory may accept more than the query-names returned here.- Returns:
- the known query names.
-
-