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

java.lang.Object
  |
  +--uk.ac.ic.doc.automed.reps.Schema

public class Schema
extends java.lang.Object

The Schema class

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

Field Summary
static int LIST_SCHEMA_LONG
          Constant used to indicate where schemes in schemas must be listed with all details, including the OBID as returned by SchemaObject.getOBID() SchemaObject}, and the Construct as returned by SchemaObject.getConstruct().
static int LIST_SCHEMA_NORMAL
          Constant used to indicate where schemes in schemas must be listed with all the type of each SchemaObject prefixing the scheme of each object.
static int LIST_SCHEMA_SHORT
          Constant used to indicate where schemes in schemas must be listed with the minimum of detail.
 
Method Summary
 Schema applyAddTransformation(Construct toObjectConstructType, java.lang.Object[] toObject, java.lang.String function, java.lang.String constraint)
          Returns the Schema which is the result of applying an ADD transformation.
 Schema applyAddTransformation(Construct toObjectConstructType, java.lang.Object[] toObject, java.lang.String function, java.lang.String constraint, java.lang.String newSchemaName)
          Returns the Schema which is the result of applying an ADD transformation.
 Schema applyContractTransformation(SchemaObject fromObject, java.lang.String function, java.lang.String constraint)
          Returns the Schema which is the result of applying a CONTRACT transformation.
 Schema applyContractTransformation(SchemaObject fromObject, java.lang.String function, java.lang.String constraint, java.lang.String newSchemaName)
          Returns the Schema which is the result of applying a CONTRACT transformation.
 Schema applyDeleteTransformation(SchemaObject fromObject, java.lang.String function, java.lang.String constraint)
          Returns the Schema which is the result of applying a DELETE transformation.
 Schema applyDeleteTransformation(SchemaObject fromObject, java.lang.String function, java.lang.String constraint, java.lang.String newSchemaName)
          Returns the Schema which is the result of applying a DELETE transformation.
 Schema applyExtendTransformation(Construct toObjectConstructType, java.lang.Object[] toObject, java.lang.String function, java.lang.String constraint)
          Returns the Schema which is the result of applying an EXTEND transformation.
 Schema applyExtendTransformation(Construct toObjectConstructType, java.lang.Object[] toObject, java.lang.String function, java.lang.String constraint, java.lang.String newSchemaName)
          Returns the Schema which is the result of applying an EXTEND transformation.
 Schema applyRenameTransformation(SchemaObject fromObject, java.lang.Object[] toObject)
          Returns the Schema which is the result of applying a RENAME transformation.
 Schema applyRenameTransformation(SchemaObject fromObject, java.lang.Object[] toObject, java.lang.String newSchemaName)
          Returns the Schema which is the result of applying a RENAME transformation.
protected  void checkEditable()
          Checks whether a schema is editable.
static void clearSchemas()
          This method empties all the cached Schema, SchemaObject, Transformation, AccessMethods and Protocols that have been cached.
static Schema createSchema(java.lang.String schemaName, boolean isDataSource)
          Creates a new schema.
protected static Schema createSchema(java.lang.String schemaName, boolean isExtSchema, boolean isExtDB, boolean isDataSource, boolean dbOnly)
          Creates a new schema.
 SchemaObject createSchemaObject(Construct cType, java.lang.Object[] schemeObjects)
          Creates a schema object.
 SchemaObject[] differenceByName(Schema s2)
          Return an SchemaObject array containing the difference by name between this schema (s1) and the schema passed as a parameter (s2).
static boolean exists(java.lang.String schemaName)
          Returns true is the named schema exists
 void exportSchemaObjects(java.io.OutputStream os)
           
 void exportSchemaObjects(java.io.PrintWriter pw)
           
 Schema extendToMatch(Schema schemaToAdd)
          Create a new Schema which contains the same set of constructs as the current schema, plus all those constructs of another schema, which are defined via extend operators.
 Schema[] findAttachedDataSources()
          Returns an array of Schema's that are connected to this schema by some transformation pathway and are data sources (including this schema itself if it is a data source).
 Schema[] findAttachedExtDBs()
          Returns an array of Schema's that are connected to this schema by some transformation pathway and have extensional data (including this schema itself if it has extensional data).
 Schema[] findAttachedExtSchemas()
          Returns an array of Schema's that are connected to this schema by some transformation pathway and are extensional schemas (including this schema itself if it is an extensional schema).
 Schema[] findShortestPath(Schema target)
          Returns an array of schemas such that: There is a transformation between each pair of adjacent schamas.
 AccessMethod[] getAccessMethods()
          Find the AccessMethods that may be used to access the physical database system that holds this Schema.
 java.lang.Object[] getAllSchemeNames()
          Returns an Object array of schemes of all the schema objects that belong to the schema.
 java.lang.Object[] getAllSchemeNames(boolean all, int idDepth, int typeDepth)
           
 java.lang.String getAllSchemeNamesString()
          Returns the scheme representation (of type String) of the schemes of all the schema objects that belong to the schema.
 java.lang.String getAllSchemeNamesString(boolean all, int idDepth, int typeDepth)
           
