Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2012-12-14 16:10:58 +0000
committerDavid W. Miller2013-06-19 19:35:43 +0000
commit9f402f4a732aa9d2698a90bca838733bad7b5a20 (patch)
treefb4142f5545b4add981ebcb8ff60419844b5b675
parenta9136a3901ffec27a742e4c0550927b8e8282134 (diff)
downloadorg.eclipse.osee-9f402f4a732aa9d2698a90bca838733bad7b5a20.tar.gz
org.eclipse.osee-9f402f4a732aa9d2698a90bca838733bad7b5a20.tar.xz
org.eclipse.osee-9f402f4a732aa9d2698a90bca838733bad7b5a20.zip
bug[ats_W3MNV]: Fix tx_currents in transaction copy for branch from transaction
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/UpdatePreviousTxCurrent.java27
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/BranchCopyTxCallable.java5
2 files changed, 32 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/UpdatePreviousTxCurrent.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/UpdatePreviousTxCurrent.java
index c231a974ea7..4b67d5b3fb1 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/UpdatePreviousTxCurrent.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/UpdatePreviousTxCurrent.java
@@ -29,6 +29,17 @@ public class UpdatePreviousTxCurrent {
"update osee_txs SET tx_current = " + TxChange.NOT_CURRENT.getValue() + " where branch_id = ? AND gamma_id = ? and transaction_id = ?";
private static final String SELECT_TXS_AND_GAMMAS =
"SELECT txs.transaction_id, txs.gamma_id FROM osee_join_id idj, %s item, osee_txs txs WHERE idj.query_id = ? and idj.id = item.%s AND item.gamma_id = txs.gamma_id AND txs.branch_id = ? AND txs.tx_current <> ?";
+// @formatter:off
+ private static final String SELECT_TXS_AND_GAMMAS_FROM_TXS ="with\n"+
+ "txs as (select gamma_id from osee_txs where branch_id = ? and transaction_id = ?),\n"+
+ "item as (\n"+
+ " SELECT item2.gamma_id FROM osee_attribute item1, txs, osee_attribute item2 where txs.gamma_id = item1.gamma_id and item1.attr_id = item2.attr_id\n"+
+ "UNION ALL\n"+
+ " SELECT item2.gamma_id FROM osee_artifact item1, txs, osee_artifact item2 where txs.gamma_id = item1.gamma_id and item1.art_id = item2.art_id\n"+
+ "UNION ALL\n"+
+ " SELECT item2.gamma_id FROM osee_relation_link item1, txs, osee_relation_link item2 where txs.gamma_id = item1.gamma_id and item1.rel_link_id = item2.rel_link_id)\n"+
+ "select txsb.transaction_id, txsb.gamma_id FROM item, osee_txs txsb where item.gamma_id = txsb.gamma_id AND txsb.branch_id = ? AND transaction_id <> ? AND txsb.tx_current <> ?";
+// @formatter:on
private final IOseeDatabaseService dbService;
private final Branch branch;
@@ -94,4 +105,20 @@ public class UpdatePreviousTxCurrent {
dbService.runBatchUpdate(connection, UPDATE_TXS_NOT_CURRENT, updateData);
}
+
+ public void updateTxNotCurrentsFromTx(int transaction_id) throws OseeCoreException {
+ List<Object[]> updateData = new ArrayList<Object[]>();
+ IOseeStatement chStmt = dbService.getStatement(connection);
+ try {
+ chStmt.runPreparedQuery(10000, SELECT_TXS_AND_GAMMAS_FROM_TXS, branch.getId(), transaction_id, branch.getId(),
+ transaction_id, TxChange.NOT_CURRENT.getValue());
+ while (chStmt.next()) {
+ updateData.add(new Object[] {branch.getId(), chStmt.getLong("gamma_id"), chStmt.getInt("transaction_id")});
+ }
+ } finally {
+ chStmt.close();
+ }
+
+ dbService.runBatchUpdate(connection, UPDATE_TXS_NOT_CURRENT, updateData);
+ }
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/BranchCopyTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/BranchCopyTxCallable.java
index ca62d21bb0d..db0162ad365 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/BranchCopyTxCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/BranchCopyTxCallable.java
@@ -34,6 +34,7 @@ import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.data.CreateBranchData;
+import org.eclipse.osee.orcs.db.internal.accessor.UpdatePreviousTxCurrent;
import org.eclipse.osee.orcs.db.internal.loader.RelationalConstants;
/**
@@ -123,6 +124,10 @@ public final class BranchCopyTxCallable extends DatabaseTxCallable<Branch> {
populateTransaction(0.30, connection, record.getId(), internalBranch, savedTx);
+ UpdatePreviousTxCurrent updater =
+ new UpdatePreviousTxCurrent(getDatabaseService(), internalBranch, connection);
+ updater.updateTxNotCurrentsFromTx(record.getId());
+
} catch (Exception ex) {
OseeExceptions.wrapAndThrow(ex);
}

Back to the top