From dd13054d5755f6402e6194d472f1c6ac1c362c9e Mon Sep 17 00:00:00 2001 From: Angel Avila Date: Fri, 7 Aug 2015 12:44:00 -0700 Subject: refinement: Fix minor Dispo GUI issues Change-Id: Ic2d6eb9c539f430ba690e1272052bd550c7e9aba --- .../disposition/rest/internal/DispoApiTest.java | 10 +- .../rest/resources/DispoProgramResourceTest.java | 8 +- .../eclipse/osee/disposition/rest/DispoApi.java | 3 +- .../disposition/rest/internal/DispoApiImpl.java | 2 +- .../osee/disposition/rest/internal/DispoQuery.java | 2 +- .../disposition/rest/internal/OrcsStorageImpl.java | 86 ++++------ .../rest/internal/importer/DispoSetCopier.java | 184 +++++++++++---------- .../rest/resources/DispoProgramResource.java | 14 +- .../rest/resources/DispoSetResource.java | 14 +- .../web/legacy/admin.html | 5 +- .../web/legacy/js/adminController.js | 73 ++++++-- .../web/legacy/js/dispoApp.js | 2 +- .../web/legacy/js/mainController.js | 8 +- .../web/legacy/js/userController.js | 6 +- .../src/dispo/js/adminController.js | 74 +++++++-- .../src/dispo/js/userController.js | 3 + .../src/dispo/views/admin.html | 11 +- 17 files changed, 303 insertions(+), 202 deletions(-) (limited to 'plugins') diff --git a/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/internal/DispoApiTest.java b/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/internal/DispoApiTest.java index 16a4753b2a3..d24cdd066c2 100644 --- a/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/internal/DispoApiTest.java +++ b/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/internal/DispoApiTest.java @@ -32,8 +32,6 @@ import org.eclipse.osee.disposition.model.DispoSetDescriptorData; import org.eclipse.osee.framework.core.data.ArtifactId; 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.ResultSet; -import org.eclipse.osee.framework.jdk.core.type.ResultSets; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.orcs.data.ArtifactReadable; import org.json.JSONArray; @@ -125,9 +123,9 @@ public class DispoApiTest { @Test public void testGetDispoPrograms() { - ResultSet programsSet = ResultSets.singleton(mockBranch); + List programsSet = Collections.singletonList(mockBranch); when(storage.getDispoBranches()).thenAnswer(newAnswer(programsSet)); - ResultSet actual = dispoApi.getDispoPrograms(); + List actual = dispoApi.getDispoPrograms(); assertEquals(programsSet.iterator().next(), actual.iterator().next()); } @@ -273,9 +271,9 @@ public class DispoApiTest { when(dispoItem.getDiscrepanciesList()).thenReturn(jsonObject); when(dataFactory.createUpdatedItem(eq(jsonArray), eq(jsonObject))).thenReturn(dispoItem); when(dispoConnector.connectAnnotation(annotationToCreate, jsonObject)).thenReturn(false); - annotationToCreate.setIsConnected(true); //Assume this Annotation was connected + annotationToCreate.setIsConnected(true); //Assume this Annotation was connected - // Only need to createUpdatedItem with updateStatus = True when annotation is valid and current status is INCOMPLETE + // Only need to createUpdatedItem with updateStatus = True when annotation is valid and current status is INCOMPLETE annotationToCreate.setResolution("VALID"); when(dispoItem.getStatus()).thenReturn("COMPLETE"); when(validator.validate(Matchers.any(DispoAnnotationData.class))).thenReturn(true); diff --git a/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/resources/DispoProgramResourceTest.java b/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/resources/DispoProgramResourceTest.java index 8b4b1a97a8d..254d4aad045 100644 --- a/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/resources/DispoProgramResourceTest.java +++ b/plugins/org.eclipse.osee.disposition.rest.test/src/org/eclipse/osee/disposition/rest/resources/DispoProgramResourceTest.java @@ -12,14 +12,14 @@ package org.eclipse.osee.disposition.rest.resources; import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; +import java.util.Collections; +import java.util.List; import javax.ws.rs.core.Response; import org.eclipse.osee.disposition.model.DispoProgram; import org.eclipse.osee.disposition.rest.DispoApi; import org.eclipse.osee.disposition.rest.util.DispoFactory; import org.eclipse.osee.framework.core.data.IOseeBranch; import org.eclipse.osee.framework.core.data.TokenFactory; -import org.eclipse.osee.framework.jdk.core.type.ResultSet; -import org.eclipse.osee.framework.jdk.core.type.ResultSets; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -55,7 +55,7 @@ public class DispoProgramResourceTest { @Test public void testGetAll() throws JSONException { // No Sets - ResultSet emptyResultSet = ResultSets.emptyResultSet(); + List emptyResultSet = Collections.emptyList(); when(dispoApi.getDispoPrograms()).thenReturn(emptyResultSet); Response noProgramsResponse = resource.getAllPrograms(); String messageActual = (String) noProgramsResponse.getEntity(); @@ -63,7 +63,7 @@ public class DispoProgramResourceTest { assertEquals("[]", messageActual); IOseeBranch branch = TokenFactory.createBranch(id1.getUuid(), "testBranch"); - ResultSet branchList = ResultSets.singleton(branch); + List branchList = Collections.singletonList(branch); when(dispoApi.getDispoPrograms()).thenReturn(branchList); Response oneSetResponse = resource.getAllPrograms(); 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 f1140c3c056..379358b182f 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 @@ -24,7 +24,6 @@ import org.eclipse.osee.disposition.model.DispoSetDescriptorData; import org.eclipse.osee.disposition.rest.util.DispoFactory; 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.ResultSet; /** * @author Angel Avila @@ -32,7 +31,7 @@ import org.eclipse.osee.framework.jdk.core.type.ResultSet; public interface DispoApi { // Queries - ResultSet getDispoPrograms(); + List getDispoPrograms(); List getDispoSets(DispoProgram program); 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 182154943e3..dded9dc8539 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 @@ -285,7 +285,7 @@ public class DispoApiImpl implements DispoApi { } @Override - public ResultSet getDispoPrograms() { + public List getDispoPrograms() { return getQuery().getDispoBranches(); } 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 c377bfae337..1794b74bd3b 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 @@ -43,7 +43,7 @@ public interface DispoQuery { DispoItem findDispoItemById(DispoProgram program, String itemId); - ResultSet getDispoBranches(); + List getDispoBranches(); Collection findDispoItemByAnnoationText(DispoProgram program, String setId, String keyword); 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 198eea5a6eb..369a5571ead 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 @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.osee.disposition.rest.internal; -import static org.eclipse.osee.disposition.model.DispoStrings.Dispo_Config_Art; import static org.eclipse.osee.disposition.rest.DispoConstants.DispoTypesArtifact; import static org.eclipse.osee.framework.core.enums.CoreArtifactTypes.OseeTypeDefinition; import static org.eclipse.osee.framework.core.enums.CoreAttributeTypes.UriGeneralStringData; @@ -21,8 +20,6 @@ import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.eclipse.osee.disposition.model.DispoConfig; import org.eclipse.osee.disposition.model.DispoItem; import org.eclipse.osee.disposition.model.DispoProgram; @@ -43,7 +40,6 @@ import org.eclipse.osee.framework.core.enums.SystemUser; 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.framework.jdk.core.type.ResultSets; import org.eclipse.osee.framework.jdk.core.util.Lib; import org.eclipse.osee.framework.jdk.core.util.Strings; import org.eclipse.osee.framework.resource.management.IResource; @@ -146,10 +142,10 @@ public class OrcsStorageImpl implements Storage { @Override public boolean isUniqueSetName(DispoProgram program, String name) { ResultSet results = getQuery()// - .fromBranch(program.getUuid())// - .andTypeEquals(DispoConstants.DispoSet)// - .andNameEquals(name)// - .getResults(); + .fromBranch(program.getUuid())// + .andTypeEquals(DispoConstants.DispoSet)// + .andNameEquals(name)// + .getResults(); return results.isEmpty(); } @@ -158,11 +154,11 @@ public class OrcsStorageImpl implements Storage { public boolean isUniqueItemName(DispoProgram program, String setId, String name) { ArtifactReadable setArt = findDispoArtifact(program, setId, DispoConstants.DispoSet); ResultSet 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(); } @@ -170,9 +166,9 @@ public class OrcsStorageImpl implements Storage { @Override public List findDispoSets(DispoProgram program) { ResultSet results = getQuery()// - .fromBranch(program.getUuid())// - .andTypeEquals(DispoConstants.DispoSet)// - .getResults(); + .fromBranch(program.getUuid())// + .andTypeEquals(DispoConstants.DispoSet)// + .getResults(); List toReturn = new ArrayList(); for (ArtifactReadable art : results) { @@ -189,10 +185,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 @@ -396,48 +392,22 @@ public class OrcsStorageImpl implements Storage { tx.commit(); } - private String getDispoConfigContents() { - BranchReadable branchRead = getQuery().branchQuery().andIds(CoreBranches.COMMON).getResults().getExactlyOne(); - - ArtifactReadable configArt = - getQuery().fromBranch(branchRead).andNameEquals(Dispo_Config_Art).getResults().getExactlyOne(); - - return configArt.getSoleAttributeAsString(CoreAttributeTypes.GeneralStringData); - } + @Override + public List getDispoBranches() { + List dispoBranchesNormalized = new ArrayList(); + BranchReadable dispoBranch = getQuery().branchQuery().andNameEquals("Dispo Parent").getResults().getExactlyOne(); - private IOseeBranch convertToDispoBranch(String configContents, IOseeBranch baselineBranch) { - IOseeBranch toReturn = null; + ResultSet dispoBranches = + getQuery().branchQuery().andIsOfType(BranchType.WORKING).andIsChildOf(dispoBranch).getResults(); - Pattern regex = Pattern.compile("(\\n|^+)" + baselineBranch.getUuid() + "\\s*:\\s*.*"); - Matcher matcher = regex.matcher(configContents); + for (BranchReadable branch : dispoBranches) { + IOseeBranch newName = + TokenFactory.createBranch(branch.getUuid(), branch.getName().replaceFirst("\\(DISPO\\)", "")); - Long uuid = null; - if (matcher.find()) { - String match = matcher.group(); - String[] split = match.split(":"); - uuid = Long.valueOf(split[1]); - } - if (uuid != null) { - toReturn = TokenFactory.createBranch(uuid, baselineBranch.getName()); + dispoBranchesNormalized.add(newName); } - return toReturn; - } - - @Override - public ResultSet getDispoBranches() { - ResultSet baselineBranches = - getQuery().branchQuery().andIsOfType(BranchType.BASELINE).getResults(); - - String configContents = getDispoConfigContents(); - List results = new ArrayList(); - for (BranchReadable baselineBranch : baselineBranches) { - IOseeBranch dispoBranch = convertToDispoBranch(configContents, baselineBranch); - if (dispoBranch != null) { - results.add(dispoBranch); - } - } - return ResultSets.newResultSet(results); + return dispoBranchesNormalized; } @Override @@ -452,7 +422,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/internal/importer/DispoSetCopier.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/DispoSetCopier.java index 7a78d052585..25b37277749 100644 --- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/DispoSetCopier.java +++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/importer/DispoSetCopier.java @@ -145,7 +145,7 @@ public class DispoSetCopier { * Annotation is invalid, mark as such by making the location Ref negative, don't bother connecting the * annotation */ - // Make location ref negative to indicate this + // Make location ref negative to indicate this String locationRefs = sourceAnnotation.getLocationRefs(); Integer locationRefAsInt = Integer.valueOf(locationRefs); if (locationRefAsInt > 0) { @@ -258,40 +258,42 @@ public class DispoSetCopier { String sourceCategory = sourceItem.getCategory(); String newCategory; - switch (option) { - case OVERRIDE: - newCategory = sourceCategory; - break; - case OVERRIDE_EMPTY: - if (!Strings.isValid(currentCategory)) { + if (Strings.isValid(sourceCategory)) { + switch (option) { + case OVERRIDE: newCategory = sourceCategory; - } else { + break; + case OVERRIDE_EMPTY: + if (!Strings.isValid(currentCategory)) { + newCategory = sourceCategory; + } else { + newCategory = currentCategory; + } + break; + case MERGE: + if (!Strings.isValid(currentCategory)) { + newCategory = sourceCategory; + } else { + newCategory = currentCategory + "::" + sourceCategory; + } + break; + case NONE: + default: newCategory = currentCategory; - } - break; - case MERGE: - if (!Strings.isValid(currentCategory)) { - newCategory = sourceCategory; - } else { - newCategory = currentCategory + "::" + sourceCategory; - } - break; - case NONE: - default: - newCategory = currentCategory; - break; - } + break; + } - // Check to see if this item is already set to be edited - DispoItem matchingToEdit = toEdit.get(sourceItem.getName()); - if (matchingToEdit != null) { - ((DispoItemData) matchingToEdit).setCategory(newCategory); - } else { - DispoItemData newToEdit = new DispoItemData(); - newToEdit.setGuid(destItem.getGuid()); - newToEdit.setName(destItem.getName()); - newToEdit.setCategory(newCategory); - toEdit.put(newToEdit.getName(), newToEdit); + // Check to see if this item is already set to be edited + DispoItem matchingToEdit = toEdit.get(sourceItem.getName()); + if (matchingToEdit != null) { + ((DispoItemData) matchingToEdit).setCategory(newCategory); + } else { + DispoItemData newToEdit = new DispoItemData(); + newToEdit.setGuid(destItem.getGuid()); + newToEdit.setName(destItem.getName()); + newToEdit.setCategory(newCategory); + toEdit.put(newToEdit.getName(), newToEdit); + } } } } @@ -306,35 +308,37 @@ public class DispoSetCopier { String sourceAssignee = sourceItem.getAssignee(); String newAssignee; - switch (option) { - case OVERRIDE: - newAssignee = sourceAssignee; - break; - case OVERRIDE_EMPTY: - if (currentAssignee.equalsIgnoreCase("UNASSIGNED")) { + if (!sourceAssignee.equalsIgnoreCase("UNASSIGNED")) { + switch (option) { + case OVERRIDE: newAssignee = sourceAssignee; - } else { + break; + case OVERRIDE_EMPTY: + if (currentAssignee.equalsIgnoreCase("UNASSIGNED")) { + newAssignee = sourceAssignee; + } else { + newAssignee = currentAssignee; + } + break; + case MERGE: + // Should not get here + case NONE: + default: newAssignee = currentAssignee; - } - break; - case MERGE: - // Should not get here - case NONE: - default: - newAssignee = currentAssignee; - break; - } + break; + } - // Check to see if this item is already set to be edited - DispoItem matchingToEdit = toEdit.get(sourceItem.getName()); - if (matchingToEdit != null) { - ((DispoItemData) matchingToEdit).setAssignee(newAssignee); - } else { - DispoItemData newToEdit = new DispoItemData(); - newToEdit.setGuid(destItem.getGuid()); - newToEdit.setName(destItem.getName()); - newToEdit.setAssignee(newAssignee); - toEdit.put(newToEdit.getName(), newToEdit); + // Check to see if this item is already set to be edited + DispoItem matchingToEdit = toEdit.get(sourceItem.getName()); + if (matchingToEdit != null) { + ((DispoItemData) matchingToEdit).setAssignee(newAssignee); + } else { + DispoItemData newToEdit = new DispoItemData(); + newToEdit.setGuid(destItem.getGuid()); + newToEdit.setName(destItem.getName()); + newToEdit.setAssignee(newAssignee); + toEdit.put(newToEdit.getName(), newToEdit); + } } } } @@ -349,40 +353,42 @@ public class DispoSetCopier { String sourceItemNotes = sourceItem.getItemNotes(); String newItemNotes; - switch (option) { - case OVERRIDE: - newItemNotes = sourceItemNotes; - break; - case OVERRIDE_EMPTY: - if (!Strings.isValid(currentItemNotes)) { + if (Strings.isValid(sourceItemNotes)) { + switch (option) { + case OVERRIDE: newItemNotes = sourceItemNotes; - } else { + break; + case OVERRIDE_EMPTY: + if (!Strings.isValid(currentItemNotes)) { + newItemNotes = sourceItemNotes; + } else { + newItemNotes = currentItemNotes; + } + break; + case MERGE: + if (!Strings.isValid(currentItemNotes)) { + newItemNotes = sourceItemNotes; + } else { + newItemNotes = currentItemNotes + "::" + sourceItemNotes; + } + break; + case NONE: + default: newItemNotes = currentItemNotes; - } - break; - case MERGE: - if (!Strings.isValid(currentItemNotes)) { - newItemNotes = sourceItemNotes; - } else { - newItemNotes = currentItemNotes + "::" + sourceItemNotes; - } - break; - case NONE: - default: - newItemNotes = currentItemNotes; - break; - } + break; + } - // Check to see if this item is already set to be edited - DispoItem matchingToEdit = toEdit.get(sourceItem.getName()); - if (matchingToEdit != null) { - ((DispoItemData) matchingToEdit).setItemNotes(newItemNotes); - } else { - DispoItemData newToEdit = new DispoItemData(); - newToEdit.setGuid(destItem.getGuid()); - newToEdit.setName(destItem.getName()); - newToEdit.setItemNotes(newItemNotes); - toEdit.put(newToEdit.getName(), newToEdit); + // Check to see if this item is already set to be edited + DispoItem matchingToEdit = toEdit.get(sourceItem.getName()); + if (matchingToEdit != null) { + ((DispoItemData) matchingToEdit).setItemNotes(newItemNotes); + } else { + DispoItemData newToEdit = new DispoItemData(); + newToEdit.setGuid(destItem.getGuid()); + newToEdit.setName(destItem.getName()); + newToEdit.setItemNotes(newItemNotes); + toEdit.put(newToEdit.getName(), newToEdit); + } } } } 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 a8aafb7abb9..df9bc6d1822 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 @@ -10,7 +10,13 @@ *******************************************************************************/ package org.eclipse.osee.disposition.rest.resources; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import javax.annotation.security.RolesAllowed; +import javax.ws.rs.Consumes; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; @@ -50,7 +56,13 @@ public class DispoProgramResource { @GET @Produces(MediaType.APPLICATION_JSON) public Response getAllPrograms() throws JSONException { - ResultSet allPrograms = dispoApi.getDispoPrograms(); + List allPrograms = dispoApi.getDispoPrograms(); + Collections.sort(allPrograms, new Comparator() { + @Override + public int compare(IOseeBranch o1, IOseeBranch o2) { + return o1.getName().compareTo(o2.getName()); + } + }); JSONArray jarray = new JSONArray(); for (IOseeBranch branch : allPrograms) { diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/DispoSetResource.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/DispoSetResource.java index 32f7b97e1e3..b7a0629d965 100644 --- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/DispoSetResource.java +++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/DispoSetResource.java @@ -54,7 +54,7 @@ public class DispoSetResource { /** * 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 @@ -92,7 +92,7 @@ public class DispoSetResource { /** * Get a specific Disposition Set given a setId - * + * * @param setId The Id of the Disposition Set to search for * @return The found Disposition Set if successful. Error Code otherwise * @response.representation.200.doc OK, Found Disposition Set @@ -114,7 +114,7 @@ public class DispoSetResource { /** * Get all Disposition Sets on the given program branch - * + * * @return The Disposition Sets found on the program branch * @throws JSONException * @response.representation.200.doc OK, Found Disposition Sets @@ -137,7 +137,7 @@ public class DispoSetResource { } } Status status; - if (allDispoSets.isEmpty()) { + if (jarray.length() <= 0) { status = Status.NOT_FOUND; } else { status = Status.OK; @@ -147,7 +147,7 @@ public class DispoSetResource { /** * Edit a specific Disposition Set given a setId and new Disposition Set Data - * + * * @param setId The Id of the Disposition Set to search for * @param newDispositionSet The data for the new Disposition Set * @return The updated Disposition Set if successful. Error Code otherwise @@ -173,7 +173,7 @@ public class DispoSetResource { /** * Delete a specific Disposition Set given a setId - * + * * @param setId The Id of the Disposition Set to search for * @return Response Code * @response.representation.200.doc OK, Found Disposition Set @@ -205,7 +205,7 @@ public class DispoSetResource { /** * Get a specific Dispositionable Item given a key word within the Dispositions - * + * * @param itemId The Id of the Dispositionable Item to search for * @return The found Dispositionable Item if successful. Error Code otherwise * @response.representation.200.doc OK, Found Dispositionable Item 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 cc0115743c8..6b9bd545308 100644 --- a/plugins/org.eclipse.osee.disposition.rest/web/legacy/admin.html +++ b/plugins/org.eclipse.osee.disposition.rest/web/legacy/admin.html @@ -7,6 +7,9 @@
Select ATS Version
+
+ Add New
+
@@ -21,7 +24,7 @@
- +
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 3c6b5a439cd..e80463b4064 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 @@ -5,7 +5,10 @@ $scope.modalShown = false; $scope.primarySet = ""; $scope.secondarySet = ""; - $scope.sets = []; + $scope.sets = {}; + $scope.addNew = false; + $scope.newProgramName = "" + $scope.isCopying = false; $scope.cachedValue = ""; @@ -90,6 +93,32 @@ width: 57, cellTemplate: dellCellTmpl }]; + $scope.createNewProgram = function() { + if ($scope.newProgramName != "") { + var loadingModal = $scope.showLoadingModal(); + var newProgram = new Program; + newProgram.name = $scope.newProgramName; + newProgram.$save({ + name: $scope.newProgramName + }, function() { + $scope.newProgramName = ""; + $scope.addNew = false; + loadingModal.close(); + $scope.programs = Program.query(); + }, function() { + loadingModal.close(); + alert("Oops...Something went wrong"); + }); + } + } + + $scope.toggleAddNew = function() { + if($scope.addNew) { + $scope.addNew = false; + } else { + $scope.addNew = true; + } + } $scope.columnDefs = $scope.columnDefs1; @@ -128,16 +157,19 @@ $scope.updateProgram = function updateProgram() { + var loadingModal = $scope.showLoadingModal(); $scope.loading = true; - $scope.items = {}; - $scope.sets = {}; - Set.query({ - programId: $scope.programSelection, - type: $rootScope.type - }, function(data) { - $scope.loading = false; - $scope.sets = data; - }); + $scope.items = {}; + Set.query({ + programId: $scope.programSelection, + type: $rootScope.type + }, function(data) { + loadingModal.close(); + $scope.sets = data; + }, function(data) { + loadingModal.close(); + alert(data.statusText); + }); }; $scope.editSet = function editSet(set) { @@ -204,13 +236,14 @@ newSet.dispoType = $rootScope.type; newSet.$save({ programId: $scope.programSelection - }, function() { - $scope.sets.push(newSet); + }, function(data) { + $scope.sets.push(data); }); } }; $scope.copySet = function(inputs) { + $scope.isCopying = true; var copySetOp = new CopySet; copySetOp.annotationParam = inputs.annotationParam; copySetOp.categoryParam = inputs.categoryParam; @@ -222,11 +255,27 @@ destinationSet: inputs.destinationSet, sourceSet: inputs.sourceSet, }, function(data) { + $scope.isCopying = false; var reportUrl = data.operationStatus; window.open(reportUrl); console.log(data); + }, function(data) { + $scope.isCopying = false; + alert("Oops...Something went wrong"); }); } + + // Loading Modal + $scope.showLoadingModal = function() { + var modalInstance = $modal.open({ + templateUrl: 'loadingModal.html', + size: 'sm', + windowClass: 'needsRerunModal', + backdrop: 'static' + }); + + return modalInstance; + } // Create Set Modal $scope.createNewSetModal = function() { diff --git a/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/dispoApp.js b/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/dispoApp.js index 1a4505024d5..be8693b48cc 100644 --- a/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/dispoApp.js +++ b/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/dispoApp.js @@ -1,7 +1,7 @@ /** * Dispo app definition */ -var app = angular.module('dispoApp', ['ngRoute', 'ngResource', 'ui.bootstrap', 'ngGrid', 'mc.resizer', 'ngCookies', ]); +var app = angular.module('dispoApp', ['ngRoute', 'ngResource', 'ui.bootstrap', 'ngGrid', 'mc.resizer', 'ngStorage', ]); app.config(['$routeProvider', diff --git a/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/mainController.js b/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/mainController.js index e6c873363bf..69f7113b2bc 100644 --- a/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/mainController.js +++ b/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/mainController.js @@ -1,9 +1,9 @@ app.controller('mainController', [ '$rootScope', - '$cookieStore', + '$localStorage', '$modal', - function($rootScope, $cookieStore, $modal) { + function($rootScope, $localStorage, $modal) { $rootScope.type = 'testScript'; $rootScope.searchResults = []; @@ -12,7 +12,7 @@ app.controller('mainController', [ $rootScope.attempts = 0; while(($rootScope.cachedName == null || $rootScope.cachedName == "") && $rootScope.attempts < 5) { var nameEnter=prompt("Please enter your name",""); - $cookieStore.put('cachedName', nameEnter); + $localStorage.cachedName = nameEnter; $rootScope.cachedName = nameEnter; $rootScope.attempts++; } @@ -22,7 +22,7 @@ app.controller('mainController', [ } - $rootScope.cachedName = $cookieStore.get('cachedName'); + $rootScope.cachedName = $localStorage.cachedName; $rootScope.setUserName(); $rootScope.resetUserName = function() { diff --git a/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/userController.js b/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/userController.js index 411f516512a..08aa8dfecb5 100644 --- a/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/userController.js +++ b/plugins/org.eclipse.osee.disposition.rest/web/legacy/js/userController.js @@ -2,7 +2,6 @@ app.controller('userController', [ '$scope', '$modal', '$rootScope', - '$cookieStore', 'Program', 'Set', 'Item', @@ -10,7 +9,7 @@ app.controller('userController', [ 'SetSearch', 'SourceFile', 'Config', - function($scope, $modal, $rootScope, $cookieStore, Program, Set, Item, Annotation, SetSearch, SourceFile, Config) { + function($scope, $modal, $rootScope, Program, Set, Item, Annotation, SetSearch, SourceFile, Config) { $scope.unselectingItem = false; $scope.editItems = false; $scope.selectedItems = []; @@ -70,6 +69,9 @@ app.controller('userController', [ }, function(data) { loadingModal.close(); $scope.sets = data; + }, function(data) { + loadingModal.close(); + alert(data.statusText); }); // Try to get custom config diff --git a/plugins/org.eclipse.osee.web.ui/src/dispo/js/adminController.js b/plugins/org.eclipse.osee.web.ui/src/dispo/js/adminController.js index 3c6b5a439cd..5eceaf326c8 100644 --- a/plugins/org.eclipse.osee.web.ui/src/dispo/js/adminController.js +++ b/plugins/org.eclipse.osee.web.ui/src/dispo/js/adminController.js @@ -5,7 +5,10 @@ $scope.modalShown = false; $scope.primarySet = ""; $scope.secondarySet = ""; - $scope.sets = []; + $scope.sets = {}; + $scope.addNew = false; + $scope.newProgramName = "" + $scope.isCopying = false; $scope.cachedValue = ""; @@ -90,6 +93,33 @@ width: 57, cellTemplate: dellCellTmpl }]; + + $scope.createNewProgram = function() { + if ($scope.newProgramName != "") { + var loadingModal = $scope.showLoadingModal(); + var newProgram = new Program; + newProgram.name = $scope.newProgramName; + newProgram.$save({ + name: $scope.newProgramName + }, function() { + $scope.newProgramName = ""; + $scope.addNew = false; + loadingModal.close(); + $scope.programs = Program.query(); + }, function() { + loadingModal.close(); + alert("Oops...Something went wrong"); + }); + } + } + + $scope.toggleAddNew = function() { + if($scope.addNew) { + $scope.addNew = false; + } else { + $scope.addNew = true; + } + } $scope.columnDefs = $scope.columnDefs1; @@ -128,16 +158,19 @@ $scope.updateProgram = function updateProgram() { + var loadingModal = $scope.showLoadingModal(); $scope.loading = true; - $scope.items = {}; - $scope.sets = {}; - Set.query({ - programId: $scope.programSelection, - type: $rootScope.type - }, function(data) { - $scope.loading = false; - $scope.sets = data; - }); + $scope.items = {}; + Set.query({ + programId: $scope.programSelection, + type: $rootScope.type + }, function(data) { + loadingModal.close(); + $scope.sets = data; + }, function(data) { + loadingModal.close(); + alert(data.statusText); + }); }; $scope.editSet = function editSet(set) { @@ -204,13 +237,14 @@ newSet.dispoType = $rootScope.type; newSet.$save({ programId: $scope.programSelection - }, function() { - $scope.sets.push(newSet); + }, function(data) { + $scope.sets.push(data); }); } }; $scope.copySet = function(inputs) { + $scope.isCopying = true; var copySetOp = new CopySet; copySetOp.annotationParam = inputs.annotationParam; copySetOp.categoryParam = inputs.categoryParam; @@ -222,11 +256,27 @@ destinationSet: inputs.destinationSet, sourceSet: inputs.sourceSet, }, function(data) { + $scope.isCopying = false; var reportUrl = data.operationStatus; window.open(reportUrl); console.log(data); + }, function(data) { + $scope.isCopying = false; + alert("Oops...Something went wrong"); }); } + + // Loading Modal + $scope.showLoadingModal = function() { + var modalInstance = $modal.open({ + templateUrl: 'loadingModal.html', + size: 'sm', + windowClass: 'needsRerunModal', + backdrop: 'static' + }); + + return modalInstance; + } // Create Set Modal $scope.createNewSetModal = function() { diff --git a/plugins/org.eclipse.osee.web.ui/src/dispo/js/userController.js b/plugins/org.eclipse.osee.web.ui/src/dispo/js/userController.js index 038ad480574..9fe767fdcd6 100644 --- a/plugins/org.eclipse.osee.web.ui/src/dispo/js/userController.js +++ b/plugins/org.eclipse.osee.web.ui/src/dispo/js/userController.js @@ -70,6 +70,9 @@ app.controller('userController', [ }, function(data) { loadingModal.close(); $scope.sets = data; + }, function(data) { + loadingModal.close(); + alert(data.statusText); }); }; diff --git a/plugins/org.eclipse.osee.web.ui/src/dispo/views/admin.html b/plugins/org.eclipse.osee.web.ui/src/dispo/views/admin.html index cc0115743c8..4e3232f990a 100644 --- a/plugins/org.eclipse.osee.web.ui/src/dispo/views/admin.html +++ b/plugins/org.eclipse.osee.web.ui/src/dispo/views/admin.html @@ -7,6 +7,9 @@
Select ATS Version
+
+ Add New
+
@@ -21,7 +24,7 @@
- +
@@ -95,6 +98,12 @@ + + -- cgit v1.2.3