Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormegumi.telles2018-04-13 10:45:44 -0400
committermegumi.telles2018-04-26 12:42:01 -0400
commit83b7d017247d3c9ba5e007def50b1dbc38a3bbc4 (patch)
treefbd74f62ea33d6dab47bceeed760a3df63d2f775
parent29b958a4bf4b5d905e6d20595bd8de9fae09a6d5 (diff)
downloadorg.eclipse.osee-83b7d017247d3c9ba5e007def50b1dbc38a3bbc4.tar.gz
org.eclipse.osee-83b7d017247d3c9ba5e007def50b1dbc38a3bbc4.tar.xz
org.eclipse.osee-83b7d017247d3c9ba5e007def50b1dbc38a3bbc4.zip
bug: Fix performance in CI0.25.4.v201804261649-NR
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoApiImpl.java8
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/ContinuousIntegrationResource.java34
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/util/DispoUtil.java47
3 files changed, 62 insertions, 27 deletions
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 bae6ffda17..46fa8e365f 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
@@ -703,9 +703,13 @@ public class DispoApiImpl implements DispoApi {
idOfNewDiscrepancy = dataFactory.getNewId();
discrepancy.setId(idOfNewDiscrepancy);
- discrepancy.setLocation("");
- discrepancy.setText("");
+ if (discrepancy.getLocation() == null) {
+ discrepancy.setLocation("");
+ }
+ if (discrepancy.getText() == null) {
+ discrepancy.setText("");
+ }
discrepancyList.put(idOfNewDiscrepancy, discrepancy);
DispoItemData newItem = new DispoItemData();
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/ContinuousIntegrationResource.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/ContinuousIntegrationResource.java
index 852ef7bdbb..58b8e2694f 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/ContinuousIntegrationResource.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/resources/ContinuousIntegrationResource.java
@@ -86,7 +86,7 @@ public class ContinuousIntegrationResource {
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response createDispoAnnotation(CiItemData data, @QueryParam("userName") String userName) {
- Response response = Response.status(Response.Status.NOT_FOUND).build();
+ Response response = Response.status(Response.Status.OK).build();
if (data != null) {
BranchId branch = BranchId.valueOf(data.getSetData().getBranchId());
String itemId = dispoApi.getDispoItemId(branch, data.getSetData().getDispoSetId(), data.getScriptName());
@@ -111,21 +111,33 @@ public class ContinuousIntegrationResource {
DispoItemData itemData = DispoUtil.itemArtToItemData(item, true);
String asRanges = itemData.getDiscrepanciesAsRanges();
if (!testPoints.getFail().equals(asRanges)) {
- // remove ones that are now passing
+ removePassing(branch, itemId, userName, testPoints, item);
+ addFailing(branch, itemId, userName, testPoints, item);
+ }
+ }
+
+ private void addFailing(BranchId branch, String itemId, String userName, CiTestPoint testPoints, DispoItem item) {
+ List<Integer> ranges = DispoUtil.splitDiscrepancyLocations(testPoints.getFail());
+ List<String> discrepToAdd = DispoUtil.findMissingDiscrepancyLocs(ranges, item);
+ for (String toAdd : discrepToAdd) {
+ Discrepancy discrepancy = new Discrepancy();
+ discrepancy.setLocation(toAdd);
+ String discrepancyId = dispoApi.createDispoDiscrepancy(branch, itemId, discrepancy, userName);
+ dispoApi.editDispoDiscrepancy(branch, itemId, discrepancyId, discrepancy, userName);
+ }
+ }
+
+ private void removePassing(BranchId branch, String itemId, String userName, CiTestPoint testPoints, DispoItem item) {
+ if (testPoints.getFail().equals("")) {
+ for (Discrepancy discrepancy : item.getDiscrepanciesList().values()) {
+ dispoApi.deleteDispoDiscrepancy(branch, itemId, discrepancy.getId(), userName);
+ }
+ } else {
List<Integer> ranges = DispoUtil.splitDiscrepancyLocations(testPoints.getPass());
List<String> discrepToRemove = DispoUtil.findDiscrepancyLocsToRemove(ranges, item);
for (String toRemove : discrepToRemove) {
dispoApi.deleteDispoDiscrepancy(branch, itemId, toRemove, userName);
}
- // add ones that are new
- ranges = DispoUtil.splitDiscrepancyLocations(testPoints.getFail());
- List<String> discrepToAdd = DispoUtil.findMissingDiscrepancyLocs(ranges, item);
- for (String toAdd : discrepToAdd) {
- Discrepancy discrepancy = new Discrepancy();
- String discrepancyId = dispoApi.createDispoDiscrepancy(branch, itemId, discrepancy, userName);
- discrepancy.setLocation(toAdd);
- dispoApi.editDispoDiscrepancy(branch, itemId, discrepancyId, discrepancy, userName);
- }
}
}
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/util/DispoUtil.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/util/DispoUtil.java
index 30b364bf73..bbfb85c483 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/util/DispoUtil.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/util/DispoUtil.java
@@ -592,12 +592,30 @@ public final class DispoUtil {
public static List<String> findDiscrepancyLocsToRemove(List<Integer> ranges, DispoItem item) {
List<String> removeDiscrepancies = new ArrayList<>();
if (ranges != null && !ranges.isEmpty()) {
- for (Integer locRef : ranges) {
- for (Entry<String, Discrepancy> discrepancy : item.getDiscrepanciesList().entrySet()) {
- Discrepancy value = discrepancy.getValue();
- String location = value.getLocation();
- if (Strings.isValid(location) && locRef == Integer.valueOf(location)) {
+ for (Entry<String, Discrepancy> discrepancy : item.getDiscrepanciesList().entrySet()) {
+ Discrepancy value = discrepancy.getValue();
+ String location = value.getLocation();
+ if (Strings.isValid(location)) {
+ if (ranges.contains(location)) {
removeDiscrepancies.add(discrepancy.getKey());
+ break;
+ }
+ }
+ }
+ }
+ return removeDiscrepancies;
+ }
+
+ public static List<String> removeAllDiscrepancies(List<Integer> ranges, DispoItem item) {
+ List<String> removeDiscrepancies = new ArrayList<>();
+ if (ranges != null && !ranges.isEmpty()) {
+ for (Entry<String, Discrepancy> discrepancy : item.getDiscrepanciesList().entrySet()) {
+ Discrepancy value = discrepancy.getValue();
+ String location = value.getLocation();
+ if (Strings.isValid(location)) {
+ if (ranges.contains(location)) {
+ removeDiscrepancies.add(discrepancy.getKey());
+ break;
}
}
}
@@ -608,19 +626,20 @@ public final class DispoUtil {
public static List<String> findMissingDiscrepancyLocs(List<Integer> ranges, DispoItem item) {
List<String> missingDiscrepanciesLoc = new ArrayList<>();
if (ranges != null && !ranges.isEmpty()) {
- for (Integer locRef : ranges) {
- boolean found = false;
- for (Entry<String, Discrepancy> discrepancy : item.getDiscrepanciesList().entrySet()) {
- Discrepancy value = discrepancy.getValue();
- String location = value.getLocation();
- if (Strings.isValid(location) && locRef == Integer.valueOf(location)) {
+ boolean found = false;
+ String location = "";
+ for (Entry<String, Discrepancy> discrepancy : item.getDiscrepanciesList().entrySet()) {
+ Discrepancy value = discrepancy.getValue();
+ location = value.getLocation();
+ if (Strings.isValid(location)) {
+ if (ranges.contains(location)) {
found = true;
break;
}
}
- if (!found) {
- missingDiscrepanciesLoc.add(String.valueOf(locRef));
- }
+ }
+ if (!found) {
+ missingDiscrepanciesLoc.add(String.valueOf(location));
}
}
return missingDiscrepanciesLoc;

Back to the top