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

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

public class Schema
extends java.lang.Object
implements Positionable, PersistentObject

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 DATA_SOURCE_TYPE
          In addition to the properties of STORED_TYPE schemas, DATA_SOURCE_TYPE schemas have some external data source that they represent.
static java.awt.Color default_datasource_color
          Default Color to use when creating a new data source schema
static java.awt.Color default_extensional_database_color
          Default Color to use when creating a new extensional database
static java.awt.Color default_extensional_schema_color
          Default Color to use when creating a new extensional schema
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 MATERIALISED_TYPE
          In addition to the properties of STORED_TYPE schemas, MATERIALISED_TYPE schemas may have data stored in the repository.
static int NEW_SCHEMA_Y_OFFSET
          Default distance to place a new schema created by a transformation from the schema it is created from
static int STORED_TYPE
          All details about the constructs of STORED_TYPE schemas are held in the repository, and this type my exist in isolation..
static int VIRTUAL_TYPE
          No details are held in the repository about VIRTUAL_TYPE schemas, other than the name of schema.
 
Constructor Summary
Schema(java.lang.String schemaName)
          Deprecated. Not the correct way to do things!!!! see #createSchema() Just create an empty Schema object with name dmle 9/11/2005
 
Method Summary
 boolean addSchemaChangeListener(SchemaChangeListener scl)
           
static boolean addSchemasListener(SchemasListener nl)
          Add an instance of any class implementing interface SchemasListener such that it will be notified of any adding or deleting of schemas that may occur.
 Schema applyAddTransformation(Construct toObjectConstructType, AutoMedType amtype, java.lang.Object[] toObject, java.lang.String function, java.lang.String constraint)
           
 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 applyIdentTransformation(Schema otherSchema)
          Links this schema to another schema which should have exactly the same structure, i.e.
 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 Schema checkSchemaName(java.lang.StringBuffer schemaName)
          Check if a given schema name already been assigned.
static void clearSchemas()
          This method empties all the cached Schema, SchemaObject, Transformation, AccessMethods and Protocols that have been cached.
 boolean contains(SchemaObject so)
          Determine if a SchemaObject exists in this Schema
 boolean contains(java.lang.String name)
          Determine if the SchemaObject that has the supplied name exists in this Schema
 boolean containsSchemaObject(java.lang.String name)
           
 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)
          Creates a new STORED_TYPE schema.
static Schema createSchema(java.lang.String schemaName, boolean isDataSource)
          Creates a new schema.
protected static Schema createSchema(java.lang.String schemaName, int type, Schema subnetSchema)
          Creates a new schema.
 SchemaObject createSchemaObject(Construct cType, AutoMedType amtype, java.lang.Object[] schemeObjects)
           
 SchemaObject createSchemaObject(Construct cType, java.lang.Object[] schemeObjects)
          Creates a schema object.
 SchemaObject createSchemaObject(Construct cType, java.lang.Object[] schemeObjects, int tid)
          Create a schema object with type_id
 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.
 java.util.List findAllPathwayAbstractions(Schema target)
          Find abstractions of all transformation pathways from this schema to another schema
 java.util.List findAllPathways(Schema target)
           
 Schema[] findAttachedDataSources()
          Deprecated. Use getAttachedSchemas(int) instead. 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.
 Schema[] findAttachedExtDBs()
          Deprecated. Use getAttachedSchemas(int) instead. 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.
 Schema[] findAttachedExtSchemas()
          Deprecated. Use getAttachedSchemas(int) instead. 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.
 Schema[] findShortestPath(Schema target)
          Returns an array of schemas such that: There is a transformation between each pair of adjacent schamas.
 java.awt.Point getAbsolutePosition()
          Same behaviour as getPosition() since Schema instances are not placed relative to other Positionables.
 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)
           
 Schema[] getAttachedSchemas(int type)
          Returns an array of Schema's that are connected to this schema by some pathway.
 java.util.List getAttributeDomains()
          Return the attribute domain specifications
 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>>".
 DataSource getDataSource()
          Create the DataSource object representing the data source represented by this schema
 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()
           
 java.lang.String getGlobalName()
          Returns the global schema name
 PersistentKey getKey()
           