static java.lang.String getCloseSchemeBracket()
          find what string is used to deliminate the closing of a scheme name, such as the ">>" in "<<person>>" or "<<person,name>>".
 java.lang.String getName()
          Find the name of the schema.
static java.lang.String getName(int SID)
          Returns the name of a schema from its SID without instantiating it
static java.lang.String getOpenSchemeBracket()
          Find what string is used to deliminate the opening of a scheme name, such as the "<<" in "<<person>>" or "<<person,name>>".
static Schema getSchema(int sid)
          Returns the Schema object which has the given schema identifier (SID).
static Schema getSchema(java.lang.String schemaName)
          Returns the Schema object with the given name.
static int[] getSchemaIDs()
          Returns an array of SID of all the schemas found in the STR.
static java.lang.String[] getSchemaNames()
          Returns an array of names of all the schemas found in the STR.
 SchemaObject getSchemaObject(java.lang.String name)
          Return the SchemaObject that has the supplied name in this schema.
 SchemaObject getSchemaObjectByName(java.lang.String name)
          Return the SchemaObject that has the supplied name in this schema.
 SchemaObject[] getSchemaObjects()
          Returns an array of schema objects (of class SchemaObject) that belong to the schema.
 int getSID()
          Returns the schema identifier (SID) of the schema.
 Transformation[] getTransformations()
          Return an array of all Transformation that go out from a particular schema.
protected  Transformation[] getTransformationsFrom()
          Returns an array of Transformation's that have this schema as the fromSchema field in the transformation table of the STR.
protected  Transformation[] getTransformationsTo()
          Returns an array of Transformation's that have this schema as the toSchema field in the transformation table of the STR.
protected  boolean hasObject(SchemaObject so)
          Determines if the schema contains the given schema object.
 void importSchemaObjects(java.io.InputStream is)
           
 SchemaObject[] intersectionByName(Schema s2)
          Return an SchemaObject array containing the intersection by name between this schema (s1) and the schema passed as a parameter (s2).
 boolean isCached()
          Deprecated. the isCached field in the schema table of the STR is no longer used. Determines whether or not the schema is cached. If a schema is cached, its contents (schema objects) are materialized and stored temporarily in the STR.
 boolean isDataSource()
          Determines whether or not the schema represents an external data source.
 boolean isExtDB()
          Determines whether or not the schema represents an extentional database.
 boolean isExtSchema()
          Determines whether or not the schema is an extentional schema.
 void listSchema()
          List the Schema to the current output in a form designed for human interpretation.
 void listSchema(java.io.PrintStream out)
          Shorthand for calling listSchema(out,LIST_SCHEMA_NORMAL)
 void listSchema(java.io.PrintStream out, int mode)
          List the Schema to an output stream, using the specified format.
 void materialize(uk.ac.ic.doc.automed.reps.Path path)
          Materialize the contents of an intentional schema via the given path.
 Schema prefixAllNodalNames(java.lang.String prefix)
          Create a new Schema which contains the same set of constructs as an existing, except each has been renamed to have a common prefix if it is of Construct type Nodal.
 Transformation prefixSchemaObjectName(java.lang.String prefix, SchemaObject nodeObject)
          Create a new Schema if the SchemaObject is a Nodal object, where the SchemaObject has had a prefix applied to the node name,
static Schema read(java.io.InputStream is)
           
static Schema read(java.io.InputStream is, java.lang.String name)
           
static void reloadSchemas()
           
 void remove()
          Removes the Schema from the repository.
static void remove(java.lang.String schemaName)
          Removes the Schema with the given schemaName.
 void removeAccessMethods()
          Remove all AccessMethods recorded for this schema.
 void removeSchemaObjects()
          Removes all schema objects that belong to the schema, i.e., the schema's SchemaObject list is emptied.
 void retract()
          Removes the Schema from the repository, together with any SchemaObjects left in the schema, and any Transformations that link to this schema.
static void retract(java.lang.String schemaName)
          Removes any Schema with the given name from the repository, together with any SchemaObjects left in the schema, and any Transformations that link to this schema.
 void setCached(boolean cached)
          Deprecated. the isCached field in the schema table of the STR is no longer used. Sets whether or not the schema is cached. A schema can only be cached if it is an extentional schema.
 void setDataSource(boolean dataSource)
          Sets whether or not the schema represents an external data source.
 void setExtDB(boolean extDB)
          Sets whether or not the schema represents an extentional database.
 void setExtSchema(boolean extSchema)
          Sets whether or not the schema is an extentional schema.
 void setName(java.lang.String name)
          Set the name of a Schema.
