gate.persist
Class JDBCDataStore

java.lang.Object
  |
  +--gate.util.AbstractFeatureBearer
        |
        +--gate.persist.JDBCDataStore
All Implemented Interfaces:
CreoleListener, DatabaseDataStore, DataStore, EventListener, FeatureBearer, NameBearer, Serializable
Direct Known Subclasses:
OracleDataStore, PostgresDataStore

public abstract class JDBCDataStore
extends AbstractFeatureBearer
implements DatabaseDataStore, CreoleListener

See Also:
Serialized Form

Fields inherited from interface gate.DataStore
DATASTORE_FEATURE_NAME, LR_ID_FEATURE_NAME
 
Method Summary
 void addDatastoreListener(DatastoreListener l)
          Registers a new DatastoreListener with this datastore
 LanguageResource adopt(LanguageResource lr, SecurityInfo secInfo)
          Adopt a resource for persistence.
 void beginTrans()
          starts a transaction note that if u're already in transaction context this will not open nested transaction i.e.
 boolean canReadLR(Object lrID)
          Checks if the user (identified by the sessionID) has read access to the LR
 boolean canWriteLR(Object lrID)
          Checks if the user (identified by the sessionID) has write access to the LR
 void close()
          Close the data store.
 void commitTrans()
          commits transaction note that this will commit all the uncommited calls made so far
 void create()
          Create a new data store.
 void datastoreClosed(CreoleEvent e)
          Called when a DataStore has been closed
 void datastoreCreated(CreoleEvent e)
          Called when a DataStore has been created
 void datastoreOpened(CreoleEvent e)
          Called when a DataStore has been opened
 void delete()
          Delete the data store.
 void delete(String lrClassName, Object lrId)
          Delete a resource from the data store.
 void deleteSince(Long timestamp)
          not used
abstract  List findLrIds(List constraints)
          Get a list of LRs that satisfy some set or restrictions
abstract  List findLrIds(List constraints, String lrType)
          Get a list of LRs that satisfy some set or restrictions and are of a particular type
 String getComment()
          Save: synchonise the in-memory image of the LR with the persistent image.
 String getDatabaseID()
          ---
 String getIconName()
          Returns the name of the icon to be used when this datastore is displayed in the GUI
 LanguageResource getLr(String lrClassName, Object lrPersistenceId)
          Get a resource from the persistent store.
 List getLrIds(String lrType)
          Get a list of the IDs of LRs of a particular type that are present.
 String getLrName(Object lrId)
          Get the name of an LR from its ID.
 List getLrNames(String lrType)
          Get a list of the names of LRs of a particular type that are present.
 List getLrTypes()
          Get a list of the types of LR that are present in the data store.
 String getName()
          Returns the name of this resource
 SecurityInfo getSecurityInfo(LanguageResource lr)
          get security information for LR .
 Session getSession(Session s)
          identify user using this datastore
 String getStorageUrl()
          Get the URL for the underlying storage mechanism.
 boolean isAutoSaving()
          Get the autosaving behaviour of the LR.
 void open()
          Open a connection to the data store.
 void removeDatastoreListener(DatastoreListener l)
          Removes a a previously registered DatastoreListener from the list listeners for this datastore
 void resourceLoaded(CreoleEvent e)
          Called when a new Resource has been loaded into the system
 void resourceRenamed(Resource resource, String oldName, String newName)
          Called when the creole register has renamed a resource.1
 void resourceUnloaded(CreoleEvent e)
          Called when a Resource has been removed from the system
 void rollbackTrans()
          rollsback a transaction
 void setAutoSaving(boolean autoSaving)
          Set method for the autosaving behaviour of the data store.
 void setName(String name)
          Sets the name of this resource
 void setSession(Session s)
          identify user using this datastore
 void setStorageUrl(String storageUrl)
          Set the URL for the underlying storage mechanism.
 void sync(LanguageResource lr)
          Save: synchonise the in-memory image of the LR with the persistent image.
 Long timestamp()
          not used
 
