Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/UpdatePreviousTxCurrent.java')
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/accessor/UpdatePreviousTxCurrent.java27
1 files changed, 27 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);
+ }
}

Back to the top