static Schema getKnownSchema(int sid)
          Use to obtain a schema that is known to exist, and therefore no sense in trapping NotFoundException.
static Schema getKnownSchema(java.lang.String name)
          Use to obtain a schema that is known to exist, and therefore no sense in trapping NotFoundException.
 java.lang.String getLabel()
          Get the text used to label this Schema.
 java.awt.Point getLabelPosition()
           
 int getLabelXPos()
           
 int getLabelYPos()
           
 java.util.Map getModels()
          Get all associated models to a schema object.
 java.lang.String getModelsAsString()
          Works similar to getModels() method except that this method returns a delimited string of Models' names
 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.util.Map getPersistentAttributes()
           
 java.awt.Point getPosition()
          Return the Point that represents the position of this Positionable in a Panel.
 Positionable getPositionedRelativeTo()
          Return the Positionable this is relative to.
 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 getType()
          Return the type (VIRTUAL_TYPE, STORED_TYPE, ...) of this schema..
 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()
          Deprecated. use getType() instead. Determines whether or not the schema represents an external data source.
 boolean isExtDB()
          Deprecated. use getType() instead. Determines whether or not the schema represents an extentional database.
 boolean isExtSchema()
          Deprecated. use getType() instead. 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)
          A variant of read(InputStream, String), where the name of the new Schema created is taken from that held in the textual description read from the InputStream.
static Schema read(java.io.InputStream is, java.lang.String name)
          Read a schema description held in a textually format (possibly created by write()) into the repository.
 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)
          Remove an instance of any class implementing interface SchemasListener such that it will no longer be notified of any adding or deleting of schemas that may occur.
 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 setAbsolutePosition(int x, int y)
          Same behaviour as #setPosition() since Schema instances are not placed relative to other Positionables.
 void setAttributeDomains(java.util.List domainSpec)
          Manually set the domain information for some attributes.
 void setBackgroundColor(java.awt.Color c)
           
 void setDataSource(boolean dataSource)
          Deprecated. use {@link setType) instead. Sets whether or not the schema represents an external data source.
 void setExtDB(boolean extDB)
          Deprecated. use {@link setType) instead. Sets whether or not the schema represents an extentional database.
 void setExtSchema(boolean extSchema)
          Deprecated. use {@link setType) instead. Sets whether or not the schema is an extentional schema.
 void setForegroundColor(java.awt.Color c)
           
 void setGlobalName(java.lang.String globalName)
          The original (global) name of a schema as advertised by a peer.
 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 setType(int type)
          Set what type of Schema this is.
 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.OutputStream os, int format)
           
 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

default_datasource_color

public static final java.awt.Color default_datasource_color
Default Color to use when creating a new data source schema


default_extensional_database_color

public static final java.awt.Color default_extensional_database_color
Default Color to use when creating a new extensional database


default_extensional_schema_color

public static final java.awt.Color default_extensional_schema_color
Default Color to use when creating a new extensional schema


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

VIRTUAL_TYPE

public static final int VIRTUAL_TYPE
No details are held in the repository about VIRTUAL_TYPE schemas, other than the name of schema. There must be a pathway that attaches schemas of this type to schemas of one of the other types. Applications of the repository will not create this type of schema directly, but will create it as part of creating transformations on existing schemas.

See Also:
Constant Field Values

STORED_TYPE

public static final int STORED_TYPE
All details about the constructs of STORED_TYPE schemas are held in the repository, and this type my exist in isolation..

See Also:
Constant Field Values

MATERIALISED_TYPE

public static final int MATERIALISED_TYPE
In addition to the properties of STORED_TYPE schemas, MATERIALISED_TYPE schemas may have data stored in the repository. However this data is not persistent.

See Also:
Constant Field Values

DATA_SOURCE_TYPE

public static final int DATA_SOURCE_TYPE
In addition to the properties of STORED_TYPE schemas, DATA_SOURCE_TYPE schemas have some external data source that they represent. This may be queried using AutoMedWrappers, and the details of the data source are recorded in AccessMethod.

See Also:
Constant Field Values
Constructor Detail

Schema

