uk.ac.ic.doc.automed.wrappers
Class SQLWrapperFactory

java.lang.Object
  extended by uk.ac.ic.doc.automed.wrappers.AutoMedWrapperFactory
      extended by uk.ac.ic.doc.automed.wrappers.SQLWrapperFactory
Direct Known Subclasses:
HsqldbWrapperFactory, MSAccessWrapperFactory, OracleWrapperFactory, PostgresWrapperFactory, QueryCacheWrapperFactory, SchemaMatchingSQLWrapperFactory, TransactSQLWrapperFactory

public class SQLWrapperFactory
extends AutoMedWrapperFactory

An AutoMed high wrapper factory for creating SQLWrapper instances. Note that this implements a generic interface to JDBC drivers. To make use of special features of a database, subclasses of the class must be used.

Author:
Peter McBrien (pjm@doc.ic.ac.uk)

Field Summary
protected  Model automed
           
static java.lang.String AUTOMED_SQL_MODEL_COLUMN
           
static java.lang.String AUTOMED_SQL_MODEL_FOREIGN_KEY
           
static java.lang.String AUTOMED_SQL_MODEL_INDEX
           
static java.lang.String AUTOMED_SQL_MODEL_NOTNULL_CONSTRAINT
           
static java.lang.String AUTOMED_SQL_MODEL_PRIMARY_KEY
           
static java.lang.String AUTOMED_SQL_MODEL_TABLE
           
static int COLUMN_POSITION
          A feature option to model the position of a column in a table as part of a column in any Schema the factory generates
static int DATA_SIZE
          A feature option to model the size in bytes of a column as part of a column in any Schema the factory generates
static int DATA_TYPE
          A feature option to model the datatype of a column as part of a column in any Schema the factory generates
static int FOREIGN_KEY
          A feature option to model foreign keys in any Schema the factory generates
static int INDEX
          A feature option to model SQL Indexes in any Schema the factory generates
protected static boolean justTableName
           
static int NONSCALAR_COMPOUND_KEY
           
static int NULL_CONSTRAINT
          A feature option to model the null/notnull distinction as part of a column in any Schema the factory generates
protected  Construct primary_key
           
static int PRIMARY_KEY
          A feature option to model primary keys in any Schema the factory generates
static java.lang.String ROOT_TYPE_NAME
           
static int SCHEMA_AWARE
          A feature option to model SQL schemas.
static int SCHEMA_MERGING
           
protected  java.awt.Color source_background_colour
           
protected  Model sql
           
static java.lang.String SQL_MODEL_FOREIGN_KEY
           
static java.lang.String SQL_MODEL_INDEX
           
static java.lang.String SQL_MODEL_PRIMARY_KEY
           
static java.lang.String SQL_MODEL_TABLE
          The name of the Construct used to represent SQL tables.
protected  Construct table
           
protected  int tableSchemeLength
           
 
Fields inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapperFactory
automedModelName, baseName, empty, factoryInUse, modelName, SOURCE_PREFIX
 
