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

java.lang.Object
  |
  +--uk.ac.ic.doc.automed.reps.Schema
All Implemented Interfaces:
Positionable

public class Schema
extends java.lang.Object
implements Positionable

The Schema class represents a database schema as a set of SchemaObjects. Each schema may be extensional (i.e. correspond to source real data source) or intentional (i.e. be defined the use of one or more Transformation objects linking to an extentional Schema. @see Scheme @see Construct

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 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.
static int NEW_SCHEMA_Y_OFFSET
          Default distance to place a new schema created by a transformation from the schema it is created from
 
Method Summary
 boolean addSchemaChangeListener(SchemaChangeListener scl)
           
static boolean addSchemasListener(SchemasListener nl)
           
 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 applyAddTransformation(Construct type, java.lang.String scheme, java.lang.String function, java.lang.String constraint)
           
 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 applyExtendTransformation(Construct type, java.lang.String scheme, java.lang.String function, java.lang.String constraint)
           
 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.
 boolean containsSchemaObject(java.lang.String name)
          Determine if the SchemaObject that has the supplied name exists in this Schema
 java.lang.String createFollowingSchemaName()
           
 java.lang.String createFollowingSchemaName(java.lang.String name)
          Generate a name of a schema that "appears" to be following the name used for this Schema, and which has not already been used as a Schema name
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, Schema subnetSchema)
          Creates a new schema.
 SchemaObject createSchemaObject(Construct cType, java.lang.Object[] schemeObjects)
          Creates a schema object.
 java.lang.String debugString()
          A String representation of this object useful for debugging code
 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 keyOnly)
           
 java.lang.Object[] getAllSchemeNames(boolean all, int idDepth, int typeDepth)
           
 java.lang.Object[] getAllSchemeNames(boolean all, int idDepth, int typeDepth, boolean keyOnly)
           
 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 keyOnly)
           
 java.lang.String getAllSchemeNamesString(boolean all, int idDepth, int typeDepth)
           
 java.lang.String getAllSchemeNamesString(boolean all, int idDepth, int typeDepth, boolean keyOnly)
           
 java.awt.Color getBackgroundColor()
           
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>>".
 SchemaObject[] getDependentSchemaObjects(SchemaObject so)
          Return all SchemaObjects of a particular Construct in this Schema which have a reference to the given SchemaObject in their scheme.
 SchemaObject[] getDependentSchemaObjects(SchemaObject so, Construct c)
          Return those SchemaObjects of a particular Construct in this Schema which have a reference to the given SchemaObject in their scheme.
 java.awt.Color getForegroundColor()
           
 HDMNetwork getHDMNetwork()
           
 java.lang.String getLabel()
          Get the text used to label this Schema.
 java.awt.Point getLabelPosition()
           
 int getLabelXPos()
           
 int getLabelYPos()
           
 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>>".
 java.awt.Point getPosition()
           
 java.lang.Object getRepObject()
           
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)
           
 SchemaObject getSchemaObject(java.lang.String name, int searchMethod)
          Return the SchemaObject that has the supplied name in this schema.
 SchemaObject getSchemaObjectByName(java.lang.String name)
          Deprecated. 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()
 SchemaObject[] getSchemaObjects()
          Returns an array of schema objects (of class SchemaObject) that belong to the schema.
static Schema[] getSchemas()
          Find all Schema instances held in the repository.
 int getSID()
          Returns the schema identifier (SID) of the schema.
 Schema getSubnetSchema()
          Find the extensional schema in the same subnetwork as this Schema.
 java.awt.Color getTextColor()
           
 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.
 int getXPos()
           
 int getYPos()
           
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 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)
          Shorthand for calling listSchema(out,LIST_SCHEMA_NORMAL,false)
 void listSchema(java.io.PrintStream out, int mode, boolean keyOnly)
          List the Schema to an output stream, using the specified format.
 Schema[] match(Schema s2)
          Return a array of two Schemas, which are formed by extending two conformed schemes such that they are identical.
 Schema newapplyExtendTransformation(Construct type, java.lang.String scheme, java.lang.String function, java.lang.String constraint)
           
 void oldRetract()
           
 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)
           
 java.lang.Object[] readSchemeDefinition(Construct cons, java.lang.String sd)
          Take a String containing the definition of a scheme of a SchemaObject and create an Object array that would be used in creating the SchemaObject
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.
 boolean removeSchemaChangeListener(SchemaChangeListener scl)
           
 void removeSchemaObjects()
          Removes all schema objects that belong to the schema, i.e., the schema's SchemaObject list is emptied.
