Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java4
-rw-r--r--plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CreateBranchCallable.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java17
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/BranchCopyTxCallable.java54
-rw-r--r--plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java45
5 files changed, 53 insertions, 75 deletions
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java
index 6c294322ac8..934a9b6f06f 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/ds/BranchDataStore.java
@@ -31,9 +31,9 @@ import org.eclipse.osee.orcs.data.TransactionReadable;
*/
public interface BranchDataStore {
- Callable<Void> createBranch(OrcsSession session, CreateBranchData branchData);
+ void createBranch(CreateBranchData branchData);
- Callable<Void> createBranchCopyTx(OrcsSession session, CreateBranchData branchData);
+ void createBranchCopyTx(CreateBranchData branchData);
Callable<Void> purgeBranch(OrcsSession session, BranchReadable branch);
diff --git a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CreateBranchCallable.java b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CreateBranchCallable.java
index 4842c33cc72..d194afc3ec1 100644
--- a/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CreateBranchCallable.java
+++ b/plugins/org.eclipse.osee.orcs.core/src/org/eclipse/osee/orcs/core/internal/branch/CreateBranchCallable.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.orcs.core.internal.branch;
-import java.util.concurrent.Callable;
import org.eclipse.osee.framework.core.data.ITransaction;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.logger.Log;
@@ -44,7 +43,6 @@ public class CreateBranchCallable extends AbstractBranchCallable<BranchReadable>
ITransaction txData = branchData.getFromTransaction();
Conditions.checkNotNull(txData, "sourceTransaction");
- Callable<?> callable;
if (branchData.isTxCopyBranchType()) {
TransactionQuery txQuery = queryFactory.transactionQuery();
ITransaction givenTx = branchData.getFromTransaction();
@@ -52,11 +50,11 @@ public class CreateBranchCallable extends AbstractBranchCallable<BranchReadable>
branchData.setSavedTransaction(givenTx);
TransactionReadable priorTx = txQuery.andIsPriorTx(givenTx.getGuid()).getResults().getExactlyOne();
branchData.setFromTransaction(priorTx);
- callable = getBranchStore().createBranchCopyTx(getSession(), branchData);
+ getBranchStore().createBranchCopyTx(branchData);
} else {
- callable = getBranchStore().createBranch(getSession(), branchData);
+ getBranchStore().createBranch(branchData);
}
- callAndCheckForCancel(callable);
+
return queryFactory.branchQuery().andUuids(branchData.getUuid()).getResults().getExactlyOne();
}
}
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java
index 9d9b29953b4..50fe9422289 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/branch/BranchModule.java
@@ -78,13 +78,13 @@ public class BranchModule {
final MissingChangeItemFactory missingChangeItemFactory = new MissingChangeItemFactoryImpl(dataLoaderFactory);
return new BranchDataStore() {
@Override
- public Callable<Void> createBranch(OrcsSession session, CreateBranchData branchData) {
- return new CreateBranchDatabaseTxCallable(logger, session, jdbcClient, idManager, branchData);
+ public void createBranch(CreateBranchData branchData) {
+ jdbcClient.runTransaction(new CreateBranchDatabaseTxCallable(jdbcClient, idManager, branchData));
}
@Override
- public Callable<Void> createBranchCopyTx(OrcsSession session, CreateBranchData branchData) {
- return new BranchCopyTxCallable(logger, session, jdbcClient, joinFactory, idManager, branchData);
+ public void createBranchCopyTx(CreateBranchData branchData) {
+ jdbcClient.runTransaction(new BranchCopyTxCallable(jdbcClient, joinFactory, idManager, branchData));
}
@Override
@@ -108,15 +108,14 @@ public class BranchModule {
public Callable<URI> exportBranch(OrcsSession session, OrcsTypes orcsTypes, List<IOseeBranch> branches, PropertyStore options, String exportName) {
ExportItemFactory factory =
new ExportItemFactory(logger, preferences, jdbcClient, resourceManager, orcsTypes);
- return new ExportBranchDatabaseCallable(session, factory, joinFactory, preferences, executorAdmin,
- branches, options, exportName);
+ return new ExportBranchDatabaseCallable(session, factory, joinFactory, preferences, executorAdmin, branches,
+ options, exportName);
}
@Override
public Callable<URI> importBranch(OrcsSession session, OrcsTypes orcsTypes, URI fileToImport, List<IOseeBranch> branches, PropertyStore options) {
- ImportBranchDatabaseCallable callable =
- new ImportBranchDatabaseCallable(logger, session, jdbcClient, preferences, resourceManager, idManager,
- orcsTypes, fileToImport, branches, options);
+ ImportBranchDatabaseCallable callable = new ImportBranchDatabaseCallable(logger, session, jdbcClient,
+ preferences, resourceManager, idManager, orcsTypes, fileToImport, branches, options);
return callable;
}
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 c3a84e48162..e79e4257554 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
@@ -14,19 +14,16 @@ import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
-import java.util.concurrent.Callable;
import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.enums.TxChange;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.jdbc.JdbcConnection;
import org.eclipse.osee.jdbc.JdbcConstants;
import org.eclipse.osee.jdbc.JdbcStatement;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
+import org.eclipse.osee.jdbc.JdbcTransaction;
import org.eclipse.osee.orcs.data.CreateBranchData;
import org.eclipse.osee.orcs.db.internal.IdentityManager;
import org.eclipse.osee.orcs.db.internal.accessor.UpdatePreviousTxCurrent;
@@ -35,10 +32,10 @@ import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory;
/**
* the behavior of this class - it needs to: have a branch
- *
+ *
* @author David Miller
*/
-public final class BranchCopyTxCallable extends AbstractDatastoreTxCallable<Void> {
+public final class BranchCopyTxCallable extends JdbcTransaction {
private final CreateBranchData branchData;
@@ -51,48 +48,40 @@ public final class BranchCopyTxCallable extends AbstractDatastoreTxCallable<Void
private static final String SELECT_ADDRESSING =
"SELECT gamma_id, mod_type FROM osee_txs txs WHERE txs.branch_id = ? AND txs.transaction_id = ?";
+ private final JdbcClient jdbcClient;
private final SqlJoinFactory joinFactory;
private final IdentityManager idManager;
- public BranchCopyTxCallable(Log logger, OrcsSession session, JdbcClient jdbcClient, SqlJoinFactory joinFactory, IdentityManager idManager, CreateBranchData branchData) {
- super(logger, session, jdbcClient);
+ public BranchCopyTxCallable(JdbcClient jdbcClient, SqlJoinFactory joinFactory, IdentityManager idManager, CreateBranchData branchData) {
+ this.jdbcClient = jdbcClient;
this.joinFactory = joinFactory;
this.branchData = branchData;
this.idManager = idManager;
}
@Override
- public Void handleTxWork(JdbcConnection connection) throws OseeCoreException {
+ public void handleTxWork(JdbcConnection connection) {
// copy the branch up to the prior transaction - the goal is to have the provided
// transaction available on the new branch for merging or comparison purposes
// first set aside the transaction
- Callable<Void> callable =
- new CreateBranchDatabaseTxCallable(getLogger(), getSession(), getJdbcClient(), idManager, branchData);
-
- try {
- callable.call();
-
- Timestamp timestamp = GlobalTime.GreenwichMeanTimestamp();
- int nextTransactionId = idManager.getNextTransactionId();
+ new CreateBranchDatabaseTxCallable(jdbcClient, idManager, branchData).handleTxWork(connection);
- String creationComment = branchData.getCreationComment();
+ Timestamp timestamp = GlobalTime.GreenwichMeanTimestamp();
+ int nextTransactionId = idManager.getNextTransactionId();
- getJdbcClient().runPreparedUpdate(connection, INSERT_TX_DETAILS, branchData.getUuid(), nextTransactionId,
- creationComment, timestamp, branchData.getUserArtifactId(), TransactionDetailsType.NonBaselined.getId());
+ String creationComment = branchData.getCreationComment();
- populateTransaction(0.30, connection, nextTransactionId, branchData.getParentBranchUuid(),
- branchData.getSavedTransaction().getGuid());
+ jdbcClient.runPreparedUpdate(connection, INSERT_TX_DETAILS, branchData.getUuid(), nextTransactionId,
+ creationComment, timestamp, branchData.getUserArtifactId(), TransactionDetailsType.NonBaselined.getId());
- UpdatePreviousTxCurrent updater =
- new UpdatePreviousTxCurrent(getJdbcClient(), joinFactory, connection, branchData.getUuid());
- updater.updateTxNotCurrentsFromTx(nextTransactionId);
+ populateTransaction(0.30, connection, nextTransactionId, branchData.getParentBranchUuid(),
+ branchData.getSavedTransaction().getGuid());
- } catch (Exception ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- return null;
+ UpdatePreviousTxCurrent updater =
+ new UpdatePreviousTxCurrent(jdbcClient, joinFactory, connection, branchData.getUuid());
+ updater.updateTxNotCurrentsFromTx(nextTransactionId);
}
private void populateTransaction(double workAmount, JdbcConnection connection, int intoTx, Long parentBranch, int copyTxId) throws OseeCoreException {
@@ -106,18 +95,15 @@ public final class BranchCopyTxCallable extends AbstractDatastoreTxCallable<Void
populateAddressingToCopy(connection, data, intoTx, gammas, SELECT_ADDRESSING, parentBranchId, copyTxId);
if (!data.isEmpty()) {
- getJdbcClient().runBatchUpdate(connection, INSERT_ADDRESSING, data);
+ jdbcClient.runBatchUpdate(connection, INSERT_ADDRESSING, data);
}
-
- checkForCancelled();
}
private void populateAddressingToCopy(JdbcConnection connection, List<Object[]> data, int baseTxId, HashSet<Integer> gammas, String query, Object... parameters) throws OseeCoreException {
- JdbcStatement chStmt = getJdbcClient().getStatement(connection);
+ JdbcStatement chStmt = jdbcClient.getStatement(connection);
try {
chStmt.runPreparedQuery(JdbcConstants.JDBC__MAX_FETCH_SIZE, query, parameters);
while (chStmt.next()) {
- checkForCancelled();
Integer gamma = chStmt.getInt("gamma_id");
if (!gammas.contains(gamma)) {
ModificationType modType = ModificationType.getMod(chStmt.getInt("mod_type"));
diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java
index a0759747013..b5b7ca409d8 100644
--- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java
+++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CreateBranchDatabaseTxCallable.java
@@ -32,9 +32,8 @@ import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.jdbc.JdbcConnection;
import org.eclipse.osee.jdbc.JdbcConstants;
import org.eclipse.osee.jdbc.JdbcStatement;
+import org.eclipse.osee.jdbc.JdbcTransaction;
import org.eclipse.osee.jdbc.OseePreparedStatement;
-import org.eclipse.osee.logger.Log;
-import org.eclipse.osee.orcs.OrcsSession;
import org.eclipse.osee.orcs.data.CreateBranchData;
import org.eclipse.osee.orcs.db.internal.IdentityManager;
import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
@@ -42,7 +41,7 @@ import org.eclipse.osee.orcs.db.internal.sql.RelationalConstants;
/**
* @author Roberto E. Escobar
*/
-public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<Void> {
+public class CreateBranchDatabaseTxCallable extends JdbcTransaction {
private static final String INSERT_TX_DETAILS =
"INSERT INTO osee_tx_details (branch_id, transaction_id, osee_comment, time, author, tx_type) VALUES (?,?,?,?,?,?)";
@@ -92,19 +91,19 @@ public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
private static final String SELECT_INHERIT_ACCESS_CONTROL =
"SELECT inherit_access_control from osee_branch where branch_id = ?";
+ private final JdbcClient jdbcClient;
private final IdentityManager idManager;
-
private final CreateBranchData newBranchData;
- public CreateBranchDatabaseTxCallable(Log logger, OrcsSession session, JdbcClient jdbcClient, IdentityManager idManager, CreateBranchData branchData) {
- super(logger, session, jdbcClient);
+ public CreateBranchDatabaseTxCallable(JdbcClient jdbcClient, IdentityManager idManager, CreateBranchData branchData) {
+ this.jdbcClient = jdbcClient;
this.idManager = idManager;
this.newBranchData = branchData;
}
- private void checkPreconditions(Long parentBranch, Long destinationBranch) throws OseeCoreException {
+ private void checkPreconditions(JdbcConnection connection, Long parentBranch, Long destinationBranch) throws OseeCoreException {
if (newBranchData.getBranchType().isMergeBranch()) {
- if (getJdbcClient().runPreparedQueryFetchObject(0, TEST_MERGE_BRANCH_EXISTENCE, parentBranch,
+ if (jdbcClient.runPreparedQueryFetchObject(connection, 0, TEST_MERGE_BRANCH_EXISTENCE, parentBranch,
destinationBranch) > 0) {
throw new OseeStateException("Existing merge branch detected for [%d] and [%d]", parentBranch,
destinationBranch);
@@ -114,7 +113,7 @@ public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
// this checks to see if there are any branches that aren't either DELETED or REBASELINED with the same artifact ID
if (associatedArtifactId > -1 && associatedArtifactId != SystemUser.OseeSystem.getUuid()) {
- int count = getJdbcClient().runPreparedQueryFetchObject(0,
+ int count = jdbcClient.runPreparedQueryFetchObject(connection, 0,
"SELECT (1) FROM osee_branch WHERE associated_art_id = ? AND branch_state NOT IN (?, ?)",
newBranchData.getAssociatedArtifactId(), BranchState.DELETED.getValue(),
BranchState.REBASELINED.getValue());
@@ -124,7 +123,7 @@ public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
// port branch with the same artifact ID - if the type is port type, then we need an additional check
if (newBranchData.getBranchType().equals(BranchType.PORT)) {
- int portcount = getJdbcClient().runPreparedQueryFetchObject(0,
+ int portcount = jdbcClient.runPreparedQueryFetchObject(connection, 0,
"SELECT (1) FROM osee_branch WHERE associated_art_id = ? AND branch_state NOT IN (?, ?) AND branch_type = ?",
newBranchData.getAssociatedArtifactId(), BranchState.DELETED.getValue(),
BranchState.REBASELINED.getValue(), BranchType.PORT.getValue());
@@ -141,11 +140,11 @@ public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
}
@Override
- protected Void handleTxWork(JdbcConnection connection) throws OseeCoreException {
+ public void handleTxWork(JdbcConnection connection) {
Long parentBranchUuid = newBranchData.getParentBranchUuid();
Long destinationBranchUuid = newBranchData.getMergeDestinationBranchId();
- checkPreconditions(parentBranchUuid, destinationBranchUuid);
+ checkPreconditions(connection, parentBranchUuid, destinationBranchUuid);
long uuid = newBranchData.getUuid();
@@ -168,7 +167,7 @@ public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
int inheritAccessControl = 0;
if (parentBranchUuid != null) {
inheritAccessControl =
- getJdbcClient().runPreparedQueryFetchObject(connection, 0, SELECT_INHERIT_ACCESS_CONTROL, parentBranchUuid);
+ jdbcClient.runPreparedQueryFetchObject(connection, 0, SELECT_INHERIT_ACCESS_CONTROL, parentBranchUuid);
}
//write to branch table
@@ -203,34 +202,32 @@ public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
}
String insertBranch = insertBranchGuid ? INSERT_BRANCH_WITH_GUID : INSERT_BRANCH;
- getJdbcClient().runPreparedUpdate(connection, insertBranch, toInsert);
+ jdbcClient.runPreparedUpdate(connection, insertBranch, toInsert);
if (inheritAccessControl != 0) {
copyAccessRules(connection, newBranchData.getUserArtifactId(), parentBranchUuid, uuid);
}
- getJdbcClient().runPreparedUpdate(connection, INSERT_TX_DETAILS, uuid, nextTransactionId,
+ jdbcClient.runPreparedUpdate(connection, INSERT_TX_DETAILS, uuid, nextTransactionId,
newBranchData.getCreationComment(), timestamp, newBranchData.getUserArtifactId(),
TransactionDetailsType.Baselined.getId());
populateBaseTransaction(0.30, connection, nextTransactionId, sourceTx);
addMergeBranchEntry(0.20, connection);
- return null;
}
private boolean isBranchGuidNeeded(JdbcConnection connection) {
- return getJdbcClient().runPreparedQueryFetchObject(connection, false,
+ return jdbcClient.runPreparedQueryFetchObject(connection, false,
"select osee_value from osee_info where osee_key = ?", "osee.insert.branch.guid.on.create");
}
private void addMergeBranchEntry(double workAmount, JdbcConnection connection) {
if (newBranchData.getBranchType().isMergeBranch()) {
long parentBranchId = newBranchData.getParentBranchUuid() != null ? newBranchData.getParentBranchUuid() : -1;
- getJdbcClient().runPreparedUpdate(connection, MERGE_BRANCH_INSERT, parentBranchId,
+ jdbcClient.runPreparedUpdate(connection, MERGE_BRANCH_INSERT, parentBranchId,
newBranchData.getMergeDestinationBranchId(), newBranchData.getUuid(), 0);
}
- checkForCancelled();
}
private void populateBaseTransaction(double workAmount, JdbcConnection connection, int baseTxId, int sourceTxId) throws OseeCoreException {
@@ -238,7 +235,7 @@ public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
HashSet<Integer> gammas = new HashSet<Integer>(100000);
long parentBranchId = -1;
- OseePreparedStatement addressing = getJdbcClient().getBatchStatement(connection, INSERT_ADDRESSING);
+ OseePreparedStatement addressing = jdbcClient.getBatchStatement(connection, INSERT_ADDRESSING);
if (newBranchData.getParentBranchUuid() != null) {
parentBranchId = newBranchData.getParentBranchUuid();
}
@@ -254,15 +251,13 @@ public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
addressing.execute();
}
- checkForCancelled();
}
private void populateAddressingToCopy(JdbcConnection connection, OseePreparedStatement addressing, int baseTxId, HashSet<Integer> gammas, String query, Object... parameters) throws OseeCoreException {
- JdbcStatement chStmt = getJdbcClient().getStatement(connection);
+ JdbcStatement chStmt = jdbcClient.getStatement(connection);
try {
chStmt.runPreparedQuery(JdbcConstants.JDBC__MAX_FETCH_SIZE, query, parameters);
while (chStmt.next()) {
- checkForCancelled();
Integer gamma = chStmt.getInt("gamma_id");
if (!gammas.contains(gamma)) {
ModificationType modType = ModificationType.getMod(chStmt.getInt("mod_type"));
@@ -282,7 +277,7 @@ public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
int deny = PermissionEnum.DENY.getPermId();
List<Object[]> data = new ArrayList<Object[]>();
- JdbcStatement chStmt = getJdbcClient().getStatement(connection);
+ JdbcStatement chStmt = jdbcClient.getStatement(connection);
try {
chStmt.runPreparedQuery(JdbcConstants.JDBC__MAX_FETCH_SIZE, GET_BRANCH_ACCESS_CONTROL_LIST, parentBranch);
while (chStmt.next()) {
@@ -297,7 +292,7 @@ public class CreateBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<
Lib.close(chStmt);
}
if (!data.isEmpty()) {
- getJdbcClient().runBatchUpdate(INSERT_INTO_BRANCH_ACL, data);
+ jdbcClient.runBatchUpdate(INSERT_INTO_BRANCH_ACL, data);
}
}
}

Back to the top