gate.persist
Class PostgresDataStore

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

public class PostgresDataStore
extends JDBCDataStore

See Also:
Serialized Form

Field Summary
private static boolean DEBUG
          Debug flag
private static String DS_COMMENT
          Name of this resource
static String DS_ICON_NAME
          the icon for this resource
 
Fields inherited from class gate.persist.JDBCDataStore
ac, datastoreComment, dbSchema, dbType, dependentResources, iconName, jdbcConn, name, session
 
Fields inherited from class gate.util.AbstractFeatureBearer
features
 
Fields inherited from interface gate.DataStore
DATASTORE_FEATURE_NAME, LR_ID_FEATURE_NAME
 
Constructor Summary
PostgresDataStore()
           
 
Method Summary
private  Long _createFeature(Long entityID, int entityType, String key, Object value, int valueType, PreparedStatement pstmt)
          creates a feature of the specified type/value/valueType/key for the specified entity Entity is one of: LR, Annotation Value types are: boolean, int, long, string, float, Object
private  boolean _lockLr(Long lrID)
          helper for lockLR() never call directly
protected  void _syncDocumentContent(Document doc)
          helper for sync() - never call directly
protected  void _syncDocumentHeader(Document doc)
          helper for sync() - never call directly
protected  void _syncFeatures(LanguageResource lr)
          helper for sync() - never call directly
protected  void _syncLR(LanguageResource lr)
          helper for sync() NEVER call directly
protected  void _syncRemovedDocumentsFromCorpus(List docLRIDs, Long corpLRID)
          helper for sync() - never call directly
protected  void addDocumentToCorpus(Long docID, Long corpID)
          adds document to corpus in the database if the document is already part of the corpus nothing changes
protected  boolean canAccessLR(Long lrID, int mode)
          Checks if the user (identified by the sessionID) has some access (read/write) to the LR
protected  void createAnnotationSet(Long lrID, AnnotationSet aset)
          creates an entry for annotation set in the database
protected  Long createDoc(Long _lrID, URL _docURL, String _docEncoding, Long _docStartOffset, Long _docEndOffset, Boolean _docIsMarkupAware, Long _corpusID)
          helper for adopt never call directly
private  void createFeature(Long entityID, int entityType, String key, Object value, PreparedStatement pstmt)
          creates a feature with the specified type/key/value for the specified entity entitties are either LRs ot Annotations valid values are: boolean, int, long, string, float, Object, boolean List, int List, long List, string List, float List, Object List
protected  void createFeatures(Long entityID, int entityType, FeatureMap features)
          helper metod iterates a FeatureMap and creates all its features in the database
protected  void createFeaturesBulk(Long entityID, int entityType, FeatureMap features)
           
protected  Long createLR(String lrType, String lrName, SecurityInfo si, Long lrParentID)
          helper for adopt() never call directly
protected  void deleteCorpus(Long lrId)
          helper method for delete() never call it directly beause proper events will not be fired
protected  void deleteDocument(Long lrId)
          helper method for delete() never call it directly beause proper events will not be fired
 List findLrIds(List constraints)
          Get a list of LRs that satisfy some set or restrictions
 List findLrIds(List constraints, String lrType)
          Get a list of LRs that satisfy some set or restrictions and are of a particular type
 boolean lockLr(LanguageResource lr)
          Try to acquire exlusive lock on a resource from the persistent store.
protected  FeatureMap readFeatures(Long entityID, int entityType)
          reads the features of an entity entities are of type LR or Annotation
 void setSecurityInfo(LanguageResource parm1, SecurityInfo parm2)
          set security information for LR .
 void unlockLr(LanguageResource lr)
          Releases the exlusive lock on a resource from the persistent store.
protected  void updateDocumentContent(Long docID, DocumentContent content)
          updates the content of the document if it is binary or a long string (that does not fit into VARCHAR2)
 
