uk.ac.ic.doc.automed
Class ModelDefinitionsRepository

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

public class ModelDefinitionsRepository
extends java.lang.Object

Properties used from the MDR data source

SQLDelime String used to seperate multi-statement SQL strings, defaults to a semicolon at the end of its line Optional
TestDB SQL Query to assert existence of repository Required


Field Summary
static java.lang.String MDR_DataSourceName
           
static java.lang.String userName
           
 
Constructor Summary
ModelDefinitionsRepository()
           
 
Method Summary
static void cidExists(int cid)
          Checks if a particular construct identifier (CID) exists in the MDR.
static int createConstruct(int mid, java.lang.String name, int constructClass, boolean isRoot)
          Creates a new construct for a modelling language
static int createConstructScheme(int cid, int type, int argCID, boolean isKey, int HDMType, int lowerBound, int upperBound)
          Creates a new constructScheme argument for a construct
static int createModel(java.lang.String name)
          Creates a new data modelling language which can then have constructs added.
static int getConstructClass(int cid)
           
static int getConstructMID(int cid)
          Gets the Model Identifier for a given construct
static java.lang.String getConstructName(int cid)
           
static java.lang.String[] getConstructNames(int mid)
          Gets a list of all construct names for a modelling language
static int[] getConstructs(int mid)
          Get the CIDs of all constructs for a modelling language
static int getConstructSchemeArgCID(int cid, int pos)
           
static int getConstructSchemeCount(int cid)
          Gets the count of construct scheme arguments for this construct, the number is also the highest index (argument pos) usable as the construct scheme numbering starts at 1
static int getConstructSchemeHDMType(int cid, int pos)
           
static int getConstructSchemeLowerBound(int cid, int pos)
           
static int getConstructSchemeType(int cid, int pos)
           
static int getConstructSchemeUpperBound(int cid, int pos)
           
static java.lang.String getDataSourceName()
          Returns the name of the repository in the local database.
static java.lang.String getMDR_DataSourceName()
          Deprecated, use getDataSourceName instead
static int getModelByName(java.lang.String name)
           
static java.lang.String getModelName(int mid)
           
static java.lang.String[] getModelNames()
          Gets a list of all modelling language names in the MDR
static int[] getModels()
          Gets a list of all modelling language identifiers in the MDR
static boolean isConstructRoot(int cid)
           
static boolean isConstructSchemeKey(int cid, int pos)
           
static void main(java.lang.String[] args)
          Executing this class invokes this method which supplies a command line interface to the ModelDefinitionsRepository.
static void removeConstruct(int cid)
          Remove the construct.
static void removeConstructScheme(int cid, int pos)
          Remove the construct.
static void removeModel(int mid)
          Remove the modelling language.
static void setConstructClass(int cid, int constructClass)
           
static void setConstructMID(int cid, int mid)
          Changes the modelling language that a construct belongs to
static void setConstructName(int cid, java.lang.String name)
           
static void setConstructRoot(int cid, boolean isRoot)
           
static void setConstructSchemeArgCID(int cid, int pos, int argCID)
           
static void setConstructSchemeHDMType(int cid, int pos, int HDMType)
           
static void setConstructSchemeKey(int cid, int pos, boolean isKey)
           
static void setConstructSchemeLowerBound(int cid, int pos, int lowerBound)
           
static void setConstructSchemeType(int cid, int pos, int schemeType)
           
static void setConstructSchemeUpperBound(int cid, int pos, int upperBound)
           
static void setDataSourceName(java.lang.String str)
          Sets the name of the repository in the local database.
static void setMDR_DataSourceName(java.lang.String mdr)
          Deprecated. use setDataSourceName()