static boolean removeSchemasListener(SchemasListener nl)
           
 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 setBackgroundColor(java.awt.Color c)
           
 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 setForegroundColor(java.awt.Color c)
           
 void setLabel(java.lang.String label)
           
 void setLabelPosition(int x, int y)
           
 void setLabelXPos(int x)
           
 void setLabelYPos(int y)
           
 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>>".
 void setPosition(int x, int y)
           
 void setTextColor(java.awt.Color c)
           
 void setXPos(int x)
           
 void setYPos(int y)
           
 java.lang.String toString()
           
 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, wait, wait, wait
 

Field Detail

NEW_SCHEMA_Y_OFFSET

public static final int NEW_SCHEMA_Y_OFFSET
Default distance to place a new schema created by a transformation from the schema it is created from

See Also:
Constant Field Values

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)
Creates a new schema.

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

createSchema

protected static Schema createSchema(java.lang.String schemaName,
                                     boolean isExtSchema,
                                     boolean isExtDB,
                                     boolean isDataSource,
                                     Schema subnetSchema)
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.
subnetSchema - is the Schema which is the extensional schema of the subnet: set null if this is the subnet schema

checkEditable

protected void checkEditable()
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)
                   throws NotFoundException,
                          IntegrityException
Removes the Schema with the given schemaName. Equivalent to calling Schema.remove() of the Schema with the given name.

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

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.

getDependentSchemaObjects

public SchemaObject[] getDependentSchemaObjects(SchemaObject so)
Return all SchemaObjects of a particular Construct in this Schema which have a reference to the given SchemaObject in their scheme.

Parameters:
so - The SchemaObject which dependents of are to be found.

getDependentSchemaObjects

public SchemaObject[] getDependentSchemaObjects(SchemaObject so,
                                                Construct c)
Return those SchemaObjects of a particular Construct in this Schema which have a reference to the given SchemaObject in their scheme.

Parameters:
so - The SchemaObject which dependents of are to be found.
c - The Construct type of the SchemaObjects to return. If null, then all SchemaObjects are returned

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

oldRetract

public void oldRetract()
                throws IntegrityException
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,
                                       IntegrityException
Creates a schema object. Note that this method can only be invoked on 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.
Throws:
IntegrityException - if the scheme contains references to schema objects from a different subnet.
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.

getSubnetSchema

public Schema getSubnetSchema()
Find the extensional schema in the same subnetwork as this Schema. The repository insists that isolated schemas are always created as extensional schemas (i.e. with all SchemaObjects explcitely stated) and that non-IDENT Tranformation instances link the extensional schema with other Schema instances that belong to the same subnet. IDENT Transformation instances link subnets together where they have two Schemas which have identical SchemaObject schemes.

Returns:
the Schema that is the only extensional schema in this subnet.

getXPos

public int getXPos()
Specified by:
getXPos in interface Positionable

getYPos

public int getYPos()
Specified by:
getYPos in interface Positionable

setXPos

public void setXPos(int x)
Specified by:
setXPos in interface Positionable

setYPos

public void setYPos(int y)
Specified by:
setYPos in interface Positionable

setPosition

public void setPosition(int x,
                        int y)
Specified by:
setPosition in interface Positionable

getPosition

public java.awt.Point getPosition()
Specified by:
getPosition in interface Positionable

getLabelXPos

public int getLabelXPos()
Specified by:
getLabelXPos in interface Positionable

