diff options
author | Ryan D. Brooks | 2016-06-14 23:28:09 +0000 |
---|---|---|
committer | Angel Avila | 2016-06-14 23:28:09 +0000 |
commit | c06df82d61e0fbaba865fc82413a3981d664d0e0 (patch) | |
tree | 8f983e45b7423f3834d1154027b64bf17a587c9a /plugins/org.eclipse.osee.orcs.db/src/org | |
parent | eb4bf3bf6d8cad58dad30c359741d15bbaef65d8 (diff) | |
download | org.eclipse.osee-c06df82d61e0fbaba865fc82413a3981d664d0e0.tar.gz org.eclipse.osee-c06df82d61e0fbaba865fc82413a3981d664d0e0.tar.xz org.eclipse.osee-c06df82d61e0fbaba865fc82413a3981d664d0e0.zip |
refactor: Remove unnecessary usage of TransactionReadable
Change-Id: I253fb85c0c23445eeac173799adb51d7c541e932
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.db/src/org')
9 files changed, 75 insertions, 74 deletions
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 34a14eb4aeb..05272436b57 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 @@ -15,6 +15,8 @@ import java.util.List; import java.util.concurrent.Callable; import org.eclipse.osee.executor.admin.ExecutorAdmin; import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.TransactionId; +import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.BranchType; import org.eclipse.osee.framework.core.model.change.ChangeItem; @@ -31,7 +33,6 @@ import org.eclipse.osee.orcs.data.ArchiveOperation; import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.BranchReadable; import org.eclipse.osee.orcs.data.CreateBranchData; -import org.eclipse.osee.orcs.data.TransactionReadable; import org.eclipse.osee.orcs.db.internal.IdentityManager; import org.eclipse.osee.orcs.db.internal.callable.AbstractDatastoreTxCallable; import org.eclipse.osee.orcs.db.internal.callable.ArchiveUnarchiveBranchCallable; @@ -88,7 +89,7 @@ public class BranchModule { } @Override - public Callable<Integer> commitBranch(OrcsSession session, ArtifactReadable committer, BranchReadable source, TransactionReadable sourceHead, BranchReadable destination, TransactionReadable destinationHead) { + public Callable<TransactionId> commitBranch(OrcsSession session, ArtifactReadable committer, BranchReadable source, TransactionToken sourceHead, BranchReadable destination, TransactionToken destinationHead) { return new CommitBranchDatabaseCallable(logger, session, jdbcClient, joinFactory, idManager, committer, source, sourceHead, destination, destinationHead, missingChangeItemFactory); } @@ -99,7 +100,7 @@ public class BranchModule { } @Override - public Callable<List<ChangeItem>> compareBranch(OrcsSession session, TransactionReadable sourceTx, TransactionReadable destinationTx) { + public Callable<List<ChangeItem>> compareBranch(OrcsSession session, TransactionToken sourceTx, TransactionToken destinationTx) { return new CompareDatabaseCallable(logger, session, jdbcClient, joinFactory, sourceTx, destinationTx, missingChangeItemFactory); } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseCallable.java index 8b3e759de0b..675dd074aa3 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseCallable.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseCallable.java @@ -10,12 +10,13 @@ *******************************************************************************/ package org.eclipse.osee.orcs.db.internal.callable; -import static org.eclipse.osee.framework.core.data.RelationalConstants.TRANSACTION_SENTINEL; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; import org.eclipse.osee.executor.admin.CancellableCallable; import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.TransactionId; +import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.model.change.ChangeIgnoreType; import org.eclipse.osee.framework.core.model.change.ChangeItem; import org.eclipse.osee.jdbc.JdbcClient; @@ -23,7 +24,6 @@ import org.eclipse.osee.logger.Log; import org.eclipse.osee.orcs.OrcsSession; import org.eclipse.osee.orcs.data.ArtifactReadable; import org.eclipse.osee.orcs.data.BranchReadable; -import org.eclipse.osee.orcs.data.TransactionReadable; import org.eclipse.osee.orcs.db.internal.IdentityManager; import org.eclipse.osee.orcs.db.internal.change.ComputeNetChangeCallable; import org.eclipse.osee.orcs.db.internal.change.LoadDeltasBetweenBranches; @@ -33,14 +33,14 @@ import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory; /** * @author Roberto E. Escobar */ -public class CommitBranchDatabaseCallable extends AbstractDatastoreCallable<Integer> { +public class CommitBranchDatabaseCallable extends AbstractDatastoreCallable<TransactionId> { private final SqlJoinFactory joinFactory; private final IdentityManager idManager; private final ArtifactReadable committer; - private final TransactionReadable sourceHead; + private final TransactionToken sourceHead; private final BranchReadable source; - private final TransactionReadable destinationHead; + private final TransactionToken destinationHead; private final BranchReadable destination; private final MissingChangeItemFactory missingChangeItemFactory; @@ -49,7 +49,7 @@ public class CommitBranchDatabaseCallable extends AbstractDatastoreCallable<Inte private static final String SELECT_MERGE_BRANCH_HEAD_TX = "select max(transaction_id) from osee_tx_details where branch_id = ?"; - public CommitBranchDatabaseCallable(Log logger, OrcsSession session, JdbcClient service, SqlJoinFactory joinFactory, IdentityManager idManager, ArtifactReadable committer, BranchReadable source, TransactionReadable sourceHead, BranchReadable destination, TransactionReadable destinationHead, MissingChangeItemFactory missingChangeItemFactory) { + public CommitBranchDatabaseCallable(Log logger, OrcsSession session, JdbcClient service, SqlJoinFactory joinFactory, IdentityManager idManager, ArtifactReadable committer, BranchReadable source, TransactionToken sourceHead, BranchReadable destination, TransactionToken destinationHead, MissingChangeItemFactory missingChangeItemFactory) { super(logger, session, service); this.joinFactory = joinFactory; this.idManager = idManager; @@ -66,11 +66,10 @@ public class CommitBranchDatabaseCallable extends AbstractDatastoreCallable<Inte } private List<ChangeItem> callComputeChanges(BranchId mergeBranch) throws Exception { - Integer mergeTxId = getJdbcClient().fetch(TRANSACTION_SENTINEL, SELECT_MERGE_BRANCH_HEAD_TX, mergeBranch); + TransactionId mergeTxId = getJdbcClient().fetch(TransactionId.SENTINEL, SELECT_MERGE_BRANCH_HEAD_TX, mergeBranch); - Callable<List<ChangeItem>> loadChanges = - new LoadDeltasBetweenBranches(getLogger(), getSession(), getJdbcClient(), joinFactory, sourceHead.getBranch(), - destinationHead.getBranch(), destinationHead.getGuid(), mergeBranch, mergeTxId); + Callable<List<ChangeItem>> loadChanges = new LoadDeltasBetweenBranches(getLogger(), getSession(), getJdbcClient(), + joinFactory, sourceHead.getBranch(), destinationHead.getBranch(), destinationHead, mergeBranch, mergeTxId); List<ChangeItem> changes = callAndCheckForCancel(loadChanges); changes.addAll( @@ -92,13 +91,13 @@ public class CommitBranchDatabaseCallable extends AbstractDatastoreCallable<Inte } @Override - public Integer call() throws Exception { + public TransactionId call() throws Exception { BranchId mergeBranch = getJdbcClient().fetch(BranchId.SENTINEL, SELECT_MERGE_BRANCH_UUID, source, destination); List<ChangeItem> changes = callComputeChanges(mergeBranch); - CancellableCallable<Integer> commitCallable = new CommitBranchDatabaseTxCallable(getLogger(), getSession(), + CancellableCallable<TransactionId> commitCallable = new CommitBranchDatabaseTxCallable(getLogger(), getSession(), getJdbcClient(), joinFactory, idManager, getUserArtId(), source, destination, mergeBranch, changes); - Integer newTx = callAndCheckForCancel(commitCallable); + TransactionId newTx = callAndCheckForCancel(commitCallable); return newTx; } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java index 699a917e862..4b016125554 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CommitBranchDatabaseTxCallable.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.osee.framework.core.data.ApplicabilityId; import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.BranchState; import org.eclipse.osee.framework.core.enums.ConflictStatus; import org.eclipse.osee.framework.core.enums.ModificationType; @@ -36,7 +37,7 @@ import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory; /** * @author Ryan D. Brooks */ -public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<Integer> { +public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable<TransactionId> { private static final String COMMIT_COMMENT = "Commit Branch "; private static final String INSERT_COMMIT_TRANSACTION = @@ -76,7 +77,7 @@ public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable< } @Override - protected Integer handleTxWork(JdbcConnection connection) throws OseeCoreException { + protected TransactionId handleTxWork(JdbcConnection connection) throws OseeCoreException { BranchState storedBranchState; if (changes.isEmpty()) { throw new OseeStateException("A branch can not be committed without any changes made."); @@ -84,7 +85,7 @@ public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable< storedBranchState = sourceBranch.getBranchState(); checkPreconditions(); - Integer newTx = null; + TransactionId newTx = null; try { newTx = addCommitTransactionToDatabase(userArtId, connection); updatePreviousCurrentsOnDestinationBranch(connection); @@ -106,8 +107,8 @@ public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable< } public synchronized void checkPreconditions() throws OseeCoreException { - int count = getJdbcClient().fetch(0, SELECT_SOURCE_BRANCH_STATE, sourceBranch, - BranchState.COMMIT_IN_PROGRESS.getValue()); + int count = + getJdbcClient().fetch(0, SELECT_SOURCE_BRANCH_STATE, sourceBranch, BranchState.COMMIT_IN_PROGRESS.getValue()); if (sourceBranch.getBranchState().isCommitInProgress() || sourceBranch.getArchiveState().isArchived() || count > 0) { throw new OseeStateException("Commit completed or in progress for [%s]", sourceBranch); } @@ -142,8 +143,8 @@ public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable< updater.updateTxNotCurrents(); } - private Integer addCommitTransactionToDatabase(int userArtId, JdbcConnection connection) throws OseeCoreException { - int newTransactionNumber = idManager.getNextTransactionId(); + private TransactionId addCommitTransactionToDatabase(int userArtId, JdbcConnection connection) throws OseeCoreException { + TransactionId newTransactionNumber = TransactionId.valueOf(idManager.getNextTransactionId()); Timestamp timestamp = GlobalTime.GreenwichMeanTimestamp(); String comment = COMMIT_COMMENT + sourceBranch.getName(); @@ -154,7 +155,7 @@ public class CommitBranchDatabaseTxCallable extends AbstractDatastoreTxCallable< return newTransactionNumber; } - private void insertCommitAddressing(Integer newTx, JdbcConnection connection) throws OseeCoreException { + private void insertCommitAddressing(TransactionId newTx, JdbcConnection connection) throws OseeCoreException { List<Object[]> insertData = new ArrayList<>(); for (ChangeItem change : changes) { ModificationType modType = change.getNetChange().getModType(); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CompareDatabaseCallable.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CompareDatabaseCallable.java index 25bda088700..7b514b2b47c 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CompareDatabaseCallable.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/callable/CompareDatabaseCallable.java @@ -10,16 +10,16 @@ *******************************************************************************/ package org.eclipse.osee.orcs.db.internal.callable; -import static org.eclipse.osee.framework.core.data.RelationalConstants.TRANSACTION_SENTINEL; import java.util.List; import java.util.concurrent.Callable; import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.TransactionId; +import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.model.change.ChangeItem; import org.eclipse.osee.jdbc.JdbcClient; import org.eclipse.osee.logger.Log; import org.eclipse.osee.orcs.OrcsSession; -import org.eclipse.osee.orcs.data.TransactionReadable; -import org.eclipse.osee.orcs.data.TransactionReadableDelta; +import org.eclipse.osee.orcs.data.TransactionTokenDelta; import org.eclipse.osee.orcs.db.internal.change.AddArtifactChangeDataCallable; import org.eclipse.osee.orcs.db.internal.change.ComputeNetChangeCallable; import org.eclipse.osee.orcs.db.internal.change.LoadDeltasBetweenBranches; @@ -30,8 +30,8 @@ import org.eclipse.osee.orcs.db.internal.sql.join.SqlJoinFactory; public class CompareDatabaseCallable extends AbstractDatastoreCallable<List<ChangeItem>> { private final SqlJoinFactory joinFactory; - private final TransactionReadable sourceTx; - private final TransactionReadable destinationTx; + private final TransactionToken sourceTx; + private final TransactionToken destinationTx; private final MissingChangeItemFactory missingChangeItemFactory; private static final String SELECT_MERGE_BRANCH_UUID = @@ -39,7 +39,7 @@ public class CompareDatabaseCallable extends AbstractDatastoreCallable<List<Chan private static final String SELECT_MERGE_BRANCH_HEAD_TX = "select max(transaction_id) from osee_tx_details where branch_id = ?"; - public CompareDatabaseCallable(Log logger, OrcsSession session, JdbcClient service, SqlJoinFactory joinFactory, TransactionReadable sourceTx, TransactionReadable destinationTx, MissingChangeItemFactory missingChangeItemFactory) { + public CompareDatabaseCallable(Log logger, OrcsSession session, JdbcClient service, SqlJoinFactory joinFactory, TransactionToken sourceTx, TransactionToken destinationTx, MissingChangeItemFactory missingChangeItemFactory) { super(logger, session, service); this.joinFactory = joinFactory; this.sourceTx = sourceTx; @@ -49,7 +49,7 @@ public class CompareDatabaseCallable extends AbstractDatastoreCallable<List<Chan @Override public List<ChangeItem> call() throws Exception { - TransactionReadableDelta txDelta = new TransactionReadableDelta(sourceTx, destinationTx); + TransactionTokenDelta txDelta = new TransactionTokenDelta(sourceTx, destinationTx); Callable<List<ChangeItem>> callable; if (txDelta.areOnTheSameBranch()) { @@ -59,12 +59,12 @@ public class CompareDatabaseCallable extends AbstractDatastoreCallable<List<Chan BranchId mergeBranch = getJdbcClient().fetch(BranchId.SENTINEL, SELECT_MERGE_BRANCH_UUID, sourceTx.getBranch(), destinationTx.getBranch()); - Integer mergeTxId = null; + TransactionId mergeTx = TransactionId.SENTINEL; if (mergeBranch.isValid()) { - mergeTxId = getJdbcClient().fetch(TRANSACTION_SENTINEL, SELECT_MERGE_BRANCH_HEAD_TX, mergeBranch); + mergeTx = getJdbcClient().fetch(TransactionId.SENTINEL, SELECT_MERGE_BRANCH_HEAD_TX, mergeBranch); } callable = new LoadDeltasBetweenBranches(getLogger(), getSession(), getJdbcClient(), joinFactory, - sourceTx.getBranch(), destinationTx.getBranch(), destinationTx.getGuid(), mergeBranch, mergeTxId); + sourceTx.getBranch(), destinationTx.getBranch(), destinationTx, mergeBranch, mergeTx); } List<ChangeItem> changes = callAndCheckForCancel(callable); diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenBranches.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenBranches.java index ce807bf4588..fa364b557eb 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenBranches.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenBranches.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.orcs.db.internal.change; -import static org.eclipse.osee.framework.core.data.RelationalConstants.TRANSACTION_SENTINEL; import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; @@ -18,6 +17,7 @@ import java.util.List; import java.util.function.Consumer; import org.eclipse.osee.framework.core.data.ApplicabilityId; import org.eclipse.osee.framework.core.data.BranchId; +import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.enums.TxChange; import org.eclipse.osee.framework.core.model.change.ChangeItem; @@ -46,19 +46,19 @@ public class LoadDeltasBetweenBranches extends AbstractDatastoreCallable<List<Ch private static final String SELECT_SOURCE_BRANCH_CHANGES = "select gamma_id, mod_type, app_id from osee_txs txs where txs.branch_id = ? and txs.tx_current <> ? and txs.transaction_id <> ? AND NOT EXISTS (SELECT 1 FROM osee_txs txs1 WHERE txs1.branch_id = ? AND txs1.transaction_id = ? AND txs1.gamma_id = txs.gamma_id and txs1.mod_type = txs.mod_type and txs1.app_id = txs.app_id)"; - private static final String SELECT_BASE_TRANSACTION = - "select baseline_transaction_id from osee_branch where branch_id = ?"; + private static final String SELECT_BASE_TX = "select baseline_transaction_id from osee_branch where branch_id = ?"; private final HashMap<Long, Pair<ModificationType, ApplicabilityId>> changeByGammaId = new HashMap<>(); private final BranchId sourceBranch, destinationBranch; private final BranchId mergeBranch; - private final Integer destinationHeadTxId, mergeTxId; + private final TransactionId mergeTxId; + private final TransactionId destinationHeadTxId; private final ChangeItemLoader changeItemLoader; private final SqlJoinFactory joinFactory; - public LoadDeltasBetweenBranches(Log logger, OrcsSession session, JdbcClient jdbcClient, SqlJoinFactory joinFactory, BranchId sourceBranch, BranchId destinationBranch, Integer destinationHeadTxId, BranchId mergeBranch, Integer mergeTxId) { + public LoadDeltasBetweenBranches(Log logger, OrcsSession session, JdbcClient jdbcClient, SqlJoinFactory joinFactory, BranchId sourceBranch, BranchId destinationBranch, TransactionId destinationHeadTxId, BranchId mergeBranch, TransactionId mergeTxId) { super(logger, session, jdbcClient); this.joinFactory = joinFactory; this.sourceBranch = sourceBranch; @@ -73,10 +73,6 @@ public class LoadDeltasBetweenBranches extends AbstractDatastoreCallable<List<Ch return mergeBranch.isValid(); } - private int getSourceBaselineTxId() { - return getBaseTxId(sourceBranch); - } - @Override public List<ChangeItem> call() throws Exception { List<ChangeItem> changeData = new LinkedList<>(); @@ -85,7 +81,7 @@ public class LoadDeltasBetweenBranches extends AbstractDatastoreCallable<List<Ch "Unable to compute deltas between transactions on the same branch [%s]", sourceBranch); TransactionJoinQuery txJoin = joinFactory.createTransactionJoinQuery(); - int sourceBaselineTxId = getSourceBaselineTxId(); + TransactionId sourceBaselineTxId = getJdbcClient().fetch(TransactionId.SENTINEL, SELECT_BASE_TX, sourceBranch); loadSourceBranchChanges(txJoin, sourceBaselineTxId); @@ -104,7 +100,7 @@ public class LoadDeltasBetweenBranches extends AbstractDatastoreCallable<List<Ch return changeData; } - private void loadSourceBranchChanges(TransactionJoinQuery txJoin, int sourceBaselineTxId) throws OseeCoreException { + private void loadSourceBranchChanges(TransactionJoinQuery txJoin, TransactionId sourceBaselineTxId) throws OseeCoreException { Consumer<JdbcStatement> consumer = stmt -> { checkForCancelled(); Long gammaId = stmt.getLong("gamma_id"); @@ -119,7 +115,7 @@ public class LoadDeltasBetweenBranches extends AbstractDatastoreCallable<List<Ch txJoin.store(); } - private void loadByItemId(Collection<ChangeItem> changeData, int txJoinId, ChangeItemFactory factory, int sourceBaselineTxId) throws OseeCoreException { + private void loadByItemId(Collection<ChangeItem> changeData, int txJoinId, ChangeItemFactory factory, TransactionId sourceBaselineTxId) throws OseeCoreException { HashMap<Integer, ChangeItem> changesByItemId = new HashMap<>(); IdJoinQuery idJoin = joinFactory.createIdJoinQuery(); @@ -145,7 +141,7 @@ public class LoadDeltasBetweenBranches extends AbstractDatastoreCallable<List<Ch } } - private void loadCurrentData(String tableName, String columnName, IdJoinQuery idJoin, HashMap<Integer, ChangeItem> changesByItemId, BranchId txBranchId, Integer txId, boolean isMergeBranch) throws OseeCoreException { + private void loadCurrentData(String tableName, String columnName, IdJoinQuery idJoin, HashMap<Integer, ChangeItem> changesByItemId, BranchId txBranchId, TransactionId txId, boolean isMergeBranch) throws OseeCoreException { try (JdbcStatement chStmt = getJdbcClient().getStatement()) { String query = "select txs.gamma_id, txs.mod_type, txs.app_id, item." + columnName + " from osee_join_id idj, " // + tableName + " item, osee_txs txs where idj.query_id = ? and idj.id = item." + columnName + // @@ -175,7 +171,7 @@ public class LoadDeltasBetweenBranches extends AbstractDatastoreCallable<List<Ch } } - private void loadNonCurrentSourceData(String tableName, String idColumnName, IdJoinQuery idJoin, HashMap<Integer, ChangeItem> changesByItemId, String columnValueName, int sourceBaselineTxId) throws OseeCoreException { + private void loadNonCurrentSourceData(String tableName, String idColumnName, IdJoinQuery idJoin, HashMap<Integer, ChangeItem> changesByItemId, String columnValueName, TransactionId sourceBaselineTxId) throws OseeCoreException { try (JdbcStatement chStmt = getJdbcClient().getStatement()) { String valueColumnName = columnValueName != null ? "item." + columnValueName + "," : ""; String query = @@ -191,7 +187,7 @@ public class LoadDeltasBetweenBranches extends AbstractDatastoreCallable<List<Ch while (chStmt.next()) { checkForCancelled(); int itemId = chStmt.getInt(idColumnName); - Integer transactionId = chStmt.getInt("transaction_id"); + Long transactionId = chStmt.getLong("transaction_id"); ApplicabilityId appId = ApplicabilityId.valueOf(chStmt.getLong("app_id")); ModificationType modType = ModificationType.getMod(chStmt.getInt("mod_type")); Long gammaId = chStmt.getLong("gamma_id"); @@ -205,7 +201,7 @@ public class LoadDeltasBetweenBranches extends AbstractDatastoreCallable<List<Ch if (previousItemId != itemId) { isFirstSet = false; } - if (transactionId.equals(sourceBaselineTxId)) { + if (sourceBaselineTxId.equals(transactionId)) { setVersionData(change.getBaselineVersion(), gammaId, modType, value, appId); } else if (!isFirstSet) { setVersionData(change.getFirstNonCurrentChange(), gammaId, modType, value, appId); @@ -227,9 +223,4 @@ public class LoadDeltasBetweenBranches extends AbstractDatastoreCallable<List<Ch versionedChange.setApplicabilityId(appId); } } - - private int getBaseTxId(BranchId branch) throws OseeCoreException { - return getJdbcClient().fetch(TRANSACTION_SENTINEL, SELECT_BASE_TRANSACTION, branch); - } - }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java index de4f9b8b3a8..f207f2a9ccd 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/LoadDeltasBetweenTxsOnTheSameBranch.java @@ -16,6 +16,7 @@ import java.util.LinkedList; import java.util.List; import org.eclipse.osee.framework.core.data.ApplicabilityId; import java.util.function.Consumer; +import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.enums.BranchArchivedState; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.model.change.ChangeItem; @@ -27,8 +28,7 @@ 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.orcs.data.TransactionReadable; -import org.eclipse.osee.orcs.data.TransactionReadableDelta; +import org.eclipse.osee.orcs.data.TransactionTokenDelta; import org.eclipse.osee.orcs.db.internal.callable.AbstractDatastoreCallable; import org.eclipse.osee.orcs.db.internal.change.ChangeItemLoader.ChangeItemFactory; import org.eclipse.osee.orcs.db.internal.sql.join.IdJoinQuery; @@ -52,10 +52,10 @@ public class LoadDeltasBetweenTxsOnTheSameBranch extends AbstractDatastoreCallab private final HashMap<Long, Pair<ModificationType, ApplicabilityId>> changeByGammaId = new HashMap<>(); private final SqlJoinFactory joinFactory; - private final TransactionReadableDelta txDelta; + private final TransactionTokenDelta txDelta; private final ChangeItemLoader changeItemLoader; - public LoadDeltasBetweenTxsOnTheSameBranch(Log logger, OrcsSession session, JdbcClient jdbcClient, SqlJoinFactory joinFactory, TransactionReadableDelta txDelta) { + public LoadDeltasBetweenTxsOnTheSameBranch(Log logger, OrcsSession session, JdbcClient jdbcClient, SqlJoinFactory joinFactory, TransactionTokenDelta txDelta) { super(logger, session, jdbcClient); this.joinFactory = joinFactory; this.txDelta = txDelta; @@ -66,11 +66,11 @@ public class LoadDeltasBetweenTxsOnTheSameBranch extends AbstractDatastoreCallab return getEndTx().getBranchId(); } - private TransactionReadable getEndTx() { + private TransactionToken getEndTx() { return txDelta.getEndTx(); } - private TransactionReadable getStartTx() { + private TransactionToken getStartTx() { return txDelta.getStartTx(); } @@ -126,7 +126,7 @@ public class LoadDeltasBetweenTxsOnTheSameBranch extends AbstractDatastoreCallab }; getJdbcClient().runQuery(consumer, JdbcConstants.JDBC__MAX_FETCH_SIZE, (isArchived ? SELECT_CHANGES_BETWEEN_ARCHIVED_TRANSACTIONS : SELECT_CHANGES_BETWEEN_TRANSACTIONS), - getBranchId(), getStartTx().getGuid(), getEndTx().getGuid()); + getBranchId(), getStartTx(), getEndTx()); txJoin.store(); @@ -149,10 +149,11 @@ public class LoadDeltasBetweenTxsOnTheSameBranch extends AbstractDatastoreCallab changeData.addAll(changesByItemId.values()); } - private void loadCurrentData(String tableName, String columnName, int queryId, HashMap<Integer, ChangeItem> changesByItemId, TransactionReadable transactionLimit, boolean isArchived) throws OseeCoreException { - String query = String.format("select txs.gamma_id, txs.mod_type, txs.app_id, item." + columnName + " from osee_join_id idj, " // - + tableName + " item, %s txs where idj.query_id = ? and idj.id = item." + columnName + // - " and item.gamma_id = txs.gamma_id and txs.branch_id = ? and txs.transaction_id <= ?", + private void loadCurrentData(String tableName, String columnName, int queryId, HashMap<Integer, ChangeItem> changesByItemId, TransactionToken transactionLimit, boolean isArchived) throws OseeCoreException { + String query = String.format( + "select txs.gamma_id, txs.mod_type, txs.app_id, item." + columnName + " from osee_join_id idj, " // + + tableName + " item, %s txs where idj.query_id = ? and idj.id = item." + columnName + // + " and item.gamma_id = txs.gamma_id and txs.branch_id = ? and txs.transaction_id <= ?", isArchived ? "osee_txs_archived" : "osee_txs"); Consumer<JdbcStatement> consumer = stmt -> { checkForCancelled(); @@ -169,7 +170,7 @@ public class LoadDeltasBetweenTxsOnTheSameBranch extends AbstractDatastoreCallab change.getBaselineVersion().copy(change.getDestinationVersion()); }; getJdbcClient().runQuery(consumer, JdbcConstants.JDBC__MAX_FETCH_SIZE, query, queryId, - transactionLimit.getBranchId(), transactionLimit.getGuid()); + transactionLimit.getBranchId(), transactionLimit); } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactory.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactory.java index 055766edbb4..139f787054c 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactory.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactory.java @@ -13,16 +13,16 @@ package org.eclipse.osee.orcs.db.internal.change; import java.util.Collection; import java.util.List; import org.eclipse.osee.executor.admin.HasCancellation; +import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.model.change.ChangeItem; import org.eclipse.osee.framework.jdk.core.type.OseeCoreException; import org.eclipse.osee.orcs.OrcsSession; -import org.eclipse.osee.orcs.data.TransactionReadable; /** * @author John Misinco */ public interface MissingChangeItemFactory { - Collection<ChangeItem> createMissingChanges(HasCancellation cancellation, OrcsSession session, List<ChangeItem> changes, TransactionReadable sourceTx, TransactionReadable destTx) throws OseeCoreException; + Collection<ChangeItem> createMissingChanges(HasCancellation cancellation, OrcsSession session, List<ChangeItem> changes, TransactionToken sourceTx, TransactionToken destTx) throws OseeCoreException; } diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java index f48c34c7707..05d84bcdfca 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/change/MissingChangeItemFactoryImpl.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.Set; import org.eclipse.osee.executor.admin.HasCancellation; import org.eclipse.osee.framework.core.data.ApplicabilityId; +import org.eclipse.osee.framework.core.data.TransactionToken; import org.eclipse.osee.framework.core.enums.LoadLevel; import org.eclipse.osee.framework.core.enums.ModificationType; import org.eclipse.osee.framework.core.model.change.ChangeItem; @@ -34,7 +35,6 @@ import org.eclipse.osee.orcs.core.ds.DataLoaderFactory; import org.eclipse.osee.orcs.core.ds.LoadDataHandlerAdapter; import org.eclipse.osee.orcs.core.ds.OrcsData; import org.eclipse.osee.orcs.core.ds.RelationData; -import org.eclipse.osee.orcs.data.TransactionReadable; /** * @author John Misinco @@ -49,7 +49,7 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory { } @Override - public Collection<ChangeItem> createMissingChanges(HasCancellation cancellation, OrcsSession session, List<ChangeItem> changes, TransactionReadable sourceTx, TransactionReadable destTx) throws OseeCoreException { + public Collection<ChangeItem> createMissingChanges(HasCancellation cancellation, OrcsSession session, List<ChangeItem> changes, TransactionToken sourceTx, TransactionToken destTx) throws OseeCoreException { if (changes != null && !changes.isEmpty()) { Set<Integer> modifiedArtIds = new HashSet<>(); Multimap<Integer, Integer> modifiedAttrIds = LinkedListMultimap.create(); @@ -88,7 +88,7 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory { return Collections.emptyList(); } - private Set<Integer> determineWhichArtifactsNotOnDestination(HasCancellation cancellation, OrcsSession session, Set<Integer> artIds, TransactionReadable destTx) throws OseeCoreException { + private Set<Integer> determineWhichArtifactsNotOnDestination(HasCancellation cancellation, OrcsSession session, Set<Integer> artIds, TransactionToken destTx) throws OseeCoreException { DataLoader loader = dataLoaderFactory.newDataLoaderFromIds(session, destTx.getBranchId(), artIds); final Set<Integer> missingArtIds = new LinkedHashSet<>(artIds); loader.includeDeletedArtifacts(); @@ -104,7 +104,7 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory { return missingArtIds; } - private Collection<ChangeItem> createMissingChangeItems(HasCancellation cancellation, OrcsSession session, TransactionReadable sourceTx, TransactionReadable destTx, final Set<Integer> modifiedArtIds, final Multimap<Integer, Integer> modifiedAttrIds, final Multimap<Integer, Integer> modifiedRels, final Set<Integer> missingArtIds, final Set<Integer> allArtIds) throws OseeCoreException { + private Collection<ChangeItem> createMissingChangeItems(HasCancellation cancellation, OrcsSession session, TransactionToken sourceTx, TransactionToken destTx, final Set<Integer> modifiedArtIds, final Multimap<Integer, Integer> modifiedAttrIds, final Multimap<Integer, Integer> modifiedRels, final Set<Integer> missingArtIds, final Set<Integer> allArtIds) throws OseeCoreException { final Set<ChangeItem> toReturn = new LinkedHashSet<>(); final Set<RelationData> relations = new LinkedHashSet<>(); @@ -162,7 +162,7 @@ public class MissingChangeItemFactoryImpl implements MissingChangeItemFactory { return toReturn; } - private Set<ChangeItem> createExistingRelations(HasCancellation cancellation, OrcsSession session, TransactionReadable destTx, final Multimap<Integer, RelationData> relationChangesToAdd) throws OseeCoreException { + private Set<ChangeItem> createExistingRelations(HasCancellation cancellation, OrcsSession session, TransactionToken destTx, final Multimap<Integer, RelationData> relationChangesToAdd) throws OseeCoreException { final Set<ChangeItem> toReturn = new LinkedHashSet<>(); DataLoader loader = diff --git a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionDataImpl.java b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionDataImpl.java index b5bb5882407..613095d38eb 100644 --- a/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionDataImpl.java +++ b/plugins/org.eclipse.osee.orcs.db/src/org/eclipse/osee/orcs/db/internal/loader/data/TransactionDataImpl.java @@ -13,6 +13,7 @@ package org.eclipse.osee.orcs.db.internal.loader.data; import java.util.Date; import org.eclipse.osee.framework.core.data.BranchId; import org.eclipse.osee.framework.core.data.RelationalConstants; +import org.eclipse.osee.framework.core.data.TransactionId; import org.eclipse.osee.framework.core.enums.TransactionDetailsType; import org.eclipse.osee.orcs.core.ds.TxOrcsData; @@ -102,4 +103,11 @@ public class TransactionDataImpl extends OrcsObjectImpl<Integer> implements TxOr return super.getLocalId(); } + @Override + public boolean equals(Object other) { + if (other instanceof TransactionId) { + return getId().equals(((TransactionId) other).getId()); + } + return false; + } } |