mirror of
https://github.com/nasa/openmct.git
synced 2025-06-15 21:58:13 +00:00
[Persistence] Allow nested transactions
This commit is contained in:
@ -38,6 +38,7 @@ define(
|
|||||||
this.$q = $q;
|
this.$q = $q;
|
||||||
this.$log = $log;
|
this.$log = $log;
|
||||||
this.transaction = undefined;
|
this.transaction = undefined;
|
||||||
|
this.transactionStack = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,8 +49,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
TransactionService.prototype.startTransaction = function () {
|
TransactionService.prototype.startTransaction = function () {
|
||||||
if (this.transaction) {
|
if (this.transaction) {
|
||||||
//Log error because this is a programming error if it occurs.
|
this.transactionStack.push(this.transaction);
|
||||||
this.$log.error("Transaction already in progress");
|
|
||||||
}
|
}
|
||||||
this.transaction = new Transaction(this.$log);
|
this.transaction = new Transaction(this.$log);
|
||||||
};
|
};
|
||||||
@ -86,7 +86,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
TransactionService.prototype.commit = function () {
|
TransactionService.prototype.commit = function () {
|
||||||
var transaction = this.transaction;
|
var transaction = this.transaction;
|
||||||
this.transaction = undefined;
|
this.transaction = this.transactionStack.pop();
|
||||||
return transaction && transaction.commit();
|
return transaction && transaction.commit();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
TransactionService.prototype.cancel = function () {
|
TransactionService.prototype.cancel = function () {
|
||||||
var transaction = this.transaction;
|
var transaction = this.transaction;
|
||||||
this.transaction = undefined;
|
this.transaction = this.transactionStack.pop();
|
||||||
return transaction && transaction.cancel();
|
return transaction && transaction.cancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user