getLabelYPos

public int getLabelYPos()
Specified by:
getLabelYPos in interface Positionable

getLabelPosition

public java.awt.Point getLabelPosition()
Specified by:
getLabelPosition in interface Positionable

setLabelXPos

public void setLabelXPos(int x)
                  throws IntegrityException
Specified by:
setLabelXPos in interface Positionable
IntegrityException

setLabelYPos

public void setLabelYPos(int y)
                  throws IntegrityException
Specified by:
setLabelYPos in interface Positionable
IntegrityException

setLabelPosition

public void setLabelPosition(int x,
                             int y)
                      throws IntegrityException
Specified by:
setLabelPosition in interface Positionable
IntegrityException

getLabel

public java.lang.String getLabel()
Get the text used to label this Schema. Note that this will differ from getName() at least in that any characters that need escaping for printing are escaped.

Specified by:
getLabel in interface Positionable
Returns:
Name of this schema used for writing on to the screen or file

setLabel

public void setLabel(java.lang.String label)
Specified by:
setLabel in interface Positionable

getRepObject

public java.lang.Object getRepObject()
Specified by:
getRepObject in interface Positionable

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.

getSchemaObjects

public SchemaObject[] getSchemaObjects()
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.

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 keyOnly)

getAllSchemeNames

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

getAllSchemeNames

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

getAllSchemeNamesString

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


getAllSchemeNamesString

public java.lang.String getAllSchemeNamesString(boolean keyOnly)

getAllSchemeNamesString

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

getAllSchemeNamesString

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

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)
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

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()
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.

getSchemas

public static Schema[] getSchemas()
Find all Schema instances held in the repository.

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

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

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()
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.

getTransformationsTo

protected Transformation[] getTransformationsTo()
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.

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:
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 - if the scheme contains references to schema objects from a different subnet.

applyAddTransformation

public Schema applyAddTransformation(Construct type,
                                     java.lang.String scheme,
                                     java.lang.String function,
                                     java.lang.String constraint)
                              throws TypeMismatchException,
                                     IntegrityException,
                                     SyntaxException,
                                     NotFoundException
TypeMismatchException
IntegrityException
SyntaxException
NotFoundException

applyExtendTransformation

public Schema applyExtendTransformation(Construct type,
                                        java.lang.String scheme,
                                        java.lang.String function,
                                        java.lang.String constraint)
                                 throws TypeMismatchException,
                                        IntegrityException,
                                        SyntaxException,
                                        NotFoundException
TypeMismatchException
IntegrityException
SyntaxException
NotFoundException

newapplyExtendTransformation

public Schema newapplyExtendTransformation(Construct type,
                                           java.lang.String scheme,
                                           java.lang.String function,
                                           java.lang.String constraint)
                                    throws TypeMismatchException,
                                           IntegrityException,
                                           SyntaxException,
                                           NotFoundException
TypeMismatchException
IntegrityException
SyntaxException
NotFoundException

createFollowingSchemaName

public java.lang.String createFollowingSchemaName()

createFollowingSchemaName

public java.lang.String createFollowingSchemaName(java.lang.String name)
Generate a name of a schema that "appears" to be following the name used for this Schema, and which has not already been used as a Schema name


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)
Deprecated. 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()


getSchemaObject

public SchemaObject getSchemaObject(java.lang.String name)
                             throws NotFoundException
NotFoundException

getSchemaObject

public SchemaObject getSchemaObject(java.lang.String name,
                                    int searchMethod)
                             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
searchMethod - must be one of #SEARCH_BY_KEY_NAME, #SEARCH_BY_FULL_NAME or #SEARCH_BY_KEY_THEN_FULL_NAME
Throws:
NotFoundException - if no SchemaObject with the supplied named exists

containsSchemaObject

public boolean containsSchemaObject(java.lang.String name)
Determine if the SchemaObject that has the supplied name exists in this Schema

Parameters:
name - the String name of the SchemaObject
Returns:
true if named object exists in this Schema

