org.pentaho.reporting.engine.classic.core
Class CompoundDataFactory

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.CompoundDataFactory
All Implemented Interfaces:
Serializable, Cloneable, CompoundDataFactorySupport, DataFactory
Direct Known Subclasses:
CascadingDataFactory

public class CompoundDataFactory
extends Object
implements DataFactory, 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

Field Summary
 
Fields inherited from interface org.pentaho.reporting.engine.classic.core.DataFactory
QUERY_LIMIT, QUERY_TIMEOUT
 
Constructor Summary
CompoundDataFactory()
           
 
Method Summary
 void add(DataFactory factory)
           
 void add(int index, DataFactory factory)
           
 void cancelRunningQuery()
          Attempts to cancel the query process that is generating the data for this data factory.
 Object clone()
          Creates and returns a copy of this object.
 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.
 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)
           
 void initialize(org.pentaho.reporting.libraries.base.config.Configuration configuration, org.pentaho.reporting.libraries.resourceloader.ResourceManager resourceManager, org.pentaho.reporting.libraries.resourceloader.ResourceKey contextKey, ResourceBundleFactory resourceBundleFactory)
          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)
           
 void open()
          Opens the data factory.
 TableModel queryData(String query, DataRow parameters)
          Queries a datasource.
 TableModel queryFreeForm(String query, DataRow parameters)
           
 TableModel queryStatic(String query, DataRow parameters)
           
 void remove(DataFactory dataFactory)
           
 void remove(int index)
           
 void set(int index, DataFactory factory)
           
 int size()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompoundDataFactory

public CompoundDataFactory()
Method Detail

initialize

public void initialize(org.pentaho.reporting.libraries.base.config.Configuration configuration,
                       org.pentaho.reporting.libraries.resourceloader.ResourceManager resourceManager,
                       org.pentaho.reporting.libraries.resourceloader.ResourceKey contextKey,
                       ResourceBundleFactory resourceBundleFactory)
                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 interface DataFactory
Parameters:
configuration - the current report configuration.
resourceManager - the report's resource manager.
contextKey - the report's context key to access resources relative to the report location.
resourceBundleFactory - the report's resource-bundle factory to access localization information.
Throws:
ReportDataFactoryException

open

public void open()
          throws ReportDataFactoryException
Description copied from interface: DataFactory
Opens the data factory. This initializes everything. Performing queries on data factories which have not yet been opened will result in exceptions.

Specified by:
open in interface DataFactory
Throws:
ReportDataFactoryException - if an error occured while opening the datafactory resources.

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 interface DataFactory
Parameters:
query - the query string
parameters - the parameters for the query
Returns:
the result of the query as table model.
Throws:
ReportDataFactoryException - if an error occured while performing the query.

queryFreeForm

public TableModel queryFreeForm(String query,
                                DataRow parameters)
                         throws ReportDataFactoryException
Specified by:
queryFreeForm in interface CompoundDataFactorySupport
Throws:
ReportDataFactoryException

queryStatic

public TableModel queryStatic(String query,
                              DataRow parameters)
                       throws ReportDataFactoryException
Specified by:
queryStatic in interface CompoundDataFactorySupport
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 interface DataFactory
Returns:
a copy of the data factory.

close

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

Specified by:
close in interface DataFactory

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 interface DataFactory
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 interface CompoundDataFactorySupport

isStaticQueryExecutable

public boolean isStaticQueryExecutable(String query,
                                       DataRow parameters)
Specified by:
isStaticQueryExecutable in interface CompoundDataFactorySupport

clone

public Object clone()
Creates and returns a copy of this object.

Specified by:
clone in interface DataFactory
Overrides:
clone in class Object
Returns:
a clone.

add

public void add(DataFactory factory)

add

public void add(int index,
                DataFactory factory)
         throws ReportDataFactoryException
Throws:
ReportDataFactoryException

set

public void set(int index,
                DataFactory factory)
         throws ReportDataFactoryException
Throws:
ReportDataFactoryException

remove

public void remove(int index)

remove

public void remove(DataFactory dataFactory)

size

public int size()

get

public DataFactory get(int idx)

getReference

public DataFactory getReference(int idx)

isNormalized

public boolean isNormalized()

normalize

public static CompoundDataFactory normalize(DataFactory dataFactory)

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 interface DataFactory
Returns:
the known query names.

cancelRunningQuery

public void cancelRunningQuery()
Description copied from interface: DataFactory
Attempts to cancel the query process that is generating the data for this data factory. If it is not possible to cancel the query, this call should be ignored.

Specified by:
cancelRunningQuery in interface DataFactory

getDataFactoryForQuery

public DataFactory getDataFactoryForQuery(String queryName,
                                          boolean freeform)
Specified by:
getDataFactoryForQuery in interface CompoundDataFactorySupport

getDataFactoryForQuery

public DataFactory getDataFactoryForQuery(String queryName)