uk.ac.ic.doc.automed
Class TemplateTransformationSyntaxRepository

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

public class TemplateTransformationSyntaxRepository
extends java.lang.Object

Manipulate the Template Transformation Syntax Repository, create new statements.


Constructor Summary
TemplateTransformationSyntaxRepository()
           
 
Method Summary
static int createStatement(java.lang.String name)
          Adds a new statement to the TTSR.
static void createStatementDefinition(int st_id, int arg_pos, java.lang.String table_name, java.lang.String field_name, java.lang.String description)
          Adds a new argument definition to the statement's definitions of arguments.
static java.lang.String getDataSourceName()
          Returns the name of the repository in the local database.
static int getStatementByName(java.lang.String name)
          Returns the ID (st_id) of the statement specified by name, or -1 if a statement with the specified name doesn't exist in the TTSR.
static int[] getStatementDefinitionArgPosList(int st_id)
          Returns a particular statement's list of argument positions.
static java.lang.String getStatementDefinitionDescription(int st_id, int arg_pos)
          Returns a particular statement's argument definition (only the description field).
static java.lang.String[] getStatementDefinitionDescriptionList(int st_id)
          Returns a particular statement's list of argument definitions (only the description field).
static java.lang.String getStatementDefinitionFieldName(int st_id, int arg_pos)
          Returns a particular statement's argument definition (only the field_name field).
static java.lang.String[] getStatementDefinitionFieldNameList(int st_id)
          Returns a particular statement's list of argument definitions (only the field_name field).
static java.lang.String getStatementDefinitionTableName(int st_id, int arg_pos)
          Returns a particular statement's argument definition (only the table_name field).
static java.lang.String[] getStatementDefinitionTableNameList(int st_id)
          Returns a particular statement's list of argument definitions (only the table_name field).
static java.lang.String getStatementName(int st_id)
          Returns the name of the statement specified by st_id
static java.lang.String[] getStatementsNameList()
          Returns the names of all the statements found in the TTSR
static int[] getStatementsStIdList()
          Returns the IDs of all the statements found in the TTSR
static boolean isValidStId(int st_id)
          This method determines if a statement with the specified st_id exists in the TTSR.
static void main(java.lang.String[] args)
           
static void removeStatement(int st_id)
          Removes the statement from the TTSR statements table.
static void removeStatementDefinition(int st_id)
          Removes all arguments definitions of a particular statement
static void removeStatementDefinition(int st_id, int arg_pos)
          Removes a particular position of a statement's sequence of arguments
static void setDataSourceName(java.lang.String str)
          Sets the name of the repository in the local database.
static void setStatementDefinitionDescription(int st_id, int arg_pos, java.lang.String description)
          Sets a particular statement's argument definition (the description field).
static void setStatementDefinitionFieldName(int st_id, int arg_pos, java.lang.String field_name)
          Sets a particular statement's argument definition (the field_name field).
static void setStatementDefinitionTableName(int st_id, int arg_pos, java.lang.String table_name)
          Sets a particular statement's argument definition (the table_name field).
static void setStatementName(int st_id, java.lang.String name)
          Sets the name of the statement specified by st_id
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplateTransformationSyntaxRepository

public TemplateTransformationSyntaxRepository()
Method Detail

createStatement

public static int createStatement(java.lang.String name)
                           throws TemplateTransformationSyntaxRepositoryException,
                                  RepositoryAccessException
Adds a new statement to the TTSR. Statement names are assumed to be unique. The creation of a statement whose name already exists in the TTSR is rejected.
Returns an integer that specifies the ID assigned to the new statement.

Parameters:
name - name of statement
Returns:
the statement ID of the added statement
Throws:
TemplateTransformationSyntaxRepositoryException - if the specified name is null, or if a statement with the same name already exists in the TTSR
RepositoryAccessException - if the repository cannot be accessed

getStatementByName

public static int getStatementByName(java.lang.String name)
                              throws TemplateTransformationSyntaxRepositoryException,
                                     RepositoryAccessException
Returns the ID (st_id) of the statement specified by name, or -1 if a statement with the specified name doesn't exist in the TTSR.

Parameters:
name - name of statement
Returns:
the ID of the statement
Throws:
TemplateTransformationSyntaxRepositoryException - if the argument is null, or if no record for the specified statement is found in the TTSR
RepositoryAccessException - if the repository cannot be accessed

getStatementName

public static java.lang.String getStatementName(int st_id)
                                         throws TemplateTransformationSyntaxRepositoryException,
                                                RepositoryAccessException
Returns the name of the statement specified by st_id

Parameters:
st_id - ID of the statement
Returns:
the name of the statement specified by st_id
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id is found in the TTSR
RepositoryAccessException - if the repository cannot be accessed

