Package com._1c.g5.v8.bm.core
Interface IBmTransaction
-
public interface IBmTransaction
Interface for BM engine transaction.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
addPostCommitHandler(Runnable handler)
Adds a post-commit handler.void
attachTopObject(IBmObject object, String fqn)
Attaches a new top-level object with the specified FQN, i.e.IBmTransactionCommitResult
commit()
Commits the transaction.IBmTransactionCommitResult
commit(Consumer<BmEvent> eventConsumer)
Commits the transaction.void
detachTopObject(IBmObject object)
Detaches (removes) a top object.void
evict(long id)
Evicts the specified object form the transaction.String
getEngineId()
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.IBmObject
getObjectById(long id)
Gets object by ID.IBmObject
getObjectByUri(org.eclipse.emf.common.util.URI uri)
Gets object by URI.Iterator<IBmObject>
getObjectsByAttributeValue(org.eclipse.emf.ecore.EAttribute attribute, Object value)
Gets objects by attribute value.com._1c.g5.v8.bm.core.internal.IBmInternalResourceSet
getResourceSet()
Deprecated.This method has been added to support existing legacy solutions.IBmObject
getTopObjectByFqn(String fqn)
Gets top-level object by FQN.Iterable<org.eclipse.emf.ecore.EClass>
getTopObjectEClasses()
Gets specificEClass
'es of all top objects being registered in the store at this pointIBmLongIterator
getTopObjectIdsByEClass(org.eclipse.emf.ecore.EClass eClass)
Gets IDs of the top objects of the specifiedEMF class
.Iterator<IBmObject>
getTopObjectIterator()
Gets iterator over the top objects managed by this engine.Iterator<IBmObject>
getTopObjectIterator(org.eclipse.emf.ecore.EClass eClass)
Gets iterator over the top objects of the specifiedEMF class
(note that that the top objects of descendant classes are not selected).boolean
isReadOnly()
Checks whether the transaction is read-only.void
redo(IBmTransactionRecord record)
Redoes the modifications represented by the specified transaction record.void
rollback()
Rolls back the transaction.<T extends org.eclipse.emf.ecore.EObject>
TtoTransactionObject(T object)
The shortcut for getting the transaction counterpart by the given object.void
undo(IBmTransactionRecord record)
Undoes the modifications represented by the specified transaction record.void
updateTopObjectFqn(IBmObject object, String fqn)
Assigns the specified top-level object a new FQN.
-
-
-
Method Detail
-
commit
IBmTransactionCommitResult commit()
Commits the transaction.- Returns:
- an instance of
IBmTransactionCommitResult
, nevernull
.
-
commit
IBmTransactionCommitResult commit(Consumer<BmEvent> 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 benull
.- Returns:
- an instance of
IBmTransactionCommitResult
, nevernull
.
-
rollback
void rollback()
Rolls back the transaction.
-
attachTopObject
void attachTopObject(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:
object
- The object to attach. May not benull
.fqn
- The FQN. May not benull
.
-
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 benull
.
-
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 orcommit()
will throw an exception.- Parameters:
object
- The object to assign FQN to. May not benull
.fqn
- The FQN to assign. May not benull
.
-
getObjectById
IBmObject getObjectById(long id)
Gets object by ID.- Parameters:
id
- The ID to get object by.- Returns:
- the object with the specified ID or
null
if it does not exist.
-
getTopObjectByFqn
IBmObject getTopObjectByFqn(String fqn)
Gets top-level object by FQN.- Parameters:
fqn
- The FQN to get object by. May not benull
- Returns:
- the object with the specified FQN or
null
if it does not exist.
-
getObjectByUri
IBmObject getObjectByUri(org.eclipse.emf.common.util.URI uri)
Gets object by URI.- Parameters:
uri
- The URI to get object by. May not benull
.- 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 record)
Undoes the modifications represented by the specified transaction record.- Parameters:
record
- The record. May not benull
.
-
redo
void redo(IBmTransactionRecord record)
Redoes the modifications represented by the specified transaction record.- Parameters:
record
- The record. May not benull
.
-
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 benull
.- 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 benull
.- Returns:
- transaction object or
null
if the object gets detached from BM before this invocation finishes.
-
getTopObjectIterator
Iterator<IBmObject> getTopObjectIterator()
Gets iterator over the top objects managed by this engine. The iterator does not implementremove
method.- Returns:
- the iterator, never
null
.
-
getTopObjectIterator
Iterator<IBmObject> getTopObjectIterator(org.eclipse.emf.ecore.EClass eClass)
Gets iterator over the top objects of the specifiedEMF class
(note that that the top objects of descendant classes are not selected). The iterator does not implementremove
method.- Parameters:
eClass
- TheEMF class
. May not benull
.- Returns:
- the iterator, never
null
.
-
getTopObjectEClasses
Iterable<org.eclipse.emf.ecore.EClass> getTopObjectEClasses()
Gets specificEClass
'es of all top objects being registered in the store at this point- Returns:
- The iterable of
EClass
for known top objects. May not benull
. Elements are guaranteed to be unique
-
getTopObjectIdsByEClass
IBmLongIterator getTopObjectIdsByEClass(org.eclipse.emf.ecore.EClass eClass)
Gets IDs of the top objects of the specifiedEMF class
. Please note that the correponding objects aren't attached to the transaction thus no blocking. So the returned set of identifiers may be already outdated. Should be used only for mass operations with external control on BM contents changing and external means of data integrity tracking and support- Returns:
- an iterator over the IDs of the top objects of the specified
EMF class
. Nevernull
.
-
getObjectsByAttributeValue
Iterator<IBmObject> getObjectsByAttributeValue(org.eclipse.emf.ecore.EAttribute attribute, Object value)
Gets objects by attribute value. Throws an exception if the attribute is not indexed.- Parameters:
attribute
- The attribute. May not benull
.value
- The value. May not benull
.- Returns:
- an iterator over the objects with the specified attribute value, never
null
. The iterator does not implementremove
method. - See Also:
BmEngineSettings.indexedAttributes(java.util.Collection)
-
getEngineId
@Deprecated String getEngineId()
Deprecated.Gets the identifier of the engine this transaction belongs to.- Returns:
- the identifier of the engine, never
null
.
-
evict
void evict(long id)
Evicts the specified object form the transaction. After evicting the object from the transaction, any change to the evicted object won't 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:
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 benull
.
-
-