Methods inherited from class gate.persist.JDBCDataStore
_adopt, _sync, _syncAddedAnnotations, _syncAnnotations, _syncAnnotationSets, _syncChangedAnnotations, _syncRemovedAnnotations, addDatastoreListener, adopt, beginTrans, canReadLR, canWriteLR, close, commitTrans, create, createCorpus, createDocument, createDocument, datastoreClosed, datastoreCreated, datastoreOpened, delete, delete, deleteSince, findFeatureType, fireResourceAdopted, fireResourceDeleted, fireResourceWritten, getComment, getDatabaseID, getIconName, getLockingUser, getLockingUser, getLr, getLrIds, getLrName, getLrNames, getLrTypes, getName, getSecurityInfo, getSession, getStorageUrl, isAutoSaving, open, readDatabaseID, removeDatastoreListener, resourceLoaded, resourceRenamed, resourceUnloaded, rollbackTrans, setAutoSaving, setName, setSession, setStorageUrl, sync, syncCorpus, syncDocument, timestamp, unloadLR
 
Methods inherited from class gate.util.AbstractFeatureBearer
getFeatures, setFeatures
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gate.util.FeatureBearer
getFeatures, setFeatures
 

Field Detail

DS_COMMENT

private static final String DS_COMMENT
Name of this resource

See Also:
Constant Field Values

DS_ICON_NAME

public static final String DS_ICON_NAME
the icon for this resource

See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG
Debug flag

See Also:
Constant Field Values
Constructor Detail

PostgresDataStore

public PostgresDataStore()
Method Detail

setSecurityInfo

public void setSecurityInfo(LanguageResource parm1,
                            SecurityInfo parm2)
                     throws PersistenceException,
                            SecurityException
Description copied from interface: DataStore
set security information for LR .

PersistenceException
SecurityException

findLrIds

public List findLrIds(List constraints,
                      String lrType)
               throws PersistenceException
Description copied from class: JDBCDataStore
Get a list of LRs that satisfy some set or restrictions and are of a particular type

Specified by:
findLrIds in interface DataStore
Specified by:
findLrIds in class JDBCDataStore
PersistenceException

findLrIds

public List findLrIds(List constraints)
               throws PersistenceException
Description copied from class: JDBCDataStore
Get a list of LRs that satisfy some set or restrictions

Specified by:
findLrIds in interface DataStore
Specified by:
findLrIds in class JDBCDataStore
PersistenceException

unlockLr

public void unlockLr(LanguageResource lr)
              throws PersistenceException,
                     SecurityException
Releases the exlusive lock on a resource from the persistent store.

PersistenceException
SecurityException

canAccessLR

protected boolean canAccessLR(Long lrID,
                              int mode)
                       throws PersistenceException,
                              SecurityException
Checks if the user (identified by the sessionID) has some access (read/write) to the LR

Overrides:
canAccessLR in class JDBCDataStore
PersistenceException
SecurityException

lockLr

public boolean lockLr(LanguageResource lr)
               throws PersistenceException,
                      SecurityException
Try to acquire exlusive lock on a resource from the persistent store. Always call unlockLR() when the lock is no longer needed

PersistenceException
SecurityException

_lockLr

private boolean _lockLr(Long lrID)
                 throws PersistenceException,
                        SecurityException
helper for lockLR() never call directly

PersistenceException
SecurityException

createLR

protected Long createLR(String lrType,
                        String lrName,
                        SecurityInfo si,
                        Long lrParentID)
                 throws PersistenceException,
                        SecurityException
helper for adopt() never call directly

Specified by:
createLR in class JDBCDataStore
PersistenceException
SecurityException

createDoc

protected Long createDoc(Long _lrID,
                         URL _docURL,
                         String _docEncoding,
                         Long _docStartOffset,
                         Long _docEndOffset,
                         Boolean _docIsMarkupAware,
                         Long _corpusID)
                  throws PersistenceException
helper for adopt never call directly

Specified by:
createDoc in class JDBCDataStore
PersistenceException

createAnnotationSet

