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

java.lang.Object
  extended by uk.ac.ic.doc.automed.reps.Utility

public class Utility
extends java.lang.Object

Class offering utility methods for accessing a SchemaObject's scheme. Models are "er" with constructs entity, attribute, relationship, generalisation and "sql92" with constructs table,field,primary_key,foreign_key,index.

See Also:
SchemaObject, AppConstants

Field Summary
private static java.lang.String attributeConstructName
           
private static java.lang.String entityConstructName
           
private static java.lang.String erModelName
           
private static java.lang.String fieldConstructName
           
private static java.lang.String foreignKeyConstructName
           
private static java.lang.String generalizationConstructName
           
private static java.lang.String indexConstructName
           
private static java.lang.String primaryKeyConstructName
           
private static java.lang.String relationalModelName
           
private static java.lang.String relationshipConstructName
           
private static java.lang.String tableConstructName
           
 
Constructor Summary
Utility()
           
 
Method Summary
static DBAccess connectToReps(java.lang.String repsName)
          Connect to a local AutoMed reps by name
static SchemaObject[] getConstraintReferencedConstructs(SchemaObject schemaObject)
          Returns all the objects in a SchemaObject's scheme that are correspond to positions in the SchemaObject's scheme of type SCHEME_TYPE_CONSTRUCT
static SchemaObject getGeneralConstruct(SchemaObject schemaObject)
          Returns a SchemaObject corresponding to the "general" entity of a generalization.
static java.util.Vector getHDMSchemasFromReps(java.lang.String repsName)
          Get a list of schemas from a repository.
static SchemaObject getPrimaryKeyOfTable(Schema schema, SchemaObject schemaObject)
          Returns the primary key of a table SchemaObject.
static SchemaObject getReferencedConstruct(SchemaObject schemaObject)
          Returns the object a SchemaObject is attached to.
static SchemaObject[] getReferencedConstructs(SchemaObject schemaObject)
          Returns all the objects in a SchemaObject's scheme that are correspond to positions in the SchemaObject's scheme of type SCHEME_TYPE_CONSTRUCT that are of NODAL class.
static SchemaObject getReferencedField(SchemaObject schemaObject)
          Returns the field of a primary key SchemaObject.
static SchemaObject[] getReferencedObjects(SchemaObject schemaObject)
          Returns all the objects in a SchemaObject's scheme that are correspond to positions in the SchemaObject's scheme of type SCHEME_TYPE_CONSTRUCT.
static SchemaObject getReferencedTable(SchemaObject schemaObject)
          Returns the table of a primary key SchemaObject.
static SchemaObject[] getReferringObjects(Schema schema, SchemaObject object)
          Returns the SchemaObject objects that include object in their schemes.
static SchemaObject[] getSpecialConstructs(SchemaObject schemaObject)
          Returns an array of SchemaObject objects corresponing to the sub-entities of a generalization.
static SchemaObject getTableForeignKeyPoints(SchemaObject schemaObject)
          Returns the table that a foreign key SchemaObject points.
static SchemaObject getTableWithForeignKey(SchemaObject schemaObject)
          Returns the table of a foreign key SchemaObject.
static void initialiseRepository(java.lang.String sourceName)
          Used by initRepository() to initialise a particulare data source
static void initRepository()
          This method reinitialises the peer's repository assuming that the default configuration
has been pre-loaded by DSRConfiguration in a previous step.
static boolean isPrimaryKeyForeignKey(Schema schema, SchemaObject schemaObject)
          Returns whether a foreign-key field SchemaObject is also a primary-key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

erModelName

private static java.lang.String erModelName

entityConstructName

private static java.lang.String entityConstructName

attributeConstructName

private static java.lang.String attributeConstructName

relationshipConstructName

private static java.lang.String relationshipConstructName

generalizationConstructName

private static java.lang.String generalizationConstructName

relationalModelName

private static java.lang.String relationalModelName

tableConstructName

private static java.lang.String tableConstructName

fieldConstructName

private static java.lang.String fieldConstructName

primaryKeyConstructName

private static java.lang.String primaryKeyConstructName

foreignKeyConstructName

private static java.lang.String foreignKeyConstructName

indexConstructName

