org.pentaho.reporting.engine.classic.core.modules.misc.datafactory
Class StaticDataFactory

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.StaticDataFactory
All Implemented Interfaces:
Serializable, Cloneable, DataFactory
Direct Known Subclasses:
NamedStaticDataFactory

public class StaticDataFactory
extends Object
implements DataFactory, Cloneable

This report data factory uses introspection to search for a report data source. The query can have the following formats:

<full-qualified-classname>#methodName(Parameters) <full-qualified-classname>(constructorparams)#methodName(Parameters) <full-qualified-classname>(constructorparams)

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
StaticDataFactory()
          DefaultConstructor.
 
Method Summary
 void cancelRunningQuery()
          Attempts to cancel the query process that is generating the data for this data factory.
 Object clone()
          Returns a clone of the 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.
 String[] getParameterFields(String query)
           
 String[] getQueryNames()
          Returns all known query-names.
 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 isQueryExecutable(String query, DataRow parameters)
          Checks whether the query would be executable by this datafactory.
 void open()
          Opens the data factory.
 TableModel queryData(String query, DataRow parameters)
          Queries a datasource.
 String translateQuery(String queryName)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticDataFactory

public StaticDataFactory()
DefaultConstructor.

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 interface DataFactory
Parameters:
query -
parameters -
Returns:

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 interface DataFactory
Parameters:
query - the method call.
parameters - the set of parameters.
Returns:
the tablemodel from the executed method call, never null.
Throws:
ReportDataFactoryException - if an error occured while performing the query.

getParameterFields

public String[] getParameterFields(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 interface DataFactory
Returns:
a copy of the data factory.

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.

close

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

This method is empty.

Specified by:
close in interface DataFactory

clone

public Object clone()
Returns a clone of the factory.

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

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

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)
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.

translateQuery

public String translateQuery(String queryName)