Constructor Summary
SQLWrapperFactory()
           
 
Method Summary
 void createAutoMedModel()
          Define a relational modelling language for the SQL standard which is an "AutoMed" oriented modelling language..
 Schema createAutoMedSchema(AutoMedWrapper wrapper, java.lang.String schemaName)
          Create an AutoMed oriented schema from the source oriented schema.
 void createModel()
          Define a relational modelling language for the SQL standard, together with the JDBC protocol for accessing SQL compliant databases.
 Model getAutoMedModel()
          Return the AutoMed relational Model used to represent the Schema for the SQL datasource wrapper.
 int getColumnDetailsSchemeLength()
          Return the number of fields in a full source table scheme that are used to represent the structure and type of one column (ie its name, data type, size, null, ...)
 java.lang.String getDefaultSchemaName(AutoMedWrapper wrapper)
          Return the name of the default schema for the type of database being wrapped.
 java.lang.String[] getFeatureNames()
          Return a string list of features supported by this wrapper, where the first one is bit zero in the feature bit map, second bit one, etc
 Model getModel()
          Return the `raw' relational Model used to represent the Schema for the SQL datasource wrapper.
protected  java.lang.String getSQLTableReference(java.lang.Object[] scheme)
          Given the scheme of a table, get the name SQL uses to reference that table.
 int getTableDetailsSchemeLength()
          Return the number of fields in a full source table scheme used to reprsent the table details
protected  AutoMedWrapper newAutoMedWrapper()
          Create a new empty wrapper instance that this wrapper factory is then able to populate.
protected  void populateSchema(AutoMedWrapper wrapper)
          Read the metadata from the wrapper connection, and store in existing Schema within the wrapper.
 void setFeatures(int features)
          Allows certain features of the SQL92 data model to be represented in the AutoMed repository.
 
Methods inherited from class uk.ac.ic.doc.automed.wrappers.AutoMedWrapperFactory
clearFeatures, getAttributeDomains, getAutoMedModelName, getFeatures, getModelBaseName, getModelName, isFeatureInUse, safeIQL, setAttributeDomains, setFeatures, setModelBaseName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sql

protected Model sql

table

protected Construct table

primary_key

protected Construct primary_key

source_background_colour

protected java.awt.Color source_background_colour

SQL_MODEL_TABLE

public static final java.lang.String SQL_MODEL_TABLE
The name of the Construct used to represent SQL tables. This is a HDM node, where the node name is that of the SQL table, and the labels that follow it represent column names of the table.

See Also:
Constant Field Values

SQL_MODEL_PRIMARY_KEY

public static final java.lang.String SQL_MODEL_PRIMARY_KEY
See Also:
Constant Field Values

SQL_MODEL_FOREIGN_KEY

public static final java.lang.String SQL_MODEL_FOREIGN_KEY
See Also:
Constant Field Values

SQL_MODEL_INDEX

public static final java.lang.String SQL_MODEL_INDEX
See Also:
Constant Field Values

justTableName

protected static final boolean justTableName
See Also:
Constant Field Values

ROOT_TYPE_NAME

public static final java.lang.String ROOT_TYPE_NAME
See Also:
Constant Field Values

automed

protected Model automed

AUTOMED_SQL_MODEL_TABLE

public static final java.lang.String AUTOMED_SQL_MODEL_TABLE
See Also:
Constant Field Values

AUTOMED_SQL_MODEL_COLUMN

public static final java.lang.String AUTOMED_SQL_MODEL_COLUMN
See Also:
Constant Field Values

AUTOMED_SQL_MODEL_NOTNULL_CONSTRAINT

public static final java.lang.String AUTOMED_SQL_MODEL_NOTNULL_CONSTRAINT
See Also:
Constant Field Values

AUTOMED_SQL_MODEL_PRIMARY_KEY

public static final java.lang.String AUTOMED_SQL_MODEL_PRIMARY_KEY
See Also:
Constant Field Values

AUTOMED_SQL_MODEL_FOREIGN_KEY

public static final java.lang.String AUTOMED_SQL_MODEL_FOREIGN_KEY
See Also:
Constant Field Values

AUTOMED_SQL_MODEL_INDEX

public static final java.lang.String AUTOMED_SQL_MODEL_INDEX
See Also:
Constant Field Values

tableSchemeLength

protected int tableSchemeLength

INDEX

public static final int INDEX
A feature option to model SQL Indexes in any Schema the factory generates

See Also:
Constant Field Values

PRIMARY_KEY

public static final int PRIMARY_KEY
A feature option to model primary keys in any Schema the factory generates

See Also:
Constant Field Values

FOREIGN_KEY

public static final int FOREIGN_KEY
A feature option to model foreign keys in any Schema the factory generates

See Also:
Constant Field Values

NULL_CONSTRAINT

public static final int NULL_CONSTRAINT
A feature option to model the null/notnull distinction as part of a column in any Schema the factory generates

See Also:
Constant Field Values

DATA_TYPE

public static final int DATA_TYPE
A feature option to model the datatype of a column as part of a column in any Schema the factory generates

See Also:
Constant Field Values

DATA_SIZE

public static final int DATA_SIZE
A feature option to model the size in bytes of a column as part of a column in any Schema the factory generates

See Also:
Constant Field Values

COLUMN_POSITION

public static final int COLUMN_POSITION
A feature option to model the position of a column in a table as part of a column in any Schema the factory generates

See Also:
Constant Field Values

SCHEMA_AWARE

public static final int SCHEMA_AWARE
A feature option to model SQL schemas. When not set, the factory will only model the user's default schema. When set, the factory will model all schemas in the database, unless the SCHEMA_FILTER option is used.

See Also:
Constant Field Values

SCHEMA_MERGING

public static final int SCHEMA_MERGING
See Also:
Constant Field Values

NONSCALAR_COMPOUND_KEY

public static final int NONSCALAR_COMPOUND_KEY
See Also:
Constant Field Values
Constructor Detail

SQLWrapperFactory

public SQLWrapperFactory()
Method Detail

getColumnDetailsSchemeLength

public int getColumnDetailsSchemeLength()
Return the number of fields in a full source table scheme that are used to represent the structure and type of one column (ie its name, data type, size, null, ...)


getTableDetailsSchemeLength

public int getTableDetailsSchemeLength()
Return the number of fields in a full source table scheme used to reprsent the table details


getFeatureNames

public java.lang.String[] getFeatureNames()
Return a string list of features supported by this wrapper, where the first one is bit zero in the feature bit map, second bit one, etc

Specified by:
getFeatureNames in class AutoMedWrapperFactory

getModel

public final Model getModel()
Return the `raw' relational Model used to represent the Schema for the SQL datasource wrapper.