private static java.lang.String indexConstructName
Constructor Detail

Utility

public Utility()
Method Detail

getSpecialConstructs

public static SchemaObject[] getSpecialConstructs(SchemaObject schemaObject)
                                           throws AutoRepException,
                                                  NotFoundException
Returns an array of SchemaObject objects corresponing to the sub-entities of a generalization. The parameter must be a generalization object(model-name: "er", costruct-name: "erGeneralization") , and the objects returned are contained in its scheme.

Parameters:
schemaObject - the generalization object
Returns:
the "specialised" SchemaObject objects in a generalisation hierarchy
Throws:
AutoRepException - if schemaObject isn't an ER generailzation, or if the object has no scheme.
NotFoundException

getGeneralConstruct

public static SchemaObject getGeneralConstruct(SchemaObject schemaObject)
                                        throws AutoRepException,
                                               NotFoundException
Returns a SchemaObject corresponding to the "general" entity of a generalization. The parameter must be a generalization object(model-name: "er", costruct-name: "erGeneralization"), and the object returned is contained in its scheme.

Parameters:
schemaObject - the generalization object
Returns:
the "general" SchemaObject in a generalization hierarchy
Throws:
AutoRepException - if schemaObject isn't an ER generailzation, or if the object has no scheme.
NotFoundException

getReferencedConstructs

public static SchemaObject[] getReferencedConstructs(SchemaObject schemaObject)
Returns all the objects in a SchemaObject's scheme that are correspond to positions in the SchemaObject's scheme of type SCHEME_TYPE_CONSTRUCT that are of NODAL class.

Parameters:
schemaObject - the SchemaObject whose scheme is checked
Returns:
the objects in SchemaObject's scheme that correspond to SCHEME_TYPE_CONSTRUCT positions
Throws:
NotFoundException - if the schemaObject isn't a link-type object or if it hasn't got a scheme.
See Also:
AppConstants

getReferencedObjects

public static SchemaObject[] getReferencedObjects(SchemaObject schemaObject)
                                           throws NotFoundException
Returns all the objects in a SchemaObject's scheme that are correspond to positions in the SchemaObject's scheme of type SCHEME_TYPE_CONSTRUCT.

Parameters:
schemaObject - the SchemaObject whose scheme is checked
Returns:
the objects in SchemaObject's scheme that correspond to SCHEME_TYPE_CONSTRUCT positions
Throws:
NotFoundException - if the object hasn't got a scheme.
See Also:
AppConstants

getReferencedConstruct

public static SchemaObject getReferencedConstruct(SchemaObject schemaObject)
                                           throws AutoRepException
Returns the object a SchemaObject is attached to. The SchemaObject has to be a link-nodal object.

Parameters:
schemaObject - the linknodal object
Returns:
the SchemaObject a link-nodal SchemaObject is arrached to
Throws:
AutoRepException - if schemaObject isn't a link-nodal object or if it hasn't got a scheme.

getReferencedTable

public static SchemaObject getReferencedTable(SchemaObject schemaObject)
                                       throws AutoRepException,
                                              NotFoundException
Returns the table of a primary key SchemaObject. schemaObject must be a primary-key SchemaObject (model: "sql92", construct: "primary_key").

Parameters:
schemaObject - the primary-key object " @return the primary-key's table
Throws:
AutoRepException - if schemaObject isn't a primary-key or if it hasn't got a scheme.
AutoMedException
DSRException
NotFoundException
java.sql.SQLException
java.io.IOException
MDRException

getReferencedField

public static SchemaObject getReferencedField(SchemaObject schemaObject)
                                       throws AutoRepException,
                                              NotFoundException
Returns the field of a primary key SchemaObject. schemaObject must be a primary-key SchemaObject (model: "sql92", construct: "primary_key").

Parameters:
schemaObject - the primary-key object " @return the primary-key's table
Throws:
AutoRepException - if schemaObject isn't a primary-key or if it hasn't got a scheme.
InconsistentException
NotFoundException

getTableWithForeignKey

public static SchemaObject getTableWithForeignKey(SchemaObject schemaObject)
                                           throws AutoRepException,
                                                  NotFoundException
