|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectuk.ac.ic.doc.automed.wrappers.AutoMedWrapper
public abstract class AutoMedWrapper
An AutoMedWrapper represents an open connection to a datasource.
Since datasources are so varied, much of the functionality of a
wrapper is deligated to implementions of this class. Thus
AutoMedWrapper is a foundation class for AutoMed wrappers to be
built upon.
All valid implementations of this class must provide two constructors,
one with no arguements, and one that takes an AccessMethod and
String representing a password (that if not null overrides any
password held in the AccessMethod. The PostgresWrapper and
associated PostgresWrapperFactory can be used examples
of correctly structured wrappers.
| Field Summary | |
|---|---|
protected AccessMethod |
am
|
protected AutoMedWrapperFactory |
awf
|
protected static int |
debug
|
protected java.lang.String |
driver
|
protected static boolean[] |
emptyKeyProtection
|
protected static java.lang.String[] |
emptyKeys
|
protected boolean[] |
optionKeyProtection
|
protected java.lang.String[] |
optionKeys
|
protected java.lang.String |
password
|
protected Protocol |
protocol
|
protected Schema |
s
|
protected java.lang.String |
url
|
protected java.lang.String |
username
|
| Constructor Summary | |
|---|---|
protected |
AutoMedWrapper()
|
|
AutoMedWrapper(AccessMethod am,
java.lang.String password)
Generate a new wrapper instance from information held in the repository about how to access a data source. |
| Method Summary | |
|---|---|
static boolean |
atDebugLevel(int level)
Determine is debug is at or above a certain level. |
protected void |
cacheWrapper()
Cache this AutoMedWrapper as being able to provide the
implementation of an AccessMethod used to create the wrapper. |
protected abstract void |
connect()
Use the connection details held with this wrapper to connect to the data source. |
boolean |
deleteIQL(ASG q)
|
abstract ASG |
executeIQL(ASG q)
Execute an IQL query on the datasource. |
ASG |
executeIQL(ASG q,
java.lang.String queryID)
Execute an IQL query on the datasource. |
AutoMedResult |
executeLocalQuery(AutoMedQuery q)
Execute a query in the datasource's native query language, and obtain a result in an AutoMedResult class |
AccessMethod |
getAccessMethod()
Returns the AccessMethod associated with this wrapper,
which holds the details of the datasource being wrapped. |
static AutoMedWrapper |
getAutoMedWrapper(AccessMethod am)
Equivalent to calling newAutoMedWrapper(am,null) |
static AutoMedWrapper |
getAutoMedWrapper(AccessMethod am,
java.lang.String password)
Return the wrapper asspciated to a stored AccessMethod. |
AutoMedWrapperFactory |
getAutoMedWrapperFactory()
Return the AutoMedWrapperFactory currently associated with this wrapper. |
protected abstract AutoMedWrapperFactory |
getDefaultWrapperFactory()
Return the default AutoMedWrapperFactory that is used to
generate Schema instances from information in a data sources |
static java.lang.Object[] |
getDrivers()
Returns all the drivers currently loaded into the system |
java.lang.String |
getOption(java.lang.String key)
Return an option setting. |
boolean[] |
getOptionKeyProtection()
Return the list of boolean values that indicate if the value associated with a key should be altered by a user application. |
java.lang.String[] |
getOptionKeys()
Return the list of options keys that this wrapper understands. |
Protocol |
getProtocol()
Returns the Protocol associated with the Wrapper. |
abstract java.lang.String |
getProtocolName()
The name of the Protocol that this wrapper uses |
static DefaultQueryCache |
getQueryCache()
Return a unique reference to the query cache |
static DefaultQueryCache |
getQueryCache(java.lang.String peerName,
java.lang.String schemaName)
|
QueryParser |
getQueryParser(ASG query)
Return a parser that will accept queries for the wrapper. |
Schema |
getSchema()
Returns the Schema that represents in the datasource
in terms of SchemaObjects in a data source oriented manner. |
Schema |
getSchema(java.lang.String schemaName)
A method that creates in the repository a Schema and AccessMethod from the supplied information, together with a Protocol if necessary, and returns the AccessMethod. |
abstract void |
getSODefinition(QuerySubGoal qsg)
An abstract method used by #getSOQuality(String schemeDef). |
QuerySubGoal |
getSODefinition(java.lang.String schemeDef)
Calculate the quality of a schema object. |
boolean |
insertIQL(ASG q)
Execute an IQL insert on the datasource. |
Schema |
newAutoMedSchema(java.lang.String name)
Returns the Schema that represents in the datasource
in terms of SchemaObjects in an AutoMed oriented manner. |
static AutoMedWrapper |
newAutoMedWrapper(AccessMethod am)
Deprecated. use getAutoMedWrapper(am) instead |
static AutoMedWrapper |
newAutoMedWrapper(AccessMethod am,
java.lang.String password)
Deprecated. use getAutoMedWrapper |
static AutoMedWrapper |
newAutoMedWrapper(java.lang.String username,
java.lang.String password,
java.lang.String driver,
java.lang.String url,
java.lang.String schemaName,
AutoMedWrapperFactory awf)
Create an AutoMed Schema containing SchemaObjects
that represent a database, in such a form that queries on that
schema can be mapped by executeQuery in the query lanuage of the database. |
static void |
registerWrapper(java.lang.Class c,
Protocol protocol,
java.lang.String driver,
java.lang.String url)
Register an AutoMedWrapper implementation with the AutoMed system. |
static AutoMedWrapper |
selectNewAutoMedWrapper(java.lang.String username,
java.lang.String password,
Protocol protocol,
java.lang.String driver,
java.lang.String url)
Using the url and driver information, try to select an appropriate type of AutoMedWrapper to create. |
static AutoMedWrapper |
selectNewAutoMedWrapper(java.lang.String username,
java.lang.String password,
Protocol protocol,
java.lang.String driver,
java.lang.String url,
java.lang.String schemaName,
AutoMedWrapperFactory wrapperFactory)
Using the url and driver information, try to select an appropriate type of AutoMedWrapper to create. |
static void |
setDebugLevel(int debug)
Set the debug level for all AutoMed wrappers. |
void |
setOption(java.lang.String key,
java.lang.String value)
Make an option setting. |
protected void |
updateCache(java.lang.String queryID,
ASG subQuery,
ASG result)
Update query cache as queries are executed over the data source. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Protocol protocol
protected static int debug
protected AccessMethod am
protected Schema s
protected java.lang.String url
protected java.lang.String driver
protected java.lang.String username
protected java.lang.String password
protected AutoMedWrapperFactory awf
protected static final java.lang.String[] emptyKeys
protected static final boolean[] emptyKeyProtection
protected java.lang.String[] optionKeys
protected boolean[] optionKeyProtection
| Constructor Detail |
|---|
protected AutoMedWrapper()
public AutoMedWrapper(AccessMethod am,
java.lang.String password)
throws DataSourceException
AccessMethod and Schema can
be created using TransactSQLWrapperFactory#build
DataSourceException| Method Detail |
|---|
public QueryParser getQueryParser(ASG query)
Schemes, which accepts only single
schemes, with no other IQL operators supported. The SimpleComp
parser will allow simple list comprehensions to be passed to the
wrapper.
public static void setDebugLevel(int debug)
public static boolean atDebugLevel(int level)
level - to test if debug is at or abovepublic final AccessMethod getAccessMethod()
AccessMethod associated with this wrapper,
which holds the details of the datasource being wrapped.
public final Schema getSchema()
throws NotFoundException
Schema that represents in the datasource
in terms of SchemaObjects in a data source oriented manner.
NotFoundException - if you have not called getSchema(String) on the wrapper previouslypublic abstract java.lang.String getProtocolName()
Protocol that this wrapper uses
protected abstract void connect()
throws DataSourceException
DataSourceException - if unable to connect to the data source
public final Schema getSchema(java.lang.String schemaName)
throws IntegrityException,
DataSourceException
schemaName - is the name of the Schema that is
used to represent the datasource in AutoMed.
IntegrityException - is the schemaName already exists
DataSourceExceptionpublic Protocol getProtocol()
Protocol associated with the Wrapper.
public final Schema newAutoMedSchema(java.lang.String name)
throws IntegrityException,
NotFoundException
Schema that represents in the datasource
in terms of SchemaObjects in an AutoMed oriented manner.
This might be the same as the result of getSchema() or might
not.
name - of new schema, which must not already exist
NotFoundException - if you have not previously wrapped the
datasource as a source oriented schema, using either #AutoMedWrapper.getSchema(String) or #AutoMedWrapper.selectNewAutoMedWrapper
IntegrityException
public AutoMedResult executeLocalQuery(AutoMedQuery q)
throws DataSourceException
DataSourceException
public static AutoMedWrapper newAutoMedWrapper(AccessMethod am)
throws DataSourceException
DataSourceException
public static AutoMedWrapper newAutoMedWrapper(java.lang.String username,
java.lang.String password,
java.lang.String driver,
java.lang.String url,
java.lang.String schemaName,
AutoMedWrapperFactory awf)
throws IntegrityException,
DataSourceException
Schema containing SchemaObjects
that represent a database, in such a form that queries on that
schema can be mapped by executeQuery in the query lanuage of the database.
This should be called once per data source, so as to configure
the repository. Subsequent uses of the data source should call
the constructor for AutoMedWrapper instance
with the AccessMethod of
the AutoMedWrapper returned here.
schemaName - is the name of the Schema to create in the
repository to represent the data source. If this is left null then
a connection is established to the data source, and the Schema
may be created later using getSchema(String)awf - is an AutoMedWrapperFactory instance
configured to model
the source schema in the desired manner.
IntegrityException
DataSourceException
public static AutoMedWrapper getAutoMedWrapper(AccessMethod am)
throws DataSourceException
DataSourceException
public static AutoMedWrapper newAutoMedWrapper(AccessMethod am,
java.lang.String password)
throws DataSourceException
DataSourceExceptionpublic static java.lang.Object[] getDrivers()
public static void registerWrapper(java.lang.Class c,
Protocol protocol,
java.lang.String driver,
java.lang.String url)
selectNewAutoMedWrapper(java.lang.String, java.lang.String, uk.ac.ic.doc.automed.reps.Protocol, java.lang.String, java.lang.String).
protected void cacheWrapper()
AutoMedWrapper as being able to provide the
implementation of an AccessMethod used to create the wrapper.
This means that
any call to getAutoMedWrapper(uk.ac.ic.doc.automed.reps.AccessMethod) will
return an existing AutoMedWrapper rather than instantiate a new
one, which is more efficient. However the AutoMedWrapper will then need
to support possibly concurrent execution of queries.
public static AutoMedWrapper getAutoMedWrapper(AccessMethod am,
java.lang.String password)
throws DataSourceException
am - The AccessMethod which contains the details
needed in order to create the wrapper.password - Any password that the datasource may require to
access it. If no password is required, or the password has been
stored in the AccessMethod, this may be left null.
DataSourceException - if the AccessMethod.getDBDriver()
returns a java class for which there is not a known supporting
AutoMedWrapper subclass.
public static AutoMedWrapper selectNewAutoMedWrapper(java.lang.String username,
java.lang.String password,
Protocol protocol,
java.lang.String driver,
java.lang.String url)
throws IntegrityException,
DataSourceException
IntegrityException
DataSourceException
public static AutoMedWrapper selectNewAutoMedWrapper(java.lang.String username,
java.lang.String password,
Protocol protocol,
java.lang.String driver,
java.lang.String url,
java.lang.String schemaName,
AutoMedWrapperFactory wrapperFactory)
throws IntegrityException,
DataSourceException
IntegrityException
DataSourceException
public abstract ASG executeIQL(ASG q)
throws DataSourceException,
NotFoundException
q - An IQL query held in an ASG which complies with
the limitations of what this wrapper is able to process
ASG containing the results of the query
DataSourceException
NotFoundException
public ASG executeIQL(ASG q,
java.lang.String queryID)
throws DataSourceException,
NotFoundException
executeIQL(ASG q)
in that it accepts an unique query ID argument which is used for updating query result
to cache.
queryID - an unique query identifier (generated by the query cache)q - An IQL query held in an ASG which complies with
the limitations of what this wrapper is able to process
ASG containing the results of the query
DataSourceException
NotFoundException
public boolean insertIQL(ASG q)
throws DataSourceException
q - is the ASG representation of an IQL
query of the form
sub [t1, ..., tn] s
where:The semantics and execution of the insert request will depend on the data source e.g. for a relational database it could be translated into a series of INSERT requests within a single transaction, which may fail or succeeed as a whole (and thus return False or True respectively from the insertIQL method). For a non-transactional repository like the HDM or XML flat files, we may choose to allow partial updates e.g. some of a set of tuples are inserted, while some already exist or violate some constraint or another.
DataSourceException
public boolean deleteIQL(ASG q)
throws DataSourceException
DataSourceException
public QuerySubGoal getSODefinition(java.lang.String schemeDef)
throws IntegrityException,
DataSourceException
#getSOQuality(Schema s, String schemeName)
method of the sub-class wrapper to do the job.QueryMediator class and the query optimisation process.
quality - a List object of the aggregated quality valuesschemeDef - the scheme definition of the schema object (e.g. uni_s1:<List an aggregated list of quality values
IntegrityException
DataSourceException
public abstract void getSODefinition(QuerySubGoal qsg)
throws DataSourceException
#getSOQuality(String schemeDef). This method
must be implemented by all sub-classes
List -
DataSourceException
protected void updateCache(java.lang.String queryID,
ASG subQuery,
ASG result)
throws AutoMedException
queryID - the unique query identifier (generated by the query cache)subQuery - the actual query that is being evaluated. It is a sub-setresult - the ASG representation of query result
AutoMedExceptionprotected abstract AutoMedWrapperFactory getDefaultWrapperFactory()
AutoMedWrapperFactory that is used to
generate Schema instances from information in a data sources
public AutoMedWrapperFactory getAutoMedWrapperFactory()
public final java.lang.String getOption(java.lang.String key)
public final java.lang.String[] getOptionKeys()
public final boolean[] getOptionKeyProtection()
getOptionKeys() should not be
used in setOption. At present this is not enforced, but that
might change in the future.
public final void setOption(java.lang.String key,
java.lang.String value)
AutoMedWrapper implementation is used.
public static DefaultQueryCache getQueryCache()
throws CacheException
CacheException
public static DefaultQueryCache getQueryCache(java.lang.String peerName,
java.lang.String schemaName)
throws CacheException
CacheException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||