Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java6
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF7
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java130
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchCommitOptions.java42
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java117
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/CompareResults.java39
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/NewBranch.java123
-rw-r--r--plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java42
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java366
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java98
13 files changed, 948 insertions, 32 deletions
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
index c3c824bffc..4b66ed5abe 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/OseeClient.java
@@ -14,6 +14,7 @@ import java.io.Writer;
import java.util.Collection;
import java.util.Properties;
import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.orcs.rest.model.BranchEndpoint;
/**
* @author John Misinco
@@ -30,4 +31,6 @@ public interface OseeClient {
Collection<String> getIdeClientSupportedVersions();
+ BranchEndpoint getBranchEndpoint();
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
index 08261e8287..cb164cecdd 100644
--- a/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
+++ b/plugins/org.eclipse.osee.orcs.rest.client/src/org/eclipse/osee/orcs/rest/client/internal/OseeClientImpl.java
@@ -37,6 +37,7 @@ import org.eclipse.osee.orcs.rest.client.internal.search.PredicateFactoryImpl;
import org.eclipse.osee.orcs.rest.client.internal.search.QueryBuilderImpl;
import org.eclipse.osee.orcs.rest.client.internal.search.QueryExecutor;
import org.eclipse.osee.orcs.rest.client.internal.search.QueryOptions;
+import org.eclipse.osee.orcs.rest.model.BranchEndpoint;
import org.eclipse.osee.orcs.rest.model.IdeVersion;
import org.eclipse.osee.orcs.rest.model.search.artifact.Predicate;
import org.eclipse.osee.orcs.rest.model.search.artifact.RequestType;
@@ -176,4 +177,9 @@ public class OseeClientImpl implements OseeClient, QueryExecutor {
}
}
+ @Override
+ public BranchEndpoint getBranchEndpoint() {
+ return client.targetProxy(baseUri, BranchEndpoint.class);
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF
index a4c7e6d618..bb1613a7fe 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.rest.model/META-INF/MANIFEST.MF
@@ -8,9 +8,14 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: org.eclipse.osee.orcs.rest.model,
org.eclipse.osee.orcs.rest.model.search.artifact,
org.eclipse.osee.orcs.rest.model.search.branch
-Import-Package: javax.xml.bind.annotation,
+Import-Package: javax.annotation.security;version="1.2.0",
+ javax.ws.rs;version="2.0.0",
+ javax.ws.rs.core;version="2.0.0",
+ javax.xml.bind.annotation,
+ org.eclipse.osee.framework.core.data,
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.exception,
+ org.eclipse.osee.framework.core.model.change,
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.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java
index 92ab72b086..a1fe15534a 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Branch.java
@@ -21,40 +21,138 @@ import org.eclipse.osee.framework.core.enums.BranchType;
@XmlRootElement
public class Branch {
- private String uuid;
+ private static final int DEFAULT_INT = -1;
+
+ private long branchUuid;
private String name;
- private BranchType branchType;
- private BranchState branchState;
- private BranchArchivedState branchArchivedState;
- private Transaction baseTransaction;
- private Transaction sourceTransaction;
+ private long parentBranchUuid;
+
+ private int associatedArtifactId = DEFAULT_INT;
+ private int baseTransaction = DEFAULT_INT;
+ private int sourceTransaction = DEFAULT_INT;
+
+ private BranchArchivedState archiveState = BranchArchivedState.UNARCHIVED;
+ private BranchState branchState = BranchState.CREATED;
+ private BranchType branchType = BranchType.WORKING;
+ private boolean inheritAccessControl = false;
+
+ public Branch() {
+ super();
+ }
+
+ public long getBranchUuid() {
+ return branchUuid;
+ }
- public String getId() {
- return uuid;
+ public void setBranchUuid(long branchUuid) {
+ this.branchUuid = branchUuid;
}
public String getName() {
return name;
}
- public BranchType getBranchType() {
- return branchType;
+ public void setName(String name) {
+ this.name = name;
}
- public BranchState getBranchState() {
- return branchState;
+ public int getAssociatedArtifactId() {
+ return associatedArtifactId;
}
- public BranchArchivedState getArchiveState() {
- return branchArchivedState;
+ public void setAssociatedArtifactId(int artId) {
+ associatedArtifactId = artId;
}
- public Transaction getBaseTransaction() {
+ public int getBaseTransactionId() {
return baseTransaction;
}
- public Transaction getSourceTransaction() {
+ public void setBaseTransactionId(int baseTx) {
+ baseTransaction = baseTx;
+ }
+
+ public int getSourceTransactionId() {
return sourceTransaction;
}
+ public void setSourceTransactionId(int sourceTx) {
+ sourceTransaction = sourceTx;
+ }
+
+ public long getParentBranchUuid() {
+ return parentBranchUuid;
+ }
+
+ public void setParentBranchUuid(long parentBranchUuid) {
+ this.parentBranchUuid = parentBranchUuid;
+ }
+
+ public boolean hasParentBranchUuid() {
+ return getParentBranchUuid() > 0;
+ }
+
+ public BranchArchivedState getArchiveState() {
+ return archiveState;
+ }
+
+ public void setArchiveState(BranchArchivedState state) {
+ this.archiveState = state;
+ }
+
+ public BranchState getBranchState() {
+ return branchState;
+ }
+
+ public void setBranchState(BranchState state) {
+ this.branchState = state;
+ }
+
+ public BranchType getBranchType() {
+ return branchType;
+ }
+
+ public void setBranchType(BranchType type) {
+ branchType = type;
+ }
+
+ public boolean isInheritAccessControl() {
+ return inheritAccessControl;
+ }
+
+ public void setInheritAccessControl(boolean inheritAccessControl) {
+ this.inheritAccessControl = inheritAccessControl;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (branchUuid ^ (branchUuid >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Branch other = (Branch) obj;
+ if (branchUuid != other.branchUuid) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Branch [branchUuid=" + getBranchUuid() + ", name=" + name + ", parentBranchUuid=" + getParentBranchUuid() + ", associatedArtifactId=" + associatedArtifactId + ", baseTransaction=" + baseTransaction + ", sourceTransaction=" + sourceTransaction + ", archiveState=" + archiveState + ", branchState=" + branchState + ", branchType=" + branchType + ", inheritAccessControl=" + inheritAccessControl + "]";
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchCommitOptions.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchCommitOptions.java
new file mode 100644
index 0000000000..e52653ec64
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchCommitOptions.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class BranchCommitOptions {
+
+ private static final int DEFAULT_COMMITTER_ID = -1;
+
+ private int committerId = DEFAULT_COMMITTER_ID;
+ private boolean archive;
+
+ public int getCommitterId() {
+ return committerId;
+ }
+
+ public void setCommitterId(int committerId) {
+ this.committerId = committerId;
+ }
+
+ public boolean isArchive() {
+ return archive;
+ }
+
+ public void setArchive(boolean archive) {
+ this.archive = archive;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java
new file mode 100644
index 0000000000..a48e3a4fbb
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/BranchEndpoint.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.model;
+
+import java.util.List;
+import javax.annotation.security.RolesAllowed;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.DefaultValue;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import org.eclipse.osee.framework.core.enums.BranchState;
+import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.jdk.core.type.SystemRoles;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@Path("branches")
+@RolesAllowed(SystemRoles.ROLES_AUTHENTICATED)
+public interface BranchEndpoint {
+
+ @GET
+ @Produces({MediaType.APPLICATION_JSON})
+ List<Branch> getBranches();
+
+ @GET
+ @Path("baseline")
+ @Produces(MediaType.APPLICATION_JSON)
+ List<Branch> getBaselineBranches();
+
+ @GET
+ @Path("working")
+ @Produces(MediaType.APPLICATION_JSON)
+ List<Branch> getWorkingBranches();
+
+ @GET
+ @Path("{branch-uuid}")
+ @Produces({MediaType.APPLICATION_JSON})
+ Branch getBranch(@PathParam("branch-uuid") long branchUuid);
+
+ @GET
+ @Path("{branch-uuid}/diff/{branch-uuid2}")
+ @Produces({MediaType.APPLICATION_JSON})
+ CompareResults compareBranches(@PathParam("branch-uuid") long branchUuid, @PathParam("branch-uuid2") long branchUuid2);
+
+ @POST
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ Response createBranch(NewBranch data);
+
+ @POST
+ @Path("{branch-uuid}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ Response createBranchWithId(@PathParam("branch-uuid") long branchUuid, NewBranch data);
+
+ @POST
+ @Path("{branch-uuid}/commit/{destination-branch-uuid}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Produces({MediaType.APPLICATION_JSON})
+ Response commitBranch(@PathParam("branch-uuid") long branchUuid, @PathParam("destination-branch-uuid") long destinationBranchUuid, BranchCommitOptions options);
+
+ @POST
+ @Path("{branch-uuid}/archive")
+ Response archiveBranch(@PathParam("branch-uuid") long branchUuid);
+
+ @PUT
+ @Path("{branch-uuid}/name/{branch-name}")
+ Response setBranchName(@PathParam("branch-uuid") long branchUuid, @PathParam("branch-name") String newName);
+
+ @PUT
+ @Path("{branch-uuid}/type/{branch-type}")
+ Response setBranchType(@PathParam("branch-uuid") long branchUuid, @PathParam("branch-type") BranchType newType);
+
+ @PUT
+ @Path("{branch-uuid}/state/{branch-state}")
+ Response setBranchState(@PathParam("branch-uuid") long branchUuid, @PathParam("branch-state") BranchState newState);
+
+ @PUT
+ @Path("{branch-uuid}/associated-artifact/{art-id}")
+ Response associateBranchToArtifact(@PathParam("branch-uuid") long branchUuid, @PathParam("art-id") int artifactId);
+
+ @DELETE
+ @Path("{branch-uuid}")
+ Response purgeBranch(@PathParam("branch-uuid") long branchUuid, @DefaultValue("false") @QueryParam("recurse") boolean recurse);
+
+ @DELETE
+ @Path("{branch-uuid}/associated-artifact")
+ Response unassociateBranch(@PathParam("branch-uuid") long branchUuid);
+
+ @DELETE
+ @Path("{branch-uuid}/commit/{destination-branch-uuid}")
+ @Produces({MediaType.APPLICATION_JSON})
+ Response unCommitBranch(@PathParam("branch-uuid") long branchUuid, @PathParam("destination-branch-uuid") long destinationBranchUuid);
+
+ @DELETE
+ @Path("{branch-uuid}/archive")
+ @Produces({MediaType.APPLICATION_JSON})
+ Response unarchiveBranch(@PathParam("branch-uuid") long branchUuid);
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/CompareResults.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/CompareResults.java
new file mode 100644
index 0000000000..35cf58e649
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/CompareResults.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.model;
+
+import java.util.Collections;
+import java.util.List;
+import javax.xml.bind.annotation.XmlRootElement;
+import org.eclipse.osee.framework.core.model.change.ChangeItem;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class CompareResults {
+
+ private List<ChangeItem> changes;
+
+ public List<ChangeItem> getChanges() {
+ return changes != null ? changes : Collections.<ChangeItem> emptyList();
+ }
+
+ public void setChanges(List<ChangeItem> changes) {
+ this.changes = changes;
+ }
+
+ @Override
+ public String toString() {
+ return "CompareResults [changes=" + changes + "]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/NewBranch.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/NewBranch.java
new file mode 100644
index 0000000000..321b4a9978
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/NewBranch.java
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import org.eclipse.osee.framework.core.enums.BranchType;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@XmlRootElement
+public class NewBranch {
+
+ private String branchName;
+ private long parentBranchId;
+ private int associatedArtifactId;
+ private BranchType branchType;
+
+ private int authorId;
+ private int sourceTransactionId;
+ private String creationComment;
+ private int mergeAddressingQueryId;
+ private long mergeDestinationBranchId;
+ private boolean txCopyBranchType;
+
+ public NewBranch() {
+ super();
+ }
+
+ public String getBranchName() {
+ return branchName;
+ }
+
+ public long getParentBranchId() {
+ return parentBranchId;
+ }
+
+ public int getAssociatedArtifactId() {
+ return associatedArtifactId;
+ }
+
+ public BranchType getBranchType() {
+ return branchType;
+ }
+
+ public int getAuthorId() {
+ return authorId;
+ }
+
+ public int getSourceTransactionId() {
+ return sourceTransactionId;
+ }
+
+ public String getCreationComment() {
+ return creationComment;
+ }
+
+ public int getMergeAddressingQueryId() {
+ return mergeAddressingQueryId;
+ }
+
+ public long getMergeDestinationBranchId() {
+ return mergeDestinationBranchId;
+ }
+
+ public boolean isTxCopyBranchType() {
+ return txCopyBranchType;
+ }
+
+ public void setBranchName(String branchName) {
+ this.branchName = branchName;
+ }
+
+ public void setParentBranchId(long parentBranchId) {
+ this.parentBranchId = parentBranchId;
+ }
+
+ public void setAssociatedArtifactId(int associatedArtifactId) {
+ this.associatedArtifactId = associatedArtifactId;
+ }
+
+ public void setBranchType(BranchType branchType) {
+ this.branchType = branchType;
+ }
+
+ public void setAuthorId(int authorId) {
+ this.authorId = authorId;
+ }
+
+ public void setSourceTransactionId(int sourceTransactionId) {
+ this.sourceTransactionId = sourceTransactionId;
+ }
+
+ public void setCreationComment(String creationComment) {
+ this.creationComment = creationComment;
+ }
+
+ public void setMergeAddressingQueryId(int mergeAddressingQueryId) {
+ this.mergeAddressingQueryId = mergeAddressingQueryId;
+ }
+
+ public void setMergeDestinationBranchId(long mergeDestinationBranchId) {
+ this.mergeDestinationBranchId = mergeDestinationBranchId;
+ }
+
+ public void setTxCopyBranchType(boolean txCopyBranchType) {
+ this.txCopyBranchType = txCopyBranchType;
+ }
+
+ @Override
+ public String toString() {
+ return "NewBranch [branchName=" + branchName + ", parentBranchId=" + parentBranchId + ", associatedArtifactId=" + associatedArtifactId + ", branchType=" + branchType + ", authorId=" + authorId + ", sourceTransactionId=" + sourceTransactionId + ", creationComment=" + creationComment + ", mergeAddressingQueryId=" + mergeAddressingQueryId + ", mergeDestinationBranchId=" + mergeDestinationBranchId + ", txCopyBranchType=" + txCopyBranchType + "]";
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java
index 7ddae90abe..2a26a9822c 100644
--- a/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java
+++ b/plugins/org.eclipse.osee.orcs.rest.model/src/org/eclipse/osee/orcs/rest/model/Transaction.java
@@ -20,13 +20,22 @@ import org.eclipse.osee.framework.core.enums.TransactionDetailsType;
@XmlRootElement
public class Transaction {
- private String branchUuid;
+ private int txId = -1;
+ private long branchUuid;
private TransactionDetailsType txType;
private String comment;
- private Date time;
- private int authorArtId;
+ private Date timestamp;
+ private int authorId;
private int commitArtId;
+ public int getTxId() {
+ return txId;
+ }
+
+ public void setTxId(int txId) {
+ this.txId = txId;
+ }
+
public TransactionDetailsType getTxType() {
return txType;
}
@@ -35,11 +44,11 @@ public class Transaction {
this.txType = txType;
}
- public String getBranchId() {
+ public long getBranchUuid() {
return branchUuid;
}
- public void setBranchId(String branchUuid) {
+ public void setBranchUuid(long branchUuid) {
this.branchUuid = branchUuid;
}
@@ -52,27 +61,32 @@ public class Transaction {
}
public Date getTimeStamp() {
- return time;
+ return timestamp;
}
- public void setTimeStamp(Date time) {
- this.time = time;
+ public void setTimeStamp(Date timestamp) {
+ this.timestamp = timestamp;
}
- public int getAuthor() {
- return authorArtId;
+ public int getAuthorId() {
+ return authorId;
}
- public void setAuthor(int authorArtId) {
- this.authorArtId = authorArtId;
+ public void setAuthorId(int authorId) {
+ this.authorId = authorId;
}
- public int getCommit() {
+ public int getCommitArtId() {
return commitArtId;
}
- public void setCommit(int commitArtId) {
+ public void setCommitArtId(int commitArtId) {
this.commitArtId = commitArtId;
}
+ @Override
+ public String toString() {
+ return "Transaction [txId=" + getTxId() + ", branchUuid=" + branchUuid + ", txType=" + txType + ", comment=" + comment + ", timestamp=" + timestamp + ", authorArtId=" + authorId + ", commitArtId=" + commitArtId + "]";
+ }
+
}
diff --git a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
index 46f8aaecca..2d7e7b8e99 100644
--- a/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.rest/META-INF/MANIFEST.MF
@@ -19,13 +19,16 @@ Import-Package: com.google.common.base;version="[11.0.0,15.0.0)",
org.eclipse.osee.framework.core.enums,
org.eclipse.osee.framework.core.model,
org.eclipse.osee.framework.core.model.cache,
+ org.eclipse.osee.framework.core.model.change,
org.eclipse.osee.framework.jdk.core.type,
org.eclipse.osee.framework.jdk.core.util,
+ org.eclipse.osee.jaxrs,
org.eclipse.osee.jaxrs.mvc,
org.eclipse.osee.orcs,
org.eclipse.osee.orcs.data,
org.eclipse.osee.orcs.rest.model,
org.eclipse.osee.orcs.rest.model.search.artifact,
org.eclipse.osee.orcs.rest.model.search.branch,
- org.eclipse.osee.orcs.search
+ org.eclipse.osee.orcs.search,
+ org.eclipse.osee.orcs.transaction
Osee-JaxRs-Resource: OSEE-INF/web/*;path=/orcs/script/ui
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
new file mode 100644
index 0000000000..f0a049c628
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/BranchEndpointImpl.java
@@ -0,0 +1,366 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.internal;
+
+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.asResponse;
+import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.asTransaction;
+import static org.eclipse.osee.orcs.rest.internal.OrcsRestUtil.executeCallable;
+import java.net.URI;
+import java.util.List;
+import java.util.concurrent.Callable;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+import org.eclipse.osee.framework.core.data.IOseeBranch;
+import org.eclipse.osee.framework.core.data.TokenFactory;
+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.CoreBranches;
+import org.eclipse.osee.framework.core.model.change.ChangeItem;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+import org.eclipse.osee.framework.jdk.core.util.Lib;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.eclipse.osee.jaxrs.OseeWebApplicationException;
+import org.eclipse.osee.orcs.ApplicationContext;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.OrcsBranch;
+import org.eclipse.osee.orcs.data.ArchiveOperation;
+import org.eclipse.osee.orcs.data.ArtifactReadable;
+import org.eclipse.osee.orcs.data.BranchReadable;
+import org.eclipse.osee.orcs.data.CreateBranchData;
+import org.eclipse.osee.orcs.data.TransactionReadable;
+import org.eclipse.osee.orcs.rest.model.Branch;
+import org.eclipse.osee.orcs.rest.model.BranchCommitOptions;
+import org.eclipse.osee.orcs.rest.model.BranchEndpoint;
+import org.eclipse.osee.orcs.rest.model.CompareResults;
+import org.eclipse.osee.orcs.rest.model.NewBranch;
+import org.eclipse.osee.orcs.search.BranchQuery;
+import org.eclipse.osee.orcs.search.QueryFactory;
+import org.eclipse.osee.orcs.search.TransactionQuery;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class BranchEndpointImpl implements BranchEndpoint {
+
+ private final OrcsApi orcsApi;
+
+ @Context
+ private UriInfo uriInfo;
+
+ public BranchEndpointImpl(OrcsApi orcsApi) {
+ this.orcsApi = orcsApi;
+ }
+
+ public void setUriInfo(UriInfo uriInfo) {
+ this.uriInfo = uriInfo;
+ }
+
+ public UriInfo getUriInfo() {
+ return uriInfo;
+ }
+
+ private ApplicationContext newContext() {
+ return new ApplicationContext() {
+
+ @Override
+ public String getSessionId() {
+ return null;
+ }
+ };
+ }
+
+ private QueryFactory newQuery() {
+ return orcsApi.getQueryFactory(newContext());
+ }
+
+ private BranchQuery newBranchQuery() {
+ return newQuery().branchQuery();
+ }
+
+ private TransactionQuery newTxQuery() {
+ return newQuery().transactionQuery();
+ }
+
+ private OrcsBranch getBranchOps() {
+ return orcsApi.getBranchOps(newContext());
+ }
+
+ private ArtifactReadable getArtifactById(IOseeBranch branch, int id) {
+ ArtifactReadable artifact = null;
+ if (id > 0) {
+ artifact = newQuery().fromBranch(branch).andLocalId(id).getResults().getExactlyOne();
+ }
+ return artifact;
+ }
+
+ private Long getBranchUuidFromTxId(int tx) {
+ TransactionQuery txQuery = newQuery().transactionQuery();
+ Long branchId = txQuery.andTxId(tx).getResults().getExactlyOne().getBranchId();
+ return branchId;
+ }
+
+ private BranchReadable getBranchById(long branchUuid) {
+ ResultSet<BranchReadable> results = newBranchQuery().andUuids(branchUuid)//
+ .includeArchived()//
+ .includeDeleted()//
+ .getResults();
+ return results.getExactlyOne();
+ }
+
+ @Override
+ public List<Branch> getBranches() {
+ ResultSet<BranchReadable> results = newBranchQuery()//
+ .includeArchived()//
+ .includeDeleted()//
+ .getResults();
+ return asBranches(results);
+ }
+
+ @Override
+ public List<Branch> getBaselineBranches() {
+ ResultSet<BranchReadable> results = newBranchQuery()//
+ .includeArchived(false) //
+ .includeDeleted(false) //
+ .andIsOfType(BranchType.BASELINE)//
+ .getResults();
+ return asBranches(results);
+ }
+
+ @Override
+ public List<Branch> getWorkingBranches() {
+ ResultSet<BranchReadable> results = newBranchQuery()//
+ .includeArchived(false) //
+ .includeDeleted(false) //
+ .andIsOfType(BranchType.WORKING)//
+ .getResults();
+ return asBranches(results);
+ }
+
+ @Override
+ public Branch getBranch(long branchUuid) {
+ BranchReadable branch = getBranchById(branchUuid);
+ return asBranch(branch);
+ }
+
+ @Override
+ public CompareResults compareBranches(long branchUuid, long branchUuid2) {
+ TransactionReadable sourceTx = newTxQuery().andIsHead(branchUuid).getResults().getExactlyOne();
+ TransactionReadable destinationTx = newTxQuery().andIsHead(branchUuid2).getResults().getExactlyOne();
+
+ Callable<List<ChangeItem>> op = getBranchOps().compareBranch(sourceTx, destinationTx);
+ List<ChangeItem> changes = executeCallable(op);
+
+ CompareResults data = new CompareResults();
+ data.setChanges(changes);
+ return data;
+ }
+
+ @Override
+ public Response createBranch(NewBranch data) {
+ long branchUuid = Lib.generateUuid();
+ return createBranchWithId(branchUuid, data);
+ }
+
+ @Override
+ public Response createBranchWithId(long branchUuid, NewBranch data) {
+ if (branchUuid <= 0) {
+ throw new OseeWebApplicationException(Status.BAD_REQUEST, "branchUuid [%d] uuid must be > 0", branchUuid);
+ }
+
+ CreateBranchData createData = new CreateBranchData();
+ createData.setUuid(branchUuid);
+ createData.setName(data.getBranchName());
+ createData.setBranchType(data.getBranchType());
+ createData.setCreationComment(data.getCreationComment());
+
+ createData.setUserArtifact(getArtifactById(CoreBranches.COMMON, data.getAuthorId()));
+ createData.setAssociatedArtifact(getArtifactById(CoreBranches.COMMON, data.getAssociatedArtifactId()));
+
+ createData.setFromTransaction(TokenFactory.createTransaction(data.getSourceTransactionId()));
+ createData.setParentBranchUuid(getBranchUuidFromTxId(data.getSourceTransactionId()));
+
+ createData.setMergeDestinationBranchId(data.getMergeDestinationBranchId());
+ createData.setMergeAddressingQueryId(data.getMergeAddressingQueryId());
+
+ createData.setTxCopyBranchType(data.isTxCopyBranchType());
+
+ Callable<BranchReadable> op = getBranchOps().createBranch(createData);
+ BranchReadable result = executeCallable(op);
+
+ UriInfo uriInfo = getUriInfo();
+ URI uri = getBranchLocation(uriInfo, result);
+ return Response.created(uri).entity(asBranch(result)).build();
+ }
+
+ private URI getBranchLocation(UriInfo uriInfo, BranchReadable branch) {
+ URI location = null;
+ String path = uriInfo.getPath();
+ if (Strings.isValid(path)) {
+ String value = path.replace("branches", "");
+ value = value.replaceAll("/", "");
+ if (Strings.isNumeric(value)) {
+ try {
+ Long id = Long.parseLong(value);
+ if (branch.getGuid().equals(id)) {
+ location = uriInfo.getRequestUri();
+ }
+ } catch (Exception ex) {
+ // do nothing
+ }
+ }
+ }
+
+ if (location == null) {
+ location = uriInfo.getRequestUriBuilder().path("{branch-uuid}").build(branch.getGuid());
+ }
+ return location;
+ }
+
+ @Override
+ public Response commitBranch(long branchUuid, long destinationBranchUuid, BranchCommitOptions options) {
+ BranchReadable srcBranch = getBranchById(branchUuid);
+ BranchReadable destBranch = getBranchById(destinationBranchUuid);
+
+ ArtifactReadable committer = getArtifactById(CoreBranches.COMMON, options.getCommitterId());
+ Callable<TransactionReadable> op = getBranchOps().commitBranch(committer, srcBranch, destBranch);
+ TransactionReadable tx = executeCallable(op);
+
+ if (options.isArchive()) {
+ Callable<?> op2 = getBranchOps().archiveUnarchiveBranch(srcBranch, ArchiveOperation.ARCHIVE);
+ executeCallable(op2);
+ }
+
+ UriInfo uriInfo = getUriInfo();
+ URI location = getTxLocation(uriInfo, tx);
+ return Response.created(location).entity(asTransaction(tx)).build();
+ }
+
+ private URI getTxLocation(UriInfo uriInfo, TransactionReadable tx) {
+ UriBuilder builder = uriInfo.getRequestUriBuilder();
+ URI location = builder.path("..").path("..").path("txs").path("{tx-id}").build(tx.getGuid());
+ return location;
+ }
+
+ @Override
+ public Response archiveBranch(long branchUuid) {
+ BranchReadable branch = getBranchById(branchUuid);
+
+ boolean modified = false;
+ BranchArchivedState currentState = branch.getArchiveState();
+ if (BranchArchivedState.UNARCHIVED == currentState) {
+ Callable<?> op = getBranchOps().archiveUnarchiveBranch(branch, ArchiveOperation.ARCHIVE);
+ executeCallable(op);
+ modified = true;
+ }
+ return asResponse(modified);
+ }
+
+ @Override
+ public Response setBranchName(long branchUuid, String newName) {
+ BranchReadable branch = getBranchById(branchUuid);
+ boolean modified = false;
+ if (isDifferent(branch.getName(), newName)) {
+ Callable<?> op = getBranchOps().changeBranchName(branch, newName);
+ executeCallable(op);
+ modified = true;
+ }
+ return asResponse(modified);
+ }
+
+ @Override
+ public Response setBranchType(long branchUuid, BranchType newType) {
+ BranchReadable branch = getBranchById(branchUuid);
+ boolean modified = false;
+ if (isDifferent(branch.getBranchType(), newType)) {
+ Callable<?> op = getBranchOps().changeBranchType(branch, newType);
+ executeCallable(op);
+ modified = true;
+ }
+ return asResponse(modified);
+ }
+
+ @Override
+ public Response setBranchState(long branchUuid, BranchState newState) {
+ BranchReadable branch = getBranchById(branchUuid);
+ boolean modified = false;
+ if (isDifferent(branch.getBranchState(), newState)) {
+ Callable<?> op = getBranchOps().changeBranchState(branch, newState);
+ executeCallable(op);
+ modified = true;
+ }
+ return asResponse(modified);
+ }
+
+ @Override
+ public Response associateBranchToArtifact(long branchUuid, int artifactId) {
+ BranchReadable branch = getBranchById(branchUuid);
+ boolean modified = false;
+ if (isDifferent(branch.getAssociatedArtifactId(), artifactId)) {
+ ArtifactReadable artifact =
+ newQuery().fromBranch(CoreBranches.COMMON).andLocalId(artifactId).getResults().getExactlyOne();
+ Callable<?> op = getBranchOps().associateBranchToArtifact(branch, artifact);
+ executeCallable(op);
+ modified = true;
+ }
+ return asResponse(modified);
+ }
+
+ @Override
+ public Response purgeBranch(long branchUuid, boolean recurse) {
+ boolean modified = false;
+ BranchReadable branch = getBranchById(branchUuid);
+ if (branch != null) {
+ Callable<?> op = getBranchOps().purgeBranch(branch, recurse);
+ executeCallable(op);
+ modified = true;
+ }
+ return asResponse(modified);
+ }
+
+ @Override
+ public Response unarchiveBranch(long branchUuid) {
+ BranchReadable branch = getBranchById(branchUuid);
+ BranchArchivedState state = branch.getArchiveState();
+
+ boolean modified = false;
+ if (BranchArchivedState.ARCHIVED == state) {
+ Callable<?> op = getBranchOps().archiveUnarchiveBranch(branch, ArchiveOperation.UNARCHIVE);
+ executeCallable(op);
+ modified = true;
+ }
+ return asResponse(modified);
+ }
+
+ @Override
+ public Response unCommitBranch(long branchUuid, long destinationBranchUuid) {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ @Override
+ public Response unassociateBranch(long branchUuid) {
+ BranchReadable branch = getBranchById(branchUuid);
+ boolean modified = false;
+ if (branch.getAssociatedArtifactId() != -1) {
+ Callable<?> op = getBranchOps().unassociateBranch(branch);
+ executeCallable(op);
+ modified = true;
+ }
+ return asResponse(modified);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
index 40ac38260b..c687b40247 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsApplication.java
@@ -47,6 +47,8 @@ public class OrcsApplication extends Application {
resources.add(new TypesQueryResource(orcsApi));
resources.add(new BranchQueryResource(orcsApi));
resources.add(new IdeClientResource());
+
+ resources.add(new BranchEndpointImpl(orcsApi));
}
public void stop() {
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java
new file mode 100644
index 0000000000..2f97d1e790
--- /dev/null
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/OrcsRestUtil.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * Copyright (c) 2015 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.orcs.rest.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Callable;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.framework.jdk.core.type.ResultSet;
+import org.eclipse.osee.orcs.data.BranchReadable;
+import org.eclipse.osee.orcs.data.TransactionReadable;
+import org.eclipse.osee.orcs.rest.model.Branch;
+import org.eclipse.osee.orcs.rest.model.Transaction;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public final class OrcsRestUtil {
+
+ private OrcsRestUtil() {
+ // Utility class
+ }
+
+ public static <T> T executeCallable(Callable<T> callable) {
+ try {
+ return callable.call();
+ } catch (Exception ex) {
+ if (ex instanceof OseeCoreException) {
+ throw (OseeCoreException) ex;
+ } else {
+ throw new OseeCoreException(ex);
+ }
+ }
+ }
+
+ public static Response asResponse(boolean modified) {
+ ResponseBuilder builder;
+ if (modified) {
+ builder = Response.ok();
+ } else {
+ builder = Response.notModified();
+ }
+ return builder.build();
+ }
+
+ public static List<Transaction> asTransactions(ResultSet<? extends TransactionReadable> results) {
+ List<Transaction> toReturn = new ArrayList<Transaction>(results.size());
+ for (TransactionReadable data : results) {
+ toReturn.add(asTransaction(data));
+ }
+ return toReturn;
+ }
+
+ public static List<Branch> asBranches(ResultSet<? extends BranchReadable> results) {
+ List<Branch> toReturn = new ArrayList<Branch>(results.size());
+ for (BranchReadable data : results) {
+ toReturn.add(asBranch(data));
+ }
+ return toReturn;
+ }
+
+ public static Branch asBranch(BranchReadable src) {
+ Branch data = new Branch();
+ data.setArchiveState(src.getArchiveState());
+ data.setAssociatedArtifactId(src.getAssociatedArtifactId());
+ data.setBaseTransactionId(src.getBaseTransaction());
+ data.setBranchState(src.getBranchState());
+ data.setBranchType(src.getBranchType());
+ data.setInheritAccessControl(src.isInheritAccessControl());
+ data.setName(src.getName());
+ data.setParentBranchUuid(src.getParentBranch());
+ data.setSourceTransactionId(src.getSourceTransaction());
+ data.setBranchUuid(src.getGuid());
+ return data;
+ }
+
+ public static Transaction asTransaction(TransactionReadable tx) {
+ Transaction data = new Transaction();
+ data.setTxId(tx.getGuid());
+ data.setAuthorId(tx.getAuthorId());
+ data.setBranchUuid(tx.getBranchId());
+ data.setComment(tx.getComment());
+ data.setCommitArtId(tx.getCommit());
+ data.setTimeStamp(tx.getDate());
+ data.setTxType(tx.getTxType());
+ return data;
+ }
+}

Back to the top