Methods inherited from class gate.util.AbstractFeatureBearer
getFeatures, setFeatures
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gate.DataStore
lockLr, setSecurityInfo, unlockLr
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, setFeatures
 

Method Detail

getComment

public String getComment()
Save: synchonise the in-memory image of the LR with the persistent image.
Specified by:
getComment in interface DataStore

getIconName

public String getIconName()
Returns the name of the icon to be used when this datastore is displayed in the GUI
Specified by:
getIconName in interface DataStore

getLrName

public String getLrName(Object lrId)
                 throws PersistenceException
Get the name of an LR from its ID.
Specified by:
getLrName in interface DataStore

setStorageUrl

public void setStorageUrl(String storageUrl)
                   throws PersistenceException
Set the URL for the underlying storage mechanism.
Specified by:
setStorageUrl in interface DataStore

getStorageUrl

public String getStorageUrl()
Get the URL for the underlying storage mechanism.
Specified by:
getStorageUrl in interface DataStore

create

public void create()
            throws PersistenceException,
                   UnsupportedOperationException
Create a new data store. NOTE: for some data stores creation is an system administrator task; in such cases this method will throw an UnsupportedOperationException.
Specified by:
create in interface DataStore

open

public void open()
          throws PersistenceException
Open a connection to the data store.
Specified by:
open in interface DataStore

close

public void close()
           throws PersistenceException
Close the data store.
Specified by:
close in interface DataStore

delete

public void delete()
            throws PersistenceException,
                   UnsupportedOperationException
Delete the data store. NOTE: for some data stores deletion is an system administrator task; in such cases this method will throw an UnsupportedOperationException.
Specified by:
delete in interface DataStore

delete

public void delete(String lrClassName,
                   Object lrId)
            throws PersistenceException,
                   SecurityException
Delete a resource from the data store.
Specified by:
delete in interface DataStore
Parameters:
lrId - a data-store specific unique identifier for the resource
lrClassName - class name of the type of resource

sync

public void sync(LanguageResource lr)
          throws PersistenceException,
                 SecurityException
Save: synchonise the in-memory image of the LR with the persistent image.
Specified by:
sync in interface DataStore

setAutoSaving

public void setAutoSaving(boolean autoSaving)
                   throws UnsupportedOperationException,
                          PersistenceException
Set method for the autosaving behaviour of the data store. NOTE: many types of datastore have no auto-save function, in which case this will throw an UnsupportedOperationException.
Specified by:
setAutoSaving in interface DataStore

isAutoSaving

public boolean isAutoSaving()
Get the autosaving behaviour of the LR.
Specified by:
isAutoSaving in interface DataStore

adopt

public LanguageResource adopt(LanguageResource lr,
                              SecurityInfo secInfo)
                       throws PersistenceException,
                              SecurityException
Adopt a resource for persistence.
Specified by:
adopt in interface DataStore

getLrTypes

public List getLrTypes()
                throws PersistenceException
Get a list of the types of LR that are present in the data store.
Specified by:
getLrTypes in interface DataStore

getLrIds

public List getLrIds(String lrType)
              throws PersistenceException
Get a list of the IDs of LRs of a particular type that are present.
Specified by:
getLrIds in interface DataStore

getLrNames

public List getLrNames(String lrType)
                throws PersistenceException
Get a list of the names of LRs of a particular type that are present.
Specified by:
getLrNames in interface DataStore

canReadLR

public boolean canReadLR(Object lrID)
                  throws PersistenceException,
                         SecurityException
Checks if the user (identified by the sessionID) has read access to the LR
Specified by:
canReadLR in interface DataStore

canWriteLR

public boolean canWriteLR(Object lrID)
                   throws PersistenceException,
                          SecurityException
Checks if the user (identified by the sessionID) has write access to the LR
Specified by:
canWriteLR in interface DataStore

beginTrans

public void beginTrans()
                throws PersistenceException,
                       UnsupportedOperationException
