Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Avila2015-06-23 01:23:18 +0000
committerAngel Avila2015-09-09 19:32:34 +0000
commit66ce528b1975ae3075545e38db14b70ececc753b (patch)
tree100ddd0e7a0114382cafb0a5cb2a3f0d89baca91
parentdd13054d5755f6402e6194d472f1c6ac1c362c9e (diff)
downloadorg.eclipse.osee-66ce528b1975ae3075545e38db14b70ececc753b.tar.gz
org.eclipse.osee-66ce528b1975ae3075545e38db14b70ececc753b.tar.xz
org.eclipse.osee-66ce528b1975ae3075545e38db14b70ececc753b.zip
refinement[ats_ATS193138]: Allow Dispo Groups to be independent of build
-rw-r--r--plugins/org.eclipse.osee.disposition.rest.model/src/org/eclipse/osee/disposition/model/DispoProgamDescriptorData.java28
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/DispoApi.java5
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoApiImpl.java13
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoQuery.java4
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoWriter.java2
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java61
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/DispoProgramResource.java41
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/web/legacy/admin.html7
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/web/legacy/js/adminController.js1
9 files changed, 141 insertions, 21 deletions
diff --git a/plugins/org.eclipse.osee.disposition.rest.model/src/org/eclipse/osee/disposition/model/DispoProgamDescriptorData.java b/plugins/org.eclipse.osee.disposition.rest.model/src/org/eclipse/osee/disposition/model/DispoProgamDescriptorData.java
new file mode 100644
index 00000000000..8e25e2fe098
--- /dev/null
+++ b/plugins/org.eclipse.osee.disposition.rest.model/src/org/eclipse/osee/disposition/model/DispoProgamDescriptorData.java
@@ -0,0 +1,28 @@
+/********************************************************************************
+ * 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.disposition.model;
+
+/**
+ * @author Angel Avila
+ */
+public class DispoProgamDescriptorData {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/DispoApi.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/DispoApi.java
index 379358b182f..754978cd10b 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/DispoApi.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/DispoApi.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.disposition.rest;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
import org.eclipse.osee.disposition.model.CopySetParams;
import org.eclipse.osee.disposition.model.DispoAnnotationData;
import org.eclipse.osee.disposition.model.DispoConfig;
@@ -48,6 +49,8 @@ public interface DispoApi {
DispoConfig getDispoConfig(DispoProgram program);
// Writes
+ Long createDispoProgram(String name);
+
Identifiable<String> createDispoSet(DispoProgram program, DispoSetDescriptorData descriptor);
String createDispoAnnotation(DispoProgram program, String itemId, DispoAnnotationData annotation, String userName);
@@ -69,6 +72,8 @@ public interface DispoApi {
boolean deleteDispoAnnotation(DispoProgram program, String itemId, String annotationId, String userName);
// Utilities
+ boolean isUniqueProgramName(String name);
+
boolean isUniqueSetName(DispoProgram program, String setName);
boolean isUniqueItemName(DispoProgram program, String setId, String itemName);
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoApiImpl.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoApiImpl.java
index dded9dc8539..03465965fbe 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoApiImpl.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoApiImpl.java
@@ -19,6 +19,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import org.eclipse.osee.disposition.model.CopySetParams;
import org.eclipse.osee.disposition.model.DispoAnnotationData;
import org.eclipse.osee.disposition.model.DispoConfig;
@@ -42,7 +43,6 @@ import org.eclipse.osee.executor.admin.ExecutorAdmin;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.jdk.core.type.Identifiable;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
-import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.json.JSONArray;
@@ -107,6 +107,12 @@ public class DispoApiImpl implements DispoApi {
}
@Override
+ public Long createDispoProgram(String name) {
+ ArtifactReadable author = getQuery().findUser();
+ return getWriter().createDispoProgram(author, name);
+ }
+
+ @Override
public Identifiable<String> createDispoSet(DispoProgram program, DispoSetDescriptorData descriptor) {
DispoSetData newSet = dataFactory.creteSetDataFromDescriptor(descriptor);
ArtifactReadable author = getQuery().findUser();
@@ -345,6 +351,11 @@ public class DispoApiImpl implements DispoApi {
}
@Override
+ public boolean isUniqueProgramName(String name) {
+ return getQuery().isUniqueProgramName(name);
+ }
+
+ @Override
public boolean isUniqueItemName(DispoProgram program, String setId, String name) {
return getQuery().isUniqueItemName(program, setId, name);
}
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoQuery.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoQuery.java
index 1794b74bd3b..2bf87056f4a 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoQuery.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoQuery.java
@@ -12,12 +12,12 @@ package org.eclipse.osee.disposition.rest.internal;
import java.util.Collection;
import java.util.List;
+import java.util.Set;
import org.eclipse.osee.disposition.model.DispoConfig;
import org.eclipse.osee.disposition.model.DispoItem;
import org.eclipse.osee.disposition.model.DispoProgram;
import org.eclipse.osee.disposition.model.DispoSet;
import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.orcs.data.ArtifactReadable;
/**
@@ -31,6 +31,8 @@ public interface DispoQuery {
ArtifactReadable findUnassignedUser();
+ boolean isUniqueProgramName(String name);
+
boolean isUniqueSetName(DispoProgram program, String name);
boolean isUniqueItemName(DispoProgram program, String setId, String name);
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoWriter.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoWriter.java
index 6966f9d4e48..42c11facfd2 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoWriter.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoWriter.java
@@ -23,6 +23,8 @@ import org.eclipse.osee.orcs.data.ArtifactReadable;
*/
public interface DispoWriter {
+ Long createDispoProgram(ArtifactReadable author, String name);
+
Identifiable<String> createDispoSet(ArtifactReadable author, DispoProgram program, DispoSet descriptor);
void updateDispoSet(ArtifactReadable author, DispoProgram program, String dispoSetId, DispoSet data);
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java
index 369a5571ead..160d4758294 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java
@@ -45,6 +45,7 @@ import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.resource.management.IResource;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.OrcsApi;
+import org.eclipse.osee.orcs.OrcsBranch;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
import org.eclipse.osee.orcs.data.BranchReadable;
@@ -84,6 +85,10 @@ public class OrcsStorageImpl implements Storage {
return orcsApi.getTransactionFactory();
}
+ private OrcsBranch getBranchFactory() {
+ return orcsApi.getBranchOps();
+ }
+
private void reloadTypes() {
orcsApi.getOrcsTypes().invalidateAll();
}
@@ -140,12 +145,19 @@ public class OrcsStorageImpl implements Storage {
}
@Override
+ public boolean isUniqueProgramName(String name) {
+ ResultSet<BranchReadable> results = getQuery().branchQuery().andNameEquals(name).getResults();
+
+ return results.isEmpty();
+ }
+
+ @Override
public boolean isUniqueSetName(DispoProgram program, String name) {
ResultSet<ArtifactReadable> results = getQuery()//
- .fromBranch(program.getUuid())//
- .andTypeEquals(DispoConstants.DispoSet)//
- .andNameEquals(name)//
- .getResults();
+ .fromBranch(program.getUuid())//
+ .andTypeEquals(DispoConstants.DispoSet)//
+ .andNameEquals(name)//
+ .getResults();
return results.isEmpty();
}
@@ -154,11 +166,11 @@ public class OrcsStorageImpl implements Storage {
public boolean isUniqueItemName(DispoProgram program, String setId, String name) {
ArtifactReadable setArt = findDispoArtifact(program, setId, DispoConstants.DispoSet);
ResultSet<ArtifactReadable> results = getQuery()//
- .fromBranch(program.getUuid())//
- .andRelatedTo(CoreRelationTypes.Default_Hierarchical__Parent, setArt)//
- .andTypeEquals(DispoConstants.DispoItem)//
- .andNameEquals(name)//
- .getResults();
+ .fromBranch(program.getUuid())//
+ .andRelatedTo(CoreRelationTypes.Default_Hierarchical__Parent, setArt)//
+ .andTypeEquals(DispoConstants.DispoItem)//
+ .andNameEquals(name)//
+ .getResults();
return results.isEmpty();
}
@@ -166,9 +178,9 @@ public class OrcsStorageImpl implements Storage {
@Override
public List<DispoSet> findDispoSets(DispoProgram program) {
ResultSet<ArtifactReadable> results = getQuery()//
- .fromBranch(program.getUuid())//
- .andTypeEquals(DispoConstants.DispoSet)//
- .getResults();
+ .fromBranch(program.getUuid())//
+ .andTypeEquals(DispoConstants.DispoSet)//
+ .getResults();
List<DispoSet> toReturn = new ArrayList<DispoSet>();
for (ArtifactReadable art : results) {
@@ -185,10 +197,10 @@ public class OrcsStorageImpl implements Storage {
private ArtifactReadable findDispoArtifact(DispoProgram program, String setId, IArtifactType type) {
return getQuery()//
- .fromBranch(program.getUuid())//
- .andTypeEquals(type)//
- .andGuid(setId)//
- .getResults().getOneOrNull();
+ .fromBranch(program.getUuid())//
+ .andTypeEquals(type)//
+ .andGuid(setId)//
+ .getResults().getOneOrNull();
}
@Override
@@ -206,6 +218,21 @@ public class OrcsStorageImpl implements Storage {
}
@Override
+ public Long createDispoProgram(ArtifactReadable author, String name) {
+ String normalizedName = "(DISPO)" + name;
+ BranchReadable dispoBranch = getQuery().branchQuery().andNameEquals("Dispo Parent").getResults().getExactlyOne();
+ IOseeBranch branch = TokenFactory.createBranch(normalizedName);
+
+ try {
+ getBranchFactory().createWorkingBranch(branch, author, dispoBranch, null).call();
+ } catch (Exception ex) {
+ throw new OseeCoreException(ex);
+ }
+
+ return branch.getGuid();
+ }
+
+ @Override
public Identifiable<String> createDispoSet(ArtifactReadable author, DispoProgram program, DispoSet descriptor) {
TransactionBuilder tx = getTxFactory().createTransaction(program.getUuid(), author, "Create Dispo Set");
ArtifactId creatdArtId = tx.createArtifact(DispoConstants.DispoSet, descriptor.getName());
@@ -422,7 +449,7 @@ public class OrcsStorageImpl implements Storage {
.andRelatedTo(CoreRelationTypes.Default_Hierarchical__Parent, dispoSetArt).and(
DispoConstants.DispoAnnotationsJson, keyword,//
QueryOption.CONTAINS_MATCH_OPTIONS)//
- .getResults();
+ .getResults();
for (ArtifactReadable art : dispoArtifacts) {
toReturn.add(new DispoItemArtifact(art));
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/DispoProgramResource.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/DispoProgramResource.java
index df9bc6d1822..fccca89c9b7 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/DispoProgramResource.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/DispoProgramResource.java
@@ -23,10 +23,12 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import org.eclipse.osee.disposition.model.DispoMessages;
+import org.eclipse.osee.disposition.model.DispoProgamDescriptorData;
import org.eclipse.osee.disposition.rest.DispoApi;
+import org.eclipse.osee.disposition.rest.DispoRoles;
import org.eclipse.osee.disposition.rest.util.DispoFactory;
import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -46,8 +48,43 @@ public class DispoProgramResource {
}
/**
+ * Create a new Disposition Set given a DispoSetDescriptor
+ *
+ * @param descriptor Descriptor Data which includes name and import path
+ * @return The created Disposition Set if successful. Error Code otherwise
+ * @response.representation.201.doc Created the Disposition Set
+ * @response.representation.409.doc Conflict, tried to create a Disposition Set with same name
+ * @response.representation.400.doc Bad Request, did not provide both a Name and a valid Import Path
+ */
+ @POST
+ @RolesAllowed(DispoRoles.ROLES_ADMINISTRATOR)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response createProgram(DispoProgamDescriptorData programDescriptor) {
+ String name = programDescriptor.getName();
+ Response.Status status;
+ Response response;
+
+ if (!name.isEmpty()) {
+ boolean isUniqueName = dispoApi.isUniqueProgramName(name);
+ if (isUniqueName) {
+ long createdProgramId = dispoApi.createDispoProgram(name);
+ status = Status.CREATED;
+ response = Response.status(status).entity(createdProgramId).build();
+ } else {
+ status = Status.CONFLICT;
+ response = Response.status(status).entity(DispoMessages.Set_ConflictingNames).build();
+ }
+ } else {
+ status = Status.BAD_REQUEST;
+ response = Response.status(status).entity(DispoMessages.Set_EmptyNameOrPath).build();
+ }
+ return response;
+ }
+
+ /**
* Get all Disposition Programs as JSON
- *
+ *
* @return The Disposition Programs found
* @throws JSONException
* @response.representation.200.doc OK, Found Disposition Program
diff --git a/plugins/org.eclipse.osee.disposition.rest/web/legacy/admin.html b/plugins/org.eclipse.osee.disposition.rest/web/legacy/admin.html
index 6b9bd545308..cbf480ac4c9 100644
--- a/plugins/org.eclipse.osee.disposition.rest/web/legacy/admin.html
+++ b/plugins/org.eclipse.osee.disposition.rest/web/legacy/admin.html
@@ -97,6 +97,13 @@
</div>
</script>
+
+
+ <script type="text/ng-template" id="loadingModal.html">
+ <div id="loadingModal" class="alert alert-info">
+ Loading...
+ </div>
+ </script>
</body>
diff --git a/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/adminController.js b/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/adminController.js
index e80463b4064..5eceaf326c8 100644
--- a/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/adminController.js
+++ b/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/adminController.js
@@ -93,6 +93,7 @@
width: 57,
cellTemplate: dellCellTmpl
}];
+
$scope.createNewProgram = function() {
if ($scope.newProgramName != "") {
var loadingModal = $scope.showLoadingModal();

Back to the top