uk.ac.ic.doc.automed.reps
Class AccessMethod

java.lang.Object
  extended by uk.ac.ic.doc.automed.reps.AccessMethod
All Implemented Interfaces:
PersistentObject

public class AccessMethod
extends java.lang.Object
implements PersistentObject

The AccessMethod class describes how a particular database presented by a Schema can be accessed by an AutoMed application, using a particular Protocol. This is very experimental at present, and has only been designed to handle JDBC/ODBC type protocols.

Author:
Michael Boyd (mboyd@doc.ic.ac.uk), Peter McBrien (pjm@doc.ic.ac.uk)), Nerissa Tong (nnyt98@doc.ic.ac.uk)

Field Summary
static java.lang.String PROPERTY_AUTOMED_SCHEMA
          Name to give to a AccessMethod property to hold the name of an AutoMed oriented schema that was produced from the schema associated with this AccessMethod.
static java.lang.String PROPERTY_CREATE_TIME
          Name to give to a AccessMethod property for the time in milliseconds since 1 Jan 1970 that the datasource schema was created in the AutoMed repository.
 
Method Summary
protected static void clearAccessMethods()
           
static AccessMethod createAccessMethod(Schema schema, java.lang.String url, Protocol protocol, java.lang.String dbDriver, java.lang.String username)
          Used to created an AccessMethod where no password is required to access the data source.
static AccessMethod createAccessMethod(Schema schema, java.lang.String url, Protocol protocol, java.lang.String dbDriver, java.lang.String username, java.lang.String password, java.lang.String wrapper, int awfFeatures)
          Creates a new access method.
static AccessMethod getAccessMethod(int amid)
          Returns the AccessMethod held with the given identifier in in the STR.
 int getAMID()
          Returns the access method identifier (AMID).
 int getAutoMedWrapperFactoryFeatures()
          Returns the feature settings as used with associated AutoMedWrapperFactory
 java.lang.String getDBDriver()
          Returns the database driver used for connecting to the database.
 PersistentKey getKey()
           
 java.lang.String getPassword()
          Returns the password of the user, if it exists
 java.util.Map getPersistentAttributes()
           
 java.lang.String getProperty(java.lang.String key)
          Returns a property associated with this AccessMethod.
 Protocol getProtocol()
          Returns the Protocol used for connecting to the database.
 Schema getSchema()
          Returns the schema that represents the database to which the access method connects.
 java.lang.String getURL()
          Returns the URL of the database to which the access method connects.
 java.lang.String getUsername()
          Returns the username used for connecting to the database.
 java.lang.String getWrapper()
          Returns the wrapper used for connecting to the database.
 void remove()
          Remove this AccessMethod from the repository.
 void retract()
          Remove this AccessMethod, and any other classes that are dependent upon its existance.
 void setAutoMedWrapperFactoryFeatures(int awfFeatures)
          Sets the password used for connecting to the database.
 void setDBDriver(java.lang.String dbDriver)
          Sets the database driver used for connecting to the database.
 void setPassword(java.lang.String password)
          Sets the password used for connecting to the database.
 void setProperty(java.lang.String key, java.lang.String value)
          Sets a property associated with this AccessMethod.
 void setProtocol(Protocol protocol)
          Sets the protocol used for connecting to the database.
 void setSchema(Schema schema)
          Sets the schema that represents the database to which the access method connects.
 void setURL(java.lang.String url)
          Sets the URL of the database to which the access method connects.
 void setUsername(java.lang.String username)
          Sets the username used for connecting to the database.
 void setWrapper(java.lang.String wrapper)
          Sets the wrapper asscociated with this.
 void write(java.io.OutputStream os, int format)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_CREATE_TIME

public static final java.lang.String PROPERTY_CREATE_TIME
Name to give to a AccessMethod property for the time in milliseconds since 1 Jan 1970 that the datasource schema was created in the AutoMed repository.

See Also:
Constant Field Values

PROPERTY_AUTOMED_SCHEMA

public static final java.lang.String PROPERTY_AUTOMED_SCHEMA
Name to give to a AccessMethod property to hold the name of an AutoMed oriented schema that was produced from the schema associated with this AccessMethod.

See Also:
Constant Field Values
Method Detail

createAccessMethod

public static AccessMethod createAccessMethod(Schema schema,
                                              java.lang.String url,
                                              Protocol protocol,
                                              java.lang.String dbDriver,
                                              java.lang.String username)
Used to created an AccessMethod where no password is required to access the data source.


createAccessMethod

public static AccessMethod createAccessMethod(Schema schema,
                                              java.lang.String url,
                                              Protocol protocol,
                                              java.lang.String dbDriver,
                                              java.lang.String username,
                                              java.lang.String password,
                                              java.lang.String wrapper,
                                              int awfFeatures)
Creates a new access method.