updateSchemaObjectNameHashMap

public void updateSchemaObjectNameHashMap()
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.


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)
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

unionByName

public 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). 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

match

public Schema[] match(Schema s2)
Return a array of two Schemas, which are formed by extending two conformed schemes such that they are identical. Two schemas are conformed when all SchemaObjects that have the same Construct and scheme also have the same real world semantics an extent.

Parameters:
s2 - a Schema conformed with this Schema
Returns:
array of two Schemas, which have an ident Transformation between them, where the first is extended from this Schema and then second is extended from s2.

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 defined 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

readSchemeDefinition

public java.lang.Object[] readSchemeDefinition(Construct cons,
                                               java.lang.String sd)
                                        throws SyntaxException,
                                               NotFoundException
Take a String containing the definition of a scheme of a SchemaObject and create an Object array that would be used in creating the SchemaObject

Parameters:
cons - The Construct which the SchemaObject belows to. This is used to determine if a String in the scheme is interpreted at an reference to another SchemaObject or not.
sd - The scheme definition that is the String representation of a SchemaOBject that could exist in this Schema.
Returns:
Object array that contains the scheme, in a form usable for creating the SchemaObject.
SyntaxException
NotFoundException

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,
                       boolean keyOnly)
                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:
keyOnly - if true, do not include non-key fields in attributes 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)
Shorthand for calling listSchema(out,LIST_SCHEMA_NORMAL)


listSchema

public void listSchema(java.io.PrintStream out,
                       int mode)
Shorthand for calling listSchema(out,LIST_SCHEMA_NORMAL,false)


getTransformations

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

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

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 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.

IntegrityException

findAttachedExtDBs

public Schema[] findAttachedExtDBs()
                            throws 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.

IntegrityException

findAttachedDataSources

public Schema[] findAttachedDataSources()
                                 throws 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.

IntegrityException

findShortestPath

public Schema[] findShortestPath(Schema target)
                          throws 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.
IntegrityException

getAccessMethods

public AccessMethod[] getAccessMethods()
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.

removeAccessMethods

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


getHDMNetwork

public HDMNetwork getHDMNetwork()

getForegroundColor

public java.awt.Color getForegroundColor()
Specified by:
getForegroundColor in interface Positionable

setForegroundColor

public void setForegroundColor(java.awt.Color c)
Specified by:
setForegroundColor in interface Positionable

getBackgroundColor

public java.awt.Color getBackgroundColor()
Specified by:
getBackgroundColor in interface Positionable

setBackgroundColor

public void setBackgroundColor(java.awt.Color c)
Specified by:
setBackgroundColor in interface Positionable

getTextColor

public java.awt.Color getTextColor()
Specified by:
getTextColor in interface Positionable

setTextColor

public void setTextColor(java.awt.Color c)
Specified by:
setTextColor in interface Positionable

importSchemaObjects

public void importSchemaObjects(java.io.InputStream is)
                         throws java.io.IOException,
                                SyntaxException,
                                NotFoundException,
                                TypeMismatchException
java.io.IOException
SyntaxException
NotFoundException
TypeMismatchException

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,
                          SyntaxException,
                          NotFoundException,
                          TypeMismatchException
java.io.IOException
SyntaxException
NotFoundException
TypeMismatchException

read

public static Schema read(java.io.InputStream is,
                          java.lang.String name)
                   throws java.io.IOException,
                          SyntaxException,
                          NotFoundException,
                          TypeMismatchException
java.io.IOException
SyntaxException
NotFoundException
TypeMismatchException

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

debugString

public java.lang.String debugString()
A String representation of this object useful for debugging code


addSchemaChangeListener

public boolean addSchemaChangeListener(SchemaChangeListener scl)

removeSchemaChangeListener

public boolean removeSchemaChangeListener(SchemaChangeListener scl)

addSchemasListener

public static boolean addSchemasListener(SchemasListener nl)

removeSchemasListener

public static boolean removeSchemasListener(SchemasListener nl)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object