edu.mssm.crover.scentral
Class PersistenceScheme_JDBC_Impl

java.lang.Object
  |
  +--edu.mssm.crover.scentral.PersistenceScheme_JDBC_Impl
All Implemented Interfaces:
PersistenceScheme
Direct Known Subclasses:
DS_PersistenceScheme_JDBC_Impl

public abstract class PersistenceScheme_JDBC_Impl
extends java.lang.Object
implements PersistenceScheme

JDBCsistence scheme. This scheme relies on JDBC compliant database to save the state of each object.


Field Summary
protected static java.lang.String DATABASE_DIAGRAM_KIND_STRING
           
protected  Log log
           
protected  ServletCentral sc
           
 
Fields inherited from interface edu.mssm.crover.scentral.PersistenceScheme
OWNER_REFERENCE_ID, USER_SESSION_KIND
 
Constructor Summary
PersistenceScheme_JDBC_Impl()
           
 
Method Summary
 java.lang.String byteToString(byte b)
          Converts a byte to a two character hexadecimal string representation.
abstract  UserSession createServiceUserSession(UserRecord ur)
          Returns a new instance of the service UserSession implementation.
 void dropLibraryObjectReference(int object_id, int reference_object_id, UserRecord ur)
          Drops a reference in the database to this object identified by object_id.
protected  java.lang.Object getInstance(java.lang.String query)
          Get an instance from the storage directory.
 LibraryObjectInfo getLibraryObjectInfo(int kind, int library_object_id, UserRecord ur)
          Get a LibraryObjectInfo for a given object kind with the given object ID.
 java.util.Collection getLibraryObjectsInfo(int kind, UserRecord ur)
          Get a collection of LibraryObjectInfo-s.
abstract  java.lang.String getPutSessionProcedure()
          Returns the name of the procedure to obtain a session.
abstract  java.lang.String getSessionTableName()
          Returns the name of the table that stores user sessions.
 UserSession getUserSession(UserRecord ur)
          Returns a previously serialized object or a new one if none exists.
 void initialize(Log log)
          Initialized a PersistenceScheme_JDBC_Impl.
protected  int insertSerializableLibraryObject(java.lang.String query, java.lang.String userID, java.lang.String name, java.io.Serializable library_object, java.sql.Date created, java.sql.Date last_modified, java.lang.String description, java.lang.String object_kind)
           
 void log(int level, java.lang.String msg, java.lang.Exception e)
           
 void saveUserSession(UserSession session)
          Serializes the object in a file and keep track of it.
protected  void storeInstance(java.lang.String query, java.lang.String userID, java.io.Serializable instance)
          Save an instance as a file in the storage directory.
protected  void updateSerializableLibraryObject(java.lang.String query, int object_id, java.io.Serializable library_object, java.sql.Date last_modified, java.lang.String description)
           
 UpgradableObject upgradeObject(UpgradableObject original_object, java.lang.Class current_class)
          Upgrades an UpgradableObject instance.
 void userLogsIn(UserRecord ur, java.util.Date loginTime)
          Signal the storage that the user has logged in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected Log log

sc

protected ServletCentral sc

DATABASE_DIAGRAM_KIND_STRING

protected static final java.lang.String DATABASE_DIAGRAM_KIND_STRING
See Also:
Constant Field Values
Constructor Detail

PersistenceScheme_JDBC_Impl

public PersistenceScheme_JDBC_Impl()
Method Detail

initialize

public void initialize(Log log)
Initialized a PersistenceScheme_JDBC_Impl. The connection pool reference is obtained here from ServletCentral.

Specified by:
initialize in interface PersistenceScheme
Parameters:
log - The log system where warnings and errors are reported.

getUserSession

public UserSession getUserSession(UserRecord ur)
Returns a previously serialized object or a new one if none exists. When userID is "guest" the user session returned is a newly constructed one.

Specified by:
getUserSession in interface PersistenceScheme

createServiceUserSession

public abstract UserSession createServiceUserSession(UserRecord ur)
Returns a new instance of the service UserSession implementation.


getSessionTableName

public abstract java.lang.String getSessionTableName()
Returns the name of the table that stores user sessions.


getPutSessionProcedure

public abstract java.lang.String getPutSessionProcedure()
Returns the name of the procedure to obtain a session.


saveUserSession

public void saveUserSession(UserSession session)
Serializes the object in a file and keep track of it. When userID is "guest" the user session the user session is not saved.

Specified by:
saveUserSession in interface PersistenceScheme

byteToString

public java.lang.String byteToString(byte b)
Converts a byte to a two character hexadecimal string representation.


getInstance

protected java.lang.Object getInstance(java.lang.String query)
Get an instance from the storage directory. The query must return only one row with one column selected.


log

public void log(int level,
                java.lang.String msg,
                java.lang.Exception e)

storeInstance

protected void storeInstance(java.lang.String query,
                             java.lang.String userID,
                             java.io.Serializable instance)
Save an instance as a file in the storage directory.


dropLibraryObjectReference

public void dropLibraryObjectReference(int object_id,
                                       int reference_object_id,
                                       UserRecord ur)
Drops a reference in the database to this object identified by object_id. The object_id referencing the object is reference_object_id. When owner requests to drop an object, the owner is identified by reference_object_id = OWNER_REFERENCE_ID (=0), which could never occur for regular objects. Regular objects have id-s > 0. An object is dropped when all references to it are dropped including the owner reference.

Specified by:
dropLibraryObjectReference in interface PersistenceScheme

getLibraryObjectInfo

public LibraryObjectInfo getLibraryObjectInfo(int kind,
                                              int library_object_id,
                                              UserRecord ur)
Get a LibraryObjectInfo for a given object kind with the given object ID.

Specified by:
getLibraryObjectInfo in interface PersistenceScheme
Returns:
LibraryObjectInfo.
See Also:
LibraryObjectInfo

getLibraryObjectsInfo

public java.util.Collection getLibraryObjectsInfo(int kind,
                                                  UserRecord ur)
Get a collection of LibraryObjectInfo-s.

Specified by:
getLibraryObjectsInfo in interface PersistenceScheme
Returns:
Vector of LibraryObjectInfo-s.
See Also:
LibraryObjectInfo

insertSerializableLibraryObject

protected int insertSerializableLibraryObject(java.lang.String query,
                                              java.lang.String userID,
                                              java.lang.String name,
                                              java.io.Serializable library_object,
                                              java.sql.Date created,
                                              java.sql.Date last_modified,
                                              java.lang.String description,
                                              java.lang.String object_kind)
                                       throws BadPersistentID
BadPersistentID

updateSerializableLibraryObject

protected void updateSerializableLibraryObject(java.lang.String query,
                                               int object_id,
                                               java.io.Serializable library_object,
                                               java.sql.Date last_modified,
                                               java.lang.String description)
                                        throws BadPersistentID
BadPersistentID

userLogsIn

public void userLogsIn(UserRecord ur,
                       java.util.Date loginTime)
Description copied from interface: PersistenceScheme
Signal the storage that the user has logged in. Used for accounting.

Specified by:
userLogsIn in interface PersistenceScheme

upgradeObject

public UpgradableObject upgradeObject(UpgradableObject original_object,
                                      java.lang.Class current_class)
Upgrades an UpgradableObject instance. Converts original_object to an instance of current_class such that the information contained in original_object is preserved.

Parameters:
original_object - The instance to be upgraded.
current_class - The class that represents the latest version of the UpgradableObject.
See Also:
UpgradableObject


Copyright @ 2003 Mount Sinai School of Medicine. All Rights Reserved.