Returns the table of a foreign key SchemaObject. schemaObject must be a foreign-key SchemaObject (model: "sql92", construct: "foreign_key").

Parameters:
schemaObject - the foreign-key object " @return the foreign-key field's table
Throws:
AutoRepException - if schemaObject isn't a foreign-key, or of it doesn't have a scheme
NotFoundException

getTableForeignKeyPoints

public static SchemaObject getTableForeignKeyPoints(SchemaObject schemaObject)
                                             throws AutoRepException,
                                                    NotFoundException
Returns the table that a foreign key SchemaObject points. schemaObject must be a foreign-key SchemaObject (model: "sql92", construct: "foreign_key").

Parameters:
schemaObject - the foreign-key object
Returns:
the table of the primary-key field the foreign-key points
Throws:
AutoRepException - if schemaObject isn't a foreign-key, or of it doesn't have a scheme
InconsistentException
NotFoundException

isPrimaryKeyForeignKey

public static boolean isPrimaryKeyForeignKey(Schema schema,
                                             SchemaObject schemaObject)
                                      throws AutoRepException,
                                             NotFoundException
Returns whether a foreign-key field SchemaObject is also a primary-key. schema is the schema where the table, the table's primary-key and foreign-key have been defined. schemaObject must be a foreign-key SchemaObject (model: "sql92", construct: "foreign_key").

Parameters:
schema - the schema object
schemaObject - the foreign-key object
Returns:
true if the foreign-key field is also a primary-key, false otherwise
Throws:
AutoRepException - if schemaObject isn't a foreign-key, or if it doesn't have a scheme or if the primary-key of the table the foreign-key points is illegal (isn't a primary-key)
InconsistentException
NotFoundException

getPrimaryKeyOfTable

public static SchemaObject getPrimaryKeyOfTable(Schema schema,
                                                SchemaObject schemaObject)
                                         throws NotFoundException,
                                                AutoRepException
Returns the primary key of a table SchemaObject. schema is the schema where both table and table's primary-key are defined. schemaObject must be a table SchemaObject (model: "sql92", construct: "table").

Parameters:
schema - the schema object
schemaObject - the table object
Returns:
the primary key of a table
Throws:
AutoRepException - if the schemaObject isn't a table, or if the table doesn't have a primary-key
InconsistenException
NotFoundException

getConstraintReferencedConstructs

public static SchemaObject[] getConstraintReferencedConstructs(SchemaObject schemaObject)
                                                        throws AutoRepException,
                                                               NotFoundException
Returns all the objects in a SchemaObject's scheme that are correspond to positions in the SchemaObject's scheme of type SCHEME_TYPE_CONSTRUCT

Parameters:
schemaObject - the SchemaObject whose scheme is checked
Returns:
the objects in SchemaObject's scheme that correspond to SCHEME_TYPE_CONSTRUCT positions
Throws:
AutoRepException - if the schemaObject isn't a constraint-type object or if it hasn't got a scheme.
NotFoundException
See Also:
AppConstants

getReferringObjects

public static SchemaObject[] getReferringObjects(Schema schema,
                                                 SchemaObject object)
                                          throws InconsistentException
Returns the SchemaObject objects that include object in their schemes.

Parameters:
object - the SchemaObject to look for in other SchemaObjects schemes
schema - the schema object belongs to
Returns:
the SchemaObject objects that refer to object
Throws:
InconsitentException
InconsistentException

initRepository

public static void initRepository()
                           throws AutoMedException
This method reinitialises the peer's repository assuming that the default configuration
has been pre-loaded by DSRConfiguration in a previous step.

Throws:
AutoMedException

initialiseRepository

public static void initialiseRepository(java.lang.String sourceName)
                                 throws AutoMedException
Used by initRepository() to initialise a particulare data source

Throws:
AutoMedException

connectToReps

public static DBAccess connectToReps(java.lang.String repsName)
                              throws AutoMedException
Connect to a local AutoMed reps by name

Throws:
AutoMedException

getHDMSchemasFromReps

public static java.util.Vector getHDMSchemasFromReps(java.lang.String repsName)
                                              throws AutoMedException
Get a list of schemas from a repository.

Parameters:
repsName -
Returns:
Throws:
AutoMedException