static void setOpenCloseSchemeBracket(java.lang.String openScheme, java.lang.String closeScheme)
          Set the Strings that is used to open and close a scheme name, such as the "<<" and ">>" in "<<person>>" or "<<person,name>>".
 Schema union(Schema s2)
          Return an Schema (su) containing the union of SchemaObjects in this schema (s1) and the schema passed as a parameter (s2).
 SchemaObject[] unionByName(Schema s2)
          Return an SchemaObject array containing the union by name between this schema (s1) and the schema passed as a parameter (s2).
 void updateSchemaObjectNameHashMap()
          Update this Schema's hashmap of how each SchemaObject in the schema is named.
 void write()
          Write to the standard out a text representation of this Schema object, in a form suitable for human interpretation, and suitable for being used as the input to read()
 void write(java.io.OutputStream os)
           
 void write(java.io.PrintWriter pw)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIST_SCHEMA_SHORT

public static final int LIST_SCHEMA_SHORT
Constant used to indicate where schemes in schemas must be listed with the minimum of detail.

See Also:
Constant Field Values

LIST_SCHEMA_NORMAL

public static final int LIST_SCHEMA_NORMAL
Constant used to indicate where schemes in schemas must be listed with all the type of each SchemaObject prefixing the scheme of each object.

See Also:
Constant Field Values

LIST_SCHEMA_LONG

public static final int LIST_SCHEMA_LONG
Constant used to indicate where schemes in schemas must be listed with all details, including the OBID as returned by SchemaObject.getOBID() SchemaObject}, and the Construct as returned by SchemaObject.getConstruct().

See Also:
Constant Field Values
Method Detail

reloadSchemas

public static void reloadSchemas()

createSchema

public static Schema createSchema(java.lang.String schemaName,
                                  boolean isDataSource)
                           throws InconsistentException
Creates a new schema.

Parameters:
schemaName - name of the schema.
isDataSource - set to true if the schema represents an external data source; false otherwise.
Throws:
InconsistentException

createSchema

protected static Schema createSchema(java.lang.String schemaName,
                                     boolean isExtSchema,
                                     boolean isExtDB,
                                     boolean isDataSource,
                                     boolean dbOnly)
                              throws InconsistentException
Creates a new schema.

Parameters:
schemaName - name of the schema.
isExtSchema - set to true if the schema is an extentional schema; false otherwise.
isExtDB - set to true if the schema represents an extentional database; false otherwise.
isDataSource - set to true if the schema represents an external data source; false otherwise.
dbOnly - set to true if the instantiated Schema object is not to be added to the HashMap of schemas, a structure in the Schema class that stores all instantiated schemas. Note that, for an intentional schema, its Schema is not added to this HashMap unless its contents have been materialized.
Throws:
InconsistentException

checkEditable

protected void checkEditable()
                      throws InconsistentException
Checks whether a schema is editable. A schema that is extentional or has any transformations associated with it is not editable.

Throws:
InconsistentException

remove

public static void remove(java.lang.String schemaName)
Removes the Schema with the given schemaName. Equivalent to calling {link Schema.remove()} of the Schema with the given name.

Parameters:
schemaName - the name of the schema to be removed from the repository

remove

public void remove()
            throws IntegrityException
Removes the Schema from the repository. Before being called, there must be no SchemaObjects left in this schema, nor any Transformations that link to this schema.

Throws:
IntegrityException - if the schema is an extentional schema containing one or more SchemaObjects, or any schema that has one or more Transformations attached.

retract

public void retract()
             throws IntegrityException
Removes the Schema from the repository, together with any SchemaObjects left in the schema, and any Transformations that link to this schema.

Throws:
IntegrityException

retract

public static void retract(java.lang.String schemaName)
Removes any Schema with the given name from the repository, together with any SchemaObjects left in the schema, and any Transformations that link to this schema. If no such schema exists, this method does nothing.


createSchemaObject

public SchemaObject createSchemaObject(Construct cType,
                                       java.lang.Object[] schemeObjects)
                                throws TypeMismatchException
Creates a schema object. Note that this method can only be invoked by an extentional schema.

Parameters:
cType - construct type (of class Construct) of the schema object.
schemeObjects - an array of string values and/or schema objects contained in the scheme of the new schema object. Only one string value is allowed in the array which represents the name/value of the schema object.
Returns:
a schema object.
TypeMismatchException

getSID

public int getSID()
Returns the schema identifier (SID) of the schema.

Returns:
the schema identifier (SID) of the schema.

getName

public java.lang.String getName()
Find the name of the schema.

Returns:
the name of the schema.

