Package com.nomagic.uml2.transaction
Class ModelTransaction
- java.lang.Object
-
- com.nomagic.uml2.transaction.ModelTransaction
-
public class ModelTransaction extends java.lang.Object
One Transaction, objects of this type can be reused.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<Element,java.lang.String>
changedElements
If no fire post commit changed elements are collected in this collection.private java.util.Collection<java.beans.PropertyChangeEvent>
collectedEvents
Events fired during transaction.private boolean
firePostCommit
private InvalidModelHandler
invalidModelHandler
(package private) org.apache.logging.log4j.Logger
LOG
private boolean
modelFixTransaction
private ModelValidator
modelValidator
private ModifiedElements
modifiedElements
private boolean
readOnlyMode
private AbstractRepository
repository
private com.nomagic.uml2.transaction.TransactionManagerImpl
transactionsManager
private boolean
validateModel
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
ModelTransaction(AbstractRepository repository, com.nomagic.uml2.transaction.TransactionManagerImpl manager)
private
ModelTransaction(AbstractRepository repository, com.nomagic.uml2.transaction.TransactionManagerImpl manager, boolean modelFixTransaction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addAllElementsToChanged(ModifiedElements modifiedElements)
Marks all objects in the repository as changed by this transaction, which results in that all elements are validated on commitvoid
beforeChange()
void
changed(javax.jmi.reflect.RefObject object)
Handles model change event.void
commit()
private ModelTransaction
createNestedTransaction(boolean modelFix)
private void
destroyNestedTransaction()
private java.util.Collection<java.lang.Runnable>
fireEvents(java.util.Collection<java.beans.PropertyChangeEvent> collectedEvents)
private InvalidModelHandler.Result
fixModel(java.util.Collection<ModelValidationResult> notValid, java.util.Collection<java.beans.PropertyChangeEvent> collectedEvents)
private java.util.Collection<Element>
getChangedElements(java.util.Collection<java.beans.PropertyChangeEvent> changes)
Return elements which are sources for property change events, and are still in the project.boolean
isFirePostCommit()
Determines whether post commit events are firedboolean
isStarted()
void
modelChanged(java.beans.PropertyChangeEvent evt)
Handles model change event.private void
runCodeAfterFire(java.util.Collection<java.lang.Runnable> run)
private void
runInNestedTransaction(java.lang.Runnable r, boolean readonly)
private void
runModelFixInNestedTransaction(java.lang.Runnable r, java.util.Collection<java.beans.PropertyChangeEvent> collectedEventsInParent, InvalidModelHandler.Result[] result)
void
setFirePostCommit(boolean firePostCommit)
void
setInvalidModelHandler(InvalidModelHandler handler)
void
setModelValidator(ModelValidator handler)
void
setModifiedElements(ModifiedElements modifiedElements)
void
start()
Starts transaction.void
start(boolean readOnly, boolean validateModel)
private java.util.Collection<ModelValidationResult>
validateModel()
-
-
-
Field Detail
-
LOG
org.apache.logging.log4j.Logger LOG
-
collectedEvents
private volatile java.util.Collection<java.beans.PropertyChangeEvent> collectedEvents
Events fired during transaction.
-
readOnlyMode
private boolean readOnlyMode
-
modelValidator
private ModelValidator modelValidator
-
invalidModelHandler
private InvalidModelHandler invalidModelHandler
-
repository
private final AbstractRepository repository
-
transactionsManager
private final com.nomagic.uml2.transaction.TransactionManagerImpl transactionsManager
-
modelFixTransaction
private final boolean modelFixTransaction
-
firePostCommit
private boolean firePostCommit
-
validateModel
private boolean validateModel
-
changedElements
private java.util.Map<Element,java.lang.String> changedElements
If no fire post commit changed elements are collected in this collection. In other case collection should be empty.
-
modifiedElements
private ModifiedElements modifiedElements
-
-
Constructor Detail
-
ModelTransaction
ModelTransaction(AbstractRepository repository, com.nomagic.uml2.transaction.TransactionManagerImpl manager)
-
ModelTransaction
private ModelTransaction(AbstractRepository repository, com.nomagic.uml2.transaction.TransactionManagerImpl manager, boolean modelFixTransaction)
-
-
Method Detail
-
start
public void start()
Starts transaction. After transaction started events will be recorded and analyzed.
-
start
public void start(boolean readOnly, boolean validateModel)
-
commit
public void commit() throws RollbackException
- Throws:
RollbackException
-
runInNestedTransaction
private void runInNestedTransaction(java.lang.Runnable r, boolean readonly) throws RollbackException
- Throws:
RollbackException
-
runModelFixInNestedTransaction
private void runModelFixInNestedTransaction(java.lang.Runnable r, java.util.Collection<java.beans.PropertyChangeEvent> collectedEventsInParent, InvalidModelHandler.Result[] result) throws RollbackException
- Throws:
RollbackException
-
runCodeAfterFire
private void runCodeAfterFire(java.util.Collection<java.lang.Runnable> run) throws RollbackException
- Throws:
RollbackException
-
fireEvents
private java.util.Collection<java.lang.Runnable> fireEvents(java.util.Collection<java.beans.PropertyChangeEvent> collectedEvents)
-
fixModel
private InvalidModelHandler.Result fixModel(java.util.Collection<ModelValidationResult> notValid, java.util.Collection<java.beans.PropertyChangeEvent> collectedEvents) throws RollbackException
- Throws:
RollbackException
-
validateModel
private java.util.Collection<ModelValidationResult> validateModel() throws RollbackException
- Throws:
RollbackException
-
destroyNestedTransaction
private void destroyNestedTransaction()
-
createNestedTransaction
private ModelTransaction createNestedTransaction(boolean modelFix)
-
modelChanged
public void modelChanged(java.beans.PropertyChangeEvent evt)
Handles model change event.- Parameters:
evt
- event
-
changed
public void changed(javax.jmi.reflect.RefObject object)
Handles model change event.- Parameters:
object
- object
-
addAllElementsToChanged
private void addAllElementsToChanged(ModifiedElements modifiedElements)
Marks all objects in the repository as changed by this transaction, which results in that all elements are validated on commit- Parameters:
modifiedElements
- modified elements.
-
isStarted
public boolean isStarted()
-
isFirePostCommit
public boolean isFirePostCommit()
Determines whether post commit events are fired- Returns:
true
if events are fired,false
otherwise
-
setInvalidModelHandler
public void setInvalidModelHandler(InvalidModelHandler handler)
-
setModelValidator
public void setModelValidator(ModelValidator handler)
-
beforeChange
public void beforeChange()
-
setFirePostCommit
public void setFirePostCommit(boolean firePostCommit)
-
getChangedElements
private java.util.Collection<Element> getChangedElements(java.util.Collection<java.beans.PropertyChangeEvent> changes)
Return elements which are sources for property change events, and are still in the project.- Parameters:
changes
- collected events.- Returns:
- sources from events which are registered in project.
-
setModifiedElements
public void setModifiedElements(ModifiedElements modifiedElements)
-
-