public class Transaction extends Object implements Runnable
| Modifier and Type | Field and Description |
|---|---|
protected Consultant |
consultant
Transaction information for current user.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Transaction(UserTransactionInfo uti,
String key,
String id,
boolean commitOnClose,
long timeOut)
Creates new Transaction.
|
protected |
Transaction(UserTransactionInfo uti,
String key,
String id,
boolean commitOnClose,
long timeOut,
File reportFile,
Consultant consultant)
Creates new Transaction.
|
| Modifier and Type | Method and Description |
|---|---|
TmpObject |
accessObject(String objectId,
int mmbaseId)
Create access object for an object in the persistent cloud,
in the context of this transaction.
|
void |
appendReportBuffer(String str)
Add text to reportBufferFile of this transaction.
|
protected TmpObject |
caculateMerge(TmpObject tempObj1,
TmpObject tempObj2,
ObjectMerger merger)
Calculates the fields that would result from merging two
temporary objects in this transaction.
|
void |
commit()
Commit this transaction.
|
TmpObject |
createObject(String objectId,
String type,
boolean disposeWhenNotReferenced)
Create object in the context of this transaction.
|
TmpObject |
createRelation(String objectId,
String type,
String source,
String destination)
Create relation in the context of this transaction.
|
static Transaction |
createTransaction(UserTransactionInfo uti,
String id,
boolean commitOnClose,
long timeOut)
Create a Transaction.
|
static Transaction |
createTransaction(UserTransactionInfo uti,
String id,
boolean commitOnClose,
long timeOut,
File reportFile,
Consultant consultant)
Create a Transaction.
|
void |
delete()
Delete this transaction.
|
void |
deleteObject(TmpObject tmpObject)
Deletes object from the context of this transaction, as
well as its relations.
|
(package private) void |
dropIfRequested(TmpObject tmpObject)
Drops an object from the temporary cloud, based on its
disposeWhenNotReferenced flag - i.e.
|
protected boolean |
equalRelations(TmpObject tmpObj1,
TmpObject tmpObj2)
Test if two objects in the temporary cloud represent the same relation
(are of same relation type and have the same source and destination objects).
|
TmpObject |
getAccessObject(int mmbaseId)
Gets an access object for a specified node in the persistent
cloud.
|
String |
getKey()
Key accessor.
|
TmpObject |
getMergedObject(TmpObject tempObj1)
Gets merged object, resulting from previous merge operations.
|
(package private) HashMap<String,TmpObject> |
getObjectContexts()
Gets HashMap of all non-anonymous object contexts, mapped by their id.
|
List<TmpObject> |
getRelations(TmpObject tmpObject)
For an object in this transaction, looks up all its relations,
and returns access objects for these.
|
List<TmpObject> |
getTmpObjects()
Gets (unmodifiable) list of all temporary objects in the transaction.
|
protected boolean |
handleDuplicates(TmpObject tempObj,
List<TmpObject> similarObjects,
ObjectMerger merger)
Handles sitiuations where more then one similar objects are found to
merge with.
|
void |
leave()
This method should be called when leaving this transaction's context.
|
void |
markDeleteObject(TmpObject tmpObject,
boolean deleteRelations)
Mark object in the context of this transaction for deletion.
|
void |
merge(TmpObject tempObj1,
TmpObject tempObj2,
ObjectMerger merger)
Merges two temporary objects in this transaction.
|
void |
mergeObjects(String objectType,
SimilarObjectFinder finder,
ObjectMerger merger)
Merges all objects in this transaction of a given type.
|
TmpObject |
openObject(String objectId)
Open object in the context of this transaction.
|
static Transaction |
openTransaction(UserTransactionInfo uti,
String id,
boolean commitOnClose)
Open previously created transaction.
|
void |
run()
Wait assynchronously for the transaction to time out.
|
protected void |
start()
Start the Transaction.
|
protected boolean |
stillExists(TmpObject tmpObject)
Tests if this object still exists in the temporary cloud.
|
protected void |
stop()
Stop the Transaction.
|
protected Consultant consultant
protected Transaction(UserTransactionInfo uti, String key, String id, boolean commitOnClose, long timeOut, File reportFile, Consultant consultant)
timeOut - if the transactions is not finished after the timeout
(in seconds) the transaction is cancelled.uti - transaction info for current user.key - TransactionManager key for this transaction.id - TransactionHandler id for this transactions.commitOnClose - - The user-specified commit-on-close setting.
True if this transaction is to be committed
when the user leaves it's context, false otherwise.reportFile - The file to use as reportfile.consultant - The intermediate import object. Used to set and get status from and set and get objects to and from.protected Transaction(UserTransactionInfo uti, String key, String id, boolean commitOnClose, long timeOut)
timeOut - if the transactions is not finished after the timeout
(in seconds) the transaction is cancelled.uti - transaction info for current user.key - TransactionManager key for this transaction.id - TransactionHandler id for this transactions.commitOnClose - - The user-specified commit-on-close setting.
True if this transaction is to be committed
when the user leaves it's context, false otherwise.public static Transaction createTransaction(UserTransactionInfo uti, String id, boolean commitOnClose, long timeOut) throws TransactionHandlerException
uti - - The UserTransactionInfo it belongs to.id - - The user-specified id, null for anonymous transaction.commitOnClose - - The user-specified commit-on-close setting.
True if this transaction is to be committed
when the user leaves it's context, false otherwise.timeOut - - The user-specified time-out setting.TransactionHandlerException - - When failing to create the new transaction.public static Transaction createTransaction(UserTransactionInfo uti, String id, boolean commitOnClose, long timeOut, File reportFile, Consultant consultant) throws TransactionHandlerException
uti - the UserTransactionInfo it belongs to.id - the user-specified id, null for anonymous transaction.commitOnClose - - The user-specified commit-on-close setting.
True if this transaction is to be committed
when the user leaves it's context, false otherwise.timeOut - the user-specified time-out setting.reportFile - The reportfile.consultant - The intermediate import object. Used to set and get status from and set and get objects to and from.TransactionHandlerException - When failing to create
the new transaction.public static Transaction openTransaction(UserTransactionInfo uti, String id, boolean commitOnClose) throws TransactionHandlerException
commitOnClose - - The user-specified commit-on-close setting.
True if this transaction is to be committed
when the user leaves it's context, false otherwise.uti - the UserTransactionInfo it belongs to.id - the user-specified id (not null).TransactionHandlerException - if the transaction does not exist.public void leave()
throws TransactionHandlerException
TransactionHandlerException - when a failure occured while
committing the transaction.public void commit()
throws TransactionHandlerException
TransactionHandlerException - when a failure occured while
committing the transaction:
public void delete()
throws TransactionHandlerException
TransactionHandlerException - when:
public TmpObject createObject(String objectId, String type, boolean disposeWhenNotReferenced) throws TransactionHandlerException
objectId - user-specified id for the new object
(must be unique in this transaction context),
or null for anonymous object.type - type of the new object.disposeWhenNotReferenced - flag: true if this object is
to be dropped when it has no relations on commit, false otherwise.TransactionHandlerException - When failing to create
the new object.public TmpObject createRelation(String objectId, String type, String source, String destination) throws TransactionHandlerException
objectId - user-specified id for the new object
(must be unique in this transaction context),
or null for anonymous object.type - type of the new relation.source - the user-specified id of the source object.destination - the user-specified id of the destination object.TransactionHandlerException - when
public TmpObject openObject(String objectId) throws TransactionHandlerException
objectId - the user-specified id of the object.TransactionHandlerException - when the id does not exist
in the context of this transactions.public TmpObject accessObject(String objectId, int mmbaseId) throws TransactionHandlerException
objectId - user-specified id of the new object
(must be unique in this transaction context).mmbaseId - the mmbase id for the persistent object.TransactionHandlerException - When failing to create
the access object.public void deleteObject(TmpObject tmpObject) throws TransactionHandlerException
tmpObject - the object.TransactionHandlerException - When failing to delete
the object.public void markDeleteObject(TmpObject tmpObject, boolean deleteRelations) throws TransactionHandlerException
deleteRelations - - Set to true if all relations are to be deleted too, set to false otherwise.tmpObject - - The object.TransactionHandlerException - - When a failure occurred.public void mergeObjects(String objectType, SimilarObjectFinder finder, ObjectMerger merger) throws TransactionHandlerException
objectType - The type of the objects to merge.finder - SimilarObjectFinder instance that prescribes the
actions necessary to find similar objects.merger - ObjectMerger instance that prescribes the actions
necessary to merge similar objects.TransactionHandlerException - When a failure occurred.protected boolean handleDuplicates(TmpObject tempObj, List<TmpObject> similarObjects, ObjectMerger merger) throws TransactionHandlerException
tempObj - the original object.similarObjects - the similar objects.merger - the merger.TransactionHandlerException - When a failure occurred.protected TmpObject caculateMerge(TmpObject tempObj1, TmpObject tempObj2, ObjectMerger merger)
merger - ObjectMerger instance that prescribes the actions
necessary to merge similar objects.tempObj1 - First object.tempObj2 - Second object.public void merge(TmpObject tempObj1, TmpObject tempObj2, ObjectMerger merger) throws TransactionHandlerException
merger - ObjectMerger instance that prescribes the actions
necessary to merge similar objects.tempObj1 - First object.tempObj2 - Second object.TransactionHandlerException - When a failure occurred.public TmpObject getAccessObject(int mmbaseId) throws TransactionHandlerException
mmbaseId - MMBase number of the specified node.TransactionHandlerException - When unable to create
the access object.public List<TmpObject> getRelations(TmpObject tmpObject) throws TransactionHandlerException
tmpObject - An object in the temporary cloud (can
be an access objects).TransactionHandlerException - When a failure occurred.void dropIfRequested(TmpObject tmpObject) throws TransactionHandlerException
tmpObject - An object in the temporary cloud.TransactionHandlerException - When a failure occurred.protected boolean equalRelations(TmpObject tmpObj1, TmpObject tmpObj2)
tmpObj1 - The first object.tmpObj2 - The second object.protected boolean stillExists(TmpObject tmpObject)
tmpObject - A temporary object.public String getKey()
HashMap<String,TmpObject> getObjectContexts()
public List<TmpObject> getTmpObjects()
public TmpObject getMergedObject(TmpObject tempObj1)
tempObj1 - The original object.public void appendReportBuffer(String str)
str - Text to add to reportBuffer.protected void start()
protected void stop()
MMBase 1.9-SNAPSHOT - ${javadoctimestamp}