Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2015-09-08 23:31:03 +0000
committerRyan T. Baldwin2015-09-08 23:31:03 +0000
commit5e862db0e69afbd037025d9d157480dbdfe19f1b (patch)
tree8b5a7b59cd96405bc0bc89890068b0f047cf65a4 /plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java
parent24b80e4cb9ed5005890cdf6da8e5e8378b6c2356 (diff)
downloadorg.eclipse.osee-5e862db0e69afbd037025d9d157480dbdfe19f1b.tar.gz
org.eclipse.osee-5e862db0e69afbd037025d9d157480dbdfe19f1b.tar.xz
org.eclipse.osee-5e862db0e69afbd037025d9d157480dbdfe19f1b.zip
refinement: Change server transaction.commit to not exception if empty
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java')
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java26
1 files changed, 17 insertions, 9 deletions
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java
index 29a7b49d517..774711ab9cb 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/transaction/CommitTransactionDatabaseTxCallable.java
@@ -64,9 +64,14 @@ public final class CommitTransactionDatabaseTxCallable extends AbstractDatastore
}
}
+ /**
+ * Persist changes to database.
+ *
+ * @return TransactionResult or null if no data was modified
+ */
@Override
protected TransactionResult handleTxWork(JdbcConnection connection) throws OseeCoreException {
- /////
+ /////
// TODO:
// 1. Make this whole method a critical region on a per branch basis - can only write to a branch on one thread at time
String comment = transactionData.getComment();
@@ -77,18 +82,21 @@ public final class CommitTransactionDatabaseTxCallable extends AbstractDatastore
Conditions.checkNotNull(branch, "branch");
Conditions.checkNotNull(author, "transaction author");
Conditions.checkNotNullOrEmpty(comment, "transaction comment");
- Conditions.checkExpressionFailOnTrue(changeSet.isEmpty(), "No data was modified");
+ TransactionResult result = null;
+ if (!changeSet.isEmpty()) {
- process(TxWritePhaseEnum.BEFORE_TX_WRITE);
+ process(TxWritePhaseEnum.BEFORE_TX_WRITE);
- TransactionReadable txRecord = createTransactionRecord(branch, author, comment, getNextTransactionId());
- writer.write(connection, txRecord, changeSet);
+ TransactionReadable txRecord = createTransactionRecord(branch, author, comment, getNextTransactionId());
+ writer.write(connection, txRecord, changeSet);
- Object[] params =
- new Object[] {BranchState.MODIFIED.getValue(), branch.getUuid(), BranchState.CREATED.getValue()};
- getJdbcClient().runPreparedUpdate(connection, UPDATE_BRANCH_STATE, params);
+ Object[] params =
+ new Object[] {BranchState.MODIFIED.getValue(), branch.getUuid(), BranchState.CREATED.getValue()};
+ getJdbcClient().runPreparedUpdate(connection, UPDATE_BRANCH_STATE, params);
- return new TransactionResultImpl(txRecord, changeSet);
+ result = new TransactionResultImpl(txRecord, changeSet);
+ }
+ return result;
}
@Override

Back to the top