public Schema(java.lang.String schemaName)
Deprecated. Not the correct way to do things!!!! see #createSchema() Just create an empty Schema object with name dmle 9/11/2005

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 if just STORED_TYPE.

createSchema

public static Schema createSchema(java.lang.String schemaName)
Creates a new STORED_TYPE 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,
                                     int type,
                                     Schema subnetSchema)
Creates a new schema.

Parameters:
schemaName - name of the schema.
type - of schema (DATA_SOURCE_TYPE, ...).
subnetSchema - is the Schema which is the extensional schema of the subnet: set null if this is the subnet schema

checkSchemaName

public static Schema checkSchemaName(java.lang.StringBuffer schemaName)
Check if a given schema name already been assigned. If yes, create a new schema name

Parameters:
schemaName - a schema name to check
Returns:
Schema return an existing, empty schema or null otherwise

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
Throws:
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
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,
                                       int tid)
                                throws TypeMismatchException,
                                       IntegrityException
Create a schema object with type_id

Throws:
TypeMismatchException
IntegrityException

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

createSchemaObject

public SchemaObject createSchemaObject(Construct cType,
                                       AutoMedType amtype,
                                       java.lang.Object[] schemeObjects)
                                throws TypeMismatchException,
                                       IntegrityException
Throws:
TypeMismatchException
IntegrityException

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

setAbsolutePosition

public void setAbsolutePosition(int x,
                                int y)
Same behaviour as #setPosition() since Schema instances are not placed relative to other Positionables.

Specified by:
setAbsolutePosition in interface Positionable

getPosition

public java.awt.Point getPosition()
Description copied from interface: Positionable
Return the Point that represents the position of this Positionable in a Panel. Note that depending on the implementation of the interface, this might a coordinate relative to some other positionable

Specified by:
getPosition in interface Positionable

getAbsolutePosition

public java.awt.Point getAbsolutePosition()
Same behaviour as getPosition() since Schema instances are not placed relative to other Positionables.

Specified by:
getAbsolutePosition in interface Positionable

getPositionedRelativeTo

public Positionable getPositionedRelativeTo()
Description copied from interface: Positionable
Return the Positionable this is relative to. If not relative to some other Positionable then return null.

Specified by:
getPositionedRelativeTo 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)
Specified by:
setLabelXPos in interface Positionable

setLabelYPos

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

setLabelPosition

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

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

setGlobalName

public void setGlobalName(java.lang.String globalName)
The original (global) name of a schema as advertised by a peer. No checking
is performed here as we assume the name is valid

Parameters:
localName - the original (global) name assigned to this schema

getGlobalName

public java.lang.String getGlobalName()
Returns the global schema name


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
Throws:
InconsistentException

getType

public int getType()
Return the type (VIRTUAL_TYPE, STORED_TYPE, ...) of this schema..


isExtSchema

public boolean isExtSchema()
Deprecated. use getType() instead. 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()
Deprecated. use getType() instead. 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()
Deprecated. use getType() instead. 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)

setType

public void setType(int type)
Set what type of Schema this is.


setExtSchema

public void setExtSchema(boolean extSchema)
Deprecated. use {@link setType) instead. 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)
Deprecated. use {@link setType) instead. 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)
Deprecated. use {@link setType) instead. 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

getKnownSchema

public static Schema getKnownSchema(int sid)
Use to obtain a schema that is known to exist, and therefore no sense in trapping NotFoundException. You should normally only call this inside a block that has checked that the exists with Schema exists(String)


getKnownSchema

public static Schema getKnownSchema(java.lang.String name)
Use to obtain a schema that is known to exist, and therefore no sense in trapping NotFoundException. You should normally only call this inside a block that has checked that the exists with Schema exists(String)


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.

applyIdentTransformation

public Schema applyIdentTransformation(Schema otherSchema)
                                throws SchemasNotIdenticalException
Links this schema to another schema which should have exactly the same structure, i.e. for each SchemaObject in this schema there is another SchemaObject in the other schema that has the same scheme viewed as text (but migtht have a different identifier

Throws:
SchemasNotIdenticalException

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,
                                     AutoMedType amtype,
                                     java.lang.Object[] toObject,
                                     java.lang.String function,
                                     java.lang.String constraint)
                              throws TypeMismatchException,
                                     IntegrityException
