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

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

public class Model
extends java.lang.Object
implements PersistentObject

The Model class

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

Method Summary
 Construct createConstruct(java.lang.String cName, int cClass, boolean isRoot)
          Creates a new construct and add to the model.
static Model createModel(java.lang.String modelName)
          Creates a new model with the given name.
static boolean exists(int MID)
           
static boolean exists(java.lang.String modelName)
           
 void exportConstructs(java.io.OutputStream os)
           
 void exportConstructs(java.io.PrintWriter pw)
           
 java.awt.Color getBackgroundColor()
          Return the default background colour to be used from drawing SchemaObjects of this Model.
 Construct getConstruct(java.lang.String name)
          Returns the named construct in the model or throws an AutoMedException if the construct name doesn't exist in the model.
 Construct[] getConstructs()
          Returns an array of all the constructs in the model.
 Construct[] getConstructs(boolean full)
          Get a list of Construct objects associated to a Model object for generating XML structure.
 java.awt.Color getForegroundColor()
          Return the default foreground colour to be used from drawing SchemaObjects of this Model.
 PersistentKey getKey()
          Implements the PersistentObject interface
 int getMID()
          Returns the repository identifer of the model.
static Model getModel(int MID)
          Returns a reference to the Model with the given MID.
static Model getModel(java.lang.String name)
          Returns a reference to the Model with the given modelName.
 java.lang.String getModelDescription()
          Returns a description of the model, each construct along with their schemes is listed in a way suitable for printing.
 java.lang.String getModelDescription(boolean full)
          Returns a description of the model, each construct along with its schemes are listed in a way suitable for printing.
static Model[] getModels()
          Returns an array of all models.
 java.lang.String getName()
          Returns the name of the model.
 java.util.Map getPersistentAttributes()
          Implements the PersistentObject interface
 java.awt.Color getTextColor()
          Return the default text colour to be used from drawing SchemaObjects of this Model.
 java.util.List getTypeHierarchy()
          Get a list of TypeHierarchy objects associated to this model
 void importConstructs(java.io.InputStream is)
           
static Model read(java.io.InputStream is)
           
static Model read(java.io.InputStream is, java.lang.String name)
           
static void reloadModels()
          This method empties the cached model data and then reloads it from the MDR as if the class had just been loaded.
 void remove()
          Removes the Model from the repository.
protected  void removeConstructFromMap(java.lang.String name)
          THIS METHOD DOESN'T DO ANYTHING AT THE MOMENT Sets the content of a particular position of the model's constructs list.
static void removeModel(java.lang.String modelName)
          Removes the Model with the given modelName.
 void retract()
          Removes the Model from the repository, together with all associated information --- in particular all Constructs belonging to the model are removed, and hence all SchemaObjects, and hence all Transformations on those objects.
 void setBackgroundColor(java.awt.Color c)
          Set the default background colour to be used from drawing SchemaObjects of this Model.
 void setForegroundColor(java.awt.Color c)
          Set the default foreground colour to be used from drawing SchemaObjects of this Model.
 void setName(java.lang.String modelName)
          Sets the model's name.
 void setTextColor(java.awt.Color c)
          Set the default text colour to be used from drawing SchemaObjects of this Model.
 java.lang.String toString()
           
 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
 

Method Detail

reloadModels

public static void reloadModels()
This method empties the cached model data and then reloads it from the MDR as if the class had just been loaded. If you change the contents of the MDR 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 synchronize the reps API data with the MDR


createModel

public static Model createModel(java.lang.String modelName)
                         throws IntegrityException
Creates a new model with the given name.

Parameters:
modelName - name of the model.
Throws:
IntegrityException - if model already exists

removeModel

public static void removeModel(java.lang.String modelName)
                        throws IntegrityException
Removes the Model with the given modelName.

Parameters:
modelName - name of the model to be removed.
Throws:
IntegrityException - if model does not exist

remove

public void remove()
            throws IntegrityException
Removes the Model from the repository.

Throws:
IntegrityException

retract

public void retract()
Removes the Model from the repository, together with all associated information --- in particular all Constructs belonging to the model are removed, and hence all SchemaObjects, and hence all Transformations on those objects.


getModels

public static Model[] getModels()
Returns an array of all models.

Returns:
an array of all models.

exists

public static boolean exists(java.lang.String modelName)

exists

public static boolean exists(int MID)

getModel

public static Model getModel(java.lang.String name)
                      throws NotFoundException
Returns a reference to the Model with the given modelName.

Parameters:
modelName - name of the model.
Returns:
the reference to the model with the given modelName
Throws:
NotFoundException

getModel

public static Model getModel(int MID)
                      throws NotFoundException
Returns a reference to the Model with the given MID.

Parameters:
MID - numeric identifier of the model.
Returns:
the reference to the model with the given MID, or null if the model can not be found in the repository
Throws:
NotFoundException

createConstruct

public Construct createConstruct(java.lang.String cName,
                                 int cClass,
                                 boolean isRoot)
Creates a new construct and add to the model.

