Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAngel Avila2016-04-01 21:42:54 +0000
committerRyan D. Brooks2016-04-01 21:42:54 +0000
commit16c81c5b8317daab7deaa3a7e9cf9989563210a4 (patch)
treeb3ea6608415375fcd6471290659df5b8a95f4a57 /plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoDataFactory.java
parenta3f7a351fce0f66736d18f059b80aa27d15657c9 (diff)
downloadorg.eclipse.osee-16c81c5b8317daab7deaa3a7e9cf9989563210a4.tar.gz
org.eclipse.osee-16c81c5b8317daab7deaa3a7e9cf9989563210a4.tar.xz
org.eclipse.osee-16c81c5b8317daab7deaa3a7e9cf9989563210a4.zip
refactor: Move translation to JSON to single point
Diffstat (limited to 'plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoDataFactory.java')
-rw-r--r--plugins/org.eclipse.osee.disposition.rest/src/org/eclipse/osee/disposition/rest/internal/DispoDataFactory.java48
1 files changed, 13 insertions, 35 deletions
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 d4ed38b3946..330735e79e2 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,18 +11,20 @@
package org.eclipse.osee.disposition.rest.internal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.eclipse.osee.disposition.model.Discrepancy;
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.disposition.model.Note;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.logger.Log;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
/**
* @author Angel Avila
@@ -54,25 +56,25 @@ public class DispoDataFactory {
newSet.setName(descriptor.getName());
newSet.setImportPath(descriptor.getImportPath());
newSet.setImportState("NONE");
- newSet.setNotesList(new JSONArray());
+ newSet.setNotesList(new ArrayList<Note>());
newSet.setDispoType(descriptor.getDispoType());
return newSet;
}
- public void setStatus(DispoItemData item) throws JSONException {
+ public void setStatus(DispoItemData item) {
item.setStatus(dispoConnector.getItemStatus(item));
}
public void initDispoItem(DispoItemData itemToInit) {
if (itemToInit.getAnnotationsList() == null) {
- itemToInit.setAnnotationsList(new JSONArray());
+ itemToInit.setAnnotationsList(new ArrayList<DispoAnnotationData>());
}
if (itemToInit.getDiscrepanciesList() == null) {
- itemToInit.setDiscrepanciesList(new JSONObject());
+ itemToInit.setDiscrepanciesList(new HashMap<String, Discrepancy>());
}
- if (itemToInit.getDiscrepanciesList().length() == 0) {
+ if (itemToInit.getDiscrepanciesList().size() == 0) {
itemToInit.setStatus(DispoStrings.Item_Pass);
} else {
itemToInit.setStatus(DispoStrings.Item_InComplete);
@@ -80,7 +82,7 @@ public class DispoDataFactory {
}
public void initAnnotation(DispoAnnotationData annotationToInit) {
- annotationToInit.setIdsOfCoveredDiscrepancies(new JSONArray());
+ annotationToInit.setIdsOfCoveredDiscrepancies(new ArrayList<String>());
annotationToInit.setCustomerNotes("");
annotationToInit.setDeveloperNotes("");
annotationToInit.setResolution("");
@@ -88,7 +90,7 @@ public class DispoDataFactory {
annotationToInit.setIsDefault(false);
}
- public DispoItem createUpdatedItem(JSONArray annotationsList, JSONObject discrepanciesList) throws JSONException {
+ public DispoItem createUpdatedItem(List<DispoAnnotationData> annotationsList, Map<String, Discrepancy> discrepanciesList) {
DispoItemData newItem = new DispoItemData();
newItem.setAnnotationsList(annotationsList);
newItem.setDiscrepanciesList(discrepanciesList);
@@ -97,30 +99,6 @@ public class DispoDataFactory {
return newItem;
}
- public JSONArray mergeJsonArrays(JSONArray currentArray, JSONArray arrayToAdd) {
- String currentJsonString = currentArray.toString().trim();
- String toAddJsonString = arrayToAdd.toString();
- StringBuilder sb = new StringBuilder();
-
- if (!currentJsonString.equals("[]")) {
- sb.append(currentJsonString);
- sb.replace(currentJsonString.length() - 1, currentJsonString.length(), ",");
- sb.append(toAddJsonString.replaceFirst("\\[", ""));
- } else {
- sb.append(toAddJsonString);
- }
- JSONArray toReturn;
- try {
- toReturn = new JSONArray(sb.toString());
- } catch (JSONException ex) {
- toReturn = currentArray;
- throw new OseeCoreException(ex);
- }
-
- return toReturn;
-
- }
-
public String getNewId() {
return GUID.create();
}

Back to the top