Parameters:
schema - the Schema that represents the database to which the access method connects.
url - the URL of the database the access method connects to.
protocol - the Protocol used for the connection.
dbDriver - the database driver used for the connection.
username - the username for connecting to the database.
password - for connecting to the database (which may be null if none is required).
wrapper - is the class name of the associated AutoMedWrapper
awfFeatures - is the feature settings of the associated AutoMedWrapperFactory

remove

public void remove()
            throws InconsistentException
Remove this AccessMethod from the repository.

Throws:
InconsistentException

retract

public void retract()
             throws InconsistentException
Remove this AccessMethod, and any other classes that are dependent upon its existance. Note that in the current version of the repository there are no such classes, and therefore this is equivalent to calling {link #remove()}.

Throws:
InconsistentException

getAccessMethod

public static AccessMethod getAccessMethod(int amid)
                                    throws NotFoundException
Returns the AccessMethod held with the given identifier in in the STR.

Parameters:
amid - the access method identifier (AMID) found in the STR.
Throws:
NotFoundException - is no such AccessMethod exists

getAMID

public int getAMID()
Returns the access method identifier (AMID).

Returns:
the access method identifier (AMID).

getSchema

public Schema getSchema()
Returns the schema that represents the database to which the access method connects.

Returns:
the schema that represents the database to which the access method connects.

getURL

public java.lang.String getURL()
Returns the URL of the database to which the access method connects.

Returns:
the URL of the database to which the access method connects.

getPassword

public java.lang.String getPassword()
Returns the password of the user, if it exists

Returns:
the password as a plain text string if it exists; otherwise null is returned.

getAutoMedWrapperFactoryFeatures

public int getAutoMedWrapperFactoryFeatures()
Returns the feature settings as used with associated AutoMedWrapperFactory

Returns:
integer value of the feature setting

getProtocol

public Protocol getProtocol()
Returns the Protocol used for connecting to the database.

Returns:
the Protocol used for connecting to the database.

getDBDriver

public java.lang.String getDBDriver()
Returns the database driver used for connecting to the database.

Returns:
the database driver used for connecting to the database.

getUsername

public java.lang.String getUsername()
Returns the username used for connecting to the database.

Returns:
the username used for connecting to the database.

getWrapper

public java.lang.String getWrapper()
Returns the wrapper used for connecting to the database.

Returns:
the class name of the AutoMedWrapper associated with this AccessMethod.

getProperty

public java.lang.String getProperty(java.lang.String key)
                             throws NotFoundException
Returns a property associated with this AccessMethod.

Parameters:
key - name given to identify this property. The only standard property names at present are {#link PROPERTY_CREATE_TIME} and {#link PROPERTY_AUTOMED_SCHEMA}.
Returns:
the value held against the key value.
Throws:
NotFoundException - is there is no value recorded under key.

setSchema

public void setSchema(Schema schema)
Sets the schema that represents the database to which the access method connects.

Parameters:
schema - the Schema that represents the database to which the access method connects.

setURL

public void setURL(java.lang.String url)
Sets the URL of the database to which the access method connects.

Parameters:
url - the URL of the database to which the access method connects.

setProtocol

public void setProtocol(Protocol protocol)
Sets the protocol used for connecting to the database.

Parameters:
protocol - the Protocol used for connecting to the database.

setDBDriver

public void setDBDriver(java.lang.String dbDriver)
Sets the database driver used for connecting to the database.

Parameters:
dbDriver - the database driver used for connecting to the database.

setUsername

public void setUsername(java.lang.String username)
Sets the username used for connecting to the database.

Parameters:
username - the username used for connecting to the database.

setWrapper

public void setWrapper(java.lang.String wrapper)
Sets the wrapper asscociated with this.

Parameters:
wrapper - the class name of the AutoMedWrapper associated with this AccessMethod.

setPassword

public void setPassword(java.lang.String password)
Sets the password used for connecting to the database.

Parameters:
password - the password used for connecting to the database.

setAutoMedWrapperFactoryFeatures

public void setAutoMedWrapperFactoryFeatures(int awfFeatures)
Sets the password used for connecting to the database.

Parameters:
password - the password used for connecting to the database.

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Sets a property associated with this AccessMethod.

Parameters:
key - name given to identify this property. The only standard property names at present are {#link PROPERTY_CREATE_TIME} and {#link PROPERTY_AUTOMED_SCHEMA}.
the - value to hold against the key value.

clearAccessMethods

protected static void clearAccessMethods()

getKey

public PersistentKey getKey()
Specified by:
getKey in interface PersistentObject

getPersistentAttributes

public java.util.Map getPersistentAttributes()
Specified by:
getPersistentAttributes in interface PersistentObject

write

public void write(java.io.OutputStream os,
                  int format)
           throws java.io.IOException
Throws:
java.io.IOException