getStatementsStIdList

public static int[] getStatementsStIdList()
                                   throws RepositoryAccessException
Returns the IDs of all the statements found in the TTSR

Returns:
a list of all statement identifiers found in the TTSR. Returns null if no records of statements is found in the TTSR.
Throws:
RepositoryAccessException - if the repository cannot be accessed

getStatementsNameList

public static java.lang.String[] getStatementsNameList()
                                                throws RepositoryAccessException
Returns the names of all the statements found in the TTSR

Returns:
a list of all statement names found in the TTSR. Returns null if no records of statements is found in the TTSR.
Throws:
RepositoryAccessException - if the repository cannot be accessed

setStatementName

public static void setStatementName(int st_id,
                                    java.lang.String name)
                             throws TemplateTransformationSyntaxRepositoryException,
                                    RepositoryAccessException
Sets the name of the statement specified by st_id

Parameters:
st_id - ID of the statement
name - new name of the statement
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id is found in the TTSR, or if there is already a statement with the specified name in the TTSR, or if the specified name is null.
RepositoryAccessException - if the repository cannot be accessed

removeStatement

public static void removeStatement(int st_id)
                            throws TemplateTransformationSyntaxRepositoryException,
                                   RepositoryAccessException
Removes the statement from the TTSR statements table.

Parameters:
st_id - ID of the statement
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id is found in the TTSR, or if there is a definition for this statement in the statement_definition table (dependency conflict)
RepositoryAccessException - if the repository cannot be accessed

isValidStId

public static boolean isValidStId(int st_id)
                           throws RepositoryAccessException
This method determines if a statement with the specified st_id exists in the TTSR.

Returns:
true if a record of a statement with the specified st_id exists in the statements table, or false otherwise.
Throws:
RepositoryAccessException - if the repository cannot be accessed

createStatementDefinition

public static void createStatementDefinition(int st_id,
                                             int arg_pos,
                                             java.lang.String table_name,
                                             java.lang.String field_name,
                                             java.lang.String description)
                                      throws TemplateTransformationSyntaxRepositoryException,
                                             RepositoryAccessException
Adds a new argument definition to the statement's definitions of arguments.

Parameters:
st_id - ID of statement
arg_pos - position of argument in the statement's sequence of arguments
table_name - and
field_name - define the values of this argument, i.e. from which table and field this argument gets its values.
description - explanation of what this argument stands for
Throws:
TemplateTransformationSyntaxRepositoryException - if the arguments are invalid ( st_id or arg_pos is less/equal to zero, or if either table_name, field_name is null and description is also null), or if no record for the specified st_id is found in the TTSR, or if a record already exists with the specified st_id and arg_pos.
RepositoryAccessException - if the repository cannot be accessed

getStatementDefinitionArgPosList

public static int[] getStatementDefinitionArgPosList(int st_id)
                                              throws TemplateTransformationSyntaxRepositoryException,
                                                     RepositoryAccessException
Returns a particular statement's list of argument positions. Returns null if no argument definitions exists for the specific statement.

Parameters:
st_id - ID of statement
Returns:
a list of argument positions in a statement's definition
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id is found in the TTSR
RepositoryAccessException - if the repository cannot be accessed

getStatementDefinitionTableNameList

public static java.lang.String[] getStatementDefinitionTableNameList(int st_id)
                                                              throws TemplateTransformationSyntaxRepositoryException,
                                                                     RepositoryAccessException
Returns a particular statement's list of argument definitions (only the table_name field). Returns null if no argument definitions exists for the specific statement.

Parameters:
st_id - ID of statement
Returns:
a list of argument definitions(table_name)
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id is found in the TTSR
RepositoryAccessException - if the repository cannot be accessed

getStatementDefinitionFieldNameList

public static java.lang.String[] getStatementDefinitionFieldNameList(int st_id)
                                                              throws TemplateTransformationSyntaxRepositoryException,
                                                                     RepositoryAccessException
Returns a particular statement's list of argument definitions (only the field_name field). Returns null if no argument definitions exists for the specific statement.

Parameters:
st_id - ID of statement
Returns:
a list of argument definitions(field_name)
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id is found in the TTSR
RepositoryAccessException - if the repository cannot be accessed

getStatementDefinitionDescriptionList

public static java.lang.String[] getStatementDefinitionDescriptionList(int st_id)
                                                                throws TemplateTransformationSyntaxRepositoryException,
                                                                       RepositoryAccessException
Returns a particular statement's list of argument definitions (only the description field). Returns null if no argument definitions exists for the specific statement.

