Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2016-05-09 18:28:06 +0000
committerRyan D. Brooks2016-08-31 16:17:45 +0000
commitefae4306117421e2aa3231d57583e55bb8c16f28 (patch)
tree9ef4bcbba86f14434d6b6cf9a98fe317fcb990c0
parente00cd22ea79a0e5113a6e8bc708fd0f8e961cbfa (diff)
downloadorg.eclipse.osee-efae4306117421e2aa3231d57583e55bb8c16f28.tar.gz
org.eclipse.osee-efae4306117421e2aa3231d57583e55bb8c16f28.tar.xz
org.eclipse.osee-efae4306117421e2aa3231d57583e55bb8c16f28.zip
refactor: Remove Transaction cache
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/IAtsBranchService.java13
-rw-r--r--plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/branch/AtsBranchServiceImplTest.java3
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/branch/internal/AtsBranchServiceImpl.java5
-rw-r--r--plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsBranchService.java35
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsBranchServiceImpl.java37
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsBranchManager.java20
-rw-r--r--plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/commit/XCommitLabelProvider.java3
-rw-r--r--plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ArtifactRendererTest.java16
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/cache/BranchCacheTest.java2
-rw-r--r--plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockOseeTransactionDataAccessor.java83
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecord.java3
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecordFactory.java45
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/BranchCache.java18
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/ITransactionDataAccessor.java50
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/TransactionCache.java183
-rw-r--r--plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/IOseeCachingService.java3
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/GammaId.java35
-rw-r--r--plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/sql/OseeSql.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java5
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/PurgeTransactionEventUtil.java7
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/BaseArtifactLoopbackCmd.java10
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ClientCachingServiceProxy.java18
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseBranchAccessor.java178
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseTransactionRecordAccessor.java131
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java2
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java8
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransaction.java18
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java208
-rw-r--r--plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/provider/DeletedBranchProviderTest.java3
32 files changed, 253 insertions, 896 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/IAtsBranchService.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/IAtsBranchService.java
index 31d1d9fdfb..bc3497484c 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/IAtsBranchService.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/IAtsBranchService.java
@@ -20,6 +20,7 @@ import org.eclipse.osee.framework.core.data.IOseeBranch;
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.TransactionRecord;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -61,7 +62,7 @@ public interface IAtsBranchService {
TransactionToken getEarliestTransactionId(IAtsTeamWorkflow teamWf);
- Collection<TransactionToken> getTransactionIds(IAtsTeamWorkflow teamWf, boolean forMergeBranches);
+ Collection<TransactionRecord> getTransactionIds(IAtsTeamWorkflow teamWf, boolean forMergeBranches);
boolean isBranchesAllCommittedExcept(IAtsTeamWorkflow teamWf, BranchId branchToExclude);
@@ -90,15 +91,15 @@ public interface IAtsBranchService {
boolean isWorkingBranchEverCommitted(IAtsTeamWorkflow teamWf);
- Collection<Object> combineCommitTransactionsAndConfigItems(Collection<ICommitConfigItem> configArtSet, Collection<TransactionToken> commitTxs);
+ Collection<Object> combineCommitTransactionsAndConfigItems(Collection<ICommitConfigItem> configArtSet, Collection<TransactionRecord> commitTxs);
- Collection<TransactionToken> getCommitTransactionsToUnarchivedBaselineBranchs(IAtsTeamWorkflow teamWf);
+ Collection<TransactionRecord> getCommitTransactionsToUnarchivedBaselineBranchs(IAtsTeamWorkflow teamWf);
BranchType getBranchType(BranchId branch);
BranchState getBranchState(BranchId branch);
- Collection<TransactionToken> getCommittedArtifactTransactionIds(IAtsTeamWorkflow teamWf);
+ Collection<TransactionRecord> getCommittedArtifactTransactionIds(IAtsTeamWorkflow teamWf);
boolean isMergeBranchExists(IAtsTeamWorkflow teamWf, BranchId destinationBranch);
@@ -114,13 +115,13 @@ public interface IAtsBranchService {
boolean isArchived(BranchId branch);
- TransactionToken getCommitTransactionRecord(IAtsTeamWorkflow teamWf, BranchId branch);
+ TransactionRecord getCommitTransactionRecord(IAtsTeamWorkflow teamWf, BranchId branch);
Collection<BranchId> getBranchesToCommitTo(IAtsTeamWorkflow teamWf) throws OseeCoreException;
Collection<BranchId> getBranchesInCommit();
- boolean workingBranchCommittedToDestinationBranchParentPriorToDestinationBranchCreation(IAtsTeamWorkflow teamWf, BranchId destinationBranch, Collection<TransactionToken> commitTransactionIds) throws OseeCoreException;
+ boolean workingBranchCommittedToDestinationBranchParentPriorToDestinationBranchCreation(IAtsTeamWorkflow teamWf, BranchId destinationBranch, Collection<? extends TransactionToken> commitTransactionIds) throws OseeCoreException;
BranchId getParentBranch(BranchId branch);
diff --git a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/branch/AtsBranchServiceImplTest.java b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/branch/AtsBranchServiceImplTest.java
index 999736f643..f5b2ce6ab8 100644
--- a/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/branch/AtsBranchServiceImplTest.java
+++ b/plugins/org.eclipse.osee.ats.client.integration.tests/src/org/eclipse/osee/ats/client/integration/tests/ats/core/client/branch/AtsBranchServiceImplTest.java
@@ -25,7 +25,6 @@ import org.eclipse.osee.ats.client.integration.tests.AtsClientService;
import org.eclipse.osee.ats.client.integration.tests.ats.core.client.AtsTestUtil;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.ats.core.client.util.AtsChangeSet;
-import org.eclipse.osee.framework.core.data.TransactionToken;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -113,7 +112,7 @@ public class AtsBranchServiceImplTest {
//Test TxRecords
TransactionRecord txRecord = new TransactionRecord(1234L, SAW_Bld_1, "comment", new Date(0),
UserManager.getUser().getArtId(), UserManager.getUser().getArtId(), TransactionDetailsType.Baselined);
- Collection<TransactionToken> commitTxs = new ArrayList<>();
+ Collection<TransactionRecord> commitTxs = new ArrayList<>();
Collection<ICommitConfigItem> configArtSet = new HashSet<>();
commitTxs.add(txRecord);
Collection<Object> commitObjs =
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/branch/internal/AtsBranchServiceImpl.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/branch/internal/AtsBranchServiceImpl.java
index 9569672567..6996b5882a 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/branch/internal/AtsBranchServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/branch/internal/AtsBranchServiceImpl.java
@@ -20,6 +20,7 @@ import org.eclipse.osee.framework.core.data.IOseeBranch;
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.TransactionRecord;
import org.eclipse.osee.framework.core.model.cache.BranchFilter;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
@@ -68,8 +69,8 @@ public class AtsBranchServiceImpl extends AbstractAtsBranchService {
}
@Override
- public Collection<TransactionToken> getCommittedArtifactTransactionIds(IAtsTeamWorkflow teamWf) {
- return TransactionManager.getCommittedArtifactTransactionIds((Artifact) teamWf.getStoreObject());
+ public Collection<TransactionRecord> getCommittedArtifactTransactionIds(IAtsTeamWorkflow teamWf) {
+ return TransactionManager.getCommittedArtifactTransactionIds(teamWf.getStoreObject());
}
/**
diff --git a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF
index e407fc82f0..09e1c45311 100644
--- a/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats.core/META-INF/MANIFEST.MF
@@ -13,6 +13,7 @@ Import-Package: com.google.common.base,
org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.model,
org.eclipse.osee.framework.core.util,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
diff --git a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsBranchService.java b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsBranchService.java
index 07560a071b..79a09250cb 100644
--- a/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsBranchService.java
+++ b/plugins/org.eclipse.osee.ats.core/src/org/eclipse/osee/ats/core/util/AbstractAtsBranchService.java
@@ -36,6 +36,7 @@ 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.TransactionRecord;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.jdk.core.type.ItemDoesNotExist;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -138,18 +139,18 @@ public abstract class AbstractAtsBranchService implements IAtsBranchService {
}
@Override
- public TransactionToken getCommitTransactionRecord(IAtsTeamWorkflow teamWf, BranchId branch) {
+ public TransactionRecord getCommitTransactionRecord(IAtsTeamWorkflow teamWf, BranchId branch) {
if (branch == null) {
- return TransactionToken.SENTINEL;
+ return TransactionRecord.SENTINEL;
}
- Collection<TransactionToken> transactions = getCommittedArtifactTransactionIds(teamWf);
- for (TransactionToken transId : transactions) {
+ Collection<TransactionRecord> transactions = getCommittedArtifactTransactionIds(teamWf);
+ for (TransactionRecord transId : transactions) {
if (transId.isOnBranch(branch)) {
return transId;
}
}
- return TransactionToken.SENTINEL;
+ return TransactionRecord.SENTINEL;
}
@Override
@@ -168,7 +169,7 @@ public abstract class AbstractAtsBranchService implements IAtsBranchService {
@Override
public TransactionToken getEarliestTransactionId(IAtsTeamWorkflow teamWf) {
- Collection<TransactionToken> transactionIds = getTransactionIds(teamWf, false);
+ Collection<? extends TransactionToken> transactionIds = getTransactionIds(teamWf, false);
TransactionToken earliestTransactionId;
if (transactionIds.isEmpty()) {
earliestTransactionId = TransactionToken.SENTINEL;
@@ -246,11 +247,9 @@ public abstract class AbstractAtsBranchService implements IAtsBranchService {
}
@Override
- public Collection<TransactionToken> getCommitTransactionsToUnarchivedBaselineBranchs(IAtsTeamWorkflow teamWf) {
- Collection<TransactionToken> committedTransactions = getCommittedArtifactTransactionIds(teamWf);
-
- Collection<TransactionToken> transactionIds = new ArrayList<>();
- for (TransactionToken transactionId : committedTransactions) {
+ public Collection<TransactionRecord> getCommitTransactionsToUnarchivedBaselineBranchs(IAtsTeamWorkflow teamWf) {
+ Collection<TransactionRecord> transactionIds = new ArrayList<>();
+ for (TransactionRecord transactionId : getCommittedArtifactTransactionIds(teamWf)) {
// exclude working branches including branch states that are re-baselined
BranchId branch = transactionId.getBranch();
if (getBranchType(branch).isBaselineBranch() && !isArchived(branch)) {
@@ -385,7 +384,7 @@ public abstract class AbstractAtsBranchService implements IAtsBranchService {
* This method was refactored from above so it could be tested independently
*/
@Override
- public Collection<Object> combineCommitTransactionsAndConfigItems(Collection<ICommitConfigItem> configArtSet, Collection<TransactionToken> commitTxs) throws OseeCoreException {
+ public Collection<Object> combineCommitTransactionsAndConfigItems(Collection<ICommitConfigItem> configArtSet, Collection<TransactionRecord> commitTxs) throws OseeCoreException {
// commitMgrInputObjs will hold a union of all commits from configArtSet and commitTxs.
// - first, we addAll configArtSet
// - next, we loop through commitTxs and for any tx that has the same branch as ANY pre-existing commit
@@ -421,7 +420,7 @@ public abstract class AbstractAtsBranchService implements IAtsBranchService {
@Override
public Collection<Object> getCommitTransactionsAndConfigItemsForTeamWf(IAtsTeamWorkflow teamWf) throws OseeCoreException {
Collection<ICommitConfigItem> configArtSet = getConfigArtifactsConfiguredToCommitTo(teamWf);
- Collection<TransactionToken> commitTxs = getCommitTransactionsToUnarchivedBaselineBranchs(teamWf);
+ Collection<TransactionRecord> commitTxs = getCommitTransactionsToUnarchivedBaselineBranchs(teamWf);
Collection<Object> commitMgrInputObjs = combineCommitTransactionsAndConfigItems(configArtSet, commitTxs);
return commitMgrInputObjs;
}
@@ -518,7 +517,7 @@ public abstract class AbstractAtsBranchService implements IAtsBranchService {
return CommitStatus.Branch_Not_Configured;
}
- Collection<TransactionToken> transactions = getCommittedArtifactTransactionIds(teamWf);
+ Collection<? extends TransactionToken> transactions = getCommittedArtifactTransactionIds(teamWf);
boolean mergeBranchExists = isMergeBranchExists(teamWf, destinationBranch);
for (TransactionToken transId : transactions) {
@@ -559,12 +558,12 @@ public abstract class AbstractAtsBranchService implements IAtsBranchService {
* @return TransactionId associated with this state machine artifact
*/
@Override
- public Collection<TransactionToken> getTransactionIds(IAtsTeamWorkflow teamWf, boolean forMergeBranches) {
+ public Collection<TransactionRecord> getTransactionIds(IAtsTeamWorkflow teamWf, boolean forMergeBranches) {
if (forMergeBranches) {
BranchId workingBranch = getWorkingBranch(teamWf);
// grab only the transaction that had merge conflicts
- Collection<TransactionToken> transactionIds = new ArrayList<>();
- for (TransactionToken transactionId : getCommitTransactionsToUnarchivedBaselineBranchs(teamWf)) {
+ Collection<TransactionRecord> transactionIds = new ArrayList<>();
+ for (TransactionRecord transactionId : getCommitTransactionsToUnarchivedBaselineBranchs(teamWf)) {
if (isMergeBranchExists(teamWf, workingBranch, transactionId.getBranch())) {
transactionIds.add(transactionId);
}
@@ -589,7 +588,7 @@ public abstract class AbstractAtsBranchService implements IAtsBranchService {
}
@Override
- public boolean workingBranchCommittedToDestinationBranchParentPriorToDestinationBranchCreation(IAtsTeamWorkflow teamWf, BranchId destinationBranch, Collection<TransactionToken> commitTransactionIds) throws OseeCoreException {
+ public boolean workingBranchCommittedToDestinationBranchParentPriorToDestinationBranchCreation(IAtsTeamWorkflow teamWf, BranchId destinationBranch, Collection<? extends TransactionToken> commitTransactionIds) throws OseeCoreException {
BranchId destinationBranchParent = getParentBranch(destinationBranch);
if (getBranchType(destinationBranchParent) == BranchType.SYSTEM_ROOT) {
return false;
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsBranchServiceImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsBranchServiceImpl.java
index aa383b59fb..8a26dccdee 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsBranchServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/AtsBranchServiceImpl.java
@@ -10,27 +10,28 @@
*******************************************************************************/
package org.eclipse.osee.ats.rest.internal.util;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.LinkedList;
-import java.util.List;
import org.eclipse.osee.ats.api.IAtsServices;
import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
import org.eclipse.osee.ats.core.util.AbstractAtsBranchService;
import org.eclipse.osee.ats.core.workflow.ITeamWorkflowProvidersLazy;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.IOseeBranch;
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.enums.TransactionDetailsType;
+import org.eclipse.osee.framework.core.model.TransactionRecord;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.OrcsApi;
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.search.BranchQuery;
import org.eclipse.osee.orcs.search.TransactionQuery;
@@ -40,12 +41,14 @@ import org.eclipse.osee.orcs.search.TransactionQuery;
public class AtsBranchServiceImpl extends AbstractAtsBranchService {
private final OrcsApi orcsApi;
- private static final HashMap<Integer, List<TransactionToken>> commitArtifactIdMap =
- new HashMap<Integer, List<TransactionToken>>();
+ private final TransactionQuery txQuery;
+ private final HashCollection<ArtifactId, TransactionRecord> commitArtifactIdMap =
+ new HashCollection<>(true, HashSet.class);
public AtsBranchServiceImpl(IAtsServices atsServices, OrcsApi orcsApi, ITeamWorkflowProvidersLazy teamWorkflowProvidersLazy) {
super(atsServices, teamWorkflowProvidersLazy);
this.orcsApi = orcsApi;
+ txQuery = orcsApi.getQueryFactory().transactionQuery();
}
@Override
@@ -126,21 +129,15 @@ public class AtsBranchServiceImpl extends AbstractAtsBranchService {
}
@Override
- public Collection<TransactionToken> getCommittedArtifactTransactionIds(IAtsTeamWorkflow teamWf) {
- ArtifactReadable artifactReadable = (ArtifactReadable) teamWf.getStoreObject();
- List<TransactionToken> transactionIds = commitArtifactIdMap.get(artifactReadable.getUuid());
- // Cache the transactionIds first time through. Other commits will be added to cache as they
- // happen in this client or as remote commit events come through
- if (transactionIds == null) {
- transactionIds = new ArrayList<>(5);
- TransactionQuery txQuery = orcsApi.getQueryFactory().transactionQuery();
- txQuery.andCommitIds(artifactReadable.getLocalId());
- for (TransactionReadable tx : txQuery.getResults()) {
- transactionIds.add(tx);
- }
- commitArtifactIdMap.put(artifactReadable.getLocalId(), transactionIds);
+ public Collection<TransactionRecord> getCommittedArtifactTransactionIds(IAtsTeamWorkflow teamWf) {
+ ArtifactId artifact = teamWf.getStoreObject();
+ if (!commitArtifactIdMap.containsKey(artifact)) {
+ txQuery.andCommitIds(artifact.getId().intValue());
+ txQuery.getResults().forEach(tx -> commitArtifactIdMap.put(artifact, new TransactionRecord(tx.getId(),
+ tx.getBranch(), tx.getComment(), tx.getDate(), tx.getAuthorId(), tx.getCommit(), tx.getTxType())));
}
- return transactionIds;
+ Collection<TransactionRecord> transactions = commitArtifactIdMap.getValues(artifact);
+ return transactions == null ? Collections.emptyList() : transactions;
}
@Override
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsBranchManager.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsBranchManager.java
index 02e898f255..933af5c67d 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsBranchManager.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/AtsBranchManager.java
@@ -37,7 +37,6 @@ import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
-import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.logging.OseeLevel;
import org.eclipse.osee.framework.logging.OseeLog;
@@ -119,10 +118,8 @@ public final class AtsBranchManager {
IOseeBranch workingBranch = AtsClientService.get().getBranchService().getWorkingBranch(teamArt);
MergeView.openView(workingBranch, destinationBranch, BranchManager.getBaseTransaction(workingBranch));
} else if (AtsClientService.get().getBranchService().isCommittedBranchExists(teamArt)) {
- Collection<TransactionToken> transactions =
- AtsClientService.get().getBranchService().getTransactionIds(teamArt, true);
- Collection<TransactionRecord> trs = Collections.castAll(transactions);
- for (TransactionRecord transactionId : trs) {
+ for (TransactionRecord transactionId : AtsClientService.get().getBranchService().getTransactionIds(teamArt,
+ true)) {
if (transactionId.isOnBranch(destinationBranch)) {
MergeView.openView(transactionId);
}
@@ -178,11 +175,10 @@ public final class AtsBranchManager {
*/
public static TransactionToken getTransactionIdOrPopupChoose(TeamWorkFlowArtifact teamArt, String title, boolean showMergeManager) throws OseeCoreException {
Collection<TransactionToken> transactionIds = new HashSet<>();
- Collection<TransactionToken> transactions =
+ Collection<TransactionRecord> transactions =
AtsClientService.get().getBranchService().getTransactionIds(teamArt, showMergeManager);
- Collection<TransactionRecord> trs = Collections.castAll(transactions);
- for (TransactionRecord id : trs) {
+ for (TransactionRecord id : transactions) {
// ignore working branches that have been committed or re-baselined (e.g. update form parent branch)
boolean workingBranch = BranchManager.getType(id).isWorkingBranch();
BranchState state = BranchManager.getState(id.getBranch());
@@ -247,10 +243,8 @@ public final class AtsBranchManager {
*/
public static void showChangeReportForBranch(TeamWorkFlowArtifact teamArt, BranchId destinationBranch) {
try {
- Collection<TransactionToken> transactions =
- AtsClientService.get().getBranchService().getTransactionIds(teamArt, false);
- Collection<TransactionRecord> trs = Collections.castAll(transactions);
- for (TransactionRecord transactionId : trs) {
+ for (TransactionToken transactionId : AtsClientService.get().getBranchService().getTransactionIds(teamArt,
+ false)) {
if (transactionId.isOnBranch(destinationBranch)) {
ChangeUiUtil.open(transactionId);
}
@@ -300,7 +294,7 @@ public final class AtsBranchManager {
transactionId = AtsClientService.get().getBranchService().getEarliestTransactionId(teamArt);
} else {
Collection<TransactionRecord> transIds =
- Collections.castAll(AtsClientService.get().getBranchService().getTransactionIds(teamArt, false));
+ AtsClientService.get().getBranchService().getTransactionIds(teamArt, false);
if (transIds.size() == 1) {
transactionId = transIds.iterator().next();
} else {
diff --git a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/commit/XCommitLabelProvider.java b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/commit/XCommitLabelProvider.java
index f98bd2e07d..a0a3749a05 100644
--- a/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/commit/XCommitLabelProvider.java
+++ b/plugins/org.eclipse.osee.ats/src/org/eclipse/osee/ats/util/widgets/commit/XCommitLabelProvider.java
@@ -32,7 +32,6 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.DateUtil;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
-import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
import org.eclipse.osee.framework.ui.skynet.FrameworkImage;
import org.eclipse.osee.framework.ui.swt.ImageManager;
import org.eclipse.swt.graphics.Image;
@@ -180,7 +179,7 @@ public class XCommitLabelProvider extends XViewerLabelProvider {
private TransactionRecord getTransactionRecord(BranchId branch) {
IAtsBranchService service = AtsClientService.get().getBranchService();
IAtsTeamWorkflow teamWf = commitXManager.getXCommitViewer().getTeamArt();
- return TransactionManager.getTransaction(service.getCommitTransactionRecord(teamWf, branch));
+ return service.getCommitTransactionRecord(teamWf, branch);
}
private String handleDestBranchColumn(Object element, BranchId branchToken) {
diff --git a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ArtifactRendererTest.java b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ArtifactRendererTest.java
index 4fbc88414e..de5f044b7a 100644
--- a/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ArtifactRendererTest.java
+++ b/plugins/org.eclipse.osee.client.integration.tests/src/org/eclipse/osee/client/integration/tests/integration/ui/skynet/ArtifactRendererTest.java
@@ -11,19 +11,17 @@
package org.eclipse.osee.client.integration.tests.integration.ui.skynet;
import static org.eclipse.osee.client.demo.DemoChoice.OSEE_CLIENT_DEMO;
+import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
import java.util.Arrays;
import org.eclipse.osee.client.test.framework.OseeClientIntegrationRule;
import org.eclipse.osee.client.test.framework.OseeLogMonitorRule;
import org.eclipse.osee.client.test.framework.TestInfo;
import org.eclipse.osee.framework.core.data.TransactionToken;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
-import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.model.TransactionDelta;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.GUID;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.change.ArtifactChange;
@@ -62,16 +60,14 @@ public class ArtifactRendererTest {
@Before
public void setUp() throws OseeCoreException {
- startTx = TransactionManager.getHeadTransaction(CoreBranches.COMMON);
- artifact1 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Artifact, CoreBranches.COMMON, NAME1, GUID.create(),
- Lib.generateArtifactIdAsInt());
+ startTx = TransactionManager.getHeadTransaction(COMMON);
+ artifact1 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Artifact, COMMON, NAME1);
String comment1 = getClass().getSimpleName() + "_1";
artifact1.persist(comment1);
endTx1 = TransactionManager.getTransaction(comment1).iterator().next();
endTx1.setCommit(artifact1.getArtId());
- artifact2 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Artifact, CoreBranches.COMMON, NAME2, GUID.create(),
- Lib.generateArtifactIdAsInt());
+ artifact2 = ArtifactTypeManager.addArtifact(CoreArtifactTypes.Artifact, COMMON, NAME2);
String comment2 = getClass().getSimpleName() + "_2";
artifact2.persist(comment2);
endTx2 = TransactionManager.getTransaction(comment2).iterator().next();
@@ -83,7 +79,7 @@ public class ArtifactRendererTest {
TransactionDelta deltaTx = new TransactionDelta(startTx, endTx1);
ArtifactDelta delta = new ArtifactDelta(null, artifact2, artifact1);
- Change change = new ArtifactChange(CoreBranches.COMMON, artifact1.getGammaId(), artifact1.getArtId(), deltaTx,
+ Change change = new ArtifactChange(COMMON, artifact1.getGammaId(), artifact1.getArtId(), deltaTx,
ModificationType.MODIFIED, false, artifact1, delta);
String name = RenderingUtil.getAssociatedArtifactName(Arrays.asList(change));
@@ -94,7 +90,7 @@ public class ArtifactRendererTest {
public void testAssociatedArtifact_notAllowedSingleQuotes() throws Exception {
TransactionDelta deltaTx = new TransactionDelta(startTx, endTx2);
ArtifactDelta delta = new ArtifactDelta(null, artifact1, artifact2);
- Change change = new ArtifactChange(CoreBranches.COMMON, artifact2.getGammaId(), artifact2.getArtId(), deltaTx,
+ Change change = new ArtifactChange(COMMON, artifact2.getGammaId(), artifact2.getArtId(), deltaTx,
ModificationType.MODIFIED, false, artifact2, delta);
String name = RenderingUtil.getAssociatedArtifactName(Arrays.asList(change));
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/cache/BranchCacheTest.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/cache/BranchCacheTest.java
index a9357bfc54..ed804fe8d4 100644
--- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/cache/BranchCacheTest.java
+++ b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/cache/BranchCacheTest.java
@@ -35,7 +35,7 @@ public class BranchCacheTest extends AbstractOseeCacheTest<Branch> {
branchData = new ArrayList<>();
BranchDataAccessor branchAccessor = new BranchDataAccessor(branchData);
- cache = new BranchCache(branchAccessor, new TransactionCache());
+ cache = new BranchCache(branchAccessor);
cache.ensurePopulated();
Assert.assertTrue(branchAccessor.wasLoaded());
diff --git a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockOseeTransactionDataAccessor.java b/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockOseeTransactionDataAccessor.java
deleted file mode 100644
index 50d5e13764..0000000000
--- a/plugins/org.eclipse.osee.framework.core.model.test/src/org/eclipse/osee/framework/core/model/mocks/MockOseeTransactionDataAccessor.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.model.mocks;
-
-import java.util.Collection;
-import org.eclipse.osee.framework.core.data.BranchId;
-import org.eclipse.osee.framework.core.data.TransactionId;
-import org.eclipse.osee.framework.core.enums.TransactionVersion;
-import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.core.model.cache.ITransactionDataAccessor;
-import org.eclipse.osee.framework.core.model.cache.TransactionCache;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public class MockOseeTransactionDataAccessor implements ITransactionDataAccessor {
-
- private boolean wasLoadCalled = false;
- private boolean wasStoreCalled = false;
-
- public void setLoadCalled(boolean wasLoadCalled) {
- this.wasLoadCalled = wasLoadCalled;
- }
-
- public void setStoreCalled(boolean wasStoreCalled) {
- this.wasStoreCalled = wasStoreCalled;
- }
-
- public boolean wasLoaded() {
- return wasLoadCalled;
- }
-
- public boolean wasStoreCalled() {
- return wasStoreCalled;
- }
-
- // @Override
- // public void load(AbstractOseeCache<T> cache) throws OseeCoreException {
- // Assert.assertNotNull(cache);
- // setLoadCalled(true);
- // }
- //
- // @Override
- // public void store(Collection<T> types) throws OseeCoreException {
- // Assert.assertNotNull(types);
- // setStoreCalled(true);
- // }
-
- @Override
- public void loadTransactionRecords(TransactionCache cache, Collection<Long> transactionIds) throws OseeCoreException {
- wasLoadCalled = true;
- }
-
- @Override
- public TransactionRecord loadTransactionRecord(TransactionCache cache, BranchId branch, TransactionVersion transactionType) throws OseeCoreException {
- return null;
- }
-
- @Override
- public void load(TransactionCache transactionCache) throws OseeCoreException {
- // Empty
- }
-
- @Override
- public TransactionRecord getOrLoadPriorTransaction(TransactionCache cache, TransactionId transactionNumber, long branchUuid) throws OseeCoreException {
- return null;
- }
-
- @Override
- public TransactionRecord getHeadTransaction(TransactionCache cache, BranchId branch) throws OseeCoreException {
- return null;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecord.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecord.java
index 76f7097769..3f855acda7 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecord.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecord.java
@@ -16,12 +16,15 @@ import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.TransactionToken;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.jdk.core.type.BaseId;
+import org.eclipse.osee.framework.jdk.core.type.Id;
import org.eclipse.osee.framework.jdk.core.util.Strings;
/**
* @author Jeff C. Phillips
*/
public class TransactionRecord extends BaseId implements TransactionToken, Adaptable {
+ public static TransactionRecord SENTINEL =
+ new TransactionRecord(Id.SENTINEL, BranchId.SENTINEL, null, null, 0, 0, TransactionDetailsType.INVALID);
private final TransactionDetailsType txType;
private final BranchId branch;
private String comment;
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecordFactory.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecordFactory.java
deleted file mode 100644
index e31fe62f9f..0000000000
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/TransactionRecordFactory.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.model;
-
-import java.util.Date;
-import org.eclipse.osee.framework.core.data.BranchId;
-import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
-import org.eclipse.osee.framework.core.model.cache.IOseeTypeFactory;
-import org.eclipse.osee.framework.core.model.cache.TransactionCache;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TransactionRecordFactory implements IOseeTypeFactory {
-
- public TransactionRecord create(Long transaction, BranchId branch, String comment, Date timestamp, int authorArtId, int commitArtId, TransactionDetailsType txType) throws OseeCoreException {
- return new TransactionRecord(transaction, branch, comment, timestamp, authorArtId, commitArtId, txType);
- }
-
- public TransactionRecord createOrUpdate(TransactionCache txCache, Long transaction, BranchId branch, String comment, Date timestamp, int authorArtId, int commitArtId, TransactionDetailsType txType) throws OseeCoreException {
- Conditions.checkNotNull(txCache, "txCache");
- TransactionRecord record = txCache.getById(transaction);
- if (record == null) {
- record = create(transaction, branch, comment, timestamp, authorArtId, commitArtId, txType);
- } else {
- txCache.decache(record);
- record.setAuthor(authorArtId);
- record.setComment(comment);
- record.setCommit(commitArtId);
- record.setTimeStamp(timestamp);
- }
- txCache.cache(record);
- return record;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/BranchCache.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/BranchCache.java
index 137b16b732..533c121968 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/BranchCache.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/BranchCache.java
@@ -27,11 +27,8 @@ import org.eclipse.osee.framework.jdk.core.util.Conditions;
*/
public class BranchCache extends AbstractOseeLoadingCache<Branch> {
- private final TransactionCache txCache;
-
- public BranchCache(IOseeDataAccessor<Branch> dataAccessor, TransactionCache txCache) {
+ public BranchCache(IOseeDataAccessor<Branch> dataAccessor) {
super(OseeCacheEnum.BRANCH_CACHE, dataAccessor);
- this.txCache = txCache;
}
public MergeBranch findMergeBranch(BranchId sourceBranch, BranchId destinationBranch) throws OseeCoreException {
@@ -83,17 +80,4 @@ public class BranchCache extends AbstractOseeLoadingCache<Branch> {
public synchronized List<Branch> getBranches(Predicate<Branch> branchFilter) {
return getRawValues().stream().filter(branchFilter).collect(Collectors.toList());
}
-
- @Override
- public synchronized boolean reloadCache() throws OseeCoreException {
- super.reloadCache();
- txCache.reloadCache();
- return true;
- }
-
- @Override
- public synchronized void decacheAll() {
- super.decacheAll();
- txCache.decacheAll();
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/ITransactionDataAccessor.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/ITransactionDataAccessor.java
deleted file mode 100644
index 19b509a576..0000000000
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/ITransactionDataAccessor.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.model.cache;
-
-import java.util.Collection;
-import org.eclipse.osee.framework.core.data.BranchId;
-import org.eclipse.osee.framework.core.data.TransactionId;
-import org.eclipse.osee.framework.core.enums.TransactionVersion;
-import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-
-/**
- * @author Roberto E. Escobar
- */
-public interface ITransactionDataAccessor {
-
- /**
- * Loads a specific set of transaction records
- *
- * @param cache to populate
- * @param transaction ids to load
- */
- public void loadTransactionRecords(TransactionCache cache, Collection<Long> transactionIds) throws OseeCoreException;
-
- /**
- * Load a specific branch transaction type
- *
- * @see {@link TransactionVersion}
- * @param cache to populate
- * @param branch to load
- * @param transactionType transaction type to load, can be {@link TransactionVersion#HEAD} or
- * {@link TransactionVersion#BASE}
- */
- public TransactionRecord loadTransactionRecord(TransactionCache cache, BranchId branch, TransactionVersion transactionType) throws OseeCoreException;
-
- public void load(TransactionCache transactionCache) throws OseeCoreException;
-
- public TransactionRecord getOrLoadPriorTransaction(TransactionCache cache, TransactionId transactionNumber, long branchUuid) throws OseeCoreException;
-
- public TransactionRecord getHeadTransaction(TransactionCache cache, BranchId branch) throws OseeCoreException;
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/TransactionCache.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/TransactionCache.java
deleted file mode 100644
index dabd059376..0000000000
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/model/cache/TransactionCache.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 Boeing.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Boeing - initial API and implementation
- *******************************************************************************/
-package org.eclipse.osee.framework.core.model.cache;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.logging.Level;
-import org.eclipse.osee.framework.core.data.TransactionToken;
-import org.eclipse.osee.framework.core.enums.OseeCacheEnum;
-import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
-import org.eclipse.osee.framework.jdk.core.util.Conditions;
-import org.eclipse.osee.framework.logging.OseeLog;
-
-/**
- * @author Roberto E. Escobar
- */
-public class TransactionCache implements IOseeLoadingCache<TransactionRecord> {
- private ITransactionDataAccessor accessor;
-
- private final Map<Long, TransactionRecord> transactionIdCache = new ConcurrentHashMap<>();
-
- private final OseeCacheEnum cacheId;
- private final AtomicBoolean wasLoaded;
- private long lastLoaded;
-
- public TransactionCache() {
- this.lastLoaded = 0;
- this.cacheId = OseeCacheEnum.TRANSACTION_CACHE;
- this.wasLoaded = new AtomicBoolean(false);
- }
-
- public void setAccessor(ITransactionDataAccessor accessor) {
- this.accessor = accessor;
- }
-
- @Override
- public void cache(TransactionRecord... types) throws OseeCoreException {
- Conditions.checkNotNull(types, "types to cache");
- for (TransactionRecord type : types) {
- cache(type);
- }
- }
-
- @Override
- public void cache(TransactionRecord type) throws OseeCoreException {
- Conditions.checkNotNull(type, "type to cache");
- ensurePopulated();
- transactionIdCache.put(type.getId(), type);
- }
-
- @Override
- public void decache(TransactionRecord... types) throws OseeCoreException {
- Conditions.checkNotNull(types, "types to de-cache");
- for (TransactionRecord type : types) {
- decache(type);
- }
- }
-
- @Override
- public void decache(TransactionRecord type) throws OseeCoreException {
- Conditions.checkNotNull(type, "type to de-cache");
- if (type.isValid()) {
- transactionIdCache.remove(type.getId());
- }
- }
-
- @Override
- public Collection<TransactionRecord> getAll() throws OseeCoreException {
- ensurePopulated();
- return new ArrayList<TransactionRecord>(transactionIdCache.values());
- }
-
- public TransactionRecord getOrLoad(long txId) throws OseeCoreException {
- TransactionRecord transactionRecord = getById(txId);
- if (transactionRecord == null) {
- loadTransactions(Collections.singletonList(txId));
- transactionRecord = getById(txId);
- if (transactionRecord == null) {
- throw new OseeStateException("Transaction Record[%s] was not found", txId);
- }
- }
- return transactionRecord;
- }
-
- @Override
- public TransactionRecord getById(Number txId) throws OseeCoreException {
- ensurePopulated();
- return transactionIdCache.get(txId);
- }
-
- @Override
- public TransactionRecord getByGuid(Long guid) throws OseeCoreException {
- throw new OseeStateException("TransactionCache.getByGuid() is not implemented...");
- }
-
- @Override
- public OseeCacheEnum getCacheId() {
- return cacheId;
- }
-
- @Override
- public int size() {
- return transactionIdCache.size();
- }
-
- public TransactionRecord getPriorTransaction(TransactionToken transactionId) throws OseeCoreException {
- return accessor.getOrLoadPriorTransaction(this, transactionId, transactionId.getBranchId());
- }
-
- public void loadTransactions(Collection<Long> transactionIds) throws OseeCoreException {
- ensurePopulated();
-
- List<Long> toLoad = new LinkedList<>();
- for (Long txId : transactionIds) {
- if (getById(txId) == null) {
- toLoad.add(txId);
- }
- }
-
- if (!toLoad.isEmpty()) {
- accessor.loadTransactionRecords(this, toLoad);
- }
- }
-
- private synchronized void ensurePopulated() throws OseeCoreException {
- if (wasLoaded.compareAndSet(false, true)) {
- reloadCache();
- }
- }
-
- @Override
- public long getLastLoaded() {
- return lastLoaded;
- }
-
- private synchronized void setLastLoaded(long lastLoaded) {
- this.lastLoaded = lastLoaded;
- }
-
- @Override
- public synchronized boolean reloadCache() throws OseeCoreException {
- if (accessor != null) {
- accessor.load(this);
- } else {
- OseeLog.log(this.getClass(), Level.WARNING, "Transaction Data Accessor was null");
- }
- OseeLog.log(this.getClass(), Level.INFO, "Loaded " + getCacheId().toString().toLowerCase());
- setLastLoaded(System.currentTimeMillis());
- return true;
- }
-
- @Override
- public void decacheAll() {
- transactionIdCache.clear();
- invalidate();
- }
-
- @Override
- public boolean isLoaded() {
- return wasLoaded.get();
- }
-
- @Override
- public void invalidate() {
- wasLoaded.set(false);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/IOseeCachingService.java b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/IOseeCachingService.java
index c37bf8d57a..6a45cfa2b0 100644
--- a/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/IOseeCachingService.java
+++ b/plugins/org.eclipse.osee.framework.core.model/src/org/eclipse/osee/framework/core/services/IOseeCachingService.java
@@ -18,7 +18,6 @@ import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.framework.core.model.cache.IOseeCache;
import org.eclipse.osee.framework.core.model.cache.OseeEnumTypeCache;
import org.eclipse.osee.framework.core.model.cache.RelationTypeCache;
-import org.eclipse.osee.framework.core.model.cache.TransactionCache;
/**
* @author Roberto E. Escobar
@@ -35,8 +34,6 @@ public interface IOseeCachingService {
BranchCache getBranchCache();
- TransactionCache getTransactionCache();
-
Collection<?> getCaches();
IOseeCache<?> getCache(OseeCacheEnum cacheId);
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/GammaId.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/GammaId.java
new file mode 100644
index 0000000000..554f7eddd6
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/data/GammaId.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.core.data;
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.eclipse.osee.framework.jdk.core.type.BaseId;
+import org.eclipse.osee.framework.jdk.core.type.Id;
+
+/**
+ * @author Ryan D. Brooks
+ */
+public interface GammaId extends Id {
+
+ public static GammaId valueOf(String id) {
+ return valueOf(Long.valueOf(id));
+ }
+
+ @JsonCreator
+ public static GammaId valueOf(long id) {
+ final class GammaIdImpl extends BaseId implements GammaId {
+ public GammaIdImpl(Long id) {
+ super(id);
+ }
+ }
+ return new GammaIdImpl(id);
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/sql/OseeSql.java b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/sql/OseeSql.java
index 937c17519a..19fe18284e 100644
--- a/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/sql/OseeSql.java
+++ b/plugins/org.eclipse.osee.framework.core/src/org/eclipse/osee/framework/core/sql/OseeSql.java
@@ -21,8 +21,6 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
*/
public enum OseeSql {
- TX_GET_ALL_TRANSACTIONS("SELECT * FROM osee_tx_details WHERE transaction_id = ?"),
- TX_GET_MAX_AS_LARGEST_TX("SELECT max(transaction_id) as largest_transaction_id FROM osee_tx_details WHERE branch_id = ?"),
TX_GET_PREVIOUS_TX_NOT_CURRENT_ARTIFACTS("SELECT txs.transaction_id, txs.gamma_id FROM osee_artifact art, osee_txs txs WHERE art.art_id = ? AND art.gamma_id = txs.gamma_id AND txs.branch_id = ? AND txs.tx_current <> " + TxChange.NOT_CURRENT.getValue()),
TX_GET_PREVIOUS_TX_NOT_CURRENT_ATTRIBUTES("SELECT txs.transaction_id, txs.gamma_id FROM osee_attribute atr, osee_txs txs WHERE atr.attr_id = ? AND atr.gamma_id = txs.gamma_id AND txs.branch_id = ? AND txs.tx_current <> " + TxChange.NOT_CURRENT.getValue()),
TX_GET_PREVIOUS_TX_NOT_CURRENT_RELATIONS("SELECT txs.transaction_id, txs.gamma_id FROM osee_relation_link rel, osee_txs txs WHERE rel.rel_link_id = ? AND rel.gamma_id = txs.gamma_id AND txs.branch_id = ? AND txs.tx_current <> " + TxChange.NOT_CURRENT.getValue()),
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
index 14e7a955fa..0ce10d398e 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/ArtifactLoader.java
@@ -346,7 +346,7 @@ public final class ArtifactLoader {
List<Artifact> artifacts = new ArrayList<>(1);
artifacts.add(artifact);
- loadArtifactsData(joinQuery.getQueryId(), artifacts, loadLevel, LoadType.INCLUDE_CACHE, null,
+ loadArtifactsData(joinQuery.getQueryId(), artifacts, loadLevel, LoadType.INCLUDE_CACHE, TransactionId.SENTINEL,
artifact.isDeleted() ? DeletionFlag.INCLUDE_DELETED : DeletionFlag.EXCLUDE_DELETED, isArchived);
} finally {
joinQuery.delete();
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
index f6f95a2b40..2ecf8aea04 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/artifact/search/ArtifactQuery.java
@@ -59,7 +59,6 @@ import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
import org.eclipse.osee.framework.skynet.core.event.OseeEventManager;
import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidArtifact;
import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil;
-import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
import org.eclipse.osee.orcs.rest.client.OseeClient;
import org.eclipse.osee.orcs.rest.client.QueryBuilder;
import org.eclipse.osee.orcs.rest.model.search.artifact.RequestType;
@@ -674,7 +673,7 @@ public class ArtifactQuery {
TransactionId tx = TransactionId.SENTINEL;
if (searchParameters.getFromTx() > 0) {
- tx = TransactionManager.getTransaction(searchParameters.getFromTx());
+ tx = TransactionId.valueOf(searchParameters.getFromTx());
}
DeletionFlag deletionFlag =
searchParameters.isIncludeDeleted() ? DeletionFlag.INCLUDE_DELETED : DeletionFlag.EXCLUDE_DELETED;
@@ -701,7 +700,7 @@ public class ArtifactQuery {
TransactionId tx = TransactionId.SENTINEL;
if (searchParameters.getFromTx() > 0) {
- tx = TransactionManager.getTransaction(searchParameters.getFromTx());
+ tx = TransactionId.valueOf(searchParameters.getFromTx());
}
DeletionFlag deletionFlag =
searchParameters.isIncludeDeleted() ? DeletionFlag.INCLUDE_DELETED : DeletionFlag.EXCLUDE_DELETED;
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/PurgeTransactionEventUtil.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/PurgeTransactionEventUtil.java
index b0437568a9..b04c65da4c 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/PurgeTransactionEventUtil.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/event/PurgeTransactionEventUtil.java
@@ -25,7 +25,6 @@ import org.eclipse.osee.framework.skynet.core.event.model.TransactionChange;
import org.eclipse.osee.framework.skynet.core.event.model.TransactionEvent;
import org.eclipse.osee.framework.skynet.core.event.model.TransactionEventType;
import org.eclipse.osee.framework.skynet.core.internal.Activator;
-import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
/**
* @author Roberto E. Escobar
@@ -48,12 +47,6 @@ public final class PurgeTransactionEventUtil {
Set<Artifact> artifactsInCache = new HashSet<>();
for (TransactionChange transChange : transEvent.getTransactionChanges()) {
- try {
- TransactionManager.deCache(transChange.getTransactionId());
- } catch (OseeCoreException ex1) {
- OseeLog.log(Activator.class, Level.SEVERE, ex1);
- }
-
for (DefaultBasicGuidArtifact guidArt : transChange.getArtifacts()) {
try {
Artifact artifact = ArtifactCache.getActive(guidArt);
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/BaseArtifactLoopbackCmd.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/BaseArtifactLoopbackCmd.java
index 46c7a216ab..f985cf9d56 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/BaseArtifactLoopbackCmd.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/BaseArtifactLoopbackCmd.java
@@ -16,7 +16,6 @@ import java.net.HttpURLConnection;
import java.util.Map;
import org.eclipse.osee.framework.core.client.server.HttpResponse;
import org.eclipse.osee.framework.core.data.BranchId;
-import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.data.TransactionToken;
import org.eclipse.osee.framework.core.enums.DeletionFlag;
import org.eclipse.osee.framework.jdk.core.util.Strings;
@@ -46,12 +45,11 @@ public abstract class BaseArtifactLoopbackCmd implements IClientLoopbackCmd {
final Artifact artifact;
final BranchId branch;
if (Strings.isValid(transactionIdStr)) {
- int transactionNumber = Integer.parseInt(transactionIdStr);
- TransactionToken transactionId = TransactionManager.getTransaction(transactionNumber);
- branch = transactionId.getBranch();
- artifact = ArtifactQuery.getHistoricalArtifactFromId(guid, transactionId, searchDeleted);
+ TransactionToken transaction = TransactionManager.getTransaction(Long.valueOf(transactionIdStr));
+ branch = transaction.getBranch();
+ artifact = ArtifactQuery.getHistoricalArtifactFromId(guid, transaction, searchDeleted);
} else {
- branch = TokenFactory.createBranch(Long.parseLong(branchUuid));
+ branch = BranchId.valueOf(branchUuid);
artifact = ArtifactQuery.getArtifactFromId(guid, branch, searchDeleted);
}
if (artifact == null) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java
index 321a60af11..699523bde3 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/httpRequests/CommitBranchHttpRequestOperation.java
@@ -130,7 +130,7 @@ public final class CommitBranchHttpRequestOperation extends AbstractOperation {
}
private void handleResponse(Long newTxId, IProgressMonitor monitor, BranchId sourceBranch, BranchId destinationBranch) throws OseeCoreException {
- TransactionToken newTransaction = TransactionManager.getTransaction(newTxId);
+ TransactionToken newTransaction = TransactionToken.valueOf(newTxId, destinationBranch);
AccessPolicy accessPolicy = ServiceUtil.getAccessPolicy();
accessPolicy.removePermissions(sourceBranch);
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ClientCachingServiceProxy.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ClientCachingServiceProxy.java
index 1a1e289258..1221826f1e 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ClientCachingServiceProxy.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/ClientCachingServiceProxy.java
@@ -19,20 +19,17 @@ import java.util.List;
import java.util.logging.Level;
import javax.ws.rs.core.Response;
import org.eclipse.osee.framework.core.enums.OseeCacheEnum;
-import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
import org.eclipse.osee.framework.core.model.cache.ArtifactTypeCache;
import org.eclipse.osee.framework.core.model.cache.AttributeTypeCache;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.framework.core.model.cache.IOseeCache;
import org.eclipse.osee.framework.core.model.cache.OseeEnumTypeCache;
import org.eclipse.osee.framework.core.model.cache.RelationTypeCache;
-import org.eclipse.osee.framework.core.model.cache.TransactionCache;
import org.eclipse.osee.framework.core.services.IOseeCachingService;
import org.eclipse.osee.framework.jdk.core.type.OseeArgumentException;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.logging.OseeLog;
import org.eclipse.osee.framework.skynet.core.internal.accessors.DatabaseBranchAccessor;
-import org.eclipse.osee.framework.skynet.core.internal.accessors.DatabaseTransactionRecordAccessor;
import org.eclipse.osee.jaxrs.client.JaxRsExceptions;
import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.jdbc.JdbcService;
@@ -52,7 +49,6 @@ public class ClientCachingServiceProxy implements IOseeCachingService {
private OseeClient oseeClient;
private BranchCache branchCache;
- private TransactionCache txCache;
private OseeEnumTypeCache enumTypeCache;
private AttributeTypeCache attributeTypeCache;
@@ -72,9 +68,7 @@ public class ClientCachingServiceProxy implements IOseeCachingService {
public void start() {
JdbcClient jdbcClient = jdbcService.getClient();
- txCache = new TransactionCache();
- txCache.setAccessor(new DatabaseTransactionRecordAccessor(jdbcClient, txCache, new TransactionRecordFactory()));
- branchCache = new BranchCache(new DatabaseBranchAccessor(jdbcClient, txCache), txCache);
+ branchCache = new BranchCache(new DatabaseBranchAccessor(jdbcClient));
artifactTypeCache = new ArtifactTypeCache();
enumTypeCache = new OseeEnumTypeCache();
@@ -83,7 +77,6 @@ public class ClientCachingServiceProxy implements IOseeCachingService {
caches = new ArrayList<>();
caches.add(branchCache);
- caches.add(txCache);
caches.add(artifactTypeCache);
caches.add(attributeTypeCache);
caches.add(relationTypeCache);
@@ -99,7 +92,6 @@ public class ClientCachingServiceProxy implements IOseeCachingService {
artifactTypeCache = null;
branchCache = null;
- txCache = null;
}
@Override
@@ -108,11 +100,6 @@ public class ClientCachingServiceProxy implements IOseeCachingService {
}
@Override
- public TransactionCache getTransactionCache() {
- return txCache;
- }
-
- @Override
public ArtifactTypeCache getArtifactTypeCache() {
return artifactTypeCache;
}
@@ -170,15 +157,12 @@ public class ClientCachingServiceProxy implements IOseeCachingService {
@Override
public void reloadAll() {
getBranchCache().reloadCache();
- getTransactionCache().reloadCache();
-
reloadTypes();
}
@Override
public void clearAll() {
getBranchCache().decacheAll();
- getTransactionCache().decacheAll();
clearAllTypes();
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseBranchAccessor.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseBranchAccessor.java
index 397bffc8ca..d074c2cead 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseBranchAccessor.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseBranchAccessor.java
@@ -2,26 +2,18 @@ package org.eclipse.osee.framework.skynet.core.internal.accessors;
import static org.eclipse.osee.framework.core.enums.CoreBranches.SYSTEM_ROOT;
import static org.eclipse.osee.jdbc.JdbcConstants.JDBC__MAX_FETCH_SIZE;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.function.Consumer;
+import java.util.Date;
import org.eclipse.osee.framework.core.enums.BranchArchivedState;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.BranchType;
-import org.eclipse.osee.framework.core.enums.StorageState;
+import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.exception.BranchDoesNotExist;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.MergeBranch;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.model.cache.IOseeCache;
import org.eclipse.osee.framework.core.model.cache.IOseeDataAccessor;
-import org.eclipse.osee.framework.core.model.cache.TransactionCache;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.skynet.core.artifact.BranchManager;
-import org.eclipse.osee.framework.skynet.core.transaction.TransactionManager;
import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler;
import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.jdbc.JdbcStatement;
@@ -30,60 +22,70 @@ import org.eclipse.osee.jdbc.JdbcStatement;
* @author Roberto E. Escobar
*/
public class DatabaseBranchAccessor implements IOseeDataAccessor<Branch> {
- private static final String SELECT_BRANCHES = "SELECT * FROM osee_branch";
- private static final String SELECT_BRANCH = SELECT_BRANCHES + " where branch_id = ?";
- private static final String SELECT_MERGE_BRANCHES = "SELECT * FROM osee_merge";
+ private static final String SELECT_BRANCHES =
+ "with%s recurse (id, branch_level) as (select 1, 1 from osee_branch where branch_id = 1 UNION ALL select branch_id, branch_level + 1 from recurse, osee_branch where parent_branch_id = recurse.id) select br.*, parTx.tx_type as p_tx_type, parTx.author as p_author, parTx.time as p_time, parTx.osee_comment as p_osee_comment, parTx.commit_art_id as p_commit_art_id, baseTx.tx_type as b_tx_type, baseTx.author as b_author, baseTx.time as b_time, baseTx.osee_comment as b_osee_comment, baseTx.commit_art_id as b_commit_art_id, source_branch_id, dest_branch_id from recurse, osee_branch br left outer join osee_merge on merge_branch_id = branch_id, osee_tx_details baseTx, osee_tx_details parTx where parent_transaction_id = parTx.transaction_id and baseline_transaction_id = baseTx.transaction_id and br.branch_id = recurse.id order by branch_level";
+ private static final String SELECT_BRANCH =
+ "select br.*, parTx.tx_type as p_tx_type, parTx.author as p_author, parTx.time as p_time, parTx.osee_comment as p_osee_comment, parTx.commit_art_id as p_commit_art_id, baseTx.tx_type as b_tx_type, baseTx.author as b_author, baseTx.time as b_time, baseTx.osee_comment as b_osee_comment, baseTx.commit_art_id as b_commit_art_id, source_branch_id, dest_branch_id from osee_branch br left outer join osee_merge on merge_branch_id = branch_id, osee_tx_details baseTx, osee_tx_details parTx where parent_transaction_id = parTx.transaction_id and baseline_transaction_id = baseTx.transaction_id and br.branch_id = ?";
private final JdbcClient jdbcClient;
- private final TransactionCache txCache;
- public DatabaseBranchAccessor(JdbcClient jdbcClient, TransactionCache txCache) {
+ public DatabaseBranchAccessor(JdbcClient jdbcClient) {
this.jdbcClient = jdbcClient;
- this.txCache = txCache;
- }
-
- private JdbcClient getJdbcClient() {
- return jdbcClient;
}
@Override
public void load(IOseeCache<Branch> cache) throws OseeCoreException {
- Map<Branch, Long> childToParent = new HashMap<>();
- Map<Branch, Long> branchToBaseTx = new HashMap<>();
- Map<Branch, Long> branchToSourceTx = new HashMap<>();
-
- loadBranches(cache, childToParent, branchToBaseTx, branchToSourceTx);
- loadBranchHierarchy(cache, childToParent);
- loadMergeBranches(cache);
- loadBranchRelatedTransactions(branchToBaseTx, branchToSourceTx);
+ String sql = String.format(SELECT_BRANCHES, jdbcClient.getDbType().getRecursiveWithSql());
+ jdbcClient.runQuery(stmt -> cache.cache(load(cache, stmt)), JDBC__MAX_FETCH_SIZE, sql);
}
- private void loadBranches(IOseeCache<Branch> cache, Map<Branch, Long> childToParent, Map<Branch, Long> branchToBaseTx, Map<Branch, Long> branchToSourceTx) {
- getJdbcClient().runQuery(stmt -> {
- Branch branch = load(cache, stmt);
- cache.cache(branch);
- if (!SYSTEM_ROOT.equals(branch)) {
- childToParent.put(branch, stmt.getLong("parent_branch_id"));
- }
- branchToSourceTx.put(branch, stmt.getLong("parent_transaction_id"));
- branchToBaseTx.put(branch, stmt.getLong("baseline_transaction_id"));
- }, JDBC__MAX_FETCH_SIZE, SELECT_BRANCHES);
+ public static Branch loadBranch(IOseeCache<Branch> cache, Long branchId) {
+ return ConnectionHandler.getJdbcClient().fetchOrException(
+ () -> new BranchDoesNotExist("Branch could not be acquired for branch id %d", branchId),
+ stmt -> load(cache, stmt), SELECT_BRANCH, branchId);
}
- private static Branch create(Long branchId, String name, BranchType branchType, BranchState branchState, boolean isArchived, boolean inheritAccessControl) throws OseeCoreException {
- Branch toReturn;
- if (branchType.isMergeBranch()) {
- toReturn = new MergeBranch(branchId, name, branchType, branchState, isArchived, inheritAccessControl);
+ private static Branch load(IOseeCache<Branch> cache, JdbcStatement stmt) {
+ Branch branch = createOrUpdate(cache, stmt);
+
+ Branch parentBranch;
+ Branch sourceTxBranch;
+ if (branch.equals(SYSTEM_ROOT)) {
+ sourceTxBranch = branch;
} else {
- toReturn = new Branch(branchId, name, branchType, branchState, isArchived, inheritAccessControl);
+ parentBranch = cache.getById(stmt.getLong("parent_branch_id"));
+ sourceTxBranch = parentBranch;
+ branch.setParentBranch(parentBranch);
}
- return toReturn;
+ branch.setBaseTransaction(createTx(true, branch, stmt));
+ branch.setSourceTransaction(createTx(false, sourceTxBranch, stmt));
+
+ return branch;
}
- private static Branch createOrUpdate(IOseeCache<Branch> cache, Long branchId, String name, BranchType branchType, BranchState branchState, boolean isArchived, StorageState storageState, boolean inheritAccessControl, Integer artifactId) throws OseeCoreException {
+ private static Branch createOrUpdate(IOseeCache<Branch> cache, JdbcStatement stmt) {
+ Long branchId = stmt.getLong("branch_id");
+ String name = stmt.getString("branch_name");
+ BranchType branchType = BranchType.valueOf(stmt.getInt("branch_type"));
+ BranchState branchState = BranchState.getBranchState(stmt.getInt("branch_state"));
+ boolean isArchived = BranchArchivedState.valueOf(stmt.getInt("archived")).isArchived();
+ boolean inheritAccessControl = stmt.getInt("inherit_access_control") == 1;
+ Integer artifactId = stmt.getInt("associated_art_id");
+
Branch branch = cache.getById(branchId);
if (branch == null) {
- branch = create(branchId, name, branchType, branchState, isArchived, inheritAccessControl);
+ if (branchType.isMergeBranch()) {
+ MergeBranch mergeBranch =
+ new MergeBranch(branchId, name, branchType, branchState, isArchived, inheritAccessControl);
+ branch = mergeBranch;
+ Branch sourceBranch = cache.getById(stmt.getLong("source_branch_id"));
+ Branch destBranch = cache.getById(stmt.getLong("dest_branch_id"));
+
+ mergeBranch.setSourceBranch(sourceBranch);
+ mergeBranch.setDestinationBranch(destBranch);
+ } else {
+ branch = new Branch(branchId, name, branchType, branchState, isArchived, inheritAccessControl);
+ }
} else {
branch.setName(name);
branch.setBranchType(branchType);
@@ -95,81 +97,13 @@ public class DatabaseBranchAccessor implements IOseeDataAccessor<Branch> {
return branch;
}
- private static Branch load(IOseeCache<Branch> cache, JdbcStatement stmt) {
- Long branchId = stmt.getLong("branch_id");
- String branchName = stmt.getString("branch_name");
- BranchType branchType = BranchType.valueOf(stmt.getInt("branch_type"));
- BranchState branchState = BranchState.getBranchState(stmt.getInt("branch_state"));
- boolean isArchived = BranchArchivedState.valueOf(stmt.getInt("archived")).isArchived();
- int inheritAccessControl = stmt.getInt("inherit_access_control");
- Integer artifactId = stmt.getInt("associated_art_id");
-
- Branch branch = createOrUpdate(cache, branchId, branchName, branchType, branchState, isArchived,
- StorageState.LOADED, inheritAccessControl == 1, artifactId);
-
- return branch;
- }
-
- public static Branch loadBranch(IOseeCache<Branch> cache, Long branchId) {
- return ConnectionHandler.getJdbcClient().fetchOrException(
- () -> new BranchDoesNotExist("Branch could not be acquired for branch id %d", branchId),
- stmt -> fetchBranch(cache, stmt), SELECT_BRANCH, branchId);
- }
-
- private static Branch fetchBranch(IOseeCache<Branch> cache, JdbcStatement stmt) {
- Branch branch = load(cache, stmt);
- branch.setBaseTransaction(TransactionManager.getTransactionRecord(stmt.getLong("baseline_transaction_id")));
- branch.setSourceTransaction(TransactionManager.getTransactionRecord(stmt.getLong("parent_transaction_id")));
- if (!SYSTEM_ROOT.equals(branch)) {
- branch.setParentBranch(BranchManager.getBranch(stmt.getLong("parent_branch_id")));
- }
- return branch;
- }
-
- private void loadBranchRelatedTransactions(Map<Branch, Long> branchToBaseTx, Map<Branch, Long> branchToSourceTx) throws OseeCoreException {
- Set<Long> transactionIds = new HashSet<>();
- transactionIds.addAll(branchToSourceTx.values());
- transactionIds.addAll(branchToBaseTx.values());
- txCache.loadTransactions(transactionIds);
-
- for (Entry<Branch, Long> entry : branchToBaseTx.entrySet()) {
- Branch branch = entry.getKey();
- if (branch.getBaseTransaction() == null) {
- TransactionRecord baseTx = txCache.getById(entry.getValue());
- branch.setBaseTransaction(baseTx);
- }
- }
-
- for (Entry<Branch, Long> entry : branchToSourceTx.entrySet()) {
- Branch branch = entry.getKey();
- if (BranchManager.getSourceTransaction(branch) == null) {
- TransactionRecord srcTx = txCache.getById(entry.getValue());
- branch.setSourceTransaction(srcTx);
- }
- }
- }
-
- private void loadBranchHierarchy(IOseeCache<Branch> cache, Map<Branch, Long> childToParent) throws OseeCoreException {
- for (Entry<Branch, Long> entry : childToParent.entrySet()) {
- Branch childBranch = entry.getKey();
- Branch parentBranch = cache.getById(entry.getValue());
- if (parentBranch == null) {
- throw new BranchDoesNotExist("Parent Branch uuid:[%s] does not exist for child branch [%s]",
- entry.getValue(), entry.getKey());
- }
- childBranch.setParentBranch(parentBranch);
- }
- }
-
- private void loadMergeBranches(IOseeCache<Branch> cache) throws OseeCoreException {
- Consumer<JdbcStatement> consumer = stmt -> {
- Branch sourceBranch = cache.getById(stmt.getLong("source_branch_id"));
- Branch destBranch = cache.getById(stmt.getLong("dest_branch_id"));
- MergeBranch mergeBranch = (MergeBranch) cache.getById(stmt.getLong("merge_branch_id"));
-
- mergeBranch.setSourceBranch(sourceBranch);
- mergeBranch.setDestinationBranch(destBranch);
- };
- getJdbcClient().runQuery(consumer, 1000, SELECT_MERGE_BRANCHES);
+ private static TransactionRecord createTx(boolean base, Branch branch, JdbcStatement stmt) {
+ Long transactionId = stmt.getLong(base ? "baseline_transaction_id" : "parent_transaction_id");
+ String comment = stmt.getString(base ? "b_osee_comment" : "p_osee_comment");
+ Date timestamp = stmt.getTimestamp(base ? "b_time" : "p_time");
+ Integer authorArtId = stmt.getInt(base ? "b_author" : "p_author");
+ Integer commitArtId = stmt.getInt(base ? "b_commit_art_id" : "p_commit_art_id");
+ TransactionDetailsType txType = TransactionDetailsType.toEnum(stmt.getInt(base ? "b_tx_type" : "p_tx_type"));
+ return new TransactionRecord(transactionId, branch, comment, timestamp, authorArtId, commitArtId, txType);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseTransactionRecordAccessor.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseTransactionRecordAccessor.java
deleted file mode 100644
index fc9525f5a4..0000000000
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/internal/accessors/DatabaseTransactionRecordAccessor.java
+++ /dev/null
@@ -1,131 +0,0 @@
-package org.eclipse.osee.framework.skynet.core.internal.accessors;
-
-import java.util.Collection;
-import java.util.Date;
-import org.eclipse.osee.framework.core.data.BranchId;
-import org.eclipse.osee.framework.core.data.TokenFactory;
-import org.eclipse.osee.framework.core.data.TransactionId;
-import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
-import org.eclipse.osee.framework.core.enums.TransactionVersion;
-import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
-import org.eclipse.osee.framework.core.model.cache.ITransactionDataAccessor;
-import org.eclipse.osee.framework.core.model.cache.TransactionCache;
-import org.eclipse.osee.framework.core.sql.OseeSql;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
-import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil;
-import org.eclipse.osee.framework.skynet.core.utility.IdJoinQuery;
-import org.eclipse.osee.framework.skynet.core.utility.JoinUtility;
-import org.eclipse.osee.jdbc.JdbcClient;
-import org.eclipse.osee.jdbc.JdbcStatement;
-
-/**
- * @author Roberto E. Escobar
- */
-public class DatabaseTransactionRecordAccessor implements ITransactionDataAccessor {
-
- private static final String SELECT_BASE_TRANSACTION =
- "select * from osee_tx_details where branch_id = ? and tx_type = ?";
-
- private static final String SELECT_BY_TRANSACTION = "select * from osee_tx_details WHERE transaction_id = ?";
-
- private static final String SELECT_HEAD_TRANSACTION =
- "select * from osee_tx_details where transaction_id = (select max(transaction_id) from osee_tx_details where branch_id = ?) and branch_id = ?";
-
- private static final String SELECT_TRANSACTIONS_BY_QUERY_ID =
- "select * from osee_join_id oji, osee_tx_details txd where oji.query_id = ? and txd.transaction_id = oji.id";
-
- private static final String SELECT_NON_EXISTING_TRANSACTIONS_BY_QUERY_ID =
- "select oji.id from osee_join_id oji where oji.query_id = ? and not exists (select 1 from osee_tx_details txd where txd.transaction_id = oji.id)";
-
- private static final String GET_PRIOR_TRANSACTION =
- "select max(transaction_id) FROM osee_tx_details where branch_id = ? and transaction_id < ?";
-
- private final JdbcClient jdbcClient;
- private final TransactionRecordFactory factory;
- private final TransactionCache cache;
-
- public DatabaseTransactionRecordAccessor(JdbcClient jdbcClient, TransactionCache cache, TransactionRecordFactory factory) {
- this.cache = cache;
- this.jdbcClient = jdbcClient;
- this.factory = factory;
- }
-
- @Override
- public void loadTransactionRecords(TransactionCache cache, Collection<Long> transactionIds) throws OseeCoreException {
- if (transactionIds.isEmpty()) {
- return;
- }
- if (transactionIds.size() > 1) {
- IdJoinQuery joinQuery = JoinUtility.createIdJoinQuery(jdbcClient);
- try {
- for (Long txNumber : transactionIds) {
- joinQuery.add(txNumber);
- }
- joinQuery.store();
-
- loadTransactions(transactionIds.size(), SELECT_TRANSACTIONS_BY_QUERY_ID, joinQuery.getQueryId());
-
- } finally {
- joinQuery.delete();
- }
- } else {
- loadTransaction(SELECT_BY_TRANSACTION, transactionIds.iterator().next());
- }
- }
-
- @Override
- public TransactionRecord loadTransactionRecord(TransactionCache cache, BranchId branch, TransactionVersion transactionType) throws OseeCoreException {
- TransactionRecord toReturn = null;
- switch (transactionType) {
- case BASE:
- toReturn = loadTransaction(SELECT_BASE_TRANSACTION, branch.getUuid(), TransactionDetailsType.Baselined);
- break;
- case HEAD:
- toReturn = loadTransaction(SELECT_HEAD_TRANSACTION, branch.getUuid(), branch.getUuid());
- break;
- default:
- throw new OseeStateException("Transaction Type [%s] is not supported", transactionType);
- }
- return toReturn;
- }
-
- private TransactionRecord loadInternalTransaction(JdbcStatement stmt) {
- BranchId branch = TokenFactory.createBranch(stmt.getLong("branch_id"));
- Long transactionNumber = stmt.getLong("transaction_id");
- String comment = stmt.getString("osee_comment");
- Date timestamp = stmt.getTimestamp("time");
- int authorArtId = stmt.getInt("author");
- int commitArtId = stmt.getInt("commit_art_id");
- TransactionDetailsType txType = TransactionDetailsType.toEnum(stmt.getInt("tx_type"));
- return factory.createOrUpdate(cache, transactionNumber, branch, comment, timestamp, authorArtId, commitArtId,
- txType);
- }
-
- private void loadTransactions(int expectedCount, String query, int queryId) throws OseeCoreException {
- jdbcClient.runQuery(this::loadInternalTransaction, query, queryId);
- }
-
- private TransactionRecord loadTransaction(String query, Object... parameters) throws OseeCoreException {
- return jdbcClient.fetch(null, this::loadInternalTransaction, query, parameters);
- }
-
- @Override
- public void load(TransactionCache transactionCache) throws OseeCoreException {
- // Not implemented
- }
-
- @Override
- public TransactionRecord getOrLoadPriorTransaction(TransactionCache cache, TransactionId transactionNumber, long branchUuid) throws OseeCoreException {
- Long priorTransactionId =
- jdbcClient.fetch(TransactionId.SENTINEL, GET_PRIOR_TRANSACTION, branchUuid, transactionNumber).getId();
- return cache.getOrLoad(priorTransactionId);
- }
-
- @Override
- public TransactionRecord getHeadTransaction(TransactionCache cache, BranchId branch) throws OseeCoreException {
- String query = ServiceUtil.getSql(OseeSql.TX_GET_MAX_AS_LARGEST_TX);
- return cache.getOrLoad(jdbcClient.fetch(TransactionId.SENTINEL, query, branch).getId());
- }
-}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
index 0d8ceda772..4c2624ed72 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/ChangeManager.java
@@ -127,7 +127,7 @@ public final class ChangeManager {
while (chStmt.next()) {
BranchId branch = TokenFactory.createBranch(chStmt.getLong("branch_id"));
Artifact artifact = artifactMap.get(chStmt.getInt("art_id"), branch);
- transactionMap.put(artifact, TransactionManager.getTransaction(chStmt.getLong("transaction_id")));
+ transactionMap.put(artifact, TransactionId.valueOf(chStmt.getLong("transaction_id")));
}
} finally {
chStmt.close();
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java
index 44f98e8a85..312376d1ec 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/revision/RevisionChangeLoader.java
@@ -102,17 +102,17 @@ public final class RevisionChangeLoader {
JdbcStatement chStmt = ConnectionHandler.getStatement();
try {
chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.LOAD_REVISION_HISTORY_TRANSACTION_ATTR),
- artifact.getArtId(), branch.getUuid(), transactionId.getId());
+ artifact.getArtId(), branch, transactionId);
while (chStmt.next()) {
- transactionIds.add(TransactionManager.getTransaction(chStmt.getLong("transaction_id")));
+ transactionIds.add(TransactionToken.valueOf(chStmt.getLong("transaction_id"), branch));
}
chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.LOAD_REVISION_HISTORY_TRANSACTION_REL), artifact.getArtId(),
- artifact.getArtId(), branch.getUuid(), transactionId.getId());
+ artifact.getArtId(), branch, transactionId);
while (chStmt.next()) {
- transactionIds.add(TransactionManager.getTransaction(chStmt.getLong("transaction_id")));
+ transactionIds.add(TransactionToken.valueOf(chStmt.getLong("transaction_id"), branch));
}
} finally {
chStmt.close();
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransaction.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransaction.java
index 7af1294cbf..84420db7e9 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransaction.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/SkynetTransaction.java
@@ -19,6 +19,7 @@ import static org.eclipse.osee.framework.core.enums.ModificationType.NEW;
import static org.eclipse.osee.framework.core.enums.ModificationType.REPLACED_WITH_VERSION;
import java.util.Collection;
import java.util.Collections;
+import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -31,6 +32,7 @@ import org.eclipse.osee.framework.core.enums.ModificationType;
import org.eclipse.osee.framework.core.enums.PermissionEnum;
import org.eclipse.osee.framework.core.enums.RelationSide;
import org.eclipse.osee.framework.core.enums.RelationTypeMultiplicity;
+import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.model.RelationTypeSide;
import org.eclipse.osee.framework.core.model.TransactionRecord;
import org.eclipse.osee.framework.core.model.access.PermissionStatus;
@@ -40,6 +42,7 @@ import org.eclipse.osee.framework.core.operation.Operations;
import org.eclipse.osee.framework.jdk.core.type.CompositeKeyHashMap;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.OseeStateException;
+import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
import org.eclipse.osee.framework.skynet.core.AccessPolicy;
import org.eclipse.osee.framework.skynet.core.User;
import org.eclipse.osee.framework.skynet.core.UserManager;
@@ -382,11 +385,24 @@ public final class SkynetTransaction extends TransactionOperation<BranchId> {
}
private IOperation createStorageOp() throws OseeCoreException {
- transaction = TransactionManager.internalCreateTransactionRecord(getBranch(), getAuthor(), comment);
+ transaction = internalCreateTransaction(getBranch(), getAuthor(), comment);
return new StoreSkynetTransactionOperation(getName(), getBranch(), transaction, getTransactionData(),
getArtifactReferences());
}
+ public static synchronized TransactionRecord internalCreateTransaction(BranchId branch, User userToBlame, String comment) throws OseeCoreException {
+ if (comment == null) {
+ comment = "";
+ }
+ Integer authorArtId = userToBlame.getArtId();
+ TransactionDetailsType txType = TransactionDetailsType.NonBaselined;
+ Date timestamp = GlobalTime.GreenwichMeanTimestamp();
+ //keep transaction id's sequential in the face of concurrent transaction by multiple users
+ Long txId = ConnectionHandler.getNextSequence("SKYNET_TRANSACTION_ID_SEQ", false);
+
+ return new TransactionRecord(txId, branch, comment, timestamp, authorArtId, 0, txType);
+ }
+
@Override
public boolean containsItem(Object object) {
synchronized (getTxMonitor()) {
diff --git a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java
index f5cc56f83c..9994a3b1f8 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core/src/org/eclipse/osee/framework/skynet/core/transaction/TransactionManager.java
@@ -14,9 +14,11 @@ import java.sql.Timestamp;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
-import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.data.TransactionId;
@@ -24,17 +26,12 @@ import org.eclipse.osee.framework.core.data.TransactionToken;
import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
import org.eclipse.osee.framework.core.exception.TransactionDoesNotExist;
import org.eclipse.osee.framework.core.model.TransactionRecord;
-import org.eclipse.osee.framework.core.model.TransactionRecordFactory;
-import org.eclipse.osee.framework.core.model.cache.TransactionCache;
-import org.eclipse.osee.framework.core.sql.OseeSql;
-import org.eclipse.osee.framework.jdk.core.type.Id;
+import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
-import org.eclipse.osee.framework.jdk.core.util.time.GlobalTime;
-import org.eclipse.osee.framework.skynet.core.User;
-import org.eclipse.osee.framework.skynet.core.internal.ServiceUtil;
import org.eclipse.osee.framework.skynet.core.types.IArtifact;
import org.eclipse.osee.framework.skynet.core.utility.ConnectionHandler;
+import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.jdbc.JdbcConnection;
import org.eclipse.osee.jdbc.JdbcConstants;
import org.eclipse.osee.jdbc.JdbcStatement;
@@ -46,31 +43,33 @@ import org.eclipse.osee.jdbc.JdbcStatement;
*/
public final class TransactionManager {
- private static final String TRANSACTION_ID_SEQ = "SKYNET_TRANSACTION_ID_SEQ";
-
private static final String INSERT_INTO_TRANSACTION_DETAIL =
"INSERT INTO osee_tx_details (transaction_id, osee_comment, time, author, branch_id, tx_type) VALUES (?, ?, ?, ?, ?, ?)";
private static final String SELECT_TRANSACTIONS =
"SELECT * FROM osee_tx_details WHERE branch_id = ? ORDER BY transaction_id DESC";
- private static final String SELECT_COMMIT_TRANSACTIONS =
- "SELECT transaction_id FROM osee_tx_details WHERE commit_art_id = ?";
+ private static final String SELECT_COMMIT_TRANSACTIONS = "SELECT * FROM osee_tx_details WHERE commit_art_id = ?";
private static final String UPDATE_TRANSACTION_COMMENTS =
"UPDATE osee_tx_details SET osee_comment = ? WHERE transaction_id = ?";
- private static final String SELECT_TRANSACTION_COMMENTS =
- "SELECT transaction_id FROM osee_tx_details WHERE osee_comment LIKE ?";
+ private static final String SELECT_TRANSACTION_COMMENTS = "SELECT * FROM osee_tx_details WHERE osee_comment LIKE ?";
private static final String SELECT_BRANCH_TRANSACTION_BY_DATE =
"SELECT * FROM osee_tx_details WHERE branch_id = ? AND time < ? ORDER BY time DESC";
- private static final TransactionRecordFactory factory = new TransactionRecordFactory();
+ private static final String SELECT_HEAD_TRANSACTION =
+ "select * from osee_tx_details where transaction_id = (select max(transaction_id) from osee_tx_details where branch_id = ?) and branch_id = ?";
+
+ private static final String SELECT_PRIOR_TRANSACTION =
+ "select * from osee_tx_details where transaction_id = (select max(transaction_id) from osee_tx_details where branch_id = ? and transaction_id < ?) and branch_id = ?";
- private static final HashMap<Integer, List<TransactionToken>> commitArtifactIdMap = new HashMap<>();
+ private static final String TX_GET_TRANSACTION_BY_ID = "SELECT * FROM osee_tx_details WHERE transaction_id = ?";
private static final TxMonitorImpl<BranchId> txMonitor = new TxMonitorImpl<>(new TxMonitorCache<>());
+ private static final HashCollection<ArtifactId, TransactionRecord> commitArtifactIdMap =
+ new HashCollection<>(true, HashSet.class);
public static SkynetTransaction createTransaction(BranchId branch, String comment) throws OseeCoreException {
SkynetTransaction tx = new SkynetTransaction(txMonitor, branch, comment);
@@ -79,16 +78,9 @@ public final class TransactionManager {
}
public static List<TransactionRecord> getTransaction(String comment) throws OseeCoreException {
+ JdbcClient jdbcClient = ConnectionHandler.getJdbcClient();
ArrayList<TransactionRecord> transactions = new ArrayList<>();
- JdbcStatement chStmt = ConnectionHandler.getStatement();
- try {
- chStmt.runPreparedQuery(SELECT_TRANSACTION_COMMENTS, comment);
- while (chStmt.next()) {
- transactions.add(getTransactionId(chStmt));
- }
- } finally {
- chStmt.close();
- }
+ jdbcClient.runQuery(stmt -> transactions.add(loadTransaction(stmt)), SELECT_TRANSACTION_COMMENTS, comment);
return transactions;
}
@@ -96,23 +88,11 @@ public final class TransactionManager {
ConnectionHandler.runPreparedUpdate(UPDATE_TRANSACTION_COMMENTS, comment, transaction);
}
- private static TransactionCache getTransactionCache() throws OseeCoreException {
- return ServiceUtil.getOseeCacheService().getTransactionCache();
- }
-
public static List<TransactionRecord> getTransactionsForBranch(BranchId branch) throws OseeCoreException {
+ JdbcClient jdbcClient = ConnectionHandler.getJdbcClient();
ArrayList<TransactionRecord> transactions = new ArrayList<>();
- JdbcStatement chStmt = ConnectionHandler.getStatement();
-
- try {
- chStmt.runPreparedQuery(JdbcConstants.JDBC__MAX_FETCH_SIZE, SELECT_TRANSACTIONS, branch.getUuid());
-
- while (chStmt.next()) {
- transactions.add(getTransactionId(chStmt));
- }
- } finally {
- chStmt.close();
- }
+ jdbcClient.runQuery(stmt -> transactions.add(loadTransaction(branch, stmt)), JdbcConstants.JDBC__MAX_FETCH_SIZE,
+ SELECT_TRANSACTIONS, branch);
return transactions;
}
@@ -120,25 +100,13 @@ public final class TransactionManager {
return (long) getTransaction(tx).getCommit();
}
- public synchronized static List<TransactionToken> getCommittedArtifactTransactionIds(IArtifact artifact) throws OseeCoreException {
- List<TransactionToken> transactionIds = commitArtifactIdMap.get(artifact.getArtId());
- // Cache the transactionIds first time through. Other commits will be added to cache as they
- // happen in this client or as remote commit events come through
- if (transactionIds == null) {
- transactionIds = new ArrayList<>(5);
- JdbcStatement chStmt = ConnectionHandler.getStatement();
- try {
- chStmt.runPreparedQuery(SELECT_COMMIT_TRANSACTIONS, artifact.getArtId());
- while (chStmt.next()) {
- transactionIds.add(getTransaction(chStmt.getLong("transaction_id")));
- }
-
- commitArtifactIdMap.put(artifact.getArtId(), transactionIds);
- } finally {
- chStmt.close();
- }
+ public synchronized static Collection<TransactionRecord> getCommittedArtifactTransactionIds(ArtifactId artifact) throws OseeCoreException {
+ if (!commitArtifactIdMap.containsKey(artifact)) {
+ ConnectionHandler.getJdbcClient().runQuery(stmt -> commitArtifactIdMap.put(artifact, loadTransaction(stmt)),
+ SELECT_COMMIT_TRANSACTIONS, artifact);
}
- return transactionIds;
+ Collection<TransactionRecord> transactions = commitArtifactIdMap.getValues(artifact);
+ return transactions == null ? Collections.emptyList() : transactions;
}
/**
@@ -147,48 +115,45 @@ public final class TransactionManager {
* performed through cacheCommittedArtifactTransaction.
*/
public static void clearCommitArtifactCacheForAssociatedArtifact(IArtifact associatedArtifact) {
- if (associatedArtifact != null) {
- commitArtifactIdMap.remove(associatedArtifact.getArtId());
- }
+ commitArtifactIdMap.removeValues(associatedArtifact);
}
public synchronized static void cacheCommittedArtifactTransaction(IArtifact artifact, TransactionToken transactionId) throws OseeCoreException {
- Collection<TransactionToken> transactionIds = getCommittedArtifactTransactionIds(artifact);
- if (!transactionIds.contains(transactionId)) {
- transactionIds.add(transactionId);
- getTransactionCache().cache(getTransaction(transactionId));
- }
+ commitArtifactIdMap.put(artifact, getTransactionRecord(transactionId.getId()));
}
/**
* @return the largest (most recent) transaction on the given branch
*/
public static TransactionToken getHeadTransaction(BranchId branch) throws OseeCoreException {
- Long txId = ConnectionHandler.getJdbcClient().fetch(Id.SENTINEL,
- ServiceUtil.getSql(OseeSql.TX_GET_MAX_AS_LARGEST_TX), branch);
- TransactionToken transaction = TransactionToken.valueOf(txId, branch);
- if (transaction.isInvalid()) {
- throw new TransactionDoesNotExist("No transactions where found in the database for branch: %s", branch);
- }
- return transaction;
+ return getTransaction(branch, SELECT_HEAD_TRANSACTION, branch, branch);
}
- private static Long getNextTransactionId() {
- //keep transaction id's sequential in the face of concurrent transaction by multiple users
- return ConnectionHandler.getNextSequence(TRANSACTION_ID_SEQ, false);
+ public static TransactionToken getPriorTransaction(TransactionToken tx) throws OseeCoreException {
+ BranchId branch = tx.getBranch();
+ return getTransaction(branch, SELECT_PRIOR_TRANSACTION, branch, tx.getId(), branch);
}
- public static synchronized TransactionRecord internalCreateTransactionRecord(BranchId branch, User userToBlame, String comment) throws OseeCoreException {
- if (comment == null) {
- comment = "";
- }
- Long transactionNumber = getNextTransactionId();
- int authorArtId = userToBlame.getArtId();
- TransactionDetailsType txType = TransactionDetailsType.NonBaselined;
- Date transactionTime = GlobalTime.GreenwichMeanTimestamp();
- TransactionRecord transactionId = factory.createOrUpdate(getTransactionCache(), transactionNumber, branch,
- comment, transactionTime, authorArtId, 0, txType);
- return transactionId;
+ private static TransactionRecord getTransaction(BranchId branch, String sql, Object... data) throws OseeCoreException {
+ JdbcClient jdbcClient = ConnectionHandler.getJdbcClient();
+ return jdbcClient.fetchOrException(
+ () -> new TransactionDoesNotExist("No transactions where found in the database for branch: %d",
+ branch.getId()),
+ stmt -> loadTransaction(branch, stmt), sql, data);
+ }
+
+ private static TransactionRecord loadTransaction(JdbcStatement stmt) {
+ return loadTransaction(TokenFactory.createBranch(stmt.getLong("branch_id")), stmt);
+ }
+
+ private static TransactionRecord loadTransaction(BranchId branch, JdbcStatement stmt) {
+ Long transactionNumber = stmt.getLong("transaction_id");
+ String comment = stmt.getString("osee_comment");
+ Date timestamp = stmt.getTimestamp("time");
+ Integer authorArtId = stmt.getInt("author");
+ Integer commitArtId = stmt.getInt("commit_art_id");
+ TransactionDetailsType txType = TransactionDetailsType.toEnum(stmt.getInt("tx_type"));
+ return new TransactionRecord(transactionNumber, branch, comment, timestamp, authorArtId, commitArtId, txType);
}
public static synchronized void internalPersist(JdbcConnection connection, TransactionRecord transactionRecord) throws OseeCoreException {
@@ -200,21 +165,19 @@ public final class TransactionManager {
public static TransactionToken getTransactionAtDate(BranchId branch, Date maxDateExclusive) throws OseeCoreException {
Conditions.checkNotNull(branch, "branch");
Conditions.checkNotNull(maxDateExclusive, "max date exclusive");
- long branchUuid = branch.getUuid();
TransactionRecord txRecord = null;
JdbcStatement chStmt = ConnectionHandler.getStatement();
try {
- chStmt.runPreparedQuery(SELECT_BRANCH_TRANSACTION_BY_DATE, branchUuid,
- new Timestamp(maxDateExclusive.getTime()));
+ chStmt.runPreparedQuery(SELECT_BRANCH_TRANSACTION_BY_DATE, branch, new Timestamp(maxDateExclusive.getTime()));
if (chStmt.next()) {
if (chStmt.wasNull()) {
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG);
throw new TransactionDoesNotExist("Cannot find transaction for [%s] - the transation id was null",
dateFormat.format(maxDateExclusive));
}
- txRecord = getTransactionId(chStmt);
+ txRecord = loadTransaction(chStmt);
}
} finally {
chStmt.close();
@@ -222,62 +185,21 @@ public final class TransactionManager {
return txRecord;
}
- public static TransactionRecord getTransaction(TransactionId transaction) throws OseeCoreException {
- return getTransactionId(transaction.getId(), null);
- }
-
- public static TransactionToken getTransaction(long transaction) throws OseeCoreException {
- return getTransactionId(transaction, null);
- }
-
- public static TransactionRecord getTransactionRecord(long transaction) throws OseeCoreException {
- return getTransactionId(transaction, null);
- }
-
- private static TransactionRecord getTransactionId(JdbcStatement chStmt) throws OseeCoreException {
- return getTransactionId(chStmt.getLong("transaction_id"), chStmt);
- }
-
- public static void deCache(int txId) throws OseeCoreException {
- TransactionCache txCache = getTransactionCache();
- TransactionRecord transactionRecord = txCache.getById(txId);
- if (transactionRecord != null) {
- txCache.decache(transactionRecord);
+ public static TransactionRecord getTransaction(TransactionId tx) {
+ if (tx instanceof TransactionRecord) {
+ return (TransactionRecord) tx;
}
+ return getTransactionRecord(tx.getId());
}
- private synchronized static TransactionRecord getTransactionId(Long txId, JdbcStatement chStmt) throws OseeCoreException {
- TransactionCache txCache = getTransactionCache();
- TransactionRecord transactionRecord = txCache.getById(txId);
-
- boolean useLocalConnection = chStmt == null;
- if (transactionRecord == null) {
- try {
- if (useLocalConnection) {
- chStmt = ConnectionHandler.getStatement();
- chStmt.runPreparedQuery(ServiceUtil.getSql(OseeSql.TX_GET_ALL_TRANSACTIONS), txId);
- if (!chStmt.next()) {
- throw new TransactionDoesNotExist("The transaction id %d does not exist in the databse.", txId);
- }
- }
-
- if (chStmt != null) {
- TransactionDetailsType txType = TransactionDetailsType.toEnum(chStmt.getInt("tx_type"));
- BranchId branch = TokenFactory.createBranch(chStmt.getLong("branch_id"));
- transactionRecord = factory.createOrUpdate(txCache, txId, branch, chStmt.getString("osee_comment"),
- chStmt.getTimestamp("time"), chStmt.getInt("author"), chStmt.getInt("commit_art_id"), txType);
- }
- } finally {
- if (chStmt != null) {
- chStmt.close();
- }
- }
- }
- return transactionRecord;
+ public static TransactionToken getTransaction(long txId) {
+ return getTransactionRecord(txId);
}
- public static TransactionToken getPriorTransaction(TransactionToken transactionId) {
- TransactionCache txCache = getTransactionCache();
- return txCache.getPriorTransaction(transactionId);
+ private static TransactionRecord getTransactionRecord(long txId) {
+ JdbcClient jdbcClient = ConnectionHandler.getJdbcClient();
+ return jdbcClient.fetchOrException(
+ () -> new TransactionDoesNotExist("A transaction with id %d was not found.", txId),
+ stmt -> loadTransaction(stmt), TX_GET_TRANSACTION_BY_ID, txId);
}
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/provider/DeletedBranchProviderTest.java b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/provider/DeletedBranchProviderTest.java
index a3e4ffb8eb..db11c12381 100644
--- a/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/provider/DeletedBranchProviderTest.java
+++ b/plugins/org.eclipse.osee.orcs.core.test/src/org/eclipse/osee/orcs/core/internal/branch/provider/DeletedBranchProviderTest.java
@@ -14,7 +14,6 @@ import java.util.Collection;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
-import org.eclipse.osee.framework.core.model.cache.TransactionCache;
import org.eclipse.osee.framework.core.model.mocks.MockOseeDataAccessor;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.junit.Assert;
@@ -37,7 +36,7 @@ public final class DeletedBranchProviderTest {
@Test
public void testGetBranches() throws OseeCoreException {
- BranchCache mockCache = new BranchCache(new MockOseeDataAccessor<Branch>(), new TransactionCache());
+ BranchCache mockCache = new BranchCache(new MockOseeDataAccessor<Branch>());
Collection<Branch> branches = MockBranchProvider.createTestBranches();
mockCache.cache(branches.toArray(new Branch[branches.size()]));

Back to the top