Interface ObjectStoreWriter

    • 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​(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 collection
        clazz - the class of the object that has the collection
        fieldName - the name of the collection
        hadId - the ID of the object to place in the collection
        Throws:
        ObjectStoreException - if a problem 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 ObjectStoreBag
        coll - 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 ObjectStoreBag
        element - 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 ObjectStoreBag
        coll - 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 ObjectStoreBag
        q - 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 to
        text - 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