Package org.intermine.objectstore
Interface ObjectStoreWriter
-
- All Superinterfaces:
ObjectStore
- All Known Subinterfaces:
IntegrationWriter
- All Known Implementing Classes:
IntegrationWriterAbstractImpl
,IntegrationWriterDataTrackingImpl
,ObjectStoreWriterInterMineImpl
public interface ObjectStoreWriter extends ObjectStore
Store, update, and delete objects- Author:
- Mark Woodbridge
-
-
Field Summary
-
Fields inherited from interface org.intermine.objectstore.ObjectStore
SEQUENCE_IGNORE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
abortTransaction()
Request that the ObjectStoreWriter aborts and closes the transactionvoid
addAllToBag(ObjectStoreBag osb, java.util.Collection<java.lang.Integer> coll)
Adds a collection of elements to an ObjectStoreBag.void
addToBag(ObjectStoreBag osb, java.lang.Integer element)
Adds an element to an ObjectStoreBag.void
addToBagFromQuery(ObjectStoreBag osb, Query q)
Adds elements to an ObjectStoreBag from the results of a Query.void
addToCollection(java.lang.Integer hasId, java.lang.Class<?> clazz, java.lang.String fieldName, java.lang.Integer hadId)
Place an object in a many-to-many collection of another object.void
batchCommitTransaction()
Request that the ObjectStoreWriter commits and closes the transaction and then opens a new one, without guaranteeing that the operation is finished before this method returns.void
beginTransaction()
Request that the ObjectStoreWriter begins a transactionvoid
close()
Closes the connection associated with this ObjectStoreWritervoid
commitTransaction()
Request that the ObjectStoreWriter commits and closes the transactionvoid
delete(InterMineObject o)
Delete an object from this ObjectStorevoid
delete(QueryClass qc, Constraint c)
Deletes a set of objects from this ObjectStore.ObjectStore
getObjectStore()
Retrieve this Writer's ObjectStore.boolean
isInTransaction()
Check whether the ObjectStoreWriter is performing a transactionvoid
removeAllFromBag(ObjectStoreBag osb, java.util.Collection<java.lang.Integer> coll)
Removes a collection of elements from an ObjectStoreBag.void
removeFromBag(ObjectStoreBag osb, java.lang.Integer element)
Removes an element from an ObjectStoreBag.void
replaceClob(Clob clob, java.lang.String text)
Replaces the contents of the given Clob with the given String.void
store(java.lang.Object o)
Store an object in this ObjectStore.-
Methods inherited from interface org.intermine.objectstore.ObjectStore
cacheObjectById, count, createClob, createObjectStoreBag, estimate, execute, execute, execute, executeSingleton, executeSingleton, flushObjectById, getComponentsForQuery, getMaxLimit, getMaxOffset, getMaxTime, getModel, getNewWriter, getObjectByExample, getObjectById, getObjectById, getObjectsByExample, getObjectsByIds, getSequence, getSerial, invalidateObjectById, isMultiConnection, pilferObjectById, prefetchObjectById
-
-
-
-
Method Detail
-
getObjectStore
ObjectStore getObjectStore()
Retrieve this Writer's ObjectStore. This ObjectStoreWriter is a read-write extension to the read-only ObjectStore. This ObjectStoreWriter uses a single database connection in order to allow proper transaction support - use the ObjectStore for general read-only access.- Returns:
- the ObjectStore
-
store
void store(java.lang.Object o) throws ObjectStoreException
Store an object in this ObjectStore. If the ID of this object is not set, it will be set to a previously unused value. If the ID matches the ID of an object already in the objectstore, then an update operation is performed - otherwise a store operation is performed.
Attributes and references of the stored object will be set to those of the provided object. Collections of the stored object will contain the union of the contents of any pre-existing stored object, and the contents of the provided object. There is currently no way to remove entries from a collection of a stored object.
Any objects referred to by this object will have their ID set in a similar way to this object. This object will be stored with references and collections using those IDs, however those objects will not be stored themselves. Therefore, the objectstore will be inconsistent until those objects are also stored.
If bidirectional relationships are not consistent in the objects being stored, then the behaviour of the store method is not defined. Specifically, one-to-one relationships must be stored on both sides. For example, if A has a relationship with B1 in the database, and we store a new A that has a relationship with B2, then we must also store B2 with a relationship back to A (to complete the relationship), and store B1 (to completely break the old relationship),- Parameters:
o
- the object to store- Throws:
ObjectStoreException
- if an error occurs during storage of the object
-
delete
void delete(InterMineObject o) throws ObjectStoreException
Delete an object from this ObjectStore- Parameters:
o
- the object to delete- Throws:
ObjectStoreException
- if an error occurs during deletion of the object
-
delete
void delete(QueryClass qc, Constraint c) throws ObjectStoreException
Deletes a set of objects from this ObjectStore.- Parameters:
qc
- a QueryClass for the class of objects to delete. The class given in the query class must not inherit from org.intermine.model.InterMineObject.c
- a Constraint based on the QueryClass to filter the objects to delete, or null to delete all objects- Throws:
ObjectStoreException
- if an error occurs while deleting the objects
-
addToCollection
void addToCollection(java.lang.Integer hasId, java.lang.Class<?> clazz, java.lang.String fieldName, java.lang.Integer hadId) throws ObjectStoreException
Place an object in a many-to-many collection of another object. This method provides a way to place an object into a collection in another object without having either object loaded in memory. Only the IDs of the two objects are required, along with the name of the collection.- Parameters:
hasId
- the ID of the object that has the collectionclazz
- the class of the object that has the collectionfieldName
- the name of the collectionhadId
- the ID of the object to place in the collection- Throws:
ObjectStoreException
- if a problem occurs
-
addToBag
void addToBag(ObjectStoreBag osb, java.lang.Integer element) throws ObjectStoreException
Adds an element to an ObjectStoreBag.- Parameters:
osb
- an ObjectStoreBagelement
- an Integer to add to the bag- Throws:
ObjectStoreException
- if an error occurs
-
addAllToBag
void addAllToBag(ObjectStoreBag osb, java.util.Collection<java.lang.Integer> coll) throws ObjectStoreException
Adds a collection of elements to an ObjectStoreBag.- Parameters:
osb
- an ObjectStoreBagcoll
- a Collection of Integers- Throws:
ObjectStoreException
- if an error occurs
-
removeFromBag
void removeFromBag(ObjectStoreBag osb, java.lang.Integer element) throws ObjectStoreException
Removes an element from an ObjectStoreBag.- Parameters:
osb
- an ObjectStoreBagelement
- an Integer to add to the bag- Throws:
ObjectStoreException
- if an error occurs
-
removeAllFromBag
void removeAllFromBag(ObjectStoreBag osb, java.util.Collection<java.lang.Integer> coll) throws ObjectStoreException
Removes a collection of elements from an ObjectStoreBag.- Parameters:
osb
- an ObjectStoreBagcoll
- a Collection of Integers- Throws:
ObjectStoreException
- if an error occurs
-
addToBagFromQuery
void addToBagFromQuery(ObjectStoreBag osb, Query q) throws ObjectStoreException
Adds elements to an ObjectStoreBag from the results of a Query. The data may not be loaded into Java, so this is a performance improvement method. For example, in SQL this method may issue a command like "INSERT INTO bag SELECT ...".- Parameters:
osb
- an ObjectStoreBagq
- an objectstore Query, which contains only one result column, which is a suitable type for insertion into the given bag- Throws:
ObjectStoreException
- if something goes wrong
-
replaceClob
void replaceClob(Clob clob, java.lang.String text) throws ObjectStoreException
Replaces the contents of the given Clob with the given String.- Parameters:
clob
- the Clob to write totext
- the text to write to the Clob- Throws:
ObjectStoreException
- if something goes wrong
-
isInTransaction
boolean isInTransaction() throws ObjectStoreException
Check whether the ObjectStoreWriter is performing a transaction- Returns:
- true if in a transaction, false otherwise
- Throws:
ObjectStoreException
- if an error occurs
-
beginTransaction
void beginTransaction() throws ObjectStoreException
Request that the ObjectStoreWriter begins a transaction- Throws:
ObjectStoreException
- if a transaction is in progress, or is aborted
-
commitTransaction
void commitTransaction() throws ObjectStoreException
Request that the ObjectStoreWriter commits and closes the transaction- Throws:
ObjectStoreException
- if a transaction is not in progress, or is aborted
-
abortTransaction
void abortTransaction() throws ObjectStoreException
Request that the ObjectStoreWriter aborts and closes the transaction- Throws:
ObjectStoreException
- if a transaction is not in progress
-
batchCommitTransaction
void batchCommitTransaction() throws ObjectStoreException
Request that the ObjectStoreWriter commits and closes the transaction and then opens a new one, without guaranteeing that the operation is finished before this method returns. Note that writes that are made AFTER this method may be treated as if they were BEFORE this method and be committed in the transaction.- Throws:
ObjectStoreException
- if an error occurs
-
close
void close() throws ObjectStoreException
Closes the connection associated with this ObjectStoreWriter- Throws:
ObjectStoreException
- if something goes wrong
-
-