setName

public void setName(java.lang.String name)
             throws IntegrityException
Set the name of a Schema.

Parameters:
name - new name to give to the schema
Throws:
IntegrityException - if another schema already exists with this name in the repository

getName

public static java.lang.String getName(int SID)
                                throws InconsistentException
Returns the name of a schema from its SID without instantiating it

Parameters:
SID - The schema id for which the name will be returned
Returns:
the name of the schema with id SID
InconsistentException

isExtSchema

public boolean isExtSchema()
Determines whether or not the schema is an extentional schema.

Returns:
true if the schema is an extentional schema; false if it is an intentional schema.

isExtDB

public boolean isExtDB()
Determines whether or not the schema represents an extentional database.

Returns:
true if the schema represents an extentional database; false otherwise.

isDataSource

public boolean isDataSource()
Determines whether or not the schema represents an external data source.

Returns:
true if the schema represents an external data source; false otherwise.

isCached

public boolean isCached()
Deprecated. the isCached field in the schema table of the STR is no longer used. Determines whether or not the schema is cached. If a schema is cached, its contents (schema objects) are materialized and stored temporarily in the STR.

Returns:
true if the schema has its contents cached; false otherwise.

getSchemaObjects

public SchemaObject[] getSchemaObjects()
                                throws InconsistentException
Returns an array of schema objects (of class SchemaObject) that belong to the schema.

Returns:
an array of schema objects (of class SchemaObject) that belong to the schema.
Throws:
InconsistentException

getAllSchemeNames

public java.lang.Object[] getAllSchemeNames()
Returns an Object array of schemes of all the schema objects that belong to the schema.


getAllSchemeNames

public java.lang.Object[] getAllSchemeNames(boolean all,
                                            int idDepth,
                                            int typeDepth)

getAllSchemeNamesString

public java.lang.String getAllSchemeNamesString()
                                         throws InconsistentException
Returns the scheme representation (of type String) of the schemes of all the schema objects that belong to the schema.

Throws:
InconsistentException

getAllSchemeNamesString

public java.lang.String getAllSchemeNamesString(boolean all,
                                                int idDepth,
                                                int typeDepth)
                                         throws InconsistentException
InconsistentException

setExtSchema

public void setExtSchema(boolean extSchema)
Sets whether or not the schema is an extentional schema.

Parameters:
extSchema - set to true if the schema is an extentional schema; false otherwise.

setExtDB

public void setExtDB(boolean extDB)
Sets whether or not the schema represents an extentional database.

Parameters:
extDB - set to true if the schema represents an extentional database; false otherwise.

setDataSource

public void setDataSource(boolean dataSource)
                   throws InconsistentException
Sets whether or not the schema represents an external data source.

Parameters:
dataSource - set to true if the schema represents an external data source; false otherwise.
Throws:
InconsistentException

setCached

public void setCached(boolean cached)
               throws InconsistentException
Deprecated. the isCached field in the schema table of the STR is no longer used. Sets whether or not the schema is cached. A schema can only be cached if it is an extentional schema.

Throws:
InconsistentException
See Also:
setExtSchema(boolean)

removeSchemaObjects

public void removeSchemaObjects()
                         throws IntegrityException
Removes all schema objects that belong to the schema, i.e., the schema's SchemaObject list is emptied.

Throws:
IntegrityException

exists

public static boolean exists(java.lang.String schemaName)
Returns true is the named schema exists

Parameters:
schemaName - name of the schema to check for the existance of

getSchema

public static Schema getSchema(java.lang.String schemaName)
                        throws NotFoundException
Returns the Schema object with the given name.

Parameters:
schemaName - name of the schema.
Returns:
reference to the Schema object with the given name, or null if it does not exist.
Throws:
NotFoundException - if no schema with the given name exists in the repository

getSchemaNames

public static java.lang.String[] getSchemaNames()
Returns an array of names of all the schemas found in the STR.

Returns:
an array of names of all the schemas found in the STR.

getSchemaIDs

public static int[] getSchemaIDs()
                          throws InconsistentException
Returns an array of SID of all the schemas found in the STR.

Returns:
an array of names of all the schemas found in the STR.
InconsistentException

getSchema

public static Schema getSchema(int sid)
                        throws NotFoundException
Returns the Schema object which has the given schema identifier (SID).

Parameters:
sid - the SID of the Schema to return
Returns:
the Schema object which has the SID.
Throws:
NotFoundException - if no schema exists in the repository with this SID

materialize

public void materialize(uk.ac.ic.doc.automed.reps.Path path)
                 throws NotFoundException
Materialize the contents of an intentional schema via the given path.

Parameters:
path - the path via which the intentional schema is to be materialized.
NotFoundException

hasObject

protected boolean hasObject(SchemaObject so)
Determines if the schema contains the given schema object.

