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 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 addPeer(java.lang.String[] row)
           
 boolean addPeer(java.lang.String name, java.lang.String url)
           
 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 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.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()
           
 java.util.Vector getSchemasImplementedBy(java.lang.String peerName)
           
 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
 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
 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
Throws:
java.sql.SQLException

initialiseRepository

public void initialiseRepository()
                          throws java.sql.SQLException
Throws:
java.sql.SQLException

addPeer

public boolean addPeer(java.lang.String[] row)
                throws java.sql.SQLException
Throws:
java.sql.SQLException

addPeer

public boolean addPeer(java.lang.String name,
                       java.lang.String url)
                throws java.sql.SQLException
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

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

getPeersImplementing

public java.util.Vector getPeersImplementing(java.lang.String schemaName)
                                      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

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