protected void createAnnotationSet(Long lrID,
                                   AnnotationSet aset)
                            throws PersistenceException
creates an entry for annotation set in the database

Specified by:
createAnnotationSet in class JDBCDataStore
PersistenceException

updateDocumentContent

protected void updateDocumentContent(Long docID,
                                     DocumentContent content)
                              throws PersistenceException
updates the content of the document if it is binary or a long string (that does not fit into VARCHAR2)

Specified by:
updateDocumentContent in class JDBCDataStore
PersistenceException

createFeature

private void createFeature(Long entityID,
                           int entityType,
                           String key,
                           Object value,
                           PreparedStatement pstmt)
                    throws PersistenceException
creates a feature with the specified type/key/value for the specified entity entitties are either LRs ot Annotations valid values are: boolean, int, long, string, float, Object, boolean List, int List, long List, string List, float List, Object List

PersistenceException

createFeatures

protected void createFeatures(Long entityID,
                              int entityType,
                              FeatureMap features)
                       throws PersistenceException
helper metod iterates a FeatureMap and creates all its features in the database

Specified by:
createFeatures in class JDBCDataStore
PersistenceException

createFeaturesBulk

protected void createFeaturesBulk(Long entityID,
                                  int entityType,
                                  FeatureMap features)
                           throws PersistenceException
Specified by:
createFeaturesBulk in class JDBCDataStore
PersistenceException

_createFeature

private Long _createFeature(Long entityID,
                            int entityType,
                            String key,
                            Object value,
                            int valueType,
                            PreparedStatement pstmt)
                     throws PersistenceException
creates a feature of the specified type/value/valueType/key for the specified entity Entity is one of: LR, Annotation Value types are: boolean, int, long, string, float, Object

PersistenceException

_syncLR

protected void _syncLR(LanguageResource lr)
                throws PersistenceException,
                       SecurityException
helper for sync() NEVER call directly

Specified by:
_syncLR in class JDBCDataStore
PersistenceException
SecurityException

_syncDocumentHeader

protected void _syncDocumentHeader(Document doc)
                            throws PersistenceException
helper for sync() - never call directly

Specified by:
_syncDocumentHeader in class JDBCDataStore
PersistenceException

_syncDocumentContent

protected void _syncDocumentContent(Document doc)
                             throws PersistenceException
helper for sync() - never call directly

Specified by:
_syncDocumentContent in class JDBCDataStore
PersistenceException

_syncFeatures

protected void _syncFeatures(LanguageResource lr)
                      throws PersistenceException
helper for sync() - never call directly

Specified by:
_syncFeatures in class JDBCDataStore
PersistenceException

readFeatures

protected FeatureMap readFeatures(Long entityID,
                                  int entityType)
                           throws PersistenceException
reads the features of an entity entities are of type LR or Annotation

Specified by:
readFeatures in class JDBCDataStore
PersistenceException

deleteDocument

protected void deleteDocument(Long lrId)
                       throws PersistenceException
helper method for delete() never call it directly beause proper events will not be fired

Specified by:
deleteDocument in class JDBCDataStore
PersistenceException

deleteCorpus

protected void deleteCorpus(Long lrId)
                     throws PersistenceException
helper method for delete() never call it directly beause proper events will not be fired

Specified by:
deleteCorpus in class JDBCDataStore
PersistenceException

_syncRemovedDocumentsFromCorpus

protected void _syncRemovedDocumentsFromCorpus(List docLRIDs,
                                               Long corpLRID)
                                        throws PersistenceException
helper for sync() - never call directly

Specified by:
_syncRemovedDocumentsFromCorpus in class JDBCDataStore
PersistenceException

addDocumentToCorpus

protected void addDocumentToCorpus(Long docID,
                                   Long corpID)
                            throws PersistenceException,
                                   SecurityException
adds document to corpus in the database if the document is already part of the corpus nothing changes

Specified by:
addDocumentToCorpus in class JDBCDataStore
PersistenceException
SecurityException