Returns:
true if the schema contains the given schema object; false otherwise.

getTransformationsFrom

protected Transformation[] getTransformationsFrom()
                                           throws InconsistentException
Returns an array of Transformation's that have this schema as the fromSchema field in the transformation table of the STR.

Returns:
an array of Transformation's that have this schema as the fromSchema field in the transformation table of the STR.
Throws:
InconsistentException

getTransformationsTo

protected Transformation[] getTransformationsTo()
                                         throws InconsistentException
Returns an array of Transformation's that have this schema as the toSchema field in the transformation table of the STR.

Returns:
an array of Transformation's that have this schema as the toSchema field in the transformation table of the STR.
Throws:
InconsistentException

applyAddTransformation

public Schema applyAddTransformation(Construct toObjectConstructType,
                                     java.lang.Object[] toObject,
                                     java.lang.String function,
                                     java.lang.String constraint)
                              throws TypeMismatchException,
                                     IntegrityException
Returns the Schema which is the result of applying an ADD transformation.

Parameters:
toObjectConstructType - the construct type (see Construct) of the resulting transformation object.
toObject - the scheme (in an Object array) that forms the output of the transformation.
function - the query that expresses the extent of the construct being transformed.
constraint - the constraint associated with the transformation (if any).
Returns:
the Schema which is the result of applying an ADD transformation.
Throws:
InconsistentException
IntegrityException
TypeMismatchException

applyAddTransformation

public Schema applyAddTransformation(Construct toObjectConstructType,
                                     java.lang.Object[] toObject,
                                     java.lang.String function,
                                     java.lang.String constraint,
                                     java.lang.String newSchemaName)
                              throws TypeMismatchException,
                                     IntegrityException
Returns the Schema which is the result of applying an ADD transformation.

Parameters:
toObjectConstructType - the construct type (see Construct) of the resulting transformation object.
toObject - the scheme (in an Object array) that forms the output of the transformation.
function - the query that expresses the extent of the construct being transformed.
constraint - the constraint associated with the transformation (if any).
newSchemaName - the name of the resultant schema.
Returns:
the Schema which is the result of applying an ADD transformation.
Throws:
TypeMismatchException
IntegrityException

applyDeleteTransformation

public Schema applyDeleteTransformation(SchemaObject fromObject,
                                        java.lang.String function,
                                        java.lang.String constraint)
                                 throws TypeMismatchException,
                                        IntegrityException
Returns the Schema which is the result of applying a DELETE transformation.

Parameters:
fromObject - the SchemaObject to be deleted in the transformation. Note that this schema object must belong to the given fromSchema.
function - the query that expresses the extent of the construct being transformed.
constraint - the constraint associated with the transformation (if any).
Returns:
the Schema which is the result of applying a DELETE transformation.
Throws:
TypeMismatchException
IntegrityException

applyDeleteTransformation

public Schema applyDeleteTransformation(SchemaObject fromObject,
                                        java.lang.String function,
                                        java.lang.String constraint,
                                        java.lang.String newSchemaName)
                                 throws TypeMismatchException,
                                        IntegrityException
Returns the Schema which is the result of applying a DELETE transformation.

Parameters:
fromObject - the SchemaObject to be deleted in the transformation. Note that this schema object must belong to the given fromSchema.
function - the query that expresses the extent of the construct being transformed.
constraint - the constraint associated with the transformation (if any).
newSchemaName - the name of the resultant schema.
Returns:
the Schema which is the result of applying a DELETE transformation.
Throws:
TypeMismatchException
IntegrityException

applyRenameTransformation

public Schema applyRenameTransformation(SchemaObject fromObject,
                                        java.lang.Object[] toObject)
                                 throws TypeMismatchException,
                                        IntegrityException
Returns the Schema which is the result of applying a RENAME transformation.

Parameters:
fromObject - the SchemaObject to be renamed in the transformation. Note that this schema object must belong to the given fromSchema.
toObject - the scheme (in an Object array) that forms the output of the transformation. (The construct type of toObject must be the same as the fromObject).
Returns:
the Schema which is the result of applying a RENAME transformation.
Throws:
TypeMismatchException
IntegrityException

applyRenameTransformation

public Schema applyRenameTransformation(SchemaObject fromObject,
                                        java.lang.Object[] toObject,
                                        java.lang.String newSchemaName)
                                 throws TypeMismatchException,
                                        IntegrityException
Returns the Schema which is the result of applying a RENAME transformation.

Parameters:
fromObject - the SchemaObject to be renamed in the transformation. Note that this schema object must belong to the given fromSchema.
toObject - the scheme (in an Object array) that forms the output of the transformation. (The construct type of toObject must be the same as the fromObject).
newSchemaName - the name of the resultant schema.
Returns:
the Schema which is the result of applying a RENAME transformation.
Throws:
TypeMismatchException
IntegrityException

