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

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

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

Field Summary
 
Fields inherited from interface org.pentaho.reporting.engine.classic.core.DataFactory
QUERY_LIMIT, QUERY_TIMEOUT
 
Constructor Summary
NamedStaticDataFactory()
          Defaultconstructor.
 
Method Summary
 Object 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
cancelRunningQuery, close, getParameterFields, initialize, open
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedStaticDataFactory

public NamedStaticDataFactory()
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
Overrides:
isQueryExecutable in class StaticDataFactory
Parameters:
query -
parameters -
Returns:

setQuery

public void setQuery(String alias,
                     String queryString)
Adds an query-alias to this factory.

Parameters:
alias - the alias
queryString - 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 interface DataFactory
Overrides:
derive in class StaticDataFactory
Returns:
the derived factory.

clone

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

Specified by:
clone in interface DataFactory
Overrides:
clone in class StaticDataFactory
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 interface DataFactory
Overrides:
queryData in class StaticDataFactory
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 interface DataFactory
Overrides:
getQueryNames in class StaticDataFactory
Returns:
all alias-names as string-array.

translateQuery

public String translateQuery(String queryName)
Overrides:
translateQuery in class StaticDataFactory