org.edg.info
Class SchemaInstance

java.lang.Object
  extended byorg.edg.info.InstanceBase
      extended byorg.edg.info.SchemaInstance

public class SchemaInstance
extends InstanceBase

SchemaInstance is an object that supports the SchemaServlet. It a offers package-level methods that correspond to Schema API methods. XXX-AC: note, this doesn't actually inherit much, if anything from InstanceBase. XXX-AC: registry and schema instances can be refactored to inherit from some super class with: close(), closeStatement(), dbConnection, servletLocation, get/setServletLocation(), convertResultSet()


Field Summary
 
Fields inherited from class org.edg.info.InstanceBase
DEFAULT_TERMINATION_INTERVAL_MS, s_maxTerminationInterval, s_minTerminationInterval
 
Constructor Summary
SchemaInstance(org.glite.rgma.services.config.SchemaConfig schemaConfig)
          Creates a new SchemaInstance object.
 
Method Summary
 void createTable(java.lang.String createStatement)
          Creates a new Producer table definition in the Schema.
 void destroy()
          Closes the database connection.
 void dropTable(java.lang.String tableName)
          Removes table 'tableName' from the Schema Synchronized to avoid interference between drop and create Table
 org.glite.rgma.system.ResultSet getAllSchemaTables()
          returns all the
 org.glite.rgma.system.ResultSet getColumnNames(java.lang.String[] columnIds)
          Method retrieves all column names for each column ID.
 java.lang.String getColumnType(int columnId)
          returns the type of a column that has columnId
 java.lang.String[] getColumnTypes(java.lang.String tableName, java.lang.String[] columnNames)
          returns the types that correspond to a particular table's columns.
 org.glite.rgma.system.ResultSet getPrimaryKey(java.lang.String tableName)
           
 java.lang.String getTableDesc(java.lang.String tableName)
          Returns a CREATE TABLE statement for the given table.
 org.glite.rgma.system.ResultSet getTableInfo(int tableId)
          returns the names of columns of the table with tableId.
 java.lang.String getVDBName()
           
 void setServletLocation(java.lang.String schemaServletLocation)
          sets the location of this instance's servlet.
 int translateColumnName(int tableId, java.lang.String columnName)
          returns the columnId for a particular table's columnName.
 int translateTableName(java.lang.String tableName)
          returns the tableId that corresponds to a tableName
 
Methods inherited from class org.edg.info.InstanceBase
canDestroy, disconnect, getCreationTimeMillis, getLastRegistryUpdateTimeMillis, getRegistryUpdateIntervalMillis, getResourceId, getStatus, getTerminationInterval, getTerminationIntervalMillis, getUserLastContactTimeMillis, isDestroyed, isTupleCheckingEnabled, notifyRegistrationThread, reconnect, setCloseCalled, setDestroyed, setRegistrationThread, setTerminationInterval, showSignOfLife, updateLastContactTime, updateRegistry, wasCloseCalled
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaInstance

public SchemaInstance(org.glite.rgma.services.config.SchemaConfig schemaConfig)
               throws org.glite.rgma.system.RGMAException
Creates a new SchemaInstance object.

Throws:
org.glite.rgma.system.RGMAException - DOCUMENT ME!
Method Detail

getAllSchemaTables

public org.glite.rgma.system.ResultSet getAllSchemaTables()
                                                   throws org.glite.rgma.system.RGMAException
returns all the

Returns:
DOCUMENT ME!
Throws:
org.glite.rgma.system.RGMAException - DOCUMENT ME!

getColumnNames

public org.glite.rgma.system.ResultSet getColumnNames(java.lang.String[] columnIds)
                                               throws org.glite.rgma.system.RGMAException
Method retrieves all column names for each column ID. The column IDs are encoded within the URL of the request Object.

Parameters:
columnIds - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
org.glite.rgma.system.RGMAException - DOCUMENT ME!

getColumnType

public java.lang.String getColumnType(int columnId)
                               throws org.glite.rgma.system.RGMAException
returns the type of a column that has columnId

Parameters:
columnId - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
org.glite.rgma.system.RGMAException - DOCUMENT ME!

getColumnTypes

public java.lang.String[] getColumnTypes(java.lang.String tableName,
                                         java.lang.String[] columnNames)
                                  throws org.glite.rgma.system.RGMAException
returns the types that correspond to a particular table's columns.

Parameters:
tableName - DOCUMENT ME!
columnNames - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
org.glite.rgma.system.RGMAException - DOCUMENT ME!

getPrimaryKey

public org.glite.rgma.system.ResultSet getPrimaryKey(java.lang.String tableName)
                                              throws org.glite.rgma.system.RGMAException
Throws:
org.glite.rgma.system.RGMAException

getTableDesc

public java.lang.String getTableDesc(java.lang.String tableName)
                              throws org.glite.rgma.system.RGMAException
Returns a CREATE TABLE statement for the given table. Always of the form: CREATE TABLE tableName (column1 type1 NOT NULL, column2 type2 NOT NULL, PRIMARY KEY (column1, column2)) NB: At the moment, the output from this method is compared with the parsed table description provided by the user to assess whether two tables have the same definition.

Parameters:
tableName - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
org.glite.rgma.system.RGMAException - DOCUMENT ME!

getTableInfo

public org.glite.rgma.system.ResultSet getTableInfo(int tableId)
                                             throws org.glite.rgma.system.RGMAException
returns the names of columns of the table with tableId.

Parameters:
tableId - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
org.glite.rgma.system.RGMAException - DOCUMENT ME!

createTable

public void createTable(java.lang.String createStatement)
                 throws org.glite.rgma.system.RGMAException
Creates a new Producer table definition in the Schema. CREATE TABLE statement is verified and then inserted into Schema DB if necessary. Syntax for CREATE: CREATE TABLE name ( field_name field_type [modifiers], ... ) modifiers := NOT NULL, PRIMARY KEY

Parameters:
createStatement - the CREATE TABLE statement.
Throws:
org.glite.rgma.system.RGMAException - if incorrect columns are defined as NOT NULL. If unable to find a column defined as a PRIMARY KEY. Or if unable to parse CREATE TABLE statement.

translateColumnName

public int translateColumnName(int tableId,
                               java.lang.String columnName)
                        throws org.glite.rgma.system.RGMAException
returns the columnId for a particular table's columnName.

Parameters:
tableId - DOCUMENT ME!
columnName - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
org.glite.rgma.system.RGMAException - DOCUMENT ME!

translateTableName

public int translateTableName(java.lang.String tableName)
                       throws org.glite.rgma.system.RGMAException
returns the tableId that corresponds to a tableName

Parameters:
tableName - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
org.glite.rgma.system.RGMAException - DOCUMENT ME!

setServletLocation

public void setServletLocation(java.lang.String schemaServletLocation)
sets the location of this instance's servlet.

Parameters:
schemaServletLocation - DOCUMENT ME!

destroy

public void destroy()
Closes the database connection.


dropTable

public void dropTable(java.lang.String tableName)
               throws org.glite.rgma.system.RGMAException
Removes table 'tableName' from the Schema Synchronized to avoid interference between drop and create Table

Parameters:
tableName -
Throws:
org.glite.rgma.system.RGMAException - Thrown if the database could not be contacted.

getVDBName

public java.lang.String getVDBName()
Returns:
The VDBName of the schema.