Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2016-06-14 23:28:09 +0000
committerRyan T. Baldwin2016-06-14 23:28:09 +0000
commitd46e37b6739d340f94cec4555a027caa8fe8a2c3 (patch)
tree6c3c8aaa9d7b9ccf68f5e338d3261765acc291dd /plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest
parent4a2bbb04e9e5abc8d8fb41ac45773694c4ff1bcc (diff)
downloadorg.eclipse.osee-d46e37b6739d340f94cec4555a027caa8fe8a2c3.tar.gz
org.eclipse.osee-d46e37b6739d340f94cec4555a027caa8fe8a2c3.tar.xz
org.eclipse.osee-d46e37b6739d340f94cec4555a027caa8fe8a2c3.zip
refactor: Remove unnecessary usage of TransactionReadable
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest')
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributeResource.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributesResource.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java50
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TransactionEndpointImpl.java16
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/ArtifactSearch_V1.java3
5 files changed, 38 insertions, 44 deletions
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributeResource.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributeResource.java
index f7c0461151e..7c98bbea1f6 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributeResource.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributeResource.java
@@ -22,6 +22,8 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.framework.core.data.RelationalConstants;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.orcs.data.ArtifactReadable;
@@ -42,13 +44,13 @@ public class AttributeResource {
private final Long branchUuid;
private final Long artifactUuid;
private final int attrId;
- private final int transactionId;
+ private final TransactionId transactionId;
public AttributeResource(UriInfo uriInfo, Request request, Long branchUuid, Long artifactUuid, int attributeId) {
- this(uriInfo, request, branchUuid, artifactUuid, attributeId, -1);
+ this(uriInfo, request, branchUuid, artifactUuid, attributeId, TransactionId.SENTINEL);
}
- public AttributeResource(UriInfo uriInfo, Request request, Long branchUuid, Long artifactUuid, int attributeId, int transactionId) {
+ public AttributeResource(UriInfo uriInfo, Request request, Long branchUuid, Long artifactUuid, int attributeId, TransactionId transactionId) {
this.uriInfo = uriInfo;
this.request = request;
this.branchUuid = branchUuid;
@@ -63,7 +65,7 @@ public class AttributeResource {
try {
QueryFactory factory = OrcsApplication.getOrcsApi().getQueryFactory();
QueryBuilder queryBuilder = factory.fromBranch(branchUuid).andUuid(artifactUuid);
- if (transactionId > 0) {
+ if (transactionId.isValid()) {
queryBuilder.fromTransaction(transactionId);
}
ArtifactReadable exactlyOne = queryBuilder.getResults().getExactlyOne();
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributesResource.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributesResource.java
index fd21733528b..a00994511aa 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributesResource.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/AttributesResource.java
@@ -18,6 +18,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.search.QueryFactory;
@@ -53,7 +54,7 @@ public class AttributesResource {
@GET
@Produces(MediaType.TEXT_HTML)
@Path("{attributeId}/version/{transactionId}")
- public AttributeResource getAttributeWithGamma(@PathParam("attributeId") int attributeId, @PathParam("transactionId") int transactionId) {
+ public AttributeResource getAttributeWithGamma(@PathParam("attributeId") int attributeId, @PathParam("transactionId") TransactionId transactionId) {
return new AttributeResource(uriInfo, request, branchUuid, artifactUuid, attributeId, transactionId);
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java
index ab8cce60daa..40eecb7c97b 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java
@@ -14,7 +14,6 @@ import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON_ID;
import static org.eclipse.osee.framework.jdk.core.util.Compare.isDifferent;
import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asBranch;
import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asBranches;
-import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asIntegerList;
import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asResponse;
import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asTransaction;
import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asTransactions;
@@ -41,6 +40,8 @@ import org.eclipse.osee.activity.api.ActivityLog;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.data.TokenFactory;
+import org.eclipse.osee.framework.core.data.TransactionId;
+import org.eclipse.osee.framework.core.data.TransactionToken;
import org.eclipse.osee.framework.core.enums.BranchArchivedState;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.BranchType;
@@ -145,11 +146,6 @@ public class BranchEndpointImpl implements BranchEndpoint {
return artifact;
}
- private BranchId getBranchFromTxId(int tx) {
- TransactionQuery txQuery = newQuery().transactionQuery();
- return txQuery.andTxId(tx).getResults().getExactlyOne().getBranch();
- }
-
private BranchReadable getBranchById(long branchUuid) {
ResultSet<BranchReadable> results = newBranchQuery().andUuids(branchUuid)//
.includeArchived()//
@@ -159,8 +155,7 @@ public class BranchEndpointImpl implements BranchEndpoint {
}
private TransactionReadable getTxByBranchAndId(long branchUuid, int txId) {
- ResultSet<TransactionReadable> results = newTxQuery().andBranchIds(branchUuid).andTxId(txId).getResults();
- return results.getExactlyOne();
+ return newTxQuery().andBranchIds(branchUuid).andTxId(txId).getResults().getExactlyOne();
}
private TransactionFactory newTxFactory() {
@@ -258,20 +253,18 @@ public class BranchEndpointImpl implements BranchEndpoint {
@Override
public List<Transaction> getAllBranchTxs(long branchUuid) {
- ResultSet<TransactionReadable> results = newTxQuery().andBranchIds(branchUuid).getResults();
- return asTransactions(results);
+ return asTransactions(newTxQuery().andBranchIds(branchUuid).getResults());
}
@Override
public Transaction getBranchTx(long branchUuid, int txId) {
- TransactionReadable tx = getTxByBranchAndId(branchUuid, txId);
- return asTransaction(tx);
+ return asTransaction(getTxByBranchAndId(branchUuid, txId));
}
@Override
public CompareResults compareBranches(long branchUuid, long branchUuid2) {
- TransactionReadable sourceTx = newTxQuery().andIsHead(branchUuid).getResults().getExactlyOne();
- TransactionReadable destinationTx = newTxQuery().andIsHead(branchUuid2).getResults().getExactlyOne();
+ TransactionToken sourceTx = newTxQuery().andIsHead(branchUuid).getResults().getExactlyOne();
+ TransactionToken destinationTx = newTxQuery().andIsHead(branchUuid2).getResults().getExactlyOne();
Callable<List<ChangeItem>> op = getBranchOps().compareBranch(sourceTx, destinationTx);
List<ChangeItem> changes = executeCallable(op);
@@ -309,7 +302,7 @@ public class BranchEndpointImpl implements BranchEndpoint {
createData.setUserArtifact(getArtifactById(COMMON_ID, data.getAuthorId()));
createData.setAssociatedArtifact(getArtifactById(COMMON_ID, data.getAssociatedArtifactId()));
- createData.setFromTransaction(TokenFactory.createTransaction(data.getSourceTransactionId()));
+ createData.setFromTransaction(TransactionId.valueOf(data.getSourceTransactionId()));
createData.setParentBranch(data.getParentBranch());
createData.setMergeDestinationBranchId(data.getMergeDestinationBranchId());
@@ -366,8 +359,8 @@ public class BranchEndpointImpl implements BranchEndpoint {
BranchReadable destBranch = getBranchById(destinationBranchUuid);
ArtifactReadable committer = getArtifactById(COMMON_ID, options.getCommitterId());
- Callable<TransactionReadable> op = getBranchOps().commitBranch(committer, srcBranch, destBranch);
- TransactionReadable tx = executeCallable(op);
+ Callable<TransactionToken> op = getBranchOps().commitBranch(committer, srcBranch, destBranch);
+ TransactionToken tx = executeCallable(op);
if (options.isArchive()) {
Callable<?> op2 = getBranchOps().archiveUnarchiveBranch(srcBranch, ArchiveOperation.ARCHIVE);
@@ -385,13 +378,12 @@ public class BranchEndpointImpl implements BranchEndpoint {
} catch (OseeCoreException ex) {
OseeLog.log(ActivityLog.class, OseeLevel.SEVERE_POPUP, ex);
}
- return Response.created(location).entity(asTransaction(tx)).build();
-
+ return Response.created(location).entity(asTransaction(orcsApi.getTransactionFactory().getTx(tx))).build();
}
- private URI getTxLocation(UriInfo uriInfo, TransactionReadable tx) {
+ private URI getTxLocation(UriInfo uriInfo, TransactionToken tx) {
UriBuilder builder = uriInfo.getRequestUriBuilder();
- URI location = builder.path("..").path("..").path("txs").path("{tx-id}").build(tx.getGuid());
+ URI location = builder.path("..").path("..").path("txs").path("{tx-id}").build(tx);
return location;
}
@@ -428,8 +420,8 @@ public class BranchEndpointImpl implements BranchEndpoint {
//TODO: Integrate data with TxBuilder
TransactionReadable tx = txBuilder.commit();
- if (tx != null) {
- URI location = uriInfo.getRequestUriBuilder().path("{tx-id}").build(tx.getGuid());
+ if (tx.isValid()) {
+ URI location = uriInfo.getRequestUriBuilder().path("{tx-id}").build(tx);
return Response.created(location).entity(asTransaction(tx)).build();
} else {
throw new OseeArgumentException("No Data Modified");
@@ -777,13 +769,13 @@ public class BranchEndpointImpl implements BranchEndpoint {
@Override
public Response purgeTxs(long branchUuid, String txIds) {
boolean modified = false;
- List<Integer> txsToDelete = asIntegerList(txIds);
+ List<Integer> txsToDelete = OrcsRestUtil.asIntegerList(txIds);
if (!txsToDelete.isEmpty()) {
- ResultSet<TransactionReadable> results =
+ ResultSet<? extends TransactionId> results =
newTxQuery().andBranchIds(branchUuid).andTxIds(txsToDelete).getResults();
if (!results.isEmpty()) {
checkAllTxFoundAreOnBranch("Purge Transaction", branchUuid, txsToDelete, results);
- List<TransactionReadable> list = Lists.newArrayList(results);
+ List<TransactionId> list = Lists.newArrayList(results);
Callable<?> op = newTxFactory().purgeTransaction(list);
executeCallable(op);
modified = true;
@@ -802,11 +794,11 @@ public class BranchEndpointImpl implements BranchEndpoint {
return asResponse(modified);
}
- private void checkAllTxFoundAreOnBranch(String opName, long branchUuid, List<Integer> txIds, ResultSet<TransactionReadable> result) {
+ private void checkAllTxFoundAreOnBranch(String opName, long branchUuid, List<Integer> txIds, ResultSet<? extends TransactionId> result) {
if (txIds.size() != result.size()) {
Set<Integer> found = new HashSet<>();
- for (TransactionReadable tx : result) {
- found.add(tx.getGuid());
+ for (TransactionId tx : result) {
+ found.add(tx.getId());
}
SetView<Integer> difference = Sets.difference(Sets.newHashSet(txIds), found);
if (!difference.isEmpty()) {
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TransactionEndpointImpl.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TransactionEndpointImpl.java
index e0caf470a26..ece6efdd004 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TransactionEndpointImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/TransactionEndpointImpl.java
@@ -15,8 +15,8 @@ import java.util.List;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.orcs.OrcsApi;
-import org.eclipse.osee.orcs.data.TransactionReadable;
import org.eclipse.osee.orcs.rest.model.Transaction;
import org.eclipse.osee.orcs.rest.model.TransactionEndpoint;
import org.eclipse.osee.orcs.transaction.CompareResults;
@@ -45,18 +45,17 @@ public class TransactionEndpointImpl implements TransactionEndpoint {
}
@Override
- public Transaction getTx(int txId) {
- TransactionReadable tx = orcsApi.getTransactionFactory().getTxById(txId);
- return OrcsRestUtil.asTransaction(tx);
+ public Transaction getTx(TransactionId tx) {
+ return OrcsRestUtil.asTransaction(orcsApi.getTransactionFactory().getTx(tx));
}
@Override
- public CompareResults compareTxs(int txId1, int txId2) {
+ public CompareResults compareTxs(TransactionId txId1, TransactionId txId2) {
return orcsApi.getTransactionFactory().compareTxs(txId1, txId2);
}
@Override
- public Response setTxComment(int txId, String comment) {
+ public Response setTxComment(TransactionId txId, String comment) {
return OrcsRestUtil.asResponse(orcsApi.getTransactionFactory().setTxComment(txId, comment));
}
@@ -72,9 +71,8 @@ public class TransactionEndpointImpl implements TransactionEndpoint {
}
@Override
- public Response replaceWithBaselineTxVersion(String userId, Long branchId, int txId, int artId, String comment) {
+ public Response replaceWithBaselineTxVersion(String userId, Long branchId, TransactionId txId, int artId, String comment) {
return OrcsRestUtil.asResponse(
orcsApi.getTransactionFactory().replaceWithBaselineTxVersion(userId, branchId, txId, artId, comment));
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/ArtifactSearch_V1.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/ArtifactSearch_V1.java
index c52c89f6dd6..fc5cbad2b0f 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/ArtifactSearch_V1.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/search/artifact/ArtifactSearch_V1.java
@@ -19,6 +19,7 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;
import org.eclipse.osee.framework.core.data.HasLocalId;
+import org.eclipse.osee.framework.core.data.TransactionId;
import org.eclipse.osee.framework.jdk.core.type.MatchLocation;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
@@ -67,7 +68,7 @@ public class ArtifactSearch_V1 extends ArtifactSearch {
builder.includeDeletedArtifacts(params.isIncludeDeleted());
if (params.getFromTx() > 0) {
- builder.fromTransaction(params.getFromTx());
+ builder.fromTransaction(TransactionId.valueOf(params.getFromTx()));
}
SearchResponse result = new SearchResponse();

Back to the top