Parameters:
cName - name of the construct.
cClass - class of the construct (one of CONSTRUCT_CLASS_NODAL, CONSTRUCT_CLASS_LINK, CONSTRUCT_CLASS_LINK_NODAL, and CONSTRUCT_CLASS_CONSTRAINT, see Constants).
isRoot - set to true if the construct is a construct type of its underlying data model; false otherwise.
Returns:
reference to the new construct.

getName

public java.lang.String getName()
Returns the name of the model.

Returns:
name of the model.

getMID

public int getMID()
Returns the repository identifer of the model.

Returns:
mid of the model.

getConstruct

public Construct getConstruct(java.lang.String name)
                       throws NotFoundException
Returns the named construct in the model or throws an AutoMedException if the construct name doesn't exist in the model.

Throws:
NotFoundException - if the named construct doesn't exist in the model.

getConstructs

public Construct[] getConstructs()
Returns an array of all the constructs in the model.

Returns:
an array of all the constructs in the model.

getConstructs

public Construct[] getConstructs(boolean full)
Get a list of Construct objects associated to a Model object for generating XML structure. We are interested in having full details about every Construct and its schemes.

Parameters:
full - a boolean flag indicating whether or not to get the full construct details. If set to false, it calls getConstructs() method.

getTypeHierarchy

public java.util.List getTypeHierarchy()
                                throws AutoMedException
Get a list of TypeHierarchy objects associated to this model

Throws:
AutoMedException

setName

public void setName(java.lang.String modelName)
             throws IntegrityException
Sets the model's name.

Parameters:
modelName - new name of model.
Throws:
MDRException
java.sql.SQLException
DSRException
java.io.IOException
IntegrityException

removeConstructFromMap

protected void removeConstructFromMap(java.lang.String name)
                               throws IntegrityException
THIS METHOD DOESN'T DO ANYTHING AT THE MOMENT Sets the content of a particular position of the model's constructs list.

Parameters:
position - the position in the model's list of constructs whose content is to be set.
con - the new construct to be inserted into the given position.
Throws:
IntegrityException

getModelDescription

public java.lang.String getModelDescription()
Returns a description of the model, each construct along with their schemes is listed in a way suitable for printing. This calls getModelDescription(boolean) passing it false to get the shorter description.


getModelDescription

public java.lang.String getModelDescription(boolean full)
Returns a description of the model, each construct along with its schemes are listed in a way suitable for printing. If a full description is asked for, constructs are expanded to their full description when they appear in another construct's scheme. When false, just the name of the construct is used in the schemes in which it appears.

Parameters:
full - If true, expand construct descriptions in scheme

importConstructs

public void importConstructs(java.io.InputStream is)
                      throws java.io.IOException,
                             AutoRepException,
                             AutoMedException,
                             java.sql.SQLException
Throws:
java.io.IOException
AutoRepException
AutoMedException
java.sql.SQLException

exportConstructs

public void exportConstructs(java.io.OutputStream os)

exportConstructs

public void exportConstructs(java.io.PrintWriter pw)

read

public static Model read(java.io.InputStream is)
                  throws java.io.IOException,
                         AutoRepException,
                         AutoMedException,
                         java.sql.SQLException
Throws:
java.io.IOException
AutoRepException
AutoMedException
java.sql.SQLException

read

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

write

public void write(java.io.OutputStream os)

write

public void write(java.io.PrintWriter pw)

getForegroundColor

public java.awt.Color getForegroundColor()
Return the default foreground colour to be used from drawing SchemaObjects of this Model.

Returns:
A Color, or null if no default colour is set for this Model

setForegroundColor

public void setForegroundColor(java.awt.Color c)
Set the default foreground colour to be used from drawing SchemaObjects of this Model.

Parameters:
A - Color that will be used when drawing SchemaObjects of this Model where no + invidual foreground color has been set.

getBackgroundColor

public java.awt.Color getBackgroundColor()
Return the default background colour to be used from drawing SchemaObjects of this Model.

Returns:
A Color, or null if no default colour is set for this Model

setBackgroundColor

public void setBackgroundColor(java.awt.Color c)
Set the default background colour to be used from drawing SchemaObjects of this Model.

Parameters:
A - Color that will be used when drawing SchemaObjects of this Model where no + invidual background color has been set.

getTextColor

public java.awt.Color getTextColor()
Return the default text colour to be used from drawing SchemaObjects of this Model.

Returns:
A Color, or null if no default colour is set for this Model

setTextColor

public void setTextColor(java.awt.Color c)
Set the default text colour to be used from drawing SchemaObjects of this Model.

Parameters:
A - Color that will be used when drawing SchemaObjects of this Model where no + invidual text color has been set.

toString

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

getKey

public PersistentKey getKey()
Implements the PersistentObject interface

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

getPersistentAttributes

public java.util.Map getPersistentAttributes()
Implements the PersistentObject interface

Specified by:
getPersistentAttributes in interface PersistentObject
See Also:
PersistentObject.getPersistentAttributes()