Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal')
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoApiImpl.java226
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoConnector.java241
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoDataFactory.java27
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoItemArtifact.java22
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoQuery.java8
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoResolutionValidator.java39
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoSetArtifact.java6
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoWriter.java10
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/LocationRangesCompressor.java83
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/OrcsStorageImpl.java179
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/types/OseeTypes_Dispo.osee45
11 files changed, 511 insertions, 375 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 901f5d3d1e5..93995cc6857 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
@@ -10,10 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.disposition.rest.internal;
-import static org.eclipse.osee.disposition.model.DispoStrings.Item_Complete;
-import static org.eclipse.osee.disposition.model.DispoStrings.Item_Pass;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.osee.disposition.model.DispoAnnotationData;
import org.eclipse.osee.disposition.model.DispoItem;
@@ -25,11 +22,11 @@ import org.eclipse.osee.disposition.model.DispoSetDescriptorData;
import org.eclipse.osee.disposition.rest.DispoApi;
import org.eclipse.osee.disposition.rest.util.DispoFactory;
import org.eclipse.osee.disposition.rest.util.DispoUtil;
+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.framework.jdk.core.type.ResultSets;
import org.eclipse.osee.logger.Log;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.json.JSONArray;
@@ -42,11 +39,18 @@ import org.json.JSONObject;
public class DispoApiImpl implements DispoApi {
+ private ExecutorAdmin executor;
+
private Log logger;
private StorageProvider storageProvider;
private DispoDataFactory dataFactory;
private DispoConnector dispoConnector;
private DispoFactory dispoFactory;
+ private DispoResolutionValidator resolutionValidator;
+
+ public void setExecutor(ExecutorAdmin executor) {
+ this.executor = executor;
+ }
public void setLogger(Log logger) {
this.logger = logger;
@@ -64,6 +68,10 @@ public class DispoApiImpl implements DispoApi {
this.storageProvider = storageProvider;
}
+ public void setResolutionValidator(DispoResolutionValidator resolutionValidator) {
+ this.resolutionValidator = resolutionValidator;
+ }
+
public void start() {
logger.trace("Starting DispoApiImpl...");
dispoFactory = new DispoFactoryImpl();
@@ -106,36 +114,34 @@ public class DispoApiImpl implements DispoApi {
String idOfNewAnnotation = "";
DispoItem dispoItem = getQuery().findDispoItemById(program, itemId);
if (dispoItem != null) {
- dataFactory.initAnnotation(annotationToCreate);
- idOfNewAnnotation = dataFactory.getNewId();
- annotationToCreate.setId(idOfNewAnnotation);
-
- boolean isValidResolution = false;
- String resolution = annotationToCreate.getResolution();
- if (resolution != null) {
- isValidResolution = validateResolution(resolution);
- }
- annotationToCreate.setIsResolutionValid(isValidResolution);
+ try {
+ JSONArray annotationsList = dispoItem.getAnnotationsList();
+ dataFactory.initAnnotation(annotationToCreate);
+ idOfNewAnnotation = dataFactory.getNewId();
+ annotationToCreate.setId(idOfNewAnnotation);
+ int indexOfAnnotation = annotationsList.length();
+ annotationToCreate.setIndex(indexOfAnnotation);
+
+ boolean isValidResolution = false;
+ String resolution = annotationToCreate.getResolution();
+ if (resolution != null) {
+ isValidResolution = validateResolution(annotationToCreate);
+ }
+ annotationToCreate.setIsResolutionValid(isValidResolution);
+
+ JSONObject discrepanciesList = dispoItem.getDiscrepanciesList();
- JSONArray discrepanciesList = dispoItem.getDiscrepanciesList();
- if (isValidResolution) {
dispoConnector.connectAnnotation(annotationToCreate, discrepanciesList);
- }
- JSONObject annotationsList = dispoItem.getAnnotationsList();
- try {
- annotationsList.put(idOfNewAnnotation, DispoUtil.annotationToJsonObj(annotationToCreate));
+
+ annotationsList.put(indexOfAnnotation, DispoUtil.annotationToJsonObj(annotationToCreate));
+
+ DispoItem updatedItem;
+ updatedItem = dataFactory.createUpdatedItem(annotationsList, discrepanciesList);
+ ArtifactReadable author = getQuery().findUser();
+ getWriter().updateDispoItem(author, program, dispoItem.getGuid(), updatedItem);
} catch (JSONException ex) {
throw new OseeCoreException(ex);
}
-
- String currentStatus = dispoItem.getStatus();
- boolean updateStatus = false;
- if (!currentStatus.equals(Item_Complete) && !currentStatus.equals(Item_Pass) && annotationToCreate.isValid()) {
- updateStatus = true;
- }
- DispoItem updatedItem = dataFactory.createUpdatedItem(annotationsList, discrepanciesList, updateStatus);
- ArtifactReadable author = getQuery().findUser();
- getWriter().updateDispoItem(author, program, dispoItem.getGuid(), updatedItem);
}
return idOfNewAnnotation;
}
@@ -152,7 +158,7 @@ public class DispoApiImpl implements DispoApi {
}
if (newSet.getOperation() != null) {
- runOperation(dispSetToEdit, newSet);
+ runOperation(program, dispSetToEdit, newSet);
}
ArtifactReadable author = getQuery().findUser();
@@ -173,15 +179,7 @@ public class DispoApiImpl implements DispoApi {
boolean wasUpdated = false;
DispoItem dispoItemToEdit = getQuery().findDispoItemById(program, itemId);
- if (dispoItemToEdit != null && newDispoItem.getAnnotationsList() == null) { // We will not allow them to do mass edit of Annotations
- // Check to see if we are editing the discrepancies
- if (newDispoItem.getDiscrepanciesList() != null) {
- JSONArray mergedDiscrepanciesList =
- dataFactory.mergeJsonArrays(dispoItemToEdit.getDiscrepanciesList(), newDispoItem.getDiscrepanciesList());
- newDispoItem.setDiscrepanciesList(mergedDiscrepanciesList);
- newDispoItem.setStatus(dispoConnector.allDiscrepanciesAnnotated(newDispoItem));
- }
-
+ if (dispoItemToEdit != null && newDispoItem.getAnnotationsList() == null && newDispoItem.getDiscrepanciesList() == null) { // We will not allow the user to do mass edit of Annotations or discrepancies
ArtifactReadable author = getQuery().findUser();
getWriter().updateDispoItem(author, program, dispoItemToEdit.getGuid(), newDispoItem);
wasUpdated = true;
@@ -200,19 +198,18 @@ public class DispoApiImpl implements DispoApi {
boolean wasUpdated = false;
DispoItem dispoItem = getQuery().findDispoItemById(program, itemId);
if (dispoItem != null) {
- JSONObject annotationsList = dispoItem.getAnnotationsList();
- JSONArray discrepanciesList = dispoItem.getDiscrepanciesList();
+ JSONArray annotationsList = dispoItem.getAnnotationsList();
+ JSONObject discrepanciesList = dispoItem.getDiscrepanciesList();
try {
DispoAnnotationData oldAnnotation =
- DispoUtil.jsonObjToDispoAnnotationData(annotationsList.getJSONObject(annotationId));
+ DispoUtil.jsonObjToDispoAnnotationData(DispoUtil.getById(annotationsList, annotationId));
+ int indexOfAnnotation = oldAnnotation.getIndex();
DispoAnnotationData consolidatedAnnotation = oldAnnotation;
// Check if newAnnotation has notes, if it does then merge with old notes
- JSONArray newNotes = newAnnotation.getNotesList();
- if (newNotes != null) {
- consolidatedAnnotation.setNotesList(dataFactory.mergeJsonArrays(oldAnnotation.getNotesList(), newNotes));
- }
+ String newNotes = newAnnotation.getNotes();
+ consolidatedAnnotation.setNotes(newNotes);
// now if the new Annotation modified the location Reference or resolution then disconnect the annotation and try to match it to discrepancies again
String newLocationRefs = newAnnotation.getLocationRefs();
@@ -220,22 +217,20 @@ public class DispoApiImpl implements DispoApi {
if (newLocationRefs != null || newResolution != null) {
if (newResolution != null) {
consolidatedAnnotation.setResolution(newResolution);
- consolidatedAnnotation.setIsResolutionValid(validateResolution(newResolution));
+ consolidatedAnnotation.setIsResolutionValid(validateResolution(consolidatedAnnotation));
}
if (newLocationRefs != null) {
consolidatedAnnotation.setLocationRefs(newLocationRefs);
}
- dispoConnector.disconnectAnnotation(consolidatedAnnotation, discrepanciesList);
- if (consolidatedAnnotation.getIsResolutionValid()) {
- dispoConnector.connectAnnotation(consolidatedAnnotation, discrepanciesList);
- }
+ consolidatedAnnotation.disconnect();
+ dispoConnector.connectAnnotation(consolidatedAnnotation, discrepanciesList);
}
JSONObject annotationAsJsonObject = DispoUtil.annotationToJsonObj(consolidatedAnnotation);
- annotationsList.put(annotationId, annotationAsJsonObject);
+ annotationsList.put(indexOfAnnotation, annotationAsJsonObject);
- DispoItem updatedItem = dataFactory.createUpdatedItem(annotationsList, discrepanciesList, true);
+ DispoItem updatedItem = dataFactory.createUpdatedItem(annotationsList, discrepanciesList);
ArtifactReadable author = getQuery().findUser();
getWriter().updateDispoItem(author, program, dispoItem.getGuid(), updatedItem);
wasUpdated = true;
@@ -251,20 +246,17 @@ public class DispoApiImpl implements DispoApi {
boolean wasUpdated = false;
DispoItem dispoItem = getQuery().findDispoItemById(program, itemId);
if (dispoItem != null) {
- JSONObject annotationsList = dispoItem.getAnnotationsList();
- JSONArray discrepanciesList = dispoItem.getDiscrepanciesList();
+ JSONArray annotationsList = dispoItem.getAnnotationsList();
+ JSONObject discrepanciesList = dispoItem.getDiscrepanciesList();
try {
DispoAnnotationData annotationToRemove =
- DispoUtil.jsonObjToDispoAnnotationData(annotationsList.getJSONObject(annotationId));
- // No need to update status for new item if the deleted annotation was invalid, status would remain the same
- boolean updateStatus = false;
- if (annotationToRemove.getIsConnected()) {
- updateStatus = true;
- }
- dispoConnector.disconnectAnnotation(annotationToRemove, discrepanciesList);
- annotationsList.remove(annotationId);
+ DispoUtil.jsonObjToDispoAnnotationData(DispoUtil.getById(annotationsList, annotationId));
+ annotationToRemove.disconnect();
+
+ // collapse list so there are no gaps
+ JSONArray newAnnotationsList = collapseList(annotationsList, annotationToRemove.getIndex());
- DispoItem updatedItem = dataFactory.createUpdatedItem(annotationsList, discrepanciesList, updateStatus);
+ DispoItem updatedItem = dataFactory.createUpdatedItem(newAnnotationsList, discrepanciesList);
ArtifactReadable author = getQuery().findUser();
getWriter().updateDispoItem(author, program, dispoItem.getGuid(), updatedItem);
@@ -278,74 +270,53 @@ public class DispoApiImpl implements DispoApi {
@Override
public ResultSet<IOseeBranch> getDispoPrograms() {
- List<IOseeBranch> results = new ArrayList<IOseeBranch>();
- ResultSet<? extends IOseeBranch> baselineBranches = getQuery().findBaselineBranches();
- for (IOseeBranch baselinebBranch : baselineBranches) {
- results.add(baselinebBranch);
- }
- return ResultSets.newResultSet(results);
+ return getQuery().getDispoBranches();
}
@Override
- public IOseeBranch getDispoProgramById(DispoProgram program) {
- return getQuery().findProgramId(program);
+ public List<DispoSet> getDispoSets(DispoProgram program) throws OseeCoreException {
+ return getQuery().findDispoSets(program);
}
@Override
- public ResultSet<DispoSetData> getDispoSets(DispoProgram program) throws OseeCoreException {
- return translateAllToDispoSetData(getQuery().findDispoSets(program));
+ public DispoSet getDispoSetById(DispoProgram program, String setId) throws OseeCoreException {
+ return getQuery().findDispoSetsById(program, setId);
}
@Override
- public DispoSetData getDispoSetById(DispoProgram program, String setId) throws OseeCoreException {
- return DispoUtil.setArtToSetData(getQuery().findDispoSetsById(program, setId));
+ public List<DispoItem> getDispoItems(DispoProgram program, String setArtId) {
+ return getQuery().findDipoItems(program, setArtId);
}
@Override
- public ResultSet<DispoItemData> getDispoItems(DispoProgram program, String setArtId) {
- return translateAllToDispoItemData(getQuery().findDipoItems(program, setArtId));
+ public DispoItem getDispoItemById(DispoProgram program, String itemId) {
+ return getQuery().findDispoItemById(program, itemId);
}
@Override
- public DispoItemData getDispoItemById(DispoProgram program, String itemId) {
- DispoItemData dispositionableItem;
- DispoItem result = getQuery().findDispoItemById(program, itemId);
- if (result != null) {
- dispositionableItem = DispoUtil.itemArtToItemData(result);
- } else {
- dispositionableItem = null;
- }
- return dispositionableItem;
- }
-
- @Override
- public ResultSet<DispoAnnotationData> getDispoAnnotations(DispoProgram program, String itemId) {
+ public List<DispoAnnotationData> getDispoAnnotations(DispoProgram program, String itemId) {
List<DispoAnnotationData> toReturn = new ArrayList<DispoAnnotationData>();
DispoItem dispoItem = getQuery().findDispoItemById(program, itemId);
- JSONObject annotationsList = dispoItem.getAnnotationsList();
- @SuppressWarnings("unchecked")
- Iterator<String> keys = annotationsList.keys();
+ JSONArray annotationsList = dispoItem.getAnnotationsList();
try {
- while (keys.hasNext()) {
- toReturn.add(DispoUtil.jsonObjToDispoAnnotationData(annotationsList.getJSONObject(keys.next())));
+ for (int i = 0; i < annotationsList.length(); i++) {
+ toReturn.add(DispoUtil.jsonObjToDispoAnnotationData(annotationsList.getJSONObject(i)));
}
} catch (JSONException ex) {
throw new OseeCoreException(ex);
}
- return ResultSets.newResultSet(toReturn);
+ return toReturn;
}
@Override
- public DispoAnnotationData getDispoAnnotationByIndex(DispoProgram program, String itemId, String annotationId) {
+ public DispoAnnotationData getDispoAnnotationById(DispoProgram program, String itemId, String annotationId) {
DispoAnnotationData toReturn = new DispoAnnotationData();
DispoItem dispoItem = getQuery().findDispoItemById(program, itemId);
- JSONObject annotationsList = dispoItem.getAnnotationsList();
- if (annotationsList.has(annotationId)) {
- try {
- toReturn = DispoUtil.jsonObjToDispoAnnotationData(annotationsList.getJSONObject(annotationId));
- } catch (JSONException ex) {
- throw new OseeCoreException(ex);
- }
+ JSONArray annotationsList = dispoItem.getAnnotationsList();
+ JSONObject annotationInList = DispoUtil.getById(annotationsList, annotationId);
+ if (annotationInList != null) {
+ toReturn = DispoUtil.jsonObjToDispoAnnotationData(annotationInList);
+
} else {
toReturn = null;
}
@@ -353,40 +324,37 @@ public class DispoApiImpl implements DispoApi {
}
@Override
- public boolean isUniqueSetName(DispoProgram program, String name) {
- return getQuery().isUniqueSetName(program, name);
- }
-
- @Override
public boolean isUniqueItemName(DispoProgram program, String setId, String name) {
return getQuery().isUniqueItemName(program, setId, name);
}
- private ResultSet<DispoItemData> translateAllToDispoItemData(ResultSet<DispoItem> list) {
- List<DispoItemData> toReturn = new ArrayList<DispoItemData>();
- for (DispoItem item : list) {
- toReturn.add(DispoUtil.itemArtToItemData(item));
- }
-
- return ResultSets.newResultSet(toReturn);
+ @Override
+ public boolean isUniqueSetName(DispoProgram program, String name) {
+ return getQuery().isUniqueSetName(program, name);
}
- private ResultSet<DispoSetData> translateAllToDispoSetData(ResultSet<DispoSet> list) {
- List<DispoSetData> toReturn = new ArrayList<DispoSetData>();
- for (DispoSet set : list) {
- toReturn.add(DispoUtil.setArtToSetData(set));
- }
-
- return ResultSets.newResultSet(toReturn);
+ private void runOperation(DispoProgram program, DispoSet setToEdit, DispoSetData newSet) {
+ //do nothing
}
- private void runOperation(DispoSet setToEdit, DispoSetData newSet) {
- // Add operation Functionality here
+ private JSONArray collapseList(JSONArray oldList, int indexRemoved) throws JSONException {
+ // JSONArray's remove(index) leaves a gap so this method was created to get around that
+ // If the implementation is changed and remove(index) collapses the list, then this method can be removed
+ JSONArray newList = new JSONArray();
+ for (int i = 0; i < indexRemoved; i++) {
+ newList.put(i, oldList.getJSONObject(i));
+ }
+ for (int i = indexRemoved + 1; i < oldList.length(); i++) {
+ JSONObject annotationObject = oldList.getJSONObject(i);
+ DispoAnnotationData annotation = DispoUtil.jsonObjToDispoAnnotationData(annotationObject);
+ annotation.setIndex(annotation.getIndex() - 1);
+ newList.put(annotation.getIndex(), DispoUtil.annotationToJsonObj(annotation));
+ }
+ return newList;
}
- private boolean validateResolution(String resolution) {
- return resolution.equals("VALID");
- // Add PCR validation Functionality here
+ private boolean validateResolution(DispoAnnotationData annotation) {
+ return resolutionValidator.validate(annotation);
}
@Override
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoConnector.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoConnector.java
index 17a1144143a..d2b85dcb9fa 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoConnector.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoConnector.java
@@ -12,6 +12,9 @@ package org.eclipse.osee.disposition.rest.internal;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Stack;
import java.util.StringTokenizer;
@@ -20,11 +23,9 @@ import org.eclipse.osee.disposition.model.DispoAnnotationData;
import org.eclipse.osee.disposition.model.DispoItem;
import org.eclipse.osee.disposition.model.DispoStrings;
import org.eclipse.osee.disposition.model.LocationRange;
-import org.eclipse.osee.disposition.rest.util.DiscrepancyComperator;
import org.eclipse.osee.disposition.rest.util.DispoUtil;
import org.eclipse.osee.disposition.rest.util.LocationRangeComparator;
import org.eclipse.osee.disposition.rest.util.LocationRangeUtil;
-import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.logger.Log;
import org.json.JSONArray;
import org.json.JSONException;
@@ -50,91 +51,139 @@ public class DispoConnector {
logger.trace("Stopping DispoConnector...");
}
- public String allDiscrepanciesAnnotated(DispoItem item) {
+ public String allDiscrepanciesAnnotated(DispoItem item) throws JSONException {
String toReturn;
- JSONArray discrepancies = item.getDiscrepanciesList();
- JSONObject annotations = item.getAnnotationsList();
+ JSONObject discrepancies = item.getDiscrepanciesList();
+ JSONArray annotatinos = item.getAnnotationsList();
+ HashSet<Integer> allCoveredDiscrepancies = getAllCoveredDiscrepanciesFromAnnotations(discrepancies, annotatinos);
+ ArrayList<Integer> allDiscrepancies = createDiscrepanciesList(discrepancies);
- int discrepanciesSize = discrepancies.length();
- if (discrepanciesSize == 0) {
- toReturn = DispoStrings.Item_Pass;
+ allDiscrepancies.removeAll(allCoveredDiscrepancies);
+
+ boolean allDiscrepanciesCovered = false;
+ if (allDiscrepancies.isEmpty()) {
+ allDiscrepanciesCovered = true;
} else {
- boolean allDiscrepanciesCovered = true; // Assume everything is covered, on first false we break and return false
- for (int i = 0; i < discrepanciesSize; i++) {
- try {
- JSONObject discrepancyObject = discrepancies.getJSONObject(i);
- Discrepancy discrepancy = DispoUtil.jsonObjToDiscrepancy(discrepancyObject);
- List<LocationRange> locRefsAsSortedList = getAllLocRefsAsSortedList(annotations, discrepancy);
- if (!LocationRangeUtil.isCovered(discrepancy.getLocationRange(), locRefsAsSortedList)) {
- allDiscrepanciesCovered = false;
- // We found a discrepancy that hasn't been fully covered
- break;
- }
- } catch (JSONException ex) {
- throw new OseeCoreException(ex);
- }
+ allDiscrepanciesCovered = false;
+ }
+
+ if (allAnnotationsValid(annotatinos) && allDiscrepanciesCovered) {
+ toReturn = DispoStrings.Item_Complete;
+ } else {
+ toReturn = DispoStrings.Item_InComplete;
+ }
+
+ return toReturn;
+ }
+
+ private boolean allAnnotationsValid(JSONArray annotatinos) throws JSONException {
+ int length = annotatinos.length();
+ for (int i = 0; i < length; i++) {
+ JSONObject annotationAsJson = annotatinos.getJSONObject(i);
+ DispoAnnotationData annotation = DispoUtil.jsonObjToDispoAnnotationData(annotationAsJson);
+ if (!annotation.isValid()) {
+ return false;
}
+ }
- if (allDiscrepanciesCovered) {
- toReturn = DispoStrings.Item_Complete;
- } else {
- toReturn = DispoStrings.Item_InComplete;
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ private ArrayList<Integer> createDiscrepanciesList(JSONObject discrepancies) throws JSONException {
+ ArrayList<Integer> toReturn = new ArrayList<Integer>();
+ Iterator<String> iterator = discrepancies.keys();
+ while (iterator.hasNext()) {
+ String key = iterator.next();
+ JSONObject discrepancyAsJson = discrepancies.getJSONObject(key);
+ Discrepancy discrepancy = DispoUtil.jsonObjToDiscrepancy(discrepancyAsJson);
+ toReturn.add(discrepancy.getLocation());
+ }
+
+ return toReturn;
+ }
+
+ private HashSet<Integer> getAllCoveredDiscrepanciesFromAnnotations(JSONObject discrepancies, JSONArray annotations) throws JSONException {
+ HashSet<Integer> toReturn = new HashSet<Integer>();
+ int length = annotations.length();
+ for (int j = 0; j < length; j++) {
+ JSONObject annotationAsObject = annotations.getJSONObject(j);
+ DispoAnnotationData annotation = DispoUtil.jsonObjToDispoAnnotationData(annotationAsObject);
+ JSONArray idsOfCoveredDiscrepancies = annotation.getIdsOfCoveredDiscrepancies();
+ for (int i = 0; i < idsOfCoveredDiscrepancies.length(); i++) {
+ String id = idsOfCoveredDiscrepancies.getString(i);
+ if (discrepancies.has(id)) {
+ JSONObject discrepancyAsJson = discrepancies.getJSONObject(id);
+ Discrepancy discrepancy = DispoUtil.jsonObjToDiscrepancy(discrepancyAsJson);
+ toReturn.add(discrepancy.getLocation());
+ } else {
+ String justTestPoint = id.replaceAll(DispoStrings.DeletedDiscrepancy, "");
+ toReturn.add(Integer.valueOf(justTestPoint));
+ }
}
}
return toReturn;
}
- public boolean connectAnnotation(DispoAnnotationData annotation, JSONArray discrepanciesArray) {
+ public boolean connectAnnotation(DispoAnnotationData annotation, JSONObject discrepanciesList) throws JSONException {
boolean isAllLocRefValid = true;
- List<Discrepancy> sortedDiscrepanciesList = arrayToSortedList(discrepanciesArray);
+ HashMap<Integer, String> testPointNumberToId = getPointNumbersToIds(discrepanciesList);
List<LocationRange> listOfLocationRefs = sortList(annotation.getLocationRefs());
- int startIndexForNextMatch = 0;
- int idOfPreviousMatched = -1;
+ List<String> workingIdsOfCovered = new ArrayList<String>();
for (LocationRange singleLocationRef : listOfLocationRefs) {
- try {
- Discrepancy matchedDiscrepancy =
- matchToDiscrepancy(annotation, singleLocationRef, sortedDiscrepanciesList, startIndexForNextMatch);
- if (matchedDiscrepancy == null) {
+ if (singleLocationRef.getStart() != singleLocationRef.getEnd()) {
+ for (int i = singleLocationRef.getStart(); i <= singleLocationRef.getEnd(); i++) {
+ if (!tryToAddDiscrepancyForTestPoint(testPointNumberToId, i, workingIdsOfCovered)) {
+ isAllLocRefValid = false;
+ break;
+ }
+ }
+ } else {
+ if (!tryToAddDiscrepancyForTestPoint(testPointNumberToId, singleLocationRef.getStart(), workingIdsOfCovered)) {
isAllLocRefValid = false;
break;
- } else {
- int idOfMatched = matchedDiscrepancy.getId();
- // only update discrepancy and annotation if we found a different matching discrepancy
- if (idOfPreviousMatched != idOfMatched) {
- idOfPreviousMatched = idOfMatched;
- startIndexForNextMatch = idOfMatched;
- matchedDiscrepancy.addCoveringAnnotation(annotation);
- JSONObject discrepancyAsObject = DispoUtil.discrepancyToJsonObj(matchedDiscrepancy);
- annotation.addCoveredDiscrepancyIndex(matchedDiscrepancy);
- discrepanciesArray.put(idOfMatched, discrepancyAsObject);
- //on next search start at the previously matched one since both discrepancies and annotations are in order
- }
}
- } catch (JSONException ex) {
- throw new OseeCoreException(ex);
}
}
+ // Do this every time, if nothing else will ensure Loc Refs are always ordered
annotation.setLocationRefs(getLocRefsAsString(listOfLocationRefs));
- annotation.setIsConnected(isAllLocRefValid);
+
+ if (isAllLocRefValid) {
+ annotation.setIsConnected(true);
+ annotation.setIdsOfCoveredDiscrepancies(new JSONArray(workingIdsOfCovered));
+ } else {
+ annotation.setIsConnected(false);
+ }
return isAllLocRefValid;
}
- public void disconnectAnnotation(DispoAnnotationData annotation, JSONArray discrepanciesList) throws JSONException {
- JSONArray discrepanciesConnected = annotation.getIdsOfCoveredDiscrepancies();
- int size = discrepanciesConnected.length();
- for (int i = 0; i < size; i++) {
- int indexOfDiscrepancy = discrepanciesConnected.getInt(i); // the discrepancy to remove the annotation from, index in discrepanciesList
- JSONObject discrepancyAsObject = discrepanciesList.getJSONObject(indexOfDiscrepancy);
- Discrepancy discrepancyAsData = DispoUtil.jsonObjToDiscrepancy(discrepancyAsObject);
- JSONArray indexesOfAnnotations = discrepancyAsData.getIdsOfCoveringAnnotations();
- removeElementFromArray(indexesOfAnnotations, annotation.getId());
+ private boolean tryToAddDiscrepancyForTestPoint(HashMap<Integer, String> testPointNumberToId, int testPoint, List<String> workingList) {
+ String idOfMatched = testPointNumberToId.get(testPoint);
+ if (idOfMatched == null) {
+ return false;
+ } else {
+ workingList.add(idOfMatched);
}
- // clear list of connected discrepancies for this annotation
- annotation.setIdsOfCoveredDiscrepancies(new JSONArray());
- annotation.setIsConnected(false);
+
+ return true;
+ }
+
+ @SuppressWarnings("unchecked")
+ private HashMap<Integer, String> getPointNumbersToIds(JSONObject discrepancies) throws JSONException {
+ HashMap<Integer, String> toReturn = new HashMap<Integer, String>();
+ Iterator<String> iterator = discrepancies.keys();
+ while (iterator.hasNext()) {
+ String key = iterator.next();
+ JSONObject discrepancyAsJson = discrepancies.getJSONObject(key);
+ Discrepancy discrepancy = DispoUtil.jsonObjToDiscrepancy(discrepancyAsJson);
+ int pointNumber = discrepancy.getLocation();
+ toReturn.put(pointNumber, discrepancy.getId());
+ }
+
+ return toReturn;
}
// Not currently used. May implement if users want to see what discrepancies are left to cover
@@ -183,42 +232,6 @@ public class DispoConnector {
return allUncovered;
}
- private List<LocationRange> getAllLocRefsAsSortedList(JSONObject annotations, Discrepancy discrepancy) {
- StringBuilder sb = new StringBuilder();
- JSONArray indexesOfCoveringAnnotations = discrepancy.getIdsOfCoveringAnnotations();
- int size = indexesOfCoveringAnnotations.length();
- for (int i = 0; i < size; i++) {
- try {
- if (sb.length() > 0) {
- sb.append(",");
- }
- String annotationId = indexesOfCoveringAnnotations.getString(i);
- JSONObject annotationAsJsonObj = annotations.getJSONObject(annotationId);
- DispoAnnotationData annotationAsData = DispoUtil.jsonObjToDispoAnnotationData(annotationAsJsonObj);
- sb.append(annotationAsData.getLocationRefs());
- } catch (JSONException ex) {
- throw new OseeCoreException(ex);
- }
- }
-
- return sortList(sb.toString());
-
- }
-
- private void removeElementFromArray(JSONArray listToRemoveFrom, String element) throws JSONException {
- int size = listToRemoveFrom.length();
- List<Integer> indexOfElementsToRemove = new ArrayList<Integer>();
- for (int i = 0; i < size; i++) {
- if (listToRemoveFrom.getString(i).equals(element)) {
- indexOfElementsToRemove.add(i);
- }
- }
-
- for (Integer index : indexOfElementsToRemove) {
- listToRemoveFrom.remove(index);
- }
- }
-
private static String getLocRefsAsString(List<LocationRange> list) {
StringBuilder sb = new StringBuilder();
for (LocationRange range : list) {
@@ -245,38 +258,4 @@ public class DispoConnector {
return toReturn;
}
- private List<Discrepancy> arrayToSortedList(JSONArray array) {
- List<Discrepancy> discrepanciesAsList = new ArrayList<Discrepancy>();
- int size = array.length();
- for (int i = 0; i < size; i++) {
- try {
- discrepanciesAsList.add(DispoUtil.jsonObjToDiscrepancy(array.getJSONObject(i)));
- } catch (JSONException ex) {
- throw new OseeCoreException(ex);
- }
- }
- Collections.sort(discrepanciesAsList, new DiscrepancyComperator());
- return discrepanciesAsList;
- }
-
- private Discrepancy matchToDiscrepancy(DispoAnnotationData annotation, LocationRange singleLocationRangeRef, List<Discrepancy> discrepanciesList, int startIndex) {
- Discrepancy matchedDiscrepancy = null;
- int sizeOfList = discrepanciesList.size();
- int firstUnCovered = singleLocationRangeRef.getStart();
-
- for (int i = startIndex; i < sizeOfList; i++) {
- // want to guarantee that the discrepancy we're starting at has starting index <= to the first uncovered part of the location ref
- Discrepancy discrepancy = discrepanciesList.get(i);
- if (discrepancy.getLocationRange().getStart() > firstUnCovered) {
- break;
- } else {
- if (LocationRangeUtil.isLocRefWithinRange(discrepancy.getLocationRange(), singleLocationRangeRef)) {
- matchedDiscrepancy = discrepancy;
- break;
- }
- }
- }
-
- return matchedDiscrepancy;
- }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoDataFactory.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoDataFactory.java
index 77391f77bc5..be8e28ba568 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoDataFactory.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoDataFactory.java
@@ -11,12 +11,12 @@
package org.eclipse.osee.disposition.rest.internal;
-import java.util.Date;
import org.eclipse.osee.disposition.model.DispoAnnotationData;
import org.eclipse.osee.disposition.model.DispoItem;
import org.eclipse.osee.disposition.model.DispoItemData;
import org.eclipse.osee.disposition.model.DispoSetData;
import org.eclipse.osee.disposition.model.DispoSetDescriptorData;
+import org.eclipse.osee.disposition.model.DispoStrings;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.logger.Log;
@@ -54,34 +54,35 @@ public class DispoDataFactory {
newSet.setName(descriptor.getName());
newSet.setImportPath(descriptor.getImportPath());
newSet.setImportState("NONE");
- newSet.setStatusCount("0/0");
newSet.setNotesList(new JSONArray());
return newSet;
}
public void initDispoItem(DispoItemData itemToInit) {
- itemToInit.setAnnotationsList(new JSONObject());
- itemToInit.setDiscrepanciesList(new JSONArray());
- itemToInit.setStatus("PASS");
+ itemToInit.setAnnotationsList(new JSONArray());
+ if (itemToInit.getDiscrepanciesList() == null) {
+ itemToInit.setDiscrepanciesList(new JSONObject());
+ }
- Date date = new Date();
- itemToInit.setCreationDate(date);
- itemToInit.setLastUpdate(date);
+ if (itemToInit.getDiscrepanciesList().length() == 0) {
+ itemToInit.setStatus(DispoStrings.Item_Pass);
+ } else {
+ itemToInit.setStatus(DispoStrings.Item_InComplete);
+ }
}
public void initAnnotation(DispoAnnotationData annotationToInit) {
annotationToInit.setIdsOfCoveredDiscrepancies(new JSONArray());
- annotationToInit.setNotesList(new JSONArray());
+ annotationToInit.setNotes("--Enter Notes--");
+ annotationToInit.setResolution("");
}
- public DispoItem createUpdatedItem(JSONObject annotationsList, JSONArray discrepanciesList, boolean updateStatus) {
+ public DispoItem createUpdatedItem(JSONArray annotationsList, JSONObject discrepanciesList) throws JSONException {
DispoItemData newItem = new DispoItemData();
newItem.setAnnotationsList(annotationsList);
newItem.setDiscrepanciesList(discrepanciesList);
- if (updateStatus) {
- newItem.setStatus(dispoConnector.allDiscrepanciesAnnotated(newItem));
- }
+ newItem.setStatus(dispoConnector.allDiscrepanciesAnnotated(newItem));
return newItem;
}
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoItemArtifact.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoItemArtifact.java
index 5aa5f4086ea..c83c1c64124 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoItemArtifact.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoItemArtifact.java
@@ -38,15 +38,15 @@ public class DispoItemArtifact extends BaseIdentity<String> implements DispoItem
}
@Override
- public JSONArray getDiscrepanciesList() {
- String discrepanciesJson = artifact.getSoleAttributeAsString(DispoConstants.DispoDiscrepanciesJson, "[]");
- return DispoUtil.asJSONArray(discrepanciesJson);
+ public JSONObject getDiscrepanciesList() {
+ String discrepanciesJson = artifact.getSoleAttributeAsString(DispoConstants.DispoDiscrepanciesJson, "{}");
+ return DispoUtil.asJSONObject(discrepanciesJson);
}
@Override
- public JSONObject getAnnotationsList() {
+ public JSONArray getAnnotationsList() {
String annotationsList = artifact.getSoleAttributeAsString(DispoConstants.DispoAnnotationsJson, "[]");
- return DispoUtil.asJSONOjbect(annotationsList);
+ return DispoUtil.asJSONArray(annotationsList);
}
@Override
@@ -56,12 +56,7 @@ public class DispoItemArtifact extends BaseIdentity<String> implements DispoItem
@Override
public String getAssignee() {
- ArtifactReadable assignee = artifact.getRelated(DispoConstants.DispoAssigned_Item).getAtMostOneOrNull();
- if (assignee == null) {
- return "unassigned";
- } else {
- return assignee.getName();
- }
+ return artifact.getSoleAttributeAsString(DispoConstants.DispoItemAssignee, "");
}
@Override
@@ -81,6 +76,11 @@ public class DispoItemArtifact extends BaseIdentity<String> implements DispoItem
}
@Override
+ public String getVersion() {
+ return artifact.getSoleAttributeAsString(DispoConstants.DispoItemVersion);
+ }
+
+ @Override
public int compareTo(Named other) {
if (other != null && other.getName() != null && getName() != null) {
return getName().compareTo(other.getName());
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 0a10518c848..a43eea4c885 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
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.osee.disposition.rest.internal;
+import java.util.List;
import org.eclipse.osee.disposition.model.DispoItem;
import org.eclipse.osee.disposition.model.DispoProgram;
import org.eclipse.osee.disposition.model.DispoSet;
@@ -32,15 +33,14 @@ public interface DispoQuery {
boolean isUniqueItemName(DispoProgram program, String setId, String name);
- ResultSet<DispoSet> findDispoSets(DispoProgram program);
+ List<DispoSet> findDispoSets(DispoProgram program);
DispoSet findDispoSetsById(DispoProgram program, String id);
- ResultSet<DispoItem> findDipoItems(DispoProgram program, String setId);
+ List<DispoItem> findDipoItems(DispoProgram program, String setId);
DispoItem findDispoItemById(DispoProgram program, String itemId);
- ResultSet<? extends IOseeBranch> findBaselineBranches();
+ ResultSet<IOseeBranch> getDispoBranches();
- IOseeBranch findProgramId(DispoProgram program);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoResolutionValidator.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoResolutionValidator.java
new file mode 100644
index 00000000000..0b458cb93a4
--- /dev/null
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoResolutionValidator.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.rest.internal;
+
+import org.eclipse.osee.disposition.model.DispoAnnotationData;
+import org.eclipse.osee.logger.Log;
+
+/**
+ * @author Angel Avila
+ */
+public class DispoResolutionValidator {
+
+ private Log logger;
+
+ public void setLogger(Log logger) {
+ this.logger = logger;
+ }
+
+ public void start() {
+ logger.trace("Starting ResolutionValidator...");
+ }
+
+ public void stop() {
+ logger.trace("Stopping ResolutionValidator...");
+ }
+
+ public boolean validate(DispoAnnotationData annotation) {
+ String pcr = annotation.getResolution();
+ return pcr.matches("^\\s*[CTR]\\d{4,5}\\s*$");
+ }
+}
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoSetArtifact.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoSetArtifact.java
index 205b139b967..caa8b896931 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoSetArtifact.java
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoSetArtifact.java
@@ -18,6 +18,7 @@ import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.json.JSONArray;
import org.json.JSONException;
+
/**
* @author Angel Avila
*/
@@ -41,11 +42,6 @@ public class DispoSetArtifact extends BaseIdentity<String> implements DispoSet,
}
@Override
- public String getStatusCount() {
- return artifact.getSoleAttributeAsString(DispoConstants.StatusCount, "0/0");
- }
-
- @Override
public JSONArray getNotesList() {
String notesJson = artifact.getSoleAttributeAsString(DispoConstants.DispoNotesJson, "[]");
try {
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 306c242bd06..d38bda3be9e 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2013 Boeing.
+ * Copyright (c) 2014 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
@@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.osee.disposition.rest.internal;
+import java.util.List;
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.jdk.core.type.Identifiable;
-import org.eclipse.osee.orcs.data.ArtifactId;
import org.eclipse.osee.orcs.data.ArtifactReadable;
/**
@@ -30,9 +30,11 @@ public interface DispoWriter {
Identifiable<String> createDispoItem(ArtifactReadable author, DispoProgram program, DispoSet parentSet, DispoItem itemToCreate, ArtifactReadable assigneeId);
- void updateDispoItem(ArtifactReadable author, DispoProgram program, String itemToEditId, DispoItem itemToCreate);
+ void createDispoItems(ArtifactReadable author, DispoProgram program, DispoSet parentSet, List<DispoItem> data, String assignee);
+
+ void updateDispoItems(ArtifactReadable author, DispoProgram program, String itemToEditId, List<DispoItem> itemsToUpdate);
boolean deleteDispoItem(ArtifactReadable author, DispoProgram program, String itemId);
- void createAnnotation(ArtifactReadable author, DispoProgram program, ArtifactId dispoItem, String annotationsJson);
+ void updateDispoItem(ArtifactReadable author, DispoProgram program, String dispoItemId, DispoItem data);
} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/LocationRangesCompressor.java b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/LocationRangesCompressor.java
new file mode 100644
index 00000000000..d271fc9edc8
--- /dev/null
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/LocationRangesCompressor.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2014 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.rest.internal;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.eclipse.osee.disposition.model.LocationRange;
+
+/**
+ * @author Angel Avila
+ */
+public class LocationRangesCompressor {
+
+ public static String compress(List<Integer> locationPoints) {
+ Collections.sort(locationPoints);
+ StringBuilder workingLocRefs = new StringBuilder();
+
+ boolean isRange = false;
+ boolean endOfRange = false;
+ int startOfRange = -1;
+ int previous = -1;
+
+ Iterator<Integer> iterator = locationPoints.iterator();
+
+ while (iterator.hasNext()) {
+ int currentTestPoint = iterator.next();
+ boolean isLastElement = !iterator.hasNext();
+
+ // Starting a Range
+ if (previous == (currentTestPoint - 1) && startOfRange == -1) { // if the previous is 1 less than our current we are in a range
+ isRange = true;
+ endOfRange = false;
+ startOfRange = previous;
+ int lastIndexOf = workingLocRefs.lastIndexOf(",");
+ if (lastIndexOf > 0) {
+ workingLocRefs.replace(lastIndexOf, workingLocRefs.length(), "");
+ } else {
+ workingLocRefs.setLength(0);
+ }
+ }
+ if (isRange && (previous != (currentTestPoint - 1) || isLastElement)) { // End Range
+ endOfRange = true;
+ }
+
+ StringBuilder toAppend = new StringBuilder();
+
+ if (!isRange) { // If we are not in a range just add the single point
+ toAppend.append(currentTestPoint);
+ } else if (endOfRange) { // other wise check to see if we ended the range
+ if (isLastElement) {
+ toAppend.append(new LocationRange(startOfRange, currentTestPoint).toString()); // append the range ending with the previous point and append this current point
+ } else {
+ toAppend.append(new LocationRange(startOfRange, previous).toString()); // append the range ending with the previous point and append this current point
+ toAppend.append(", ");
+ toAppend.append(currentTestPoint);
+ }
+
+ isRange = false;
+ startOfRange = -1;
+ }
+
+ if (toAppend.length() != 0) {
+ if (workingLocRefs.length() > 0) {
+ workingLocRefs.append(", ");
+ }
+ workingLocRefs.append(toAppend);
+ }
+
+ previous = currentTestPoint;
+ }
+ return workingLocRefs.toString();
+ }
+
+}
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 f86e53b730b..5b5079cb62e 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
@@ -28,6 +28,7 @@ import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.BranchType;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
@@ -54,7 +55,6 @@ import org.json.JSONObject;
* @author Angel Avila
*/
public class OrcsStorageImpl implements Storage {
-
private final Log logger;
private final OrcsApi orcsApi;
@@ -134,12 +134,9 @@ public class OrcsStorageImpl implements Storage {
return getQuery().fromBranch(getAdminBranch()).andGuid(userId).getResults().getExactlyOne();
}
- @SuppressWarnings("unchecked")
@Override
public ArtifactReadable findUnassignedUser() {
- // return getQuery().fromBranch(getAdminBranch()).andNameEquals("Unassigned").getResults().getExactlyOne(); COMMENTED OUT TEMP
- return getQuery().fromBranch(getAdminBranch()).andIds(SystemUser.OseeSystem).getResults().getExactlyOne();
-
+ return getQuery().fromBranch(getAdminBranch()).andNameEquals("UnAssigned").andTypeEquals(CoreArtifactTypes.User).getResults().getExactlyOne();
}
@Override
@@ -161,7 +158,7 @@ public class OrcsStorageImpl implements Storage {
@Override
public boolean isUniqueItemName(DispoProgram program, String setId, String name) {
IOseeBranch branch = getProgramBranch(program);
- ArtifactReadable setArt = findDispoArtifact(branch, setId, DispoConstants.DispoSet);
+ ArtifactReadable setArt = findDispoArtifact(program, setId, DispoConstants.DispoSet);
ResultSet<ArtifactReadable> results = getQuery()//
.fromBranch(branch)//
.andRelatedTo(CoreRelationTypes.Default_Hierarchical__Parent, setArt)//
@@ -173,10 +170,9 @@ public class OrcsStorageImpl implements Storage {
}
@Override
- public ResultSet<DispoSet> findDispoSets(DispoProgram program) {
- IOseeBranch branch = getProgramBranch(program);
+ public List<DispoSet> findDispoSets(DispoProgram program) {
ResultSet<ArtifactReadable> results = getQuery()//
- .fromBranch(branch)//
+ .fromBranch(TokenFactory.createBranch(program.getUuid(), program.getName()))//
.andTypeEquals(DispoConstants.DispoSet)//
.getResults();
@@ -184,45 +180,32 @@ public class OrcsStorageImpl implements Storage {
for (ArtifactReadable art : results) {
toReturn.add(new DispoSetArtifact(art));
}
- return ResultSets.newResultSet(toReturn);
+ return toReturn;
}
@Override
public DispoSet findDispoSetsById(DispoProgram program, String setId) {
- IOseeBranch branch = getProgramBranch(program);
- ArtifactReadable result = findDispoArtifact(branch, setId, DispoConstants.DispoSet);
+ ArtifactReadable result = findDispoArtifact(program, setId, DispoConstants.DispoSet);
return new DispoSetArtifact(result);
}
- private ArtifactReadable findDispoArtifact(IOseeBranch branch, String setId, IArtifactType type) {
+ private ArtifactReadable findDispoArtifact(DispoProgram program, String setId, IArtifactType type) {
return getQuery()//
- .fromBranch(branch)//
+ .fromBranch(TokenFactory.createBranch(program.getUuid(), program.getName()))//
.andTypeEquals(type)//
.andGuid(setId)//
.getResults().getOneOrNull();
}
@Override
- public ResultSet<DispoItem> findDipoItems(DispoProgram program, String setId) {
- IOseeBranch branch = getProgramBranch(program);
- ArtifactReadable setArt = findDispoArtifact(branch, setId, DispoConstants.DispoSet);
- ResultSet<ArtifactReadable> results = setArt.getRelated(CoreRelationTypes.Default_Hierarchical__Child);
+ public List<DispoItem> findDipoItems(DispoProgram program, String setId) {
+ ArtifactReadable setArt = findDispoArtifact(program, setId, DispoConstants.DispoSet);
+ ResultSet<ArtifactReadable> results = setArt.getChildren();
List<DispoItem> toReturn = new ArrayList<DispoItem>();
for (ArtifactReadable art : results) {
toReturn.add(new DispoItemArtifact(art));
}
- return ResultSets.newResultSet(toReturn);
- }
-
- @Override
- public DispoItem findDispoItemById(DispoProgram program, String itemId) {
- DispoItem toReturn = null;
- IOseeBranch branch = getProgramBranch(program);
- ArtifactReadable dispoArtifact = findDispoArtifact(branch, itemId, DispoConstants.DispoItem);
- if (dispoArtifact != null) {
- toReturn = new DispoItemArtifact(dispoArtifact);
- }
return toReturn;
}
@@ -233,7 +216,6 @@ public class OrcsStorageImpl implements Storage {
ArtifactId creatdArtId = tx.createArtifact(DispoConstants.DispoSet, descriptor.getName());
tx.setSoleAttributeFromString(creatdArtId, DispoConstants.ImportPath, descriptor.getImportPath());
tx.setSoleAttributeFromString(creatdArtId, DispoConstants.ImportState, descriptor.getImportState());
- tx.setSoleAttributeFromString(creatdArtId, DispoConstants.StatusCount, descriptor.getStatusCount());
tx.setSoleAttributeFromString(creatdArtId, DispoConstants.DispoNotesJson, descriptor.getNotesList().toString());
tx.commit();
return creatdArtId;
@@ -252,7 +234,7 @@ public class OrcsStorageImpl implements Storage {
private boolean deleteDispoEntityArtifact(ArtifactReadable author, DispoProgram program, String entityId, IArtifactType type) {
boolean toReturn = false;
IOseeBranch branch = getProgramBranch(program);
- ArtifactReadable dispoArtifact = findDispoArtifact(branch, entityId, type);
+ ArtifactReadable dispoArtifact = findDispoArtifact(program, entityId, type);
if (dispoArtifact != null) {
TransactionBuilder tx = getTxFactory().createTransaction(branch, author, "Delete Dispo Artifact");
tx.deleteArtifact(dispoArtifact);
@@ -266,7 +248,7 @@ public class OrcsStorageImpl implements Storage {
@Override
public void updateDispoSet(ArtifactReadable author, DispoProgram program, String setId, DispoSet newData) {
IOseeBranch branch = getProgramBranch(program);
- ArtifactReadable dispoSet = findDispoArtifact(branch, setId, DispoConstants.DispoSet);
+ ArtifactReadable dispoSet = findDispoArtifact(program, setId, DispoConstants.DispoSet);
String name = newData.getName();
String importPath = newData.getImportPath();
@@ -293,7 +275,7 @@ public class OrcsStorageImpl implements Storage {
@Override
public Identifiable<String> createDispoItem(ArtifactReadable author, DispoProgram program, DispoSet parentSet, DispoItem data, ArtifactReadable assignee) {
IOseeBranch branch = getProgramBranch(program);
- ArtifactReadable parentSetArt = findDispoArtifact(branch, parentSet.getGuid(), DispoConstants.DispoSet);
+ ArtifactReadable parentSetArt = findDispoArtifact(program, parentSet.getGuid(), DispoConstants.DispoSet);
TransactionBuilder tx = getTxFactory().createTransaction(branch, author, "Create Dispoable Item");
ArtifactId createdItem = tx.createArtifact(DispoConstants.DispoItem, data.getName());
@@ -313,74 +295,125 @@ public class OrcsStorageImpl implements Storage {
}
@Override
- public void createAnnotation(ArtifactReadable author, DispoProgram program, ArtifactId disposition, String annotationsJson) {
- IOseeBranch branch = getProgramBranch(program);
- TransactionBuilder tx = getTxFactory().createTransaction(branch, author, "Create Dispo Annotation");
+ public void createDispoItems(ArtifactReadable author, DispoProgram program, DispoSet parentSet, List<DispoItem> data, String assignee) {
+ IOseeBranch branch = TokenFactory.createBranch(program.getUuid(), "");
+ ArtifactReadable parentSetArt = findDispoArtifact(program, parentSet.getGuid(), DispoConstants.DispoSet);
+ TransactionBuilder tx = getTxFactory().createTransaction(branch, author, "Create Dispoable Item");
+
+ for (DispoItem item : data) {
+ ArtifactId createdItem = tx.createArtifact(DispoConstants.DispoItem, item.getName());
+
+ tx.setSoleAttributeValue(createdItem, DispoConstants.DispoDateCreated, item.getCreationDate());
+ tx.setSoleAttributeValue(createdItem, DispoConstants.DispoLastUpdated, item.getLastUpdate());
- tx.setSoleAttributeFromString(disposition, DispoConstants.DispoAnnotationsJson, annotationsJson);
+ tx.setSoleAttributeValue(createdItem, DispoConstants.DispoItemStatus, item.getStatus());
+ tx.setSoleAttributeFromString(createdItem, DispoConstants.DispoDiscrepanciesJson,
+ item.getDiscrepanciesList().toString());
+ tx.setSoleAttributeFromString(createdItem, DispoConstants.DispoAnnotationsJson,
+ item.getAnnotationsList().toString());
+ tx.setSoleAttributeFromString(createdItem, DispoConstants.DispoItemVersion, item.getVersion());
+ tx.setSoleAttributeFromString(createdItem, DispoConstants.DispoItemAssignee, assignee);
+
+ tx.relate(parentSetArt, CoreRelationTypes.Default_Hierarchical__Child, createdItem);
+ }
tx.commit();
}
@Override
public void updateDispoItem(ArtifactReadable author, DispoProgram program, String dispoItemId, DispoItem data) {
- boolean wasEdited = false;
IOseeBranch branch = getProgramBranch(program);
- ArtifactId dispoItemArt = findDispoArtifact(branch, dispoItemId, DispoConstants.DispoItem);
- String assigneeId = data.getAssignee();
-
- TransactionBuilder tx = getTxFactory().createTransaction(branch, author, "Edit Dispoable Item");
+ ArtifactId dispoItemArt = findDispoArtifact(program, dispoItemId, DispoConstants.DispoItem);
+ Date lastUpdate = data.getLastUpdate();
String name = data.getName();
- JSONArray discrepanciesList = data.getDiscrepanciesList();
- JSONObject annotationsList = data.getAnnotationsList();
+ JSONObject discrepanciesList = data.getDiscrepanciesList();
+ JSONArray annotationsList = data.getAnnotationsList();
String status = data.getStatus();
+ String assignee = data.getAssignee();
+
+ TransactionBuilder tx = getTxFactory().createTransaction(branch, author, "Edit Dispoable Item");
+
if (name != null) {
tx.setName(dispoItemArt, name);
- wasEdited = true;
}
if (discrepanciesList != null) {
tx.setSoleAttributeFromString(dispoItemArt, DispoConstants.DispoDiscrepanciesJson,
discrepanciesList.toString());
- wasEdited = true;
}
if (annotationsList != null) {
tx.setSoleAttributeFromString(dispoItemArt, DispoConstants.DispoAnnotationsJson, annotationsList.toString());
- wasEdited = true;
}
- if (assigneeId != null) {
- ArtifactReadable userAsArt = findUser(assigneeId);
- tx.relate(dispoItemArt, DispoConstants.DispoAssigned_Assignee, userAsArt);
- wasEdited = true;
+ if (assignee != null) {
+ tx.setSoleAttributeFromString(dispoItemArt, DispoConstants.DispoItemAssignee, assignee);
}
if (status != null) {
tx.setSoleAttributeFromString(dispoItemArt, DispoConstants.DispoItemStatus, status);
- wasEdited = true;
}
- if (wasEdited) {
- tx.setSoleAttributeValue(dispoItemArt, DispoConstants.DispoLastUpdated, new Date());
+ if (lastUpdate != null) {
+ tx.setSoleAttributeValue(dispoItemArt, DispoConstants.DispoLastUpdated, lastUpdate);
}
tx.commit();
}
@Override
- public IOseeBranch findProgramId(DispoProgram program) {
- IOseeBranch toReturn = null;
+ public void updateDispoItems(ArtifactReadable author, DispoProgram program, String dispoItemId, List<DispoItem> data) {
+ IOseeBranch branch = TokenFactory.createBranch(program.getUuid(), "");
+ TransactionBuilder tx = getTxFactory().createTransaction(branch, author, "Edit Dispoable Item");
+
+ for (DispoItem item : data) {
+ ArtifactId dispoItemArt = findDispoArtifact(program, dispoItemId, DispoConstants.DispoItem);
+ String assignee = item.getAssignee();
+ Date lastUpdate = item.getLastUpdate();
+ String name = item.getName();
+ JSONObject discrepanciesList = item.getDiscrepanciesList();
+ JSONArray annotationsList = item.getAnnotationsList();
+ String status = item.getStatus();
+
+ if (name != null) {
+ tx.setName(dispoItemArt, name);
+ }
+ if (discrepanciesList != null) {
+ tx.setSoleAttributeFromString(dispoItemArt, DispoConstants.DispoDiscrepanciesJson,
+ discrepanciesList.toString());
+ }
+ if (annotationsList != null) {
+ tx.setSoleAttributeFromString(dispoItemArt, DispoConstants.DispoAnnotationsJson, annotationsList.toString());
+ }
+ if (assignee != null) {
+ tx.setSoleAttributeFromString(dispoItemArt, DispoConstants.DispoItemAssignee, assignee);
+ }
+ if (status != null) {
+ tx.setSoleAttributeFromString(dispoItemArt, DispoConstants.DispoItemStatus, status);
+ }
+ if (lastUpdate != null) {
+ tx.setSoleAttributeValue(dispoItemArt, DispoConstants.DispoLastUpdated, lastUpdate);
+ }
+ }
+
+ 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();
- String configContents = configArt.getSoleAttributeAsString(CoreAttributeTypes.GeneralStringData);
+ return configArt.getSoleAttributeAsString(CoreAttributeTypes.GeneralStringData);
+ }
- Pattern regex = Pattern.compile(program.getUuid() + "\\s*:\\s*.*");
+ private IOseeBranch convertToDispoBranch(String configContents, IOseeBranch baselineBranch) {
+ IOseeBranch toReturn = null;
+
+ Pattern regex = Pattern.compile(baselineBranch.getUuid() + "\\s*:\\s*.*");
Matcher matcher = regex.matcher(configContents);
String guid = null;
if (matcher.find()) {
String match = matcher.group();
String[] split = match.split(":");
- guid = split[1];
+ toReturn = TokenFactory.createBranch(split[1], baselineBranch.getName());
}
- regex = Pattern.compile(program.getUuid() + "\\s*:\\s*.*");
+ regex = Pattern.compile(baselineBranch.getGuid() + "\\s*:\\s*.*");
matcher = regex.matcher(configContents);
Long uuid = null;
if (matcher.find()) {
@@ -393,7 +426,29 @@ public class OrcsStorageImpl implements Storage {
}
@Override
- public ResultSet<? extends IOseeBranch> findBaselineBranches() {
- return getQuery().branchQuery().andIsOfType(BranchType.BASELINE).getResults();
+ public ResultSet<IOseeBranch> getDispoBranches() {
+ ResultSet<BranchReadable> baselineBranches =
+ getQuery().branchQuery().andIsOfType(BranchType.BASELINE).getResults();
+
+ String configContents = getDispoConfigContents();
+
+ List<IOseeBranch> results = new ArrayList<IOseeBranch>();
+ for (BranchReadable baselineBranch : baselineBranches) {
+ IOseeBranch dispoBranch = convertToDispoBranch(configContents, baselineBranch);
+ if (dispoBranch != null) {
+ results.add(dispoBranch);
+ }
+ }
+ return ResultSets.newResultSet(results);
+ }
+
+ @Override
+ public DispoItem findDispoItemById(DispoProgram program, String itemId) {
+ DispoItem toReturn = null;
+ ArtifactReadable dispoArtifact = findDispoArtifact(program, itemId, DispoConstants.DispoItem);
+ if (dispoArtifact != null) {
+ toReturn = new DispoItemArtifact(dispoArtifact);
+ }
+ return toReturn;
}
}
diff --git a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/types/OseeTypes_Dispo.osee b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/types/OseeTypes_Dispo.osee
index 3ed6a3e03b7..8cc15f95df6 100644
--- a/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/types/OseeTypes_Dispo.osee
+++ b/plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/types/OseeTypes_Dispo.osee
@@ -7,8 +7,8 @@ artifactType "Disposition Set" extends "Artifact" {
attribute "dispo.Import Path"
attribute "dispo.Notes JSON"
attribute "dispo.Date Created"
- attribute "dispo.Status Count"
attribute "dispo.Import State"
+ attribute "dispo.Summary Count"
}
artifactType "dispo.Dispositionable Item" extends "Artifact" {
@@ -18,7 +18,9 @@ artifactType "dispo.Dispositionable Item" extends "Artifact" {
attribute "dispo.Discrepancies JSON"
attribute "dispo.Date Created"
attribute "dispo.Item Status"
+ attribute "dispo.Item Version"
attribute "dispo.Last Updated"
+ attribute "dispo.Assignee"
}
attributeType "dispo.Annotations JSON" extends StringAttribute {
@@ -27,7 +29,7 @@ attributeType "dispo.Annotations JSON" extends StringAttribute {
min 1
max 1
taggerId DefaultAttributeTaggerProvider
- defaultValue "[]"
+ defaultValue "{}"
fileExtension "txt"
mediaType "text/plain"
}
@@ -64,12 +66,12 @@ attributeType "dispo.Import Path" extends StringAttribute {
mediaType "text/plain"
}
-attributeType "dispo.Status Count" extends StringAttribute {
- uuid 0x1000000000000390
+attributeType "dispo.Summary Count" extends StringAttribute {
+ uuid 0x1000000000000203
dataProvider DefaultAttributeDataProvider
min 0
max 1
- fileExtension "txt"
+ defaultValue "0/0"
mediaType "text/plain"
}
@@ -102,8 +104,29 @@ attributeType "dispo.Item Status" extends EnumeratedAttribute {
dataProvider DefaultAttributeDataProvider
min 0
max 1
+ taggerId DefaultAttributeTaggerProvider
enumType "enum.dispo.item status"
- defaultValue "No Import"
+ defaultValue "Unspecified"
+ mediaType "text/plain"
+}
+
+attributeType "dispo.Item Version" extends StringAttribute {
+ uuid 0x3000000000000200
+ dataProvider DefaultAttributeDataProvider
+ min 0
+ max 1
+ taggerId DefaultAttributeTaggerProvider
+ defaultValue "0.0"
+ mediaType "text/plain"
+}
+
+attributeType "dispo.Assignee" extends StringAttribute {
+ uuid 0x3000000000000201
+ dataProvider DefaultAttributeDataProvider
+ min 0
+ max 1
+ taggerId DefaultAttributeTaggerProvider
+ defaultValue "UnAssinged"
mediaType "text/plain"
}
@@ -135,13 +158,3 @@ attributeType "dispo.Last Updated" extends DateAttribute {
max 1
mediaType "text/calendar"
}
-
-relationType "dispo.Assigned" {
- uuid 0x2000000000000181
- sideAName "dispoableItem"
- sideAArtifactType "dispo.Dispositionable Item"
- sideBName "user"
- sideBArtifactType "User"
- defaultOrderType Unordered
- multiplicity MANY_TO_ONE
-}

Back to the top