org.eobjects.metamodel.intercept
Class InterceptableDataContext

java.lang.Object
  extended by org.eobjects.metamodel.intercept.InterceptableDataContext
All Implemented Interfaces:
DataContext, UpdateableDataContext

public class InterceptableDataContext
extends Object
implements UpdateableDataContext


Constructor Summary
protected InterceptableDataContext(DataContext delegate)
           
 
Method Summary
 InterceptableDataContext addDataSetInterceptor(DataSetInterceptor interceptor)
           
 InterceptableDataContext addQueryInterceptor(QueryInterceptor interceptor)
           
 InterceptableDataContext addRowDeletionInterceptor(RowDeletionInterceptor interceptor)
           
 InterceptableDataContext addRowInsertionInterceptor(RowInsertionInterceptor interceptor)
           
 InterceptableDataContext addRowUpdationInterceptor(RowUpdationInterceptor interceptor)
           
 InterceptableDataContext addSchemaInterceptor(SchemaInterceptor interceptor)
           
 InterceptableDataContext addTableCreationInterceptor(TableCreationInterceptor interceptor)
           
 InterceptableDataContext addTableDropInterceptor(TableDropInterceptor interceptor)
           
 CompiledQuery compileQuery(Query query)
          Compiles a query, preparing it for reuse.
 DataSet executeQuery(CompiledQuery compiledQuery, Object... values)
          Executes a compiled query with given values as parameters.
 DataSet executeQuery(Query query)
          Executes a query against the DataContext.
 DataSet executeQuery(String queryString)
          Parses and executes a string-based SQL query.
 void executeUpdate(UpdateScript update)
          Submits an UpdateScript for execution on the DataContext.
 Column getColumnByQualifiedLabel(String columnName)
          Finds a column in the DataContext based on a fully qualified column label.
 InterceptorList<DataSet> getDataSetInterceptors()
           
 Schema getDefaultSchema()
          Gets the default schema of this DataContext.
 DataContext getDelegate()
           
 InterceptorList<Query> getQueryInterceptors()
           
 InterceptorList<RowDeletionBuilder> getRowDeletionInterceptors()
           
 InterceptorList<RowInsertionBuilder> getRowInsertionInterceptors()
           
 InterceptorList<RowUpdationBuilder> getRowUpdationInterceptors()
           
 Schema getSchemaByName(String name)
          Gets a schema by a specified name.
 InterceptorList<Schema> getSchemaInterceptors()
           
 String[] getSchemaNames()
          Gets the names of all schemas within this DataContext.
 Schema[] getSchemas()
          Gets all schemas within this DataContext.
 Table getTableByQualifiedLabel(String tableName)
          Finds a table in the DataContext based on a fully qualified table label.
 InterceptorList<TableCreationBuilder> getTableCreationInterceptors()
           
 Query parseQuery(String queryString)
          Parses a string-based SQL query and produces a corresponding Query object.
 InitFromBuilder query()
          Starts building a query using the query builder API.
 UpdateableDataContext refreshSchemas()
          Enforces a refresh of the schemas.
 InterceptableDataContext removeDataSetInterceptor(DataSetInterceptor interceptor)
           
 InterceptableDataContext removeQueryInterceptor(QueryInterceptor interceptor)
           
 InterceptableDataContext removeRowDeletionInterceptor(RowDeletionInterceptor interceptor)
           
 InterceptableDataContext removeRowInsertionInterceptor(RowInsertionInterceptor interceptor)
           
 InterceptableDataContext removeRowUpdationInterceptor(RowUpdationInterceptor interceptor)
           
 InterceptableDataContext removeSchemaInterceptor(SchemaInterceptor interceptor)
           
 InterceptableDataContext removeTableCreationInterceptor(TableCreationInterceptor interceptor)
           
 InterceptableDataContext removeTableDropInterceptor(TableDropInterceptor interceptor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InterceptableDataContext

protected InterceptableDataContext(DataContext delegate)
Method Detail

addTableCreationInterceptor

public InterceptableDataContext addTableCreationInterceptor(TableCreationInterceptor interceptor)

removeTableCreationInterceptor

public InterceptableDataContext removeTableCreationInterceptor(TableCreationInterceptor interceptor)

addTableDropInterceptor

public InterceptableDataContext addTableDropInterceptor(TableDropInterceptor interceptor)

removeTableDropInterceptor

public InterceptableDataContext removeTableDropInterceptor(TableDropInterceptor interceptor)

addRowInsertionInterceptor

public InterceptableDataContext addRowInsertionInterceptor(RowInsertionInterceptor interceptor)

removeRowInsertionInterceptor

public InterceptableDataContext removeRowInsertionInterceptor(RowInsertionInterceptor interceptor)

addRowUpdationInterceptor

public InterceptableDataContext addRowUpdationInterceptor(RowUpdationInterceptor interceptor)

removeRowUpdationInterceptor

public InterceptableDataContext removeRowUpdationInterceptor(RowUpdationInterceptor interceptor)

addRowDeletionInterceptor

public InterceptableDataContext addRowDeletionInterceptor(RowDeletionInterceptor interceptor)

removeRowDeletionInterceptor

public InterceptableDataContext removeRowDeletionInterceptor(RowDeletionInterceptor interceptor)

addQueryInterceptor

public InterceptableDataContext addQueryInterceptor(QueryInterceptor interceptor)

removeQueryInterceptor

public InterceptableDataContext removeQueryInterceptor(QueryInterceptor interceptor)

addSchemaInterceptor

public InterceptableDataContext addSchemaInterceptor(SchemaInterceptor interceptor)

removeSchemaInterceptor

public InterceptableDataContext removeSchemaInterceptor(SchemaInterceptor interceptor)

addDataSetInterceptor

public InterceptableDataContext addDataSetInterceptor(DataSetInterceptor interceptor)

removeDataSetInterceptor

public InterceptableDataContext removeDataSetInterceptor(DataSetInterceptor interceptor)

getDataSetInterceptors

public InterceptorList<DataSet> getDataSetInterceptors()

getQueryInterceptors

public InterceptorList<Query> getQueryInterceptors()

getRowInsertionInterceptors

public InterceptorList<RowInsertionBuilder> getRowInsertionInterceptors()

getRowUpdationInterceptors

public InterceptorList<RowUpdationBuilder> getRowUpdationInterceptors()

getRowDeletionInterceptors

public InterceptorList<RowDeletionBuilder> getRowDeletionInterceptors()

getSchemaInterceptors

public InterceptorList<Schema> getSchemaInterceptors()

getTableCreationInterceptors

public InterceptorList<TableCreationBuilder> getTableCreationInterceptors()

getDelegate

public DataContext getDelegate()

executeQuery

public DataSet executeQuery(Query query)
                     throws MetaModelException
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
Throws:
MetaModelException - if the specified query does not make sense or cannot be executed because of restraints on the type of datastore.

refreshSchemas

public UpdateableDataContext refreshSchemas()
Description copied from interface: DataContext
Enforces a refresh of the schemas. If not refreshed, cached schema objects may be used.

Specified by:
refreshSchemas in interface DataContext
Returns:
this DataContext

getSchemas

public Schema[] getSchemas()
                    throws MetaModelException
Description copied from interface: DataContext
Gets all schemas within this DataContext.

Specified by:
getSchemas in interface DataContext
Returns:
the schemas in this data context. Schemas are cached for reuse in many situations so if you want to update the schemas, use the refreshSchemas() method.
Throws:
MetaModelException - if an error occurs retrieving the schema model

getSchemaNames

public String[] getSchemaNames()
                        throws MetaModelException
Description copied from interface: DataContext
Gets the names of all schemas within this DataContext.

Specified by:
getSchemaNames in interface DataContext
Returns:
an array of valid schema names
Throws:
MetaModelException - if an error occurs retrieving the schema model

getDefaultSchema

public Schema getDefaultSchema()
                        throws MetaModelException
Description copied from interface: DataContext
Gets the default schema of this DataContext.

Specified by:
getDefaultSchema in interface DataContext
Returns:
the schema that you are most probable to be interested in. The default schema is determined by finding the schema with most available of tables. In a lot of situations there will only be a single available schema and in that case this will of course be the schema returned.
Throws:
MetaModelException - if an error occurs retrieving the schema model

getSchemaByName

public Schema getSchemaByName(String name)
                       throws MetaModelException
Description copied from interface: DataContext
Gets a schema by a specified name.

Specified by:
getSchemaByName in interface DataContext
Parameters:
name - the name of the desired schema
Returns:
the Schema with the specified name or null if no such schema exists
Throws:
MetaModelException - if an error occurs retrieving the schema model

query

public InitFromBuilder query()
Description copied from interface: DataContext
Starts building a query using the query builder API. This way of building queries is the preferred approach since it provides a more type-safe approach to building API's as well as allows the DataContext implementation to be aware of the query building process.

Specified by:
query in interface DataContext
Returns:
a query builder component at the initial position in building a query.

getColumnByQualifiedLabel

public Column getColumnByQualifiedLabel(String columnName)
Description copied from interface: DataContext
Finds a column in the DataContext based on a fully qualified column label. The qualified label consists of the the schema, table and column name, delimited by a dot (.).

Specified by:
getColumnByQualifiedLabel in interface DataContext
Returns:
a column that matches the qualified label, or null if no such column exists

getTableByQualifiedLabel

public Table getTableByQualifiedLabel(String tableName)
Description copied from interface: DataContext
Finds a table in the DataContext based on a fully qualified table label. The qualified label consists of the the schema and table name, delimited by a dot (.).

Specified by:
getTableByQualifiedLabel in interface DataContext
Returns:
a table that matches the qualified label, or null if no such table exists

executeUpdate

public void executeUpdate(UpdateScript update)
Description copied from interface: UpdateableDataContext
Submits an UpdateScript for execution on the DataContext. Since implementations of the DataContext vary quite a lot, there is no golden rule as to how an update script will be executed. But the implementors should strive towards handling an UpdateScript as a single transactional change to the data store.

Specified by:
executeUpdate in interface UpdateableDataContext
Parameters:
update - the update script to execute

parseQuery

public Query parseQuery(String queryString)
                 throws MetaModelException
Description copied from interface: DataContext
Parses a string-based SQL query and produces a corresponding Query object.

Specified by:
parseQuery in interface DataContext
Parameters:
queryString - the SQL query to parse
Returns:
a Query object corresponding to the SQL query.
Throws:
MetaModelException - in case the parsing was unsuccesful.

executeQuery

public DataSet executeQuery(String queryString)
                     throws MetaModelException
Description copied from interface: DataContext
Parses and executes a string-based SQL query. This method is essentially equivalent to calling first DataContext.parseQuery(String) and then DataContext.executeQuery(Query) with the parsed query.

Specified by:
executeQuery in interface DataContext
Returns:
the DataSet produced from executing the query
Throws:
MetaModelException - if either parsing or executing the query produces an exception

compileQuery

public CompiledQuery compileQuery(Query query)
Description copied from interface: DataContext
Compiles a query, preparing it for reuse. Often times compiled queries have a performance improvement when executed, but at the cost of a preparation time penalty. Therefore it is adviced to use compiled queries when the same query is to be fired multiple times. Compiled queries can contain QueryParameters as operands in the WHERE clause, making it possible to reuse the same query with different parameter values.

Specified by:
compileQuery in interface DataContext
Parameters:
query - the query object to execute, possibly holding one or more QueryParameters.
Returns:
the CompiledQuery after preparing the query
See Also:
CompiledQuery, QueryParameter

executeQuery

public DataSet executeQuery(CompiledQuery compiledQuery,
                            Object... values)
Description copied from interface: DataContext
Executes a compiled query with given values as parameters.

Specified by:
executeQuery in interface DataContext
Parameters:
compiledQuery - the compiledQuery object to execute
values - the values for parameters in the CompiledQuery.
Returns:
the DataSet produced from executing the query.


Copyright © 2007-2013. All Rights Reserved.