applyExtendTransformation

public Schema applyExtendTransformation(Construct toObjectConstructType,
                                        java.lang.Object[] toObject,
                                        java.lang.String function,
                                        java.lang.String constraint)
                                 throws TypeMismatchException,
                                        IntegrityException
Returns the Schema which is the result of applying an EXTEND transformation.

Parameters:
toObjectConstructType - the construct type (see Construct) of the resulting transformation object.
toObject - the scheme (in an Object array) that forms the output of the transformation.
function - the query that expresses the extent of the construct being transformed.
constraint - the constraint associated with the transformation (if any).
Returns:
the Schema which is the result of applying an EXTEND transformation.
Throws:
TypeMismatchException
IntegrityException

applyExtendTransformation

public Schema applyExtendTransformation(Construct toObjectConstructType,
                                        java.lang.Object[] toObject,
                                        java.lang.String function,
                                        java.lang.String constraint,
                                        java.lang.String newSchemaName)
                                 throws TypeMismatchException,
                                        IntegrityException
Returns the Schema which is the result of applying an EXTEND transformation.

Parameters:
toObjectConstructType - the construct type (see Construct) of the resulting transformation object.
toObject - the scheme (in an Object array) that forms the output of the transformation.
function - the query that expresses the extent of the construct being transformed.
constraint - the constraint associated with the transformation (if any).
newSchemaName - the name of the resultant schema.
Returns:
the Schema which is the result of applying an EXTEND transformation.
Throws:
TypeMismatchException
IntegrityException

applyContractTransformation

public Schema applyContractTransformation(SchemaObject fromObject,
                                          java.lang.String function,
                                          java.lang.String constraint)
                                   throws TypeMismatchException,
                                          IntegrityException
Returns the Schema which is the result of applying a CONTRACT transformation.

Parameters:
fromObject - the SchemaObject to be contracted in the transformation. Note that this schema object must belong to the given fromSchema.
function - the query that expresses the extent of the construct being transformed.
constraint - the constraint associated with the transformation (if any).
Returns:
the Schema which is the result of applying a CONTRACT transformation.
Throws:
TypeMismatchException
IntegrityException

applyContractTransformation

public Schema applyContractTransformation(SchemaObject fromObject,
                                          java.lang.String function,
                                          java.lang.String constraint,
                                          java.lang.String newSchemaName)
                                   throws TypeMismatchException,
                                          IntegrityException
Returns the Schema which is the result of applying a CONTRACT transformation.

Parameters:
fromObject - the SchemaObject to be contracted in the transformation. Note that this schema object must belong to the given fromSchema.
function - the query that expresses the extent of the construct being transformed.
constraint - the constraint associated with the transformation (if any).
newSchemaName - the name of the resultant schema.
Returns:
the Schema which is the result of applying a CONTRACT transformation.
Throws:
TypeMismatchException
IntegrityException

clearSchemas

public static void clearSchemas()
This method empties all the cached Schema, SchemaObject, Transformation, AccessMethods and Protocols that have been cached. If you change the contents of the STR directly rather than through the reps API but wish to then use the reps API in the same JVM instance then you should call this method to force the reps API to reload any data requeseted from the STR


getSchemaObjectByName

public SchemaObject getSchemaObjectByName(java.lang.String name)
                                   throws InconsistentException
Return the SchemaObject that has the supplied name in this schema. Note that the String supplied must match exactly the name of the SchemaObject as returned by SchemaObject.getSchemeNamesString()

InconsistentException

getSchemaObject

public SchemaObject getSchemaObject(java.lang.String name)
                             throws NotFoundException
Return the SchemaObject that has the supplied name in this schema. Note that the String supplied must match exactly the name of the SchemaObject as returned by SchemaObject.getSchemeNamesString()

Parameters:
name - the String name of the SchemaObject
Throws:
NotFoundException - if no SchemaObject with the supplied named exists

updateSchemaObjectNameHashMap

public void updateSchemaObjectNameHashMap()
                                   throws InconsistentException
Update this Schema's hashmap of how each SchemaObject in the schema is named. This method should not now need to be called by user programs since the map is supposed to be kept up to date, but if you suspect problems (and in particular is a object found in listSchema() is not found by getSchemaObjectByName(String)) then call this method.

InconsistentException

setOpenCloseSchemeBracket

public static void setOpenCloseSchemeBracket(java.lang.String openScheme,
                                             java.lang.String closeScheme)
Set the Strings that is used to open and close a scheme name, such as the "<<" and ">>" in "<<person>>" or "<<person,name>>". By default these are set to "<<" and ">>". Normally these pairs would be set to one of "<" and ">", or "<<" and ">>", or "«" (open double chevron) and "»" (close double chevron)

