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, datastoreListeners, dbID, dbSchema, dbType, dbURL, dependentResources, iconName, jdbcConn, name, session
 
Fields inherited from class gate.util.AbstractFeatureBearer
features, serialVersionUID
 
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, readCorpus, readDatabaseID, readDocument, 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, registerNatives, 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

DS_ICON_NAME

public static final String DS_ICON_NAME
the icon for this resource

DEBUG

private static final boolean DEBUG
Debug flag
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 .

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
Overrides:
findLrIds in class JDBCDataStore

findLrIds

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

unlockLr

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

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

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

_lockLr

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

createLR

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

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
Overrides:
createDoc in class JDBCDataStore

createAnnotationSet

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

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)
Overrides:
updateDocumentContent in class JDBCDataStore

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

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
Overrides:
createFeatures in class JDBCDataStore

createFeaturesBulk

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

_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

_syncLR

protected void _syncLR(LanguageResource lr)
                throws PersistenceException,
                       SecurityException
helper for sync() NEVER call directly
Overrides:
_syncLR in class JDBCDataStore

_syncDocumentHeader

protected void _syncDocumentHeader(Document doc)
                            throws PersistenceException
helper for sync() - never call directly
Overrides:
_syncDocumentHeader in class JDBCDataStore

_syncDocumentContent

protected void _syncDocumentContent(Document doc)
                             throws PersistenceException
helper for sync() - never call directly
Overrides:
_syncDocumentContent in class JDBCDataStore

_syncFeatures

protected void _syncFeatures(LanguageResource lr)
                      throws PersistenceException
helper for sync() - never call directly
Overrides:
_syncFeatures in class JDBCDataStore

readFeatures

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

deleteDocument

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

deleteCorpus

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

_syncRemovedDocumentsFromCorpus

protected void _syncRemovedDocumentsFromCorpus(List docLRIDs,
                                               Long corpLRID)
                                        throws PersistenceException
helper for sync() - never call directly
Overrides:
_syncRemovedDocumentsFromCorpus in class JDBCDataStore

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
Overrides:
addDocumentToCorpus in class JDBCDataStore