static void setModelName(int mid, java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MDR_DataSourceName

public static java.lang.String MDR_DataSourceName

userName

public static java.lang.String userName
Constructor Detail

ModelDefinitionsRepository

public ModelDefinitionsRepository()
Method Detail

getDataSourceName

public static java.lang.String getDataSourceName()
Returns the name of the repository in the local database.

Returns:
the name of the repository in the local database.

setDataSourceName

public static void setDataSourceName(java.lang.String str)
Sets the name of the repository in the local database. This name is set to MDR by default.

Parameters:
str - the name of the repository in the local database.

getMDR_DataSourceName

public static java.lang.String getMDR_DataSourceName()
Deprecated, use getDataSourceName instead


setMDR_DataSourceName

public static void setMDR_DataSourceName(java.lang.String mdr)
Deprecated. use setDataSourceName()


main

public static void main(java.lang.String[] args)
Executing this class invokes this method which supplies a command line interface to the ModelDefinitionsRepository.


createModel

public static int createModel(java.lang.String name)
                       throws java.sql.SQLException,
                              DataSourceRepositoryException,
                              ModelDefinitionsRepositoryException,
                              java.io.IOException
Creates a new data modelling language which can then have constructs added.

Parameters:
name - The name of the modelling language
Returns:
The MID of the new modelling language
Throws:
ModelDefinitionsRepositoryException - If the model name is already in use
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

removeModel

public static void removeModel(int mid)
                        throws java.sql.SQLException,
                               DataSourceRepositoryException,
                               ModelDefinitionsRepositoryException,
                               java.io.IOException
Remove the modelling language. If referential constraints are enforced in the database and the key does not have cascading deletes then this will fail if there are any constructs for this modelling language.

Parameters:
mid - The model identifier of the modelling language to remove
Throws:
ModelDefinitionsRepositoryException - If the model with MID=mid does not exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

getModels

public static int[] getModels()
                       throws java.sql.SQLException,
                              DataSourceRepositoryException,
                              ModelDefinitionsRepositoryException,
                              java.io.IOException
Gets a list of all modelling language identifiers in the MDR

Returns:
An int array of MIDs (Model identifiers)
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException

getModelByName

public static int getModelByName(java.lang.String name)
                          throws java.sql.SQLException,
                                 DataSourceRepositoryException,
                                 ModelDefinitionsRepositoryException,
                                 java.io.IOException
Parameters:
name - The name of the modelling language. This can include SQL wildcards, if there are more than one matches then the one with the lowest MID will be returned
Returns:
The MID (Model identifiers)
Throws:
ModelDefinitionsRepositoryException - If the model with MID=mid does not exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

getModelNames

public static java.lang.String[] getModelNames()
                                        throws java.sql.SQLException,
                                               DataSourceRepositoryException,
                                               ModelDefinitionsRepositoryException,
                                               java.io.IOException
Gets a list of all modelling language names in the MDR

Returns:
A String array of names
java.sql.SQLException
DataSourceRepositoryException
ModelDefinitionsRepositoryException
java.io.IOException

getModelName

public static java.lang.String getModelName(int mid)
                                     throws java.sql.SQLException,
                                            DataSourceRepositoryException,
                                            ModelDefinitionsRepositoryException,
                                            java.io.IOException
Parameters:
mid - The model identifier
Returns:
The name of the modelling language
Throws:
ModelDefinitionsRepositoryException - If the model with MID=mid does not exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

setModelName

public static void setModelName(int mid,
                                java.lang.String name)
                         throws java.sql.SQLException,
                                DataSourceRepositoryException,
                                ModelDefinitionsRepositoryException,
                                java.io.IOException
Parameters:
mid - The model identifier
name - The new name for the modelling language
Throws:
ModelDefinitionsRepositoryException - If the model with MID=mid does not exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

createConstruct

public static int createConstruct(int mid,
                                  java.lang.String name,
                                  int constructClass,
                                  boolean isRoot)
                           throws java.sql.SQLException,
                                  DataSourceRepositoryException,
                                  ModelDefinitionsRepositoryException,
                                  java.io.IOException
Creates a new construct for a modelling language

Parameters:
mid - The modelling language this construct belongs to
name - The name of the new construct,this must not already be in use for this modelling language
isRoot -
Returns:
The CID of the new construct
Throws:
ModelDefinitionsRepositoryException - If the model with MID=mid does not exist, the constructClass is out of range or the construct name is already in use for the specified model
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

removeConstruct

public static void removeConstruct(int cid)
                            throws java.sql.SQLException,
                                   DataSourceRepositoryException,
                                   ModelDefinitionsRepositoryException,
                                   java.io.IOException
Remove the construct. If referential constraints are enforced in the database and the key does not have cascading deletes then this will fail if there are any constructSchemes for this construct

Parameters:
cid - The construct identifier
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

getConstructs

public static int[] getConstructs(int mid)
                           throws java.sql.SQLException,
                                  DataSourceRepositoryException,
                                  ModelDefinitionsRepositoryException,
                                  java.io.IOException
Get the CIDs of all constructs for a modelling language

Parameters:
mid - The identifier of model
Returns:
An int array of CIDs (construct identifiers)
Throws:
ModelDefinitionsRepositoryException - If the model with MID=mid does not exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

getConstructNames

public static java.lang.String[] getConstructNames(int mid)
                                            throws java.sql.SQLException,
                                                   DataSourceRepositoryException,
                                                   ModelDefinitionsRepositoryException,
                                                   java.io.IOException
Gets a list of all construct names for a modelling language

Returns:
A String array of names
Throws:
ModelDefinitionsRepositoryException - If the model with MID=mid does not exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

getConstructName

public static java.lang.String getConstructName(int cid)
                                         throws java.sql.SQLException,
                                                DataSourceRepositoryException,
                                                ModelDefinitionsRepositoryException,
                                                java.io.IOException
Parameters:
cid - The construct identifier
Returns:
The name of the construct
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

setConstructName

public static void setConstructName(int cid,
                                    java.lang.String name)
                             throws java.sql.SQLException,
                                    DataSourceRepositoryException,
                                    ModelDefinitionsRepositoryException,
                                    java.io.IOException
Parameters:
cid - The construct identifier
name - The new name for the construct
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

getConstructMID

public static int getConstructMID(int cid)
                           throws java.sql.SQLException,
                                  DataSourceRepositoryException,
                                  ModelDefinitionsRepositoryException,
                                  java.io.IOException
Gets the Model Identifier for a given construct

Parameters:
cid - The construct identifier
Returns:
The MID that identifies the model this construct belongs to
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

setConstructMID

public static void setConstructMID(int cid,
                                   int mid)
                            throws java.sql.SQLException,
                                   DataSourceRepositoryException,
                                   ModelDefinitionsRepositoryException,
                                   java.io.IOException
Changes the modelling language that a construct belongs to

Parameters:
cid - The construct identifier
mid - The new MID for the construct
Throws:
ModelDefinitionsRepositoryException - if the construct or the new model doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

getConstructClass

public static int getConstructClass(int cid)
                             throws java.sql.SQLException,
                                    DataSourceRepositoryException,
                                    ModelDefinitionsRepositoryException,
                                    java.io.IOException
Parameters:
cid - The construct identifier
Returns:
The class of the construct
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for CONSTRUCT_CLASS types

setConstructClass

public static void setConstructClass(int cid,
                                     int constructClass)
                              throws java.sql.SQLException,
                                     DataSourceRepositoryException,
                                     ModelDefinitionsRepositoryException,
                                     java.io.IOException
Parameters:
cid - The construct identifier
constructClass - The new class for the construct
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist or the constructClass is out of range
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for CONSTRUCT_CLASS types

isConstructRoot

public static boolean isConstructRoot(int cid)
                               throws java.sql.SQLException,
                                      DataSourceRepositoryException,
                                      ModelDefinitionsRepositoryException,
                                      java.io.IOException
Parameters:
cid - The construct identifier
Returns:
True if the construct is considered part of the modelling language (i.e. is not just a construction to help define another construct)
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

setConstructRoot

public static void setConstructRoot(int cid,
                                    boolean isRoot)
                             throws java.sql.SQLException,
                                    DataSourceRepositoryException,
                                    ModelDefinitionsRepositoryException,
                                    java.io.IOException
Parameters:
cid - The construct identifier
isRoot - Is this construct a root construct
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

createConstructScheme

public static int createConstructScheme(int cid,
                                        int type,
                                        int argCID,
                                        boolean isKey,
                                        int HDMType,
                                        int lowerBound,
                                        int upperBound)
                                 throws java.sql.SQLException,
                                        DataSourceRepositoryException,
                                        ModelDefinitionsRepositoryException,
                                        java.io.IOException
Creates a new constructScheme argument for a construct

Parameters:
cid - The construct this scheme is for
type - The type of the scheme argument
argCID - If type is not SCHEME_TYPE_NAME the CID of the construct this type refers to
isKey - Whether or not this argument is required when referring to a construct of type CID
HDMType - The postion and function in the HDM template for the Construct's type that this argument represents or SCHEME_HDM_TYPE_C if it doesn't represent part of the HDM template. Meaningless if the Construct's type is CONSTRUCT_CLASS_CONSTRAINT
lowerBound - The lower bound to how many times this argument can occur in the HDMType position
upperBound - The lower bound to how many times this argument can occur in the HDMType position. If upperBound < lowerBound then there is no upper bound.
Returns:
The position of the new construct scheme argument
Throws:
ModelDefinitionsRepositoryException - If the construct with CID=cid does not exist or the type or HDMType is out of range.
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for CONSTRUCT_CLASS, SCHEME_HDM and SCHEME_TYPE types.

removeConstructScheme

public static void removeConstructScheme(int cid,
                                         int pos)
                                  throws java.sql.SQLException,
                                         DataSourceRepositoryException,
                                         ModelDefinitionsRepositoryException,
                                         java.io.IOException
Remove the construct. If referential constraints are enforced in the database and the key does not have cascading deletes then this will fail if there are any constructSchemes for this construct

Parameters:
cid - The construct identifier
pos - The position of the scheme argument
Throws:
ModelDefinitionsRepositoryException - if the constructScheme doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

getConstructSchemeCount

public static int getConstructSchemeCount(int cid)
                                   throws java.sql.SQLException,
                                          DataSourceRepositoryException,
                                          ModelDefinitionsRepositoryException,
                                          java.io.IOException
Gets the count of construct scheme arguments for this construct, the number is also the highest index (argument pos) usable as the construct scheme numbering starts at 1

Returns:
The count of ConstructScheme rows with CID = cid
Throws:
ModelDefinitionsRepositoryException - if the construct scheme doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

getConstructSchemeType

public static int getConstructSchemeType(int cid,
                                         int pos)
                                  throws java.sql.SQLException,
                                         DataSourceRepositoryException,
                                         ModelDefinitionsRepositoryException,
                                         java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of th construct scheme
Returns:
The type of this scheme argument
Throws:
ModelDefinitionsRepositoryException - if the construct scheme doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for CONSTRUCT_CLASS types

setConstructSchemeType

public static void setConstructSchemeType(int cid,
                                          int pos,
                                          int schemeType)
                                   throws java.sql.SQLException,
                                          DataSourceRepositoryException,
                                          ModelDefinitionsRepositoryException,
                                          java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of the construct scheme
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist or the constructClass is out of range
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for CONSTRUCT_CLASS types

getConstructSchemeArgCID

public static int getConstructSchemeArgCID(int cid,
                                           int pos)
                                    throws java.sql.SQLException,
                                           DataSourceRepositoryException,
                                           ModelDefinitionsRepositoryException,
                                           java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of the construct scheme
Returns:
The CID of the construct that should be given as the argument in this position of the scheme or 0 to denote none
Throws:
ModelDefinitionsRepositoryException - if the construct scheme doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

setConstructSchemeArgCID

public static void setConstructSchemeArgCID(int cid,
                                            int pos,
                                            int argCID)
                                     throws java.sql.SQLException,
                                            DataSourceRepositoryException,
                                            ModelDefinitionsRepositoryException,
                                            java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of the construct scheme
argCID - The CID of the construct that should be given as the argument in this position of the scheme or 0 to denote none
Throws:
ModelDefinitionsRepositoryException - if the construct scheme doesn't exist or the argCID is not 0 and doesn't exist.
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

isConstructSchemeKey

public static boolean isConstructSchemeKey(int cid,
                                           int pos)
                                    throws java.sql.SQLException,
                                           DataSourceRepositoryException,
                                           ModelDefinitionsRepositoryException,
                                           java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of th construct scheme
Returns:
True if the construct scheme argument is needed to identify an instance of the construct
Throws:
ModelDefinitionsRepositoryException - if the construct scheme doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

setConstructSchemeKey

public static void setConstructSchemeKey(int cid,
                                         int pos,
                                         boolean isKey)
                                  throws java.sql.SQLException,
                                         DataSourceRepositoryException,
                                         ModelDefinitionsRepositoryException,
                                         java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of the construct scheme
isKey - if the construct scheme argument is needed to identify an instance of the construct
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException

getConstructSchemeHDMType

public static int getConstructSchemeHDMType(int cid,
                                            int pos)
                                     throws java.sql.SQLException,
                                            DataSourceRepositoryException,
                                            ModelDefinitionsRepositoryException,
                                            java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of th construct scheme
Returns:
The HDM type of this scheme argument
Throws:
ModelDefinitionsRepositoryException - if the construct scheme doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for CONSTRUCT_CLASS types

setConstructSchemeHDMType

public static void setConstructSchemeHDMType(int cid,
                                             int pos,
                                             int HDMType)
                                      throws java.sql.SQLException,
                                             DataSourceRepositoryException,
                                             ModelDefinitionsRepositoryException,
                                             java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of the construct scheme
HDMType - The new HDMType for the construct
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist or the HDMType is out of range
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for SCHEME_HDM_TYPEs

getConstructSchemeLowerBound

public static int getConstructSchemeLowerBound(int cid,
                                               int pos)
                                        throws java.sql.SQLException,
                                               DataSourceRepositoryException,
                                               ModelDefinitionsRepositoryException,
                                               java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of th construct scheme
Returns:
The lower bound of this scheme argument
Throws:
ModelDefinitionsRepositoryException - if the construct scheme doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for CONSTRUCT_CLASS types

setConstructSchemeLowerBound

public static void setConstructSchemeLowerBound(int cid,
                                                int pos,
                                                int lowerBound)
                                         throws java.sql.SQLException,
                                                DataSourceRepositoryException,
                                                ModelDefinitionsRepositoryException,
                                                java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of the construct scheme
lowerBound - the least number of times this argument must be repeated
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for SCHEME_HDM_TYPEs

getConstructSchemeUpperBound

public static int getConstructSchemeUpperBound(int cid,
                                               int pos)
                                        throws java.sql.SQLException,
                                               DataSourceRepositoryException,
                                               ModelDefinitionsRepositoryException,
                                               java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of th construct scheme
Returns:
The upper bound of this scheme argument
Throws:
ModelDefinitionsRepositoryException - if the construct scheme doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for CONSTRUCT_CLASS types

setConstructSchemeUpperBound

public static void setConstructSchemeUpperBound(int cid,
                                                int pos,
                                                int upperBound)
                                         throws java.sql.SQLException,
                                                DataSourceRepositoryException,
                                                ModelDefinitionsRepositoryException,
                                                java.io.IOException
Parameters:
cid - The construct identifier
pos - The argument position of the construct scheme
upperBound - the least number of times this argument must be repeated
Throws:
ModelDefinitionsRepositoryException - if the construct doesn't exist
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException
See Also:
Interface Constants for SCHEME_HDM_TYPEs

cidExists

public static void cidExists(int cid)
                      throws ModelDefinitionsRepositoryException,
                             java.sql.SQLException,
                             DataSourceRepositoryException,
                             java.io.IOException
Checks if a particular construct identifier (CID) exists in the MDR.

Parameters:
cid - construct identifier (CID) of the construct.
Throws:
ModelDefinitionsRepositoryException - if no record for the specified CID is found in the MDR.
java.sql.SQLException
DataSourceRepositoryException
java.io.IOException