uk.ac.ic.doc.automed.p2p.directory
Class P2PDirectoryRepository

java.lang.Object
  extended by uk.ac.ic.doc.automed.p2p.directory.P2PDirectoryRepository

public class P2PDirectoryRepository
extends java.lang.Object


Field Summary
static java.lang.String PUBLIC_SCHEMA_DIRECTORY_SERVER_CFG
          Name given to the public schema directory server configuration file
 
Method Summary
 boolean addDataSource(java.lang.String peerName, java.lang.String schema, java.lang.String dsName, java.lang.String type, java.lang.String capability)
          Add a new data source definition to the repository
 boolean addModel(java.lang.String name, java.lang.String description, java.lang.String structure)
          Save a model structure to repository
 boolean addModel(java.lang.String name, java.lang.String description, java.lang.String structure, java.lang.String[] schemas)
          An overload method of #addModel(name, description, structure) above
 boolean addPathway(java.lang.Object[] row)
          Add a new pathway definition to the repository
 boolean addPathwayTranformation(java.lang.Object[] row)
          Add a new pathway transformation to the repository
 boolean addPeer(java.lang.String[] row)
          Add a new peer
 boolean addPeer(java.lang.String name, java.lang.String url)
          Deprecated.  
 boolean addPeerSchema(java.lang.String schema, java.lang.String peer)
           
 boolean addSchema(java.lang.String name, java.lang.String description, java.lang.String structure)
           
 void addSchemeProfile(java.lang.String peerName, java.lang.String schemaName, java.lang.String modelName)
          Add schema-model-peer association
 java.util.Vector getAllPeers()
           
 java.util.Vector getModel(java.lang.String modelName)
          Get a model structure from the database
 java.util.Vector getModelNames(java.lang.String schemaName)
          Get all models that are associated to a particular schema
 java.util.Vector getPathwayAbstractDescriptions(java.lang.String schemaName)
          Return a list of rows of pathways
 java.lang.String[] getPeers(java.lang.String status)
          Get a list of peers of a given status.
 java.util.Vector getPeersImplementing(java.lang.String schemaName)
           
 java.util.Vector getPublicSchema(java.lang.String schemaName)
           
 java.util.Vector getPublicSchemas()
          Edited by dmle 31/10/2005:
Look for schema list in a joined table Return a list of all schemas including active, inactive and flush
static P2PDirectoryRepository getRepository()
          static { //LOAD DRIVER CLASSES try { Class.forName(driver); } catch(Exception e) { e.printStackTrace(); } } private Connection connection; private Statement statement; private ResultSet resultSet; private ResultSetMetaData metaData; private DatabaseMetaData dbMetaData; -- dmle 9/2/2006
 java.util.Vector getSchemasImplementedBy(java.lang.String peerName)
           
protected  void initialiseRepository()
           
 boolean isModelExist(java.lang.String modelName)
          Check if a model exists in the repository
static void main(java.lang.String[] args)
           
 void removePeers(java.lang.String flushStatus, java.lang.String flushTime, java.lang.String timeInterval)
          Remove peers at flush-time.
 void test_AddDate(java.lang.String myDate, java.lang.String myDate1, long millisecs)
          Test adding date values
 java.util.Vector test_GetDate()
          Test getting date
 void test()
           
 boolean updatePeer(java.lang.String name, java.lang.String url)
           
 boolean updatePeer(java.lang.String name, java.lang.String url, java.lang.String status, java.lang.String lastUpdate)
          Overloaded method to update peer status
 boolean updatePeerAddress(java.lang.String domain, java.lang.String existingAddress, java.lang.String newAddress)
          Change peer's address to a new one (peer belongs specific domain)
 void updatePeersStatus(java.lang.String fromStatus, java.lang.String toStatus, java.lang.String updateTime, java.lang.String timeInterval)
          Change inactive peers into flush peers at hold-time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUBLIC_SCHEMA_DIRECTORY_SERVER_CFG

public static final java.lang.String PUBLIC_SCHEMA_DIRECTORY_SERVER_CFG
Name given to the public schema directory server configuration file

See Also:
Constant Field Values
Method Detail

getRepository

public static P2PDirectoryRepository getRepository()
                                            throws java.sql.SQLException
static { //LOAD DRIVER CLASSES try { Class.forName(driver); } catch(Exception e) { e.printStackTrace(); } } private Connection connection; private Statement statement; private ResultSet resultSet; private ResultSetMetaData metaData; private DatabaseMetaData dbMetaData; -- dmle 9/2/2006

Throws:
java.sql.SQLException

initialiseRepository

protected void initialiseRepository()
                             throws AutoMedException
Throws:
AutoMedException

test

public void test()
          throws java.lang.Exception
Throws:
java.lang.Exception

addPeer

public boolean addPeer(java.lang.String[] row)
                throws java.sql.SQLException
Add a new peer

Throws:
java.sql.SQLException

addPeer

public boolean addPeer(java.lang.String name,
                       java.lang.String url)
                throws java.sql.SQLException
Deprecated. 

Throws:
java.sql.SQLException

addSchema

public boolean addSchema(java.lang.String name,
                         java.lang.String description,
                         java.lang.String structure)
                  throws java.sql.SQLException
Throws:
java.sql.SQLException

addPeerSchema

public boolean addPeerSchema(java.lang.String schema,
                             java.lang.String peer)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException

addPathway

public boolean addPathway(java.lang.Object[] row)
                   throws java.sql.SQLException
Add a new pathway definition to the repository

Parameters:
row - an Object array of values of mixed types, one for each column
Returns:
boolean trueif insertion succeeded and false if otherwise
Throws:
java.sql.SQLException

addPathwayTranformation

public boolean addPathwayTranformation(java.lang.Object[] row)
                                throws java.sql.SQLException
Add a new pathway transformation to the repository

Parameters:
row - an Object array of values of mixed types, one for each column
Returns:
boolean trueif insertion succeeded and false if otherwise
Throws:
java.sql.SQLException

addDataSource

public boolean addDataSource(java.lang.String peerName,
                             java.lang.String schema,
                             java.lang.String dsName,
                             java.lang.String type,
                             java.lang.String capability)
                      throws java.sql.SQLException
Add a new data source definition to the repository

Parameters:
peerName -
dataSource -
quality -
abstraction -
Returns:
boolean trueif insertion succeeded and false if otherwise
Throws:
java.sql.SQLException

test_AddDate

public void test_AddDate(java.lang.String myDate,
                         java.lang.String myDate1,
                         long millisecs)
                  throws java.sql.SQLException
Test adding date values

Throws:
java.sql.SQLException

test_GetDate

public java.util.Vector test_GetDate()
                              throws java.sql.SQLException
Test getting date

Throws:
java.sql.SQLException

addModel

public boolean addModel(java.lang.String name,
                        java.lang.String description,
                        java.lang.String structure)
                 throws java.sql.SQLException
Save a model structure to repository

Parameters:
name - the model name
description - a description about the model (optional - not used at the moment)
structure - the XML representation of the model structure
Returns:
boolean indicates the result of the operation
Throws:
{@link - SQLException} if there is an error in saving it to database
java.sql.SQLException

addModel

public boolean addModel(java.lang.String name,
                        java.lang.String description,
                        java.lang.String structure,
                        java.lang.String[] schemas)
                 throws java.sql.SQLException
An overload method of #addModel(name, description, structure) above

Parameters:
name - the model name
description - a description about the model (optional - not used at the moment)
structure - the XML representation of the model structure
schemas - an array of schema names associated to this model
Returns:
boolean indicates the result of the operation
Throws:
{@link - SQLException} if there is an error in saving it to database
java.sql.SQLException

addSchemeProfile

public void addSchemeProfile(java.lang.String peerName,
                             java.lang.String schemaName,
                             java.lang.String modelName)
                      throws java.sql.SQLException
Add schema-model-peer association

Throws:
java.sql.SQLException

isModelExist

public boolean isModelExist(java.lang.String modelName)
                     throws java.sql.SQLException
Check if a model exists in the repository

Parameters:
modelName - A string representing the unique model name to check
Throws:
java.sql.SQLException

updatePeer

public boolean updatePeer(java.lang.String name,
                          java.lang.String url)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

updatePeer

public boolean updatePeer(java.lang.String name,
                          java.lang.String url,
                          java.lang.String status,
                          java.lang.String lastUpdate)
                   throws java.sql.SQLException
Overloaded method to update peer status

Throws:
java.sql.SQLException

getPublicSchema

public java.util.Vector getPublicSchema(java.lang.String schemaName)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

getModelNames

public java.util.Vector getModelNames(java.lang.String schemaName)
                               throws java.sql.SQLException
Get all models that are associated to a particular schema

Parameters:
schemaName - the schema to check
Returns:
Vector containing the associated model names
Throws:
{@link - SQLException}
java.sql.SQLException

getModel

public java.util.Vector getModel(java.lang.String modelName)
                          throws java.sql.SQLException
Get a model structure from the database

Parameters:
modelName - the model name
Throws:
{@link - SQLException}
java.sql.SQLException

getPublicSchemas

public java.util.Vector getPublicSchemas()
                                  throws java.sql.SQLException
Edited by dmle 31/10/2005:
  1. Look for schema list in a joined table
  2. Return a list of all schemas including active, inactive and flush

Throws:
java.sql.SQLException

getPathwayAbstractDescriptions

public java.util.Vector getPathwayAbstractDescriptions(java.lang.String schemaName)
                                                throws java.sql.SQLException
Return a list of rows of pathways

Throws:
java.sql.SQLException

getPeersImplementing

public java.util.Vector getPeersImplementing(java.lang.String schemaName)
                                      throws java.sql.SQLException
Throws:
java.sql.SQLException

getAllPeers

public java.util.Vector getAllPeers()
                             throws java.sql.SQLException
Throws:
java.sql.SQLException

getSchemasImplementedBy

public java.util.Vector getSchemasImplementedBy(java.lang.String peerName)
                                         throws java.sql.SQLException
Throws:
java.sql.SQLException

main

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

getPeers

public java.lang.String[] getPeers(java.lang.String status)
                            throws java.sql.SQLException
Get a list of peers of a given status. This method is used by hold-time process

Parameters:
status - a String representing in-active status
Returns:
String[] an array of names of in-active peers
Throws:
java.sql.SQLException

updatePeersStatus

public void updatePeersStatus(java.lang.String fromStatus,
                              java.lang.String toStatus,
                              java.lang.String updateTime,
                              java.lang.String timeInterval)
                       throws java.sql.SQLException
Change inactive peers into flush peers at hold-time

Parameters:
fromStatus - from status A
toStatus - to status B
updateTime - the time (in millisecs) at which this update is occuring
timeInterval - the time interval (in millisecs) to check for
Throws:
java.sql.SQLException

updatePeerAddress

public boolean updatePeerAddress(java.lang.String domain,
                                 java.lang.String existingAddress,
                                 java.lang.String newAddress)
                          throws java.sql.SQLException
Change peer's address to a new one (peer belongs specific domain)

Throws:
java.sql.SQLException

removePeers

public void removePeers(java.lang.String flushStatus,
                        java.lang.String flushTime,
                        java.lang.String timeInterval)
                 throws java.sql.SQLException
Remove peers at flush-time.

Throws:
java.sql.SQLException