org.eobjects.metamodel
Class QueryPostprocessDataContext

java.lang.Object
  extended by org.eobjects.metamodel.AbstractDataContext
      extended by org.eobjects.metamodel.QueryPostprocessDataContext
All Implemented Interfaces:
HasReadTypeConverters, DataContext
Direct Known Subclasses:
QueryPostprocessDelegate

public abstract class QueryPostprocessDataContext
extends AbstractDataContext
implements HasReadTypeConverters

Abstract DataContext for data sources that do not support SQL queries natively. Instead this superclass only requires that a subclass can materialize a single table at a time. Then the query will be executed by post processing the datasets client-side.


Field Summary
static String INFORMATION_SCHEMA_NAME
           
 
Constructor Summary
QueryPostprocessDataContext()
           
 
Method Summary
 void addConverter(Column column, TypeConverter<?,?> converter)
          Adds a TypeConverter to this DataContext's query engine (Query Postprocessor) for read operations.
protected  Number executeCountQuery(Table table, List<FilterItem> whereItems, boolean functionApproximationAllowed)
          Executes a simple count query, if possible.
 DataSet executeQuery(Query query)
          Executes a query against the DataContext.
protected  String getDefaultSchemaName()
          Gets the name of the default schema.
protected abstract  Schema getMainSchema()
           
protected  Schema getMainSchemaInternal()
           
protected abstract  String getMainSchemaName()
           
protected  Schema getSchemaByNameInternal(String name)
          Gets a specific schema from the non-abstract implementation.
protected  String[] getSchemaNamesInternal()
          Gets schema names from the non-abstract implementation.
protected  boolean isMainSchemaTable(Table table)
           
protected  DataSet materializeFromItem(FromItem fromItem, List<SelectItem> selectItems)
           
protected abstract  DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows)
          Executes a simple one-table query against a table in the main schema of the subclasses of this class.
protected  DataSet materializeMainSchemaTable(Table table, Column[] columns, int firstRow, int maxRows)
          Executes a simple one-table query against a table in the main schema of the subclasses of this class.
protected  DataSet materializeMainSchemaTable(Table table, List<SelectItem> selectItems, int firstRow, int maxRows)
          Executes a simple one-table query against a table in the main schema of the subclasses of this class.
protected  DataSet materializeTable(Table table, List<SelectItem> selectItems, int firstRow, int maxRows)
           
 
Methods inherited from class org.eobjects.metamodel.AbstractDataContext
compileQuery, executeQuery, executeQuery, getColumnByQualifiedLabel, getDefaultSchema, getSchemaByName, getSchemaNames, getSchemas, getTableByQualifiedLabel, isQualifiedPathDelim, parseQuery, query, refreshSchemas
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFORMATION_SCHEMA_NAME

public static final String INFORMATION_SCHEMA_NAME
See Also:
Constant Field Values
Constructor Detail

QueryPostprocessDataContext

public QueryPostprocessDataContext()
Method Detail

executeQuery

public DataSet executeQuery(Query query)
Description copied from interface: DataContext
Executes a query against the DataContext.

Specified by:
executeQuery in interface DataContext
Parameters:
query - the query object to execute
Returns:
the DataSet produced from executing the query

executeCountQuery

protected Number executeCountQuery(Table table,
                                   List<FilterItem> whereItems,
                                   boolean functionApproximationAllowed)
Executes a simple count query, if possible. This method is provided to allow subclasses to optimize count queries since they are quite common and often a datastore can retrieve the count using some specialized means which is much more performant than counting all records manually.

Parameters:
table - the table on which the count is requested.
whereItems - a (sometimes empty) list of WHERE items.
functionApproximationAllowed - whether approximation is allowed or not.
Returns:
the count of the particular table, or null if not available.

materializeFromItem

protected DataSet materializeFromItem(FromItem fromItem,
                                      List<SelectItem> selectItems)

materializeTable

protected DataSet materializeTable(Table table,
                                   List<SelectItem> selectItems,
                                   int firstRow,
                                   int maxRows)

isMainSchemaTable

protected boolean isMainSchemaTable(Table table)

getSchemaNamesInternal

protected final String[] getSchemaNamesInternal()
                                         throws MetaModelException
Description copied from class: AbstractDataContext
Gets schema names from the non-abstract implementation. These schema names will be cached except if the AbstractDataContext.refreshSchemas() method is called.

Specified by:
getSchemaNamesInternal in class AbstractDataContext
Returns:
an array of schema names.
Throws:
MetaModelException

getDefaultSchemaName

protected String getDefaultSchemaName()
                               throws MetaModelException
Description copied from class: AbstractDataContext
Gets the name of the default schema.

Specified by:
getDefaultSchemaName in class AbstractDataContext
Returns:
the default schema name.
Throws:
MetaModelException

getSchemaByNameInternal

protected final Schema getSchemaByNameInternal(String name)
                                        throws MetaModelException
Description copied from class: AbstractDataContext
Gets a specific schema from the non-abstract implementation. This schema object will be cached except if the AbstractDataContext.refreshSchemas() method is called.

Specified by:
getSchemaByNameInternal in class AbstractDataContext
Parameters:
name - the name of the schema to get
Returns:
a schema object representing the named schema, or null if no such schema exists.
Throws:
MetaModelException

getMainSchemaInternal

protected Schema getMainSchemaInternal()

addConverter

public void addConverter(Column column,
                         TypeConverter<?,?> converter)
Adds a TypeConverter to this DataContext's query engine (Query Postprocessor) for read operations. Note that this method should NOT be invoked directly by consuming code. Rather use Converters.addTypeConverter(DataContext, Column, TypeConverter) to ensure conversion on both reads and writes.

Specified by:
addConverter in interface HasReadTypeConverters

getMainSchema

protected abstract Schema getMainSchema()
                                 throws MetaModelException
Returns:
the main schema that subclasses of this class produce
Throws:
MetaModelException

getMainSchemaName

protected abstract String getMainSchemaName()
                                     throws MetaModelException
Returns:
the name of the main schema that subclasses of this class produce
Throws:
MetaModelException

materializeMainSchemaTable

protected DataSet materializeMainSchemaTable(Table table,
                                             List<SelectItem> selectItems,
                                             int firstRow,
                                             int maxRows)
Executes a simple one-table query against a table in the main schema of the subclasses of this class. This default implementation will delegate to materializeMainSchemaTable(Table, Column[], int, int).

Parameters:
table -
selectItems -
firstRow -
maxRows -
Returns:

materializeMainSchemaTable

protected DataSet materializeMainSchemaTable(Table table,
                                             Column[] columns,
                                             int firstRow,
                                             int maxRows)
Executes a simple one-table query against a table in the main schema of the subclasses of this class. This default implementation will delegate to materializeMainSchemaTable(Table, Column[], int) and apply a FirstRowDataSet if necessary.

Parameters:
table -
columns -
firstRow -
maxRows -
Returns:

materializeMainSchemaTable

protected abstract DataSet materializeMainSchemaTable(Table table,
                                                      Column[] columns,
                                                      int maxRows)
Executes a simple one-table query against a table in the main schema of the subclasses of this class.

Parameters:
table - the table to query
columns - the columns of the table to query
maxRows - the maximum amount of rows needed or -1 if all rows are wanted.
Returns:
a dataset with the raw table/column content.


Copyright © 2007-2013. All Rights Reserved.