Parameters:
st_id - ID of statement
Returns:
a list of argument definitions(description)
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id is found in the TTSR
RepositoryAccessException - if the repository cannot be accessed

getStatementDefinitionTableName

public static java.lang.String getStatementDefinitionTableName(int st_id,
                                                               int arg_pos)
                                                        throws TemplateTransformationSyntaxRepositoryException,
                                                               RepositoryAccessException
Returns a particular statement's argument definition (only the table_name field).

Parameters:
st_id - ID of statement
arg_pos - position in the statement's sequence of arguments
Returns:
statement's argument definition(table_name)
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id and arg_posis found in the TTSR
RepositoryAccessException - if the repository cannot be accessed

getStatementDefinitionFieldName

public static java.lang.String getStatementDefinitionFieldName(int st_id,
                                                               int arg_pos)
                                                        throws TemplateTransformationSyntaxRepositoryException,
                                                               RepositoryAccessException
Returns a particular statement's argument definition (only the field_name field).

Parameters:
st_id - ID of statement
arg_pos - position in the statement's sequence of arguments
Returns:
statement's argument definition(field_name)
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id and arg_posis found in the TTSR
RepositoryAccessException - if the repository cannot be accessed

getStatementDefinitionDescription

public static java.lang.String getStatementDefinitionDescription(int st_id,
                                                                 int arg_pos)
                                                          throws TemplateTransformationSyntaxRepositoryException,
                                                                 RepositoryAccessException
Returns a particular statement's argument definition (only the description field).

Parameters:
st_id - ID of statement
arg_pos - position in the statement's sequence of arguments
Returns:
statement's argument definition(description)
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id and arg_posis found in the TTSR
RepositoryAccessException - if the repository cannot be accessed

setStatementDefinitionTableName

public static void setStatementDefinitionTableName(int st_id,
                                                   int arg_pos,
                                                   java.lang.String table_name)
                                            throws TemplateTransformationSyntaxRepositoryException,
                                                   RepositoryAccessException
Sets a particular statement's argument definition (the table_name field).

Parameters:
st_id - ID of statement
arg_pos - position in the statement's sequence of arguments
table_name - table name to be put in the specified position
Throws:
TemplateTransformationSyntaxRepositoryException - if table_name is null, or if no record for the specified st_id is found in the TTSR's statements table, or if no record for the specified st_id and arg_posis found in the TTSR's statement_definition table.
RepositoryAccessException - if the repository cannot be accessed

setStatementDefinitionFieldName

public static void setStatementDefinitionFieldName(int st_id,
                                                   int arg_pos,
                                                   java.lang.String field_name)
                                            throws TemplateTransformationSyntaxRepositoryException,
                                                   RepositoryAccessException
Sets a particular statement's argument definition (the field_name field).

Parameters:
st_id - ID of statement
arg_pos - position in the statement's sequence of arguments
field_name - field name to be put in the specified position
Throws:
TemplateTransformationSyntaxRepositoryException - if field_name is null, or if no record for the specified st_id is found in the TTSR's statements table, or if no record for the specified st_id and arg_posis found in the TTSR's statement_definition table.
RepositoryAccessException - if the repository cannot be accessed

setStatementDefinitionDescription

public static void setStatementDefinitionDescription(int st_id,
                                                     int arg_pos,
                                                     java.lang.String description)
                                              throws TemplateTransformationSyntaxRepositoryException,
                                                     RepositoryAccessException
Sets a particular statement's argument definition (the description field).

Parameters:
st_id - ID of statement
arg_pos - position in the statement's sequence of arguments
description - description to be put in the specified position
Throws:
TemplateTransformationSyntaxRepositoryException - if description is null, or if no record for the specified st_id is found in the TTSR's statements table, or if no record for the specified st_id and arg_posis found in the TTSR's statement_definition table.
RepositoryAccessException - if the repository cannot be accessed

removeStatementDefinition

public static void removeStatementDefinition(int st_id,
                                             int arg_pos)
                                      throws TemplateTransformationSyntaxRepositoryException,
                                             RepositoryAccessException
Removes a particular position of a statement's sequence of arguments

Parameters:
st_id - ID of statement
arg_pos - position in the statement's sequence of arguments to be removed
Throws:
TemplateTransformationSyntaxRepositoryException - if no record for the specified st_id and arg_pos is found in the TTSR
RepositoryAccessException - if the repository cannot be accessed

removeStatementDefinition

public static void removeStatementDefinition(int st_id)
                                      throws RepositoryAccessException
Removes all arguments definitions of a particular statement

Parameters:
st_id - ID of statement
Throws:
RepositoryAccessException - if the repository cannot be accessed

main

public static void main(java.lang.String[] args)

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 TTSR by default.

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