Specified by:
getModel in class AutoMedWrapperFactory

getAutoMedModel

public final Model getAutoMedModel()
Return the AutoMed relational Model used to represent the Schema for the SQL datasource wrapper.

Specified by:
getAutoMedModel in class AutoMedWrapperFactory

setFeatures

public void setFeatures(int features)
                 throws IntegrityException
Allows certain features of the SQL92 data model to be represented in the AutoMed repository.

Overrides:
setFeatures in class AutoMedWrapperFactory
Parameters:
features - a bit wise `or' of the feature flags INDEX, PRIMARY_KEY, FOREIGN_KEY, NULL_CONSTRAINT, DATA_TYPE, DATA_SIZE, COLUMN_POSITION, indicating which features are to be used in addition. By default no features are used, maaning that the AutoMed comprises of tables with untyped columns
Throws:
IntegrityException - if the factory is already being used for producing wrappers. You should create a new SQLWrapperFactory for your settings.

createAutoMedModel

public final void createAutoMedModel()
Define a relational modelling language for the SQL standard which is an "AutoMed" oriented modelling language..


createModel

public final void createModel()
Define a relational modelling language for the SQL standard, together with the JDBC protocol for accessing SQL compliant databases. Note that this is automatically called by getModel() if the SQL model for this factory does not already exist, and thus only needs to called by user appications if there is the need to create the SQL model independently of wrapping a data source.


getDefaultSchemaName

public java.lang.String getDefaultSchemaName(AutoMedWrapper wrapper)
Return the name of the default schema for the type of database being wrapped.


populateSchema

protected void populateSchema(AutoMedWrapper wrapper)
                       throws DataSourceException
Description copied from class: AutoMedWrapperFactory
Read the metadata from the wrapper connection, and store in existing Schema within the wrapper. To be called by AutoMedWrapper instances as part of the wrapper creation process.

Specified by:
populateSchema in class AutoMedWrapperFactory
Throws:
DataSourceException

getSQLTableReference

protected java.lang.String getSQLTableReference(java.lang.Object[] scheme)
Given the scheme of a table, get the name SQL uses to reference that table.

Parameters:
scheme - holds the scheme of a table, as returned by SchemaObject.getSchemeDefinition().
Returns:
holding the fully qualified name of the table

createAutoMedSchema

public Schema createAutoMedSchema(AutoMedWrapper wrapper,
                                  java.lang.String schemaName)
                           throws IntegrityException,
                                  NotFoundException
Description copied from class: AutoMedWrapperFactory
Create an AutoMed oriented schema from the source oriented schema.

Specified by:
createAutoMedSchema in class AutoMedWrapperFactory
Parameters:
wrapper - A wrapper containing the source oriented Schema from which the AutoMed oriented Schema should be produced.
schemaName - name of the new AutoMed construct oriented schema that is to be created from the source oriented schema. This schema must not yet exist.
Throws:
IntegrityException - if schemaName already exists.
NotFoundException - if you have not previously wrapped the datasource as a source oriented schema, using either #AutoMedWrapper.getSchema(String) or #AutoMedWrapper.selectNewAutoMedWrapper

newAutoMedWrapper

protected AutoMedWrapper newAutoMedWrapper()
Description copied from class: AutoMedWrapperFactory
Create a new empty wrapper instance that this wrapper factory is then able to populate.

Specified by:
newAutoMedWrapper in class AutoMedWrapperFactory