Class CompoundDataFactory
- java.lang.Object
-
- org.pentaho.reporting.engine.classic.core.AbstractDataFactory
-
- org.pentaho.reporting.engine.classic.core.CompoundDataFactory
-
- All Implemented Interfaces:
Serializable
,Cloneable
,CompoundDataFactorySupport
,DataFactory
,DataFactoryDesignTimeSupport
,DataFactoryMetaProvider
- Direct Known Subclasses:
CascadingDataFactory
,SortingDataFactory
public class CompoundDataFactory extends AbstractDataFactory implements CompoundDataFactorySupport
The compound data factory is a collection of data-factories. Each of the child datafactories is queried in the order of their addition to the collection.- 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 CompoundDataFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, DataFactory factory)
void
add(DataFactory factory)
protected void
addRaw(DataFactory factory)
void
close()
Closes the data factory and frees all resources held by this instance.DataFactory
derive()
Returns a copy of the data factory that is not affected by its anchestor and holds no connection to the anchestor anymore.CompoundDataFactory
deriveEmpty()
DataFactory
get(int idx)
DataFactory
getDataFactoryForQuery(String queryName)
DataFactory
getDataFactoryForQuery(String queryName, boolean freeform)
String[]
getQueryNames()
Returns all known query-names.DataFactory
getReference(int idx)
protected TableModel
handleFallThrough(String query)
int
indexOfByReference(DataFactory d)
void
initialize(DataFactoryContext dataFactoryContext)
Initializes the data factory and provides new context information.boolean
isFreeFormQueryExecutable(String query, DataRow parameters)
boolean
isNormalized()
boolean
isQueryExecutable(String query, DataRow parameters)
Checks whether the query would be executable by this datafactory.boolean
isStaticQueryExecutable(String query, DataRow parameters)
static CompoundDataFactory
normalize(DataFactory dataFactory)
static CompoundDataFactory
normalize(DataFactory dataFactory, boolean derive)
protected CompoundDataFactory
normalizeInternal(boolean derive)
protected TableModel
postProcess(String query, DataRow parameters, TableModel tableModel)
TableModel
queryData(String query, DataRow parameters)
Queries a datasource.TableModel
queryDesignTimeStructure(String query, DataRow parameters)
TableModel
queryDesignTimeStructureFreeForm(String query, DataRow parameters)
TableModel
queryDesignTimeStructureStatic(String query, DataRow parameters)
TableModel
queryFreeForm(String query, DataRow parameters)
TableModel
queryStatic(String query, DataRow parameters)
void
remove(int index)
void
remove(DataFactory dataFactory)
void
set(int index, DataFactory factory)
int
size()
-
Methods inherited from class org.pentaho.reporting.engine.classic.core.AbstractDataFactory
calculateQueryLimit, calculateQueryTimeOut, cancelRunningQuery, clone, getConfiguration, getContextKey, getDataFactoryContext, getDisplayConnectionName, getLocale, getMetaData, getQueryHash, getReferencedFields, getResourceBundleFactory, getResourceManager
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.pentaho.reporting.engine.classic.core.DataFactory
cancelRunningQuery, clone, getMetaData
-
-
-
-
Method Detail
-
initialize
public void initialize(DataFactoryContext dataFactoryContext) throws ReportDataFactoryException
Description copied from interface:DataFactory
Initializes the data factory and provides new context information. Initialize is always called before the datafactory has been opened by calling DataFactory#open.- Specified by:
initialize
in interfaceDataFactory
- Overrides:
initialize
in classAbstractDataFactory
- Parameters:
dataFactoryContext
- the current data-factory context, holding the configuration, resource-manager, context-key and resource-bundle-factory.- Throws:
ReportDataFactoryException
-
queryData
public final 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 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 interfaceDataFactory
- Parameters:
query
- the query stringparameters
- the parameters for the query- Returns:
- the result of the query as table model.
- Throws:
ReportDataFactoryException
- if an error occured while performing the query.
-
queryDesignTimeStructureFreeForm
public TableModel queryDesignTimeStructureFreeForm(String query, DataRow parameters) throws ReportDataFactoryException
- Specified by:
queryDesignTimeStructureFreeForm
in interfaceCompoundDataFactorySupport
- Throws:
ReportDataFactoryException
-
queryFreeForm
public TableModel queryFreeForm(String query, DataRow parameters) throws ReportDataFactoryException
- Specified by:
queryFreeForm
in interfaceCompoundDataFactorySupport
- Throws:
ReportDataFactoryException
-
queryDesignTimeStructureStatic
public TableModel queryDesignTimeStructureStatic(String query, DataRow parameters) throws ReportDataFactoryException
- Specified by:
queryDesignTimeStructureStatic
in interfaceCompoundDataFactorySupport
- Throws:
ReportDataFactoryException
-
queryStatic
public TableModel queryStatic(String query, DataRow parameters) throws ReportDataFactoryException
- Specified by:
queryStatic
in interfaceCompoundDataFactorySupport
- Throws:
ReportDataFactoryException
-
postProcess
protected TableModel postProcess(String query, DataRow parameters, TableModel tableModel)
-
queryDesignTimeStructure
public TableModel queryDesignTimeStructure(String query, DataRow parameters) throws ReportDataFactoryException
- Specified by:
queryDesignTimeStructure
in interfaceDataFactoryDesignTimeSupport
- Overrides:
queryDesignTimeStructure
in classAbstractDataFactory
- Throws:
ReportDataFactoryException
-
handleFallThrough
protected TableModel handleFallThrough(String query) throws ReportDataFactoryException
- Throws:
ReportDataFactoryException
-
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.
-
deriveEmpty
public CompoundDataFactory deriveEmpty()
-
close
public void close()
Closes the data factory and frees all resources held by this instance.- Specified by:
close
in interfaceDataFactory
-
isQueryExecutable
public final 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
- Parameters:
query
- query name.parameters
- the parameters for the query.- Returns:
- true, if the query may be executable, false, if no datasource claims the query.
-
isFreeFormQueryExecutable
public boolean isFreeFormQueryExecutable(String query, DataRow parameters)
- Specified by:
isFreeFormQueryExecutable
in interfaceCompoundDataFactorySupport
-
isStaticQueryExecutable
public boolean isStaticQueryExecutable(String query, DataRow parameters)
- Specified by:
isStaticQueryExecutable
in interfaceCompoundDataFactorySupport
-
addRaw
protected void addRaw(DataFactory factory)
-
add
public void add(DataFactory factory)
-
add
public void add(int index, DataFactory factory)
-
set
public void set(int index, DataFactory factory)
-
remove
public void remove(int index)
-
remove
public void remove(DataFactory dataFactory)
-
size
public int size()
-
get
public DataFactory get(int idx)
-
indexOfByReference
public int indexOfByReference(DataFactory d)
-
getReference
public DataFactory getReference(int idx)
-
isNormalized
public boolean isNormalized()
-
normalize
public static CompoundDataFactory normalize(DataFactory dataFactory)
-
normalizeInternal
protected CompoundDataFactory normalizeInternal(boolean derive)
-
normalize
public static CompoundDataFactory normalize(DataFactory dataFactory, boolean derive)
-
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.- Specified by:
getQueryNames
in interfaceDataFactory
- Returns:
- the known query names.
-
getDataFactoryForQuery
public DataFactory getDataFactoryForQuery(String queryName, boolean freeform)
- Specified by:
getDataFactoryForQuery
in interfaceCompoundDataFactorySupport
-
getDataFactoryForQuery
public DataFactory getDataFactoryForQuery(String queryName)
-
-