Parameters:
openScheme - the string to open schemes with
closeScheme - the String to close schemes with

getOpenSchemeBracket

public static java.lang.String getOpenSchemeBracket()
Find what string is used to deliminate the opening of a scheme name, such as the "<<" in "<<person>>" or "<<person,name>>".

Returns:
String used to deliminate the opening of a scheme name

getCloseSchemeBracket

public static java.lang.String getCloseSchemeBracket()
find what string is used to deliminate the closing of a scheme name, such as the ">>" in "<<person>>" or "<<person,name>>".

Returns:
String used to deliminate the closing of a scheme name

differenceByName

public SchemaObject[] differenceByName(Schema s2)
                                throws InconsistentException
Return an SchemaObject array containing the difference by name between this schema (s1) and the schema passed as a parameter (s2). Thus the returned array will contain any SchemaObject that appears this Schema, but which there is not object in s2 with the same textual name. Thus the array will not contain an object from s1 named "<<person>>" if there is another object in s2 called "<<person>>", even if those two objects have diffient OBIDs.

Parameters:
s2 - the Schema to be subtracted from this Schema s1
Returns:
SchemaObject[] containing those SchemaObjects from s1 which have names that do not appear in s2
InconsistentException

unionByName

public SchemaObject[] unionByName(Schema s2)
                           throws InconsistentException
Return an SchemaObject array containing the union by name between this schema (s1) and the schema passed as a parameter (s2). Thus the returned array will contain any SchemaObject that appears in s1, plus those objects in s2 with different textual names. Thus the array will not contain an object from s2 named "<<person>>" if there is another object in s1 called "<<person>>", even if the two objects have different OBIDs.

Parameters:
s2 - the Schema to be unioned with this Schema s1
Returns:
SchemaObject[] containing those SchemaObjects from s1 which have names that do not appear in s2
InconsistentException

union

public Schema union(Schema s2)
Return an Schema (su) containing the union of SchemaObjects in this schema (s1) and the schema passed as a parameter (s2). SchemaObjects which have the same name in s1,s2 will have their extent in su be define as the union of the extents of the two SchemaObjects in s1,s2. In effect, this produces a similar result as the global-as-view (GAV) approach to schema integration when it combines two schemas together.

Parameters:
s2 - the Schema to be unioned with this Schema s1
Returns:
Schema containing GAV union of s1,s2

intersectionByName

public SchemaObject[] intersectionByName(Schema s2)
                                  throws InconsistentException
Return an SchemaObject array containing the intersection by name between this schema (s1) and the schema passed as a parameter (s2). The returned array will contain any SchemaObject that appears in s1, and for which there is an object with the same name in s2. Thus the array will contain an object from s1 named "<<person>>" only if there is an object in s2 called "<<person>>".

Parameters:
s2 - the Schema to be intersected with this Schema s1
Returns:
SchemaObject[] containing those SchemaObjects from s1 which have names that also appear in s2
InconsistentException

listSchema

public void listSchema()
                throws InconsistentException
List the Schema to the current output in a form designed for human interpretation. First the name of the Schema is listed, and then each SchemaObject in the Schema is prefixed by its Construct name as defined in the MDR.

InconsistentException

listSchema

public void listSchema(java.io.PrintStream out,
                       int mode)
                throws InconsistentException
List the Schema to an output stream, using the specified format.

Parameters:
out - the PrintStream to which the output is directed
mode - sets the exact format of the output, selecting one of the following: LIST_SCHEMA_SHORT list only the scheme of each object in the schema. LIST_SCHEMA_NORMAL list the scheme of the object, prefixed by the model name, object construct type, and object id LIST_SCHEMA_LONG list the scheme of the each object prefixed by the construct type (this is the default for versions of listSchema that have no mode).
InconsistentException

listSchema

public void listSchema(java.io.PrintStream out)
                throws InconsistentException
Shorthand for calling listSchema(out,LIST_SCHEMA_NORMAL)

InconsistentException

getTransformations

public Transformation[] getTransformations()
                                    throws InconsistentException
Return an array of all Transformation that go out from a particular schema.

Returns:
a (possibly empty) array containing all transformations from this schema
InconsistentException

prefixAllNodalNames

public Schema prefixAllNodalNames(java.lang.String prefix)
                           throws IntegrityException
Create a new Schema which contains the same set of constructs as an existing, except each has been renamed to have a common prefix if it is of Construct type Nodal. For example, if s1>> was a schema containing ER entities <<e1>>, <<e2>> and relationship <<r,e1,e2>>, and we called this method with prefix <<s1.>>, then the new schema would contain <<s1.e1>>, <<s1.e2>> and <<r,s1.e1,s1.e2>>