Throws:
TypeMismatchException
IntegrityException

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
Throws:
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
Throws:
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
Throws:
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
Throws:
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

contains

public boolean contains(SchemaObject so)
Determine if a SchemaObject exists in this Schema

Parameters:
a - SchemaObject to test for membership
Returns:
true if the schema object exists in this Schema

contains

public boolean contains(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

containsSchemaObject

public boolean containsSchemaObject(java.lang.String name)

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

Throws:
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).
Throws:
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.

Parameters:
schema - The Schema object for which the list of transformations is to be obtained.
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
Throws:
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
Throws:
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
Deprecated. Use getAttachedSchemas(int) instead. 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.

Throws:
IntegrityException

findAttachedExtDBs

public Schema[] findAttachedExtDBs()
                            throws IntegrityException
Deprecated. Use getAttachedSchemas(int) instead. 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.

Throws:
IntegrityException

findAttachedDataSources

public Schema[] findAttachedDataSources()
                                 throws IntegrityException
Deprecated. Use getAttachedSchemas(int) instead. 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.

Throws:
IntegrityException

getAttachedSchemas

public Schema[] getAttachedSchemas(int type)
                            throws IntegrityException
Returns an array of Schema's that are connected to this schema by some pathway. The types of schema that may be returned can be limited by choosing different types, and all schemas of that type or of a type containing more information will be returned.

Parameters:
int - One of VIRTUAL_TYPE, STORED_TYPE, MATERIALISED_TYPE, or DATA_SOURCE_TYPE. All Schemas of the type, or after, in this list will be returned. Hence using VIRTUAL_TYPE will return all attached schemas.
Throws:
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.

Parameters:
s - The schema to find the shortest path to from this schema
Returns:
An array of Schemas comprising the shortest path or null if no path exists.
Throws:
IntegrityException

findAllPathways

public java.util.List findAllPathways(Schema target)
                               throws IntegrityException
Throws:
IntegrityException

findAllPathwayAbstractions

public java.util.List findAllPathwayAbstractions(Schema target)
                                          throws IntegrityException
Find abstractions of all transformation pathways from this schema to another schema

Parameters:
target - the target Schema
Returns:
List a list containing all pathways
Throws:
IntegrityException

getDataSource

public DataSource getDataSource()
Create the DataSource object representing the data source represented by this schema


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.


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
Throws:
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
A variant of read(InputStream, String), where the name of the new Schema created is taken from that held in the textual description read from the InputStream.

Throws:
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
Read a schema description held in a textually format (possibly created by write()) into the repository. The contents of the file must have the schema objects in the correct order, such that if one object depends on the existance of anther schema object, then that second schema object is placed first in the file.

Parameters:
is - an InputStream to read the text description from.
name - is the name to give the new Schema
Returns:
a new Schema created from the textual description
Throws:
java.io.IOException
SyntaxException
NotFoundException
TypeMismatchException

write

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


write

public void write(java.io.OutputStream os)

write

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

write

public void write(java.io.PrintWriter pw)

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)
Add an instance of any class implementing interface SchemasListener such that it will be notified of any adding or deleting of schemas that may occur.


removeSchemasListener

public static boolean removeSchemasListener(SchemasListener nl)
Remove an instance of any class implementing interface SchemasListener such that it will no longer be notified of any adding or deleting of schemas that may occur.


toString

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

getKey

public PersistentKey getKey()
Specified by:
getKey in interface PersistentObject
See Also:
PersistentObject.getKey()

getPersistentAttributes

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

getModels

public java.util.Map getModels()
Get all associated models to a schema object. We do this by going through Schema -> SchemaObject -> Construct -> Model

Returns:
Map a collection of model objects

getModelsAsString

public java.lang.String getModelsAsString()
Works similar to getModels() method except that this method returns a delimited string of Models' names


setAttributeDomains

public void setAttributeDomains(java.util.List domainSpec)
Manually set the domain information for some attributes.

Parameters:
domainSpec - is a list of AttributeDomain objects

getAttributeDomains

public java.util.List getAttributeDomains()
Return the attribute domain specifications