starts a transaction note that if u're already in transaction context this will not open nested transaction i.e. many consecutive calls to beginTrans() make no difference if no commit/rollback is made meanwhile
Specified by:
beginTrans in interface DatabaseDataStore

commitTrans

public void commitTrans()
                 throws PersistenceException,
                        UnsupportedOperationException
commits transaction note that this will commit all the uncommited calls made so far
Specified by:
commitTrans in interface DatabaseDataStore

rollbackTrans

public void rollbackTrans()
                   throws PersistenceException,
                          UnsupportedOperationException
rollsback a transaction
Specified by:
rollbackTrans in interface DatabaseDataStore

timestamp

public Long timestamp()
               throws PersistenceException
not used
Specified by:
timestamp in interface DatabaseDataStore

deleteSince

public void deleteSince(Long timestamp)
                 throws PersistenceException
not used
Specified by:
deleteSince in interface DatabaseDataStore

setName

public void setName(String name)
Sets the name of this resource
Specified by:
setName in interface NameBearer

getName

public String getName()
Returns the name of this resource
Specified by:
getName in interface NameBearer

getDatabaseID

public String getDatabaseID()
---
Specified by:
getDatabaseID in interface DatabaseDataStore

removeDatastoreListener

public void removeDatastoreListener(DatastoreListener l)
Removes a a previously registered DatastoreListener from the list listeners for this datastore
Specified by:
removeDatastoreListener in interface DataStore

addDatastoreListener

public void addDatastoreListener(DatastoreListener l)
Registers a new DatastoreListener with this datastore
Specified by:
addDatastoreListener in interface DataStore

resourceLoaded

public void resourceLoaded(CreoleEvent e)
Description copied from interface: CreoleListener
Called when a new Resource has been loaded into the system
Specified by:
resourceLoaded in interface CreoleListener

resourceRenamed

public void resourceRenamed(Resource resource,
                            String oldName,
                            String newName)
Description copied from interface: CreoleListener
Called when the creole register has renamed a resource.1
Specified by:
resourceRenamed in interface CreoleListener

resourceUnloaded

public void resourceUnloaded(CreoleEvent e)
Description copied from interface: CreoleListener
Called when a Resource has been removed from the system
Specified by:
resourceUnloaded in interface CreoleListener

datastoreOpened

public void datastoreOpened(CreoleEvent e)
Description copied from interface: CreoleListener
Called when a DataStore has been opened
Specified by:
datastoreOpened in interface CreoleListener

datastoreCreated

public void datastoreCreated(CreoleEvent e)
Description copied from interface: CreoleListener
Called when a DataStore has been created
Specified by:
datastoreCreated in interface CreoleListener

datastoreClosed

public void datastoreClosed(CreoleEvent e)
Description copied from interface: CreoleListener
Called when a DataStore has been closed
Specified by:
datastoreClosed in interface CreoleListener

setSession

public void setSession(Session s)
                throws SecurityException
identify user using this datastore
Specified by:
setSession in interface DataStore

getSession

public Session getSession(Session s)
                   throws SecurityException
identify user using this datastore
Specified by:
getSession in interface DataStore

findLrIds

public abstract List findLrIds(List constraints)
                        throws PersistenceException
Get a list of LRs that satisfy some set or restrictions
Specified by:
findLrIds in interface DataStore

findLrIds

public abstract List findLrIds(List constraints,
                               String lrType)
                        throws PersistenceException
Get a list of LRs that satisfy some set or restrictions and are of a particular type
Specified by:
findLrIds in interface DataStore

getSecurityInfo

public SecurityInfo getSecurityInfo(LanguageResource lr)
                             throws PersistenceException
get security information for LR .
Specified by:
getSecurityInfo in interface DataStore

getLr

public LanguageResource getLr(String lrClassName,
                              Object lrPersistenceId)
                       throws PersistenceException,
                              SecurityException
Get a resource from the persistent store. Don't use this method - use Factory.createResource with DataStore and DataStoreInstanceId parameters set instead.
Specified by:
getLr in interface DataStore