Interface IBmPlatformTransaction


  • public interface IBmPlatformTransaction
    Platform transaction.
    • Method Detail

      • commit

        IBmTransactionCommitResult commit​(Consumer<BmPlatformEvent> eventConsumer)
        Commits the transaction.
        Parameters:
        eventConsumer - The consumer that if specified will be invoked to put the event to a processing queue in the course of the commit operation (when all the changes are already committed but locks are not released yet). Doing so allows to put the events into the queue in their logical order. May be null.
        Returns:
        an instance of IBmTransactionCommitResult, never null.
      • rollback

        void rollback()
        Rolls back the transaction.
      • attachTopObject

        void attachTopObject​(IBmNamespace namespace,
                             IBmObject object,
                             String fqn)
        Attaches a new top-level object with the specified FQN, i.e. this method makes the specified object persistent and managed by the BM.
        • The FQN must be unique.
        • If there is already an object with the specified FQN then depending on the situation either this method or commit() will throw an exception.
        • If the specified object is already attached to a BM then an exception is thrown.
        Parameters:
        namespace - The namespace to attach the object to. May not be null.
        object - The object to attach. May not be null.
        fqn - The FQN. May not be null.
      • detachTopObject

        void detachTopObject​(IBmObject object)
        Detaches (removes) a top object.
        • If the specified object is a contained object an exception is thrown.
        • If the specified object is not attached to the BM an exception is thrown.
        Parameters:
        object - The top object to detach. May not be null.
      • updateTopObjectFqn

        void updateTopObjectFqn​(IBmObject object,
                                String fqn)
        Assigns the specified top-level object a new FQN. The FQN must be unique. If there is already an object with the specified FQN then depending on the situation either this method or commit() will throw an exception.
        Parameters:
        object - The object to assign FQN to. May not be null.
        fqn - The FQN to assign. May not be null.
      • getObjectById

        IBmObject getObjectById​(IBmNamespace namespace,
                                long id)
        Gets object by ID.
        Parameters:
        namespace - The namespace the object belongs to. May not be null.
        id - The ID to get object by.
        Returns:
        the object with the specified ID or null if it does not exist.
      • getTopObjectByFqn

        IBmObject getTopObjectByFqn​(IBmNamespace namespace,
                                    String fqn)
        Gets top-level object by FQN.
        Parameters:
        namespace - The namespace the object belongs to. May not be null.
        fqn - The FQN to get object by. May not be null
        Returns:
        the object with the specified FQN or null if it does not exist.
      • getTopObjectByResourceId

        IBmObject getTopObjectByResourceId​(IBmNamespace namespace,
                                           int resourceId)
        Gets top object by resource ID.
        Parameters:
        namespace - The namespace the object belongs to. May not be null.
        resourceId - The resource ID to get object by.
        Returns:
        the top object belonging to the resource specified by ID if exists, otherwise null.
      • getTopObjectIdByFqn

        long getTopObjectIdByFqn​(IBmNamespace namespace,
                                 String fqn)
        Gets top-level object ID by FQN.
        Parameters:
        namespace - The namespace the object belongs to. May not be null.
        fqn - The FQN to get ID by. May not be null
        Returns:
        the ID of -1L if there is no object with the specified FQN.
      • getObjectByUri

        IBmObject getObjectByUri​(org.eclipse.emf.common.util.URI uri)
        Gets object by URI.
        Parameters:
        uri - The URI to get object by. May not be null.
        Returns:
        the object identified by the specified URI or null if it does not exist.
      • isReadOnly

        boolean isReadOnly()
        Checks whether the transaction is read-only.
        Returns:
        true if the transaction is read-only, false otherwise.
      • undo

        void undo​(IBmTransactionRecord transactionRecord)
        Undoes the modifications represented by the specified transaction record.
        Parameters:
        transactionRecord - The transaction record. May not be null.
      • redo

        void redo​(IBmTransactionRecord transactionRecord)
        Redoes the modifications represented by the specified transaction record.
        Parameters:
        transactionRecord - The transaction record. May not be null.
      • getResourceSet

        @Deprecated
        com._1c.g5.v8.bm.core.internal.IBmInternalResourceSet getResourceSet()
        Deprecated.
        This method has been added to support existing legacy solutions.
        Gets the transaction resource set.
        Returns:
        the transaction resource set, never null.
      • getExternalObjectByUri

        @Deprecated
        org.eclipse.emf.ecore.EObject getExternalObjectByUri​(org.eclipse.emf.common.util.URI uri)
        Deprecated.
        This method has been added to support existing legacy solutions.
        Gets external object (that is not managed by the engine this transaction belongs to) by URI.
        Parameters:
        uri - The URI to get external object by. May not be null.
        Returns:
        the object identified by the specified URI or null if it does not exist.
      • toTransactionObject

        <T extends org.eclipse.emf.ecore.EObject> T toTransactionObject​(T object)
        The shortcut for getting the transaction counterpart by the given object.
        The same thing can be made by using:
         
         T object = ...;
        
         long objectId = ((IBmObject)object).bmGetId();
         IBmObject bmObject = transaction.getObjectById(objectId);
         T transactionObject = (T)bmObject;
         
         
        Parameters:
        object - The object to get transaction counterpart for. May not be null.
        Returns:
        transaction object or null if the object gets detached from BM before this invocation finishes.
      • getTopObjectIterator

        Iterator<IBmObject> getTopObjectIterator​(IBmNamespace namespace)
        Gets an iterator over the top objects belonging to the specified namespace. The iterator does not implement remove method.
        Parameters:
        namespace - The namespace. May not be null.
        Returns:
        the iterator, never null.
      • getTopObjectIterator

        Iterator<IBmObject> getTopObjectIterator​(IBmNamespace namespace,
                                                 org.eclipse.emf.ecore.EClass eClass)
        Gets iterator over the top objects of the specified EMF class and its subclasses. The iterator does not implement remove method.
        Parameters:
        namespace - The namespace. May not be null.
        eClass - The EMF class. May not be null.
        Returns:
        the iterator, never null.
      • getTopObjectEClasses

        Iterator<org.eclipse.emf.ecore.EClass> getTopObjectEClasses​(IBmNamespace namespace)
        Gets specific EClass'es of all top objects being registered in the store at this point
        Parameters:
        namespace - The namespace. May not be null.
        Returns:
        An iterator over EMF classes of known top objects. May not be null. Elements are guaranteed to be unique.
      • getTopObjectIdsByEClass

        IBmLongIterator getTopObjectIdsByEClass​(IBmNamespace namespace,
                                                org.eclipse.emf.ecore.EClass eClass)
        Gets IDs of the top objects of the specified EMF class and its subclasses. Note that the correponding objects are not attached to the transaction i.e. not locked. Thus the returned set of identifiers may already be outdated. The method should be used only for mass operations with external control on BM contents changing and external means of data integrity tracking and support. The iterator does not implement remove method.
        Parameters:
        namespace - The namespace. May not be null.
        eClass - The EMF class. May not be null.
        Returns:
        an iterator over the IDs of the top objects of the specified EMF class. Never null.
      • getContainedObjectIterator

        Iterator<IBmObject> getContainedObjectIterator​(IBmNamespace namespace,
                                                       org.eclipse.emf.ecore.EClass eClass)
        Gets iterator over the contained objects of the specified EMF class and its subclasses. The iterator does not implement remove method.
        Parameters:
        namespace - The namespace. May not be null.
        eClass - The EMF class. May not be null.
        Returns:
        the iterator, never null.
      • getContainedObjectIterator

        Iterator<IBmObject> getContainedObjectIterator​(IBmNamespace namespace,
                                                       IBmObject topObject,
                                                       org.eclipse.emf.ecore.EClass eClass)
        Gets iterator over the contained objects of the specified EMF class (and its subclasses) contained (directly or indirectly) in the specified top object. The iterator does not implement remove method.
        Parameters:
        namespace - The namespace. May not be null.
        topObject - The top obect. May not be null.
        eClass - The EMF class. May not be null.
        Returns:
        the iterator, never null.
      • getContainedObjectIdsByEClass

        IBmLongIterator getContainedObjectIdsByEClass​(IBmNamespace namespace,
                                                      org.eclipse.emf.ecore.EClass eClass)
        Gets IDs of the contained objects of the specified EMF class and its subclasses. Note that the correponding objects are not attached to the transaction i.e. not locked. Thus the returned set of identifiers may already be outdated. The method should be used only for mass operations with external control on BM contents changing and external means of data integrity tracking and support. The iterator does not implement remove method.
        Parameters:
        namespace - The namespace. May not be null.
        eClass - The EMF class. May not be null.
        Returns:
        an iterator over the IDs of the top objects of the specified EMF class. Never null.
      • getContainedObjectIdsByTopObjectIdAndEClass

        IBmLongIterator getContainedObjectIdsByTopObjectIdAndEClass​(IBmNamespace namespace,
                                                                    long topObjectId,
                                                                    org.eclipse.emf.ecore.EClass eClass)
        Gets IDs of the contained objects of the specified EMF class (and its subclasses) contained (directly or indirectly) in the top object with the specified ID. Note that the correponding objects are not attached to the transaction i.e. not locked. Thus the returned set of identifiers may already be outdated. The method should be used only for mass operations with external control on BM contents changing and external means of data integrity tracking and support. The iterator does not implement remove method.
        Parameters:
        namespace - The namespace. May not be null.
        topObjectId - The ID of the top object.
        eClass - The EMF class. May not be null.
        Returns:
        an iterator over the IDs of the top objects of the specified EMF class. Never null.
      • getTopObjectsByFqnIgnoreCase

        Iterator<IBmObject> getTopObjectsByFqnIgnoreCase​(IBmNamespace namespace,
                                                         String fqn)
        Gets top objects by FQN ignoring case.
        Parameters:
        handle - The handle of the transaction. May not be null.
        ns - The namespace the object belongs to. May not be null.
        fqn - The FQN. May not be null.
        Returns:
        an iterator over top objects matching the FQN. Never null.
      • getObjectsByAttributeValue

        Iterator<IBmObject> getObjectsByAttributeValue​(IBmNamespace namespace,
                                                       org.eclipse.emf.ecore.EAttribute attribute,
                                                       Object value)
        Gets objects by attribute value and namespace. Throws an exception if the attribute is not indexed.
        Parameters:
        namespace - The namespace. May not be null.
        attribute - The attribute. May not be null.
        value - The value. May not be null.
        Returns:
        an iterator over the objects with the specified attribute value, never null. The iterator does not implement remove method.
        See Also:
        BmPlatformConfiguration#indexedAttributes(java.util.Collection)
      • getObjectIdsByAttributeValue

        IBmLongIterator getObjectIdsByAttributeValue​(IBmNamespace namespace,
                                                     org.eclipse.emf.ecore.EAttribute attribute,
                                                     Object value)
        Gets object identifiers by attribute value and namespace. Throws an exception if the attribute is not indexed.
        Parameters:
        namespace - The namespace. May not be null.
        attribute - The attribute. May not be null.
        value - The value. May not be null.
        Returns:
        an iterator over the objects with the specified attribute value, never null. The iterator does not implement remove method.
        See Also:
        BmPlatformConfiguration#indexedAttributes(java.util.Collection)
      • getReferences

        Collection<IBmCrossReference> getReferences​(IBmObject object,
                                                    IBmNamespace namespace)
        Gets references to the specified object from objects belonging to the specified namespace.
        Parameters:
        object - The object. May not be null.
        namespace - The namespace. May not be null.
        Returns:
        a collection of references. Never null.
      • getReferences

        Collection<IBmCrossReference> getReferences​(org.eclipse.emf.common.util.URI uri,
                                                    IBmNamespace namespace)
        Gets references to the specified object from objects belonging to the specified namespace.
        Parameters:
        uri - The URI of the object to get references to. May not be null.
        namespace - The namespace. May not be null.
        Returns:
        a collection of references. Never null.
      • peekEClass

        org.eclipse.emf.ecore.EClass peekEClass​(IBmNamespace namespace,
                                                long id)
        Peeks the EMF class of the specified object without locking the object.
        Parameters:
        namespace - The namespace the object belongs to. May not be null.
        id - The ID of the object.
        Returns:
        the EMF class of the object or null if the object does not exist.
      • evict

        @Deprecated
        void evict​(IBmNamespace namespace,
                   long id)
        Deprecated.
        Evicts the specified object from the transaction. After evicting the object from the transaction, any change to the evicted object will not be persisted on transaction commit. Evicting affects all contained objects being attached to the transaction.
        Evicting also releases all locks (both read and write) to this object being captured earlier in the transaction.
        Parameters:
        namespace - The namespace the object belongs to. May not be null.
        id - The ID to release lock for.
      • addPostCommitHandler

        void addPostCommitHandler​(Runnable handler)
        Adds a post-commit handler. The handlers are invoked until after the transaction is successfully committed.
        Parameters:
        handler - The post-commit handler to add. May not be null.
      • getNamespaceBoundTransaction

        IBmTransaction getNamespaceBoundTransaction​(IBmNamespace namespace)
        Gets legacy transaction bound to the specified namespace. Note that invocation of this method does not create a new transaction but returns an adapter for the current transaction that can be used by solutions that do not support new API.
        Parameters:
        namespace - The namespace. May not be null.
        Returns:
        the namespace-bound transaction, never null.
      • createBlob

        IBmBlob createBlob​(IBmNamespace namespace,
                           String fqn)
        Creates a blob.
        Parameters:
        namespace -
        fqn -
        Returns:
      • removeBlob

        void removeBlob​(IBmBlob blob)
        Removes a blob.
        Parameters:
        blob -
      • renameBlob

        void renameBlob​(IBmBlob blob,
                        String newFqn)
        Renames a blob. Note that the transaction result will look as though the blob was removed and then created with a new name.
        Parameters:
        blob -
        newFqn -