Parameters:
prefix - The String to prefix to all Nodal names
Returns:
A new schema with all Nodal names on this schema changed to have prefix in fron of the previous names
IntegrityException

prefixSchemaObjectName

public Transformation prefixSchemaObjectName(java.lang.String prefix,
                                             SchemaObject nodeObject)
                                      throws IntegrityException
Create a new Schema if the SchemaObject is a Nodal object, where the SchemaObject has had a prefix applied to the node name,

Parameters:
prefix - The String to prefix to Nodal names
nodeObject - The SchemaObject, which is Nodal, will have its node names changed
Returns:
A schema with the rename to be applied
IntegrityException

extendToMatch

public Schema extendToMatch(Schema schemaToAdd)
Create a new Schema which contains the same set of constructs as the current schema, plus all those constructs of another schema, which are defined via extend operators. Thus this method provides a new schema which is a union of the constructs of two schemas, but only constructs from the current schema will have an extent. For example, if <<s1>> was a schema containing ER entities <<e1>>, <<e2>> and <<s2>> contained <<e2>>, <<e3>>, then s1.extendToMatch(s2) would contain <<e1>>, <<e2>>, <<e3>>

Parameters:
schemaToAdd - The Schema which is to have the constructs added to make it match this schema.
Returns:
A new Schema which is an extension of the current schema to include all Constructs of @param schemaToAdd

findAttachedExtSchemas

public Schema[] findAttachedExtSchemas()
                                throws InconsistentException,
                                       IntegrityException
Returns an array of Schema's that are connected to this schema by some transformation pathway and are extensional schemas (including this schema itself if it is an extensional schema). For each schema s returned, s.isExtSchema() is true.

InconsistentException
IntegrityException

findAttachedExtDBs

public Schema[] findAttachedExtDBs()
                            throws InconsistentException,
                                   IntegrityException
Returns an array of Schema's that are connected to this schema by some transformation pathway and have extensional data (including this schema itself if it has extensional data). For each schema s returned, s.isExtDB() is true.

InconsistentException
IntegrityException

findAttachedDataSources

public Schema[] findAttachedDataSources()
                                 throws InconsistentException,
                                        IntegrityException
Returns an array of Schema's that are connected to this schema by some transformation pathway and are data sources (including this schema itself if it is a data source). For each schema s returned, s.isDataSource() is true.

InconsistentException
IntegrityException

findShortestPath

public Schema[] findShortestPath(Schema target)
                          throws InconsistentException,
                                 IntegrityException
Returns an array of schemas such that:
  • There is a transformation between each pair of adjacent schamas.
  • The array begins with the schema the method is called against and ends with the argument schema.
  • There is no other possible array that both meets these conditions and is shorter.

Returns:
An array of Schemas comprising the shortest path or null if no path exists.
InconsistentException
IntegrityException

getAccessMethods

public AccessMethod[] getAccessMethods()
                                throws InconsistentException
Find the AccessMethods that may be used to access the physical database system that holds this Schema.

Returns:
an array of AccessMethods that may be used to access a physical database containing this Schema.
InconsistentException

removeAccessMethods

public void removeAccessMethods()
                         throws InconsistentException
Remove all AccessMethods recorded for this schema.

InconsistentException

importSchemaObjects

public void importSchemaObjects(java.io.InputStream is)
                         throws java.io.IOException,
                                AutoRepException,
                                UnexpectedTokenException,
                                AutoMedException,
                                java.sql.SQLException
java.io.IOException
AutoRepException
UnexpectedTokenException
AutoMedException
java.sql.SQLException

exportSchemaObjects

public void exportSchemaObjects(java.io.OutputStream os)

exportSchemaObjects

public void exportSchemaObjects(java.io.PrintWriter pw)

read

public static Schema read(java.io.InputStream is)
                   throws java.io.IOException,
                          AutoRepException,
                          UnexpectedTokenException,
                          AutoMedException,
                          java.sql.SQLException
java.io.IOException
AutoRepException
UnexpectedTokenException
AutoMedException
java.sql.SQLException

read

public static Schema read(java.io.InputStream is,
                          java.lang.String name)
                   throws java.io.IOException,
                          AutoRepException,
                          UnexpectedTokenException,
                          AutoMedException,
                          java.sql.SQLException
java.io.IOException
AutoRepException
UnexpectedTokenException
AutoMedException
java.sql.SQLException

write

public void write()
           throws IllegalOperationException
Write to the standard out a text representation of this Schema object, in a form suitable for human interpretation, and suitable for being used as the input to read()

IllegalOperationException

write

public void write(java.io.OutputStream os)
           throws IllegalOperationException
IllegalOperationException

write

public void write(java.io.PrintWriter pw)
           throws IllegalOperationException
IllegalOperationException