Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2018-01-19 15:43:31 +0000
committerRyan D. Brooks2020-12-15 22:28:00 +0000
commitf4a1a07861e0af3bb4c6535d330a259b0ef277ff (patch)
treec61172855ab293a5b55d4b15dbc9b554bfb8f5f3
parentfea5e7c0b3bce10759c37618b4aaf87743eea7f0 (diff)
downloadorg.eclipse.osee-f4a1a07861e0af3bb4c6535d330a259b0ef277ff.tar.gz
org.eclipse.osee-f4a1a07861e0af3bb4c6535d330a259b0ef277ff.tar.xz
org.eclipse.osee-f4a1a07861e0af3bb4c6535d330a259b0ef277ff.zip
refactor: Replace IdentityView usage with ArtifactToken
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsActionEndpointApi.java3
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigJsonWriter.java115
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigsJsonWriter.java4
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/TargetedVersion.java5
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsActionEndpointImpl.java7
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemArrayJsonWriter.java13
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemJsonWriter.java105
-rw-r--r--plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemsJsonWriter.java16
-rw-r--r--plugins/org.eclipse.osee.jaxrs/src/org/eclipse/osee/jaxrs/mvc/IdentityView.java34
-rw-r--r--plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writers/ArtifactJsonWriter.java34
10 files changed, 117 insertions, 219 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsActionEndpointApi.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsActionEndpointApi.java
index 47752326fc2..2a0158715d3 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsActionEndpointApi.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/workflow/AtsActionEndpointApi.java
@@ -52,12 +52,11 @@ public interface AtsActionEndpointApi {
/**
* @param ids (atsId, artId) of action to display
- * @return html representation of the action
*/
@Path("{ids}")
@GET
@Produces({MediaType.APPLICATION_JSON})
- List<IAtsWorkItem> getAction(@PathParam("ids") String ids);
+ public abstract List<ArtifactToken> getAction(@PathParam("ids") String ids);
/**
* @param ids (atsId, artId) of action to display
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigJsonWriter.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigJsonWriter.java
index 2064b8fd389..6cdaa9d16a7 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigJsonWriter.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigJsonWriter.java
@@ -55,7 +55,6 @@ import org.eclipse.osee.framework.core.util.JsonUtil;
import org.eclipse.osee.framework.jdk.core.type.HashCollection;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.util.DateUtil;
-import org.eclipse.osee.jaxrs.mvc.IdentityView;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
@@ -115,7 +114,7 @@ public class ConfigJsonWriter implements MessageBodyWriter<IAtsConfigObject> {
}
}
- public static void addProgramObject(IAtsServer atsApi, IAtsObject atsObject, Annotation[] annotations, JsonGenerator writer, boolean identityView) throws IOException, JsonGenerationException, JsonProcessingException {
+ public static void addProgramObject(IAtsServer atsApi, IAtsObject atsObject, Annotation[] annotations, JsonGenerator writer) throws IOException, JsonGenerationException, JsonProcessingException {
ArtifactReadable artifact = atsApi.getArtifact(atsObject);
writer.writeStartObject();
writer.writeNumberField("id", atsObject.getId());
@@ -123,87 +122,75 @@ public class ConfigJsonWriter implements MessageBodyWriter<IAtsConfigObject> {
writer.writeStringField("Description", atsObject.getDescription());
if (atsObject instanceof IAtsTeamDefinition) {
- if (!identityView) {
- writer.writeArrayFieldStart("version");
- for (ArtifactReadable verArt : artifact.getRelated(AtsRelationTypes.TeamDefinitionToVersion_Version)) {
- IAtsVersion version = atsApi.getVersionService().getVersionById(verArt);
+ writer.writeArrayFieldStart("version");
+ for (ArtifactReadable verArt : artifact.getRelated(AtsRelationTypes.TeamDefinitionToVersion_Version)) {
+ IAtsVersion version = atsApi.getVersionService().getVersionId(verArt);
addProgramObject(atsApi, version, annotations, writer, true);
- }
- writer.writeEndArray();
}
+ writer.writeEndArray();
}
if (atsObject instanceof IAtsVersion) {
- if (!identityView) {
- writer.writeArrayFieldStart("workflow");
- for (ArtifactReadable workArt : artifact.getRelated(
- AtsRelationTypes.TeamWorkflowTargetedForVersion_TeamWorkflow)) {
- addArtifactIdentity(writer, workArt);
- }
- writer.writeEndArray();
+ writer.writeArrayFieldStart("workflow");
+ for (ArtifactReadable workArt : artifact.getRelated(
+ AtsRelationTypes.TeamWorkflowTargetedForVersion_TeamWorkflow)) {
+ addArtifactIdentity(writer, workArt);
}
+ writer.writeEndArray();
} else if (atsObject instanceof IAtsInsertionActivity) {
IAtsInsertionActivity activity = (IAtsInsertionActivity) atsObject;
writer.writeBooleanField("Active", activity.isActive());
- if (!identityView) {
- writer.writeArrayFieldStart("insertion");
- for (ArtifactReadable insertion : artifact.getRelated(
- AtsRelationTypes.InsertionToInsertionActivity_Insertion)) {
- addArtifactIdentity(writer, insertion);
- }
- writer.writeEndArray();
- writer.writeArrayFieldStart("workpackage");
- for (ArtifactReadable workPackage : artifact.getRelated(
- AtsRelationTypes.InsertionActivityToWorkPackage_WorkPackage)) {
- addArtifactIdentity(writer, workPackage);
- }
- writer.writeEndArray();
+ writer.writeArrayFieldStart("insertion");
+ for (ArtifactReadable insertion : artifact.getRelated(
+ AtsRelationTypes.InsertionToInsertionActivity_Insertion)) {
+ addArtifactIdentity(writer, insertion);
}
+ writer.writeEndArray();
+ writer.writeArrayFieldStart("workpackage");
+ for (ArtifactReadable workPackage : artifact.getRelated(
+ AtsRelationTypes.InsertionActivityToWorkPackage_WorkPackage)) {
+ addArtifactIdentity(writer, workPackage);
+ }
+ writer.writeEndArray();
} else if (atsObject instanceof IAtsInsertion) {
IAtsInsertion insertion = (IAtsInsertion) atsObject;
writer.writeBooleanField("Active", insertion.isActive());
- if (!identityView) {
- writer.writeArrayFieldStart("program");
- for (ArtifactReadable program : artifact.getRelated(AtsRelationTypes.ProgramToInsertion_Program)) {
- addArtifactIdentity(writer, program);
- }
- writer.writeEndArray();
- writer.writeArrayFieldStart("insertionactivity");
- for (ArtifactReadable activity : artifact.getRelated(
- AtsRelationTypes.InsertionToInsertionActivity_InsertionActivity)) {
- addArtifactIdentity(writer, activity);
- }
- writer.writeEndArray();
+ writer.writeArrayFieldStart("program");
+ for (ArtifactReadable program : artifact.getRelated(AtsRelationTypes.ProgramToInsertion_Program)) {
+ addArtifactIdentity(writer, program);
+ }
+ writer.writeEndArray();
+ writer.writeArrayFieldStart("insertionactivity");
+ for (ArtifactReadable activity : artifact.getRelated(
+ AtsRelationTypes.InsertionToInsertionActivity_InsertionActivity)) {
+ addArtifactIdentity(writer, activity);
}
+ writer.writeEndArray();
} else if (atsObject instanceof IAtsProgram) {
IAtsProgram program = (IAtsProgram) atsObject;
writer.writeStringField("Namespace", atsApi.getProgramService().getNamespace(program));
writer.writeBooleanField("Active", program.isActive());
- if (!identityView) {
- writer.writeArrayFieldStart("country");
- for (ArtifactReadable country : artifact.getRelated(AtsRelationTypes.CountryToProgram_Country)) {
- addArtifactIdentity(writer, country);
- }
- writer.writeEndArray();
- writer.writeArrayFieldStart("insertion");
- for (ArtifactReadable insertion : artifact.getRelated(AtsRelationTypes.ProgramToInsertion_Insertion)) {
- addArtifactIdentity(writer, insertion);
- }
- writer.writeEndArray();
+ writer.writeArrayFieldStart("country");
+ for (ArtifactReadable country : artifact.getRelated(AtsRelationTypes.CountryToProgram_Country)) {
+ addArtifactIdentity(writer, country);
+ }
+ writer.writeEndArray();
+ writer.writeArrayFieldStart("insertion");
+ for (ArtifactReadable insertion : artifact.getRelated(AtsRelationTypes.ProgramToInsertion_Insertion)) {
+ addArtifactIdentity(writer, insertion);
}
+ writer.writeEndArray();
} else if (atsObject instanceof IAtsCountry) {
IAtsCountry country = (IAtsCountry) atsObject;
- if (!identityView) {
- writer.writeArrayFieldStart("programs");
- Collection<IAtsProgram> programs = atsApi.getProgramService().getPrograms(country);
- for (IAtsProgram program : programs) {
- writer.writeStartObject();
- writer.writeNumberField("id", program.getId());
- writer.writeStringField("name", program.getName());
- writer.writeBooleanField("active", program.isActive());
- writer.writeEndObject();
- }
- writer.writeEndArray();
+ writer.writeArrayFieldStart("programs");
+ Collection<IAtsProgram> programs = atsApi.getProgramService().getPrograms(country);
+ for (IAtsProgram program : programs) {
+ writer.writeStartObject();
+ writer.writeNumberField("id", program.getId());
+ writer.writeStringField("name", program.getName());
+ writer.writeBooleanField("active", program.isActive());
+ writer.writeEndObject();
}
+ writer.writeEndArray();
} else if (atsObject instanceof IAgileTeam) {
IAgileTeam team = (IAgileTeam) atsObject;
writer.writeBooleanField("Active", team.isActive());
@@ -235,9 +222,7 @@ public class ConfigJsonWriter implements MessageBodyWriter<IAtsConfigObject> {
writer.writeStringField("Backlog Id", backlogArt.isValid() ? backlogArt.getIdString() : "");
writer.writeStringField("Backlog", backlogArt.isValid() ? backlogArt.getName() : "");
}
- if (!identityView) {
- addAttributeData(writer, artifact, Collections.emptyList(), atsApi);
- }
+ addAttributeData(writer, artifact, Collections.emptyList(), atsApi);
writer.writeEndObject();
}
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigsJsonWriter.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigsJsonWriter.java
index 1376ce5d1af..34a6b0739d5 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigsJsonWriter.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/config/ConfigsJsonWriter.java
@@ -30,7 +30,6 @@ import org.eclipse.osee.ats.api.IAtsConfigObject;
import org.eclipse.osee.ats.api.util.SkipAtsConfigJsonWriter;
import org.eclipse.osee.ats.rest.AtsApiServer;
import org.eclipse.osee.framework.core.util.JsonUtil;
-import org.eclipse.osee.jaxrs.mvc.IdentityView;
import org.eclipse.osee.orcs.OrcsApi;
/**
@@ -99,8 +98,7 @@ public class ConfigsJsonWriter implements MessageBodyWriter<Collection<IAtsConfi
writer = jsonFactory.createGenerator(entityStream);
writer.writeStartArray();
for (IAtsConfigObject program : programs) {
- ConfigJsonWriter.addProgramObject(atsApi, program, annotations, writer,
- matches(IdentityView.class, annotations));
+ ConfigJsonWriter.addProgramObject(atsApi, program, annotations, writer,);
}
writer.writeEndArray();
} finally {
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/TargetedVersion.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/TargetedVersion.java
index 7fd3a600aa8..73ef86f816a 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/TargetedVersion.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/util/TargetedVersion.java
@@ -21,8 +21,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
- * Annotation on resource methods used to indicate that the return type should be rendered as an identity pojo - id/name
- * only.
+ * Annotation on resource methods used to request inclusion of the TargetedVersion field of the parent TeamWorkflow
*
* @author Roberto E. Escobar
*/
@@ -31,4 +30,4 @@ import java.lang.annotation.Target;
@Target({TYPE, METHOD})
public @interface TargetedVersion {
//
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsActionEndpointImpl.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsActionEndpointImpl.java
index 877a60e67ef..18e29718fdc 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsActionEndpointImpl.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/AtsActionEndpointImpl.java
@@ -94,7 +94,6 @@ import org.eclipse.osee.framework.jdk.core.util.Collections;
import org.eclipse.osee.framework.jdk.core.util.Conditions;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.jaxrs.mvc.IdentityView;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.search.QueryBuilder;
@@ -132,16 +131,13 @@ public final class AtsActionEndpointImpl implements AtsActionEndpointApi {
/**
* @param ids (artId, atsId) of action to display
- * @return html representation of the action
*/
@Override
@Path("{ids}")
- @IdentityView
@GET
@Produces({MediaType.APPLICATION_JSON})
public List<IAtsWorkItem> getAction(@PathParam("ids") String ids) {
- List<IAtsWorkItem> workItems = atsQueryService.getWorkItemsByIds(ids);
- return workItems;
+ return atsQueryService.getWorkItemsByIds(ids);
}
/**
@@ -159,7 +155,6 @@ public final class AtsActionEndpointImpl implements AtsActionEndpointApi {
/**
* @param ids (artId, atsId) of action to display
- * @return html representation of the action
*/
@Override
@Path("{ids}/child")
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemArrayJsonWriter.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemArrayJsonWriter.java
index 58e62bee215..39a83de337f 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemArrayJsonWriter.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemArrayJsonWriter.java
@@ -29,7 +29,6 @@ import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.workflow.WorkItemArray;
import org.eclipse.osee.ats.rest.AtsApiServer;
import org.eclipse.osee.framework.core.util.JsonUtil;
-import org.eclipse.osee.jaxrs.mvc.IdentityView;
import org.eclipse.osee.orcs.OrcsApi;
/**
@@ -69,15 +68,6 @@ public class WorkItemArrayJsonWriter implements MessageBodyWriter<WorkItemArray>
return assignableFrom && MediaType.APPLICATION_JSON_TYPE.equals(mediaType);
}
- private boolean matches(Class<? extends Annotation> toMatch, Annotation[] annotations) {
- for (Annotation annotation : annotations) {
- if (annotation.annotationType().isAssignableFrom(toMatch)) {
- return true;
- }
- }
- return false;
- }
-
@Override
public void writeTo(WorkItemArray workItemArray, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
JsonGenerator writer = null;
@@ -86,8 +76,7 @@ public class WorkItemArrayJsonWriter implements MessageBodyWriter<WorkItemArray>
writer.writeStartObject();
writer.writeArrayFieldStart("workItems");
for (IAtsWorkItem workItem : workItemArray.getWorkItems()) {
- WorkItemJsonWriter.addWorkItem(atsApi, workItem, annotations, writer,
- matches(IdentityView.class, annotations), Collections.emptyList());
+ WorkItemJsonWriter.addWorkItem(atsApi, workItem, annotations, writer, Collections.emptyList());
}
writer.writeEndArray();
writer.writeEndObject();
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemJsonWriter.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemJsonWriter.java
index 21056af1da1..82689ad112b 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemJsonWriter.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemJsonWriter.java
@@ -40,7 +40,6 @@ import org.eclipse.osee.ats.api.workflow.WorkItemWriterOptions;
import org.eclipse.osee.ats.rest.AtsApiServer;
import org.eclipse.osee.ats.rest.internal.config.ConfigJsonWriter;
import org.eclipse.osee.ats.rest.internal.util.ActionPage;
-import org.eclipse.osee.ats.rest.internal.util.TargetedVersion;
import org.eclipse.osee.framework.core.data.ArtifactToken;
import org.eclipse.osee.framework.core.data.AttributeId;
import org.eclipse.osee.framework.core.data.AttributeTypeToken;
@@ -50,7 +49,6 @@ import org.eclipse.osee.framework.core.util.JsonUtil;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.util.DateUtil;
import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.jaxrs.mvc.IdentityView;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
@@ -93,22 +91,12 @@ public class WorkItemJsonWriter implements MessageBodyWriter<IAtsWorkItem> {
return assignableFrom && MediaType.APPLICATION_JSON_TYPE.equals(mediaType);
}
- private static boolean matches(Class<? extends Annotation> toMatch, Annotation[] annotations) {
- for (Annotation annotation : annotations) {
- if (annotation.annotationType().isAssignableFrom(toMatch)) {
- return true;
- }
- }
- return false;
- }
-
@Override
public void writeTo(IAtsWorkItem config, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException {
JsonGenerator writer = null;
try {
writer = jsonFactory.createGenerator(entityStream);
- addWorkItem(atsApi, config, annotations, writer, matches(IdentityView.class, annotations),
- Collections.emptyList());
+ addWorkItem(atsApi, config, annotations, writer, annotations),
} finally {
if (writer != null) {
writer.flush();
@@ -116,7 +104,7 @@ public class WorkItemJsonWriter implements MessageBodyWriter<IAtsWorkItem> {
}
}
- protected static void addWorkItem(IAtsServer atsApi, IAtsWorkItem workItem, Annotation[] annotations, JsonGenerator writer, boolean identityView, List<WorkItemWriterOptions> options) throws IOException {
+ protected static void addWorkItem(IAtsServer atsApi, IAtsWorkItem workItem, Annotation[] annotations, JsonGenerator writer, List<WorkItemWriterOptions> options) throws IOException {
ArtifactReadable workItemArt = (ArtifactReadable) workItem.getStoreObject();
writer.writeStartObject();
writer.writeNumberField("id", workItem.getId());
@@ -130,46 +118,43 @@ public class WorkItemJsonWriter implements MessageBodyWriter<IAtsWorkItem> {
writer.writeStringField("ArtifactType", workItemArt.getArtifactType().getName());
String actionUrl = AtsUtil.getActionUrl(atsId, ATS_UI_ACTION_PREFIX, atsApi);
writer.writeStringField("actionLocation", actionUrl);
- if (!identityView) {
- ConfigJsonWriter.addAttributeData(writer, workItemArt, options, atsApi);
- writer.writeStringField("TeamName", ActionPage.getTeamStr(atsApi, workItemArt));
- writer.writeStringField("Assignees", workItem.getStateMgr().getAssigneesStr());
- if (options.contains(WorkItemWriterOptions.WriteRelatedAsTokens)) {
- writer.writeArrayFieldStart("AssigneesTokens");
- for (AtsUser assignee : workItem.getStateMgr().getAssignees()) {
- writer.writeStartObject();
- writer.writeStringField("id", assignee.getIdString());
- writer.writeStringField("name", assignee.getName());
- writer.writeEndObject();
- }
- writer.writeEndArray();
- }
- writer.writeStringField("ChangeType", workItemArt.getSoleAttributeAsString(AtsAttributeTypes.ChangeType, ""));
- writer.writeStringField("Priority", workItemArt.getSoleAttributeAsString(AtsAttributeTypes.Priority, ""));
- writer.writeStringField("State", workItem.getStateMgr().getCurrentStateName());
- if (options.contains(WorkItemWriterOptions.DatesAsLong)) {
- writer.writeStringField("CreatedDate", String.valueOf(workItem.getCreatedDate().getTime()));
- } else {
- writer.writeStringField("CreatedDate", DateUtil.get(workItem.getCreatedDate(), DateUtil.MMDDYY));
+ ConfigJsonWriter.addAttributeData(writer, workItemArt, options, atsApi);
+ writer.writeStringField("TeamName", ActionPage.getTeamStr(atsApi, workItemArt));
+ writer.writeStringField("Assignees", workItem.getStateMgr().getAssigneesStr());
+ if (options.contains(WorkItemWriterOptions.WriteRelatedAsTokens)) {
+ writer.writeArrayFieldStart("AssigneesTokens");
+ for (AtsUser assignee : workItem.getStateMgr().getAssignees()) {
+ writer.writeStartObject();
+ writer.writeStringField("id", assignee.getIdString());
+ writer.writeStringField("name", assignee.getName());
+ writer.writeEndObject();
}
- writer.writeStringField("CreatedBy", workItem.getCreatedBy().getName());
+ writer.writeEndArray();
}
- if (!identityView || matches(TargetedVersion.class, annotations)) {
- if (teamWf != null) {
- IAtsVersion version = atsApi.getVersionService().getTargetedVersion(teamWf);
- writer.writeStringField("TargetedVersion", version == null ? "" : version.getName());
- if (options.contains(WorkItemWriterOptions.WriteRelatedAsTokens)) {
- writer.writeObjectFieldStart("TargetedVersionToken");
- writer.writeStringField("id", version == null ? "" : version.getIdString());
- writer.writeStringField("name", version == null ? "" : version.getName());
- writer.writeEndObject();
- }
+ writer.writeStringField("ChangeType", workItemArt.getSoleAttributeAsString(AtsAttributeTypes.ChangeType, ""));
+ writer.writeStringField("Priority", workItemArt.getSoleAttributeAsString(AtsAttributeTypes.Priority, ""));
+ writer.writeStringField("State", workItem.getStateMgr().getCurrentStateName());
+ if (options.contains(WorkItemWriterOptions.DatesAsLong)) {
+ writer.writeStringField("CreatedDate", String.valueOf(workItem.getCreatedDate().getTime()));
+ } else {
+ writer.writeStringField("CreatedDate", DateUtil.get(workItem.getCreatedDate(), DateUtil.MMDDYY));
+ }
+ writer.writeStringField("CreatedBy", workItem.getCreatedBy().getName());
+ IAtsTeamWorkflow teamWf = workItem.getParentTeamWorkflow();
+ if (teamWf != null) {
+ IAtsVersion version = atsApi.getVersionService().getTargetedVersion(teamWf);
+ writer.writeStringField("TargetedVersion", version == null ? "" : version.getName());
+ if (options.contains(WorkItemWriterOptions.WriteRelatedAsTokens)) {
+ writer.writeObjectFieldStart("TargetedVersionToken");
+ writer.writeStringField("id", version == null ? "" : version.getIdString());
+ writer.writeStringField("name", version == null ? "" : version.getName());
+ writer.writeEndObject();
}
}
writer.writeEndObject();
}
- protected static void addWorkItemWithIds(IAtsServer atsApi, IAtsWorkItem workItem, Annotation[] annotations, JsonGenerator writer, boolean identityView, List<WorkItemWriterOptions> options) throws IOException, JsonGenerationException, JsonProcessingException {
+ protected static void addWorkItemWithIds(IAtsServer atsApi, IAtsWorkItem workItem, JsonGenerator writer, List<WorkItemWriterOptions> options) throws IOException, JsonGenerationException, JsonProcessingException {
ArtifactReadable workItemArt = (ArtifactReadable) workItem.getStoreObject();
writer.writeStartObject();
writer.writeNumberField("id", workItem.getId());
@@ -178,21 +163,19 @@ public class WorkItemJsonWriter implements MessageBodyWriter<IAtsWorkItem> {
writer.writeStringField("ArtifactType", workItemArt.getArtifactType().getName());
String actionUrl = AtsUtil.getActionUrl(atsId, ATS_UI_ACTION_PREFIX, atsApi);
writer.writeStringField("actionLocation", actionUrl);
- if (!identityView) {
- ConfigJsonWriter.addAttributeDataWithIds(writer, workItemArt, options, atsApi);
- writer.writeStringField("TeamName", ActionPage.getTeamStr(atsApi, workItemArt));
- writeAssignees(writer, workItemArt, workItem);
- writeType(writer, workItemArt, workItem, "ChangeType", AtsAttributeTypes.ChangeType);
- writeType(writer, workItemArt, workItem, "Priority", AtsAttributeTypes.Priority);
- writeState(writer, workItemArt, workItem);
- if (options.contains(WorkItemWriterOptions.DatesAsLong)) {
- writer.writeStringField("CreatedDate", String.valueOf(workItem.getCreatedDate().getTime()));
- } else {
- writer.writeStringField("CreatedDate", DateUtil.get(workItem.getCreatedDate(), DateUtil.MMDDYY));
- }
- writer.writeStringField("CreatedBy", workItem.getCreatedBy().getName());
- writeTargetedVersion(atsApi, writer, workItemArt, workItem, options);
+ ConfigJsonWriter.addAttributeDataWithIds(writer, workItemArt, options, atsApi);
+ writer.writeStringField("TeamName", ActionPage.getTeamStr(atsApi, workItemArt));
+ writeAssignees(writer, workItemArt, workItem);
+ writeType(writer, workItemArt, workItem, "ChangeType", AtsAttributeTypes.ChangeType);
+ writeType(writer, workItemArt, workItem, "Priority", AtsAttributeTypes.Priority);
+ writeState(writer, workItemArt, workItem);
+ if (options.contains(WorkItemWriterOptions.DatesAsLong)) {
+ writer.writeStringField("CreatedDate", String.valueOf(workItem.getCreatedDate().getTime()));
+ } else {
+ writer.writeStringField("CreatedDate", DateUtil.get(workItem.getCreatedDate(), DateUtil.MMDDYY));
}
+ writer.writeStringField("CreatedBy", workItem.getCreatedBy().getName());
+ writeTargetedVersion(atsApi, writer, workItemArt, workItem, options);
writer.writeEndObject();
}
diff --git a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemsJsonWriter.java b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemsJsonWriter.java
index 7df20f97b72..5030d4782a5 100644
--- a/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemsJsonWriter.java
+++ b/plugins/org.eclipse.osee.ats.rest/src/org/eclipse/osee/ats/rest/internal/workitem/WorkItemsJsonWriter.java
@@ -34,7 +34,6 @@ import org.eclipse.osee.ats.api.workflow.WorkItemWriterOptions;
import org.eclipse.osee.ats.rest.AtsApiServer;
import org.eclipse.osee.framework.core.util.JsonUtil;
import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.jaxrs.mvc.IdentityView;
import org.eclipse.osee.orcs.OrcsApi;
/**
@@ -82,15 +81,6 @@ public class WorkItemsJsonWriter implements MessageBodyWriter<Collection<IAtsWor
return Lib.isCollectionOfType(type, genericType, IAtsWorkItem.class);
}
- private boolean matches(Class<? extends Annotation> toMatch, Annotation[] annotations) {
- for (Annotation annotation : annotations) {
- if (annotation.annotationType().isAssignableFrom(toMatch)) {
- return true;
- }
- }
- return false;
- }
-
@Override
public void writeTo(Collection<IAtsWorkItem> workItems, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
JsonGenerator writer = null;
@@ -119,11 +109,9 @@ public class WorkItemsJsonWriter implements MessageBodyWriter<Collection<IAtsWor
}
for (IAtsWorkItem workItem : workItems) {
if (valuesWithIds) {
- WorkItemJsonWriter.addWorkItemWithIds(atsApi, workItem, annotations, writer,
- matches(IdentityView.class, annotations), options);
+ WorkItemJsonWriter.addWorkItemWithIds(atsApi, workItem, writer, options);
} else {
- WorkItemJsonWriter.addWorkItem(atsApi, workItem, annotations, writer,
- matches(IdentityView.class, annotations), options);
+ WorkItemJsonWriter.addWorkItem(atsApi, workItem, annotations, writer, options);
}
}
writer.writeEndArray();
diff --git a/plugins/org.eclipse.osee.jaxrs/src/org/eclipse/osee/jaxrs/mvc/IdentityView.java b/plugins/org.eclipse.osee.jaxrs/src/org/eclipse/osee/jaxrs/mvc/IdentityView.java
deleted file mode 100644
index 48288afe38e..00000000000
--- a/plugins/org.eclipse.osee.jaxrs/src/org/eclipse/osee/jaxrs/mvc/IdentityView.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2014 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.jaxrs.mvc;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Annotation on resource methods used to indicate that the return type should be rendered as an identity pojo - id/name
- * only.
- *
- * @author Roberto E. Escobar
- */
-@Documented
-@Retention(RUNTIME)
-@Target({TYPE, METHOD})
-public @interface IdentityView {
- //
-}
diff --git a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writers/ArtifactJsonWriter.java b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writers/ArtifactJsonWriter.java
index a5131e84bcd..93edbe7c743 100644
--- a/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writers/ArtifactJsonWriter.java
+++ b/plugins/org.eclipse.osee.orcs.rest/src/org/eclipse/osee/orcs/rest/internal/writers/ArtifactJsonWriter.java
@@ -29,7 +29,6 @@ import javax.ws.rs.ext.Provider;
import org.eclipse.osee.framework.core.data.AttributeTypeGeneric;
import org.eclipse.osee.framework.core.util.JsonUtil;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
-import org.eclipse.osee.jaxrs.mvc.IdentityView;
import org.eclipse.osee.orcs.OrcsApi;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.data.AttributeReadable;
@@ -89,29 +88,26 @@ public class ArtifactJsonWriter implements MessageBodyWriter<Object> {
// writer.setPrettyPrinter(new DefaultPr)
writer.writeStartObject();
writer.writeNumberField("uuid", artifact.getUuid());
- if (matches(IdentityView.class, annotations)) {
- writer.writeStringField("Name", artifact.getName());
- } else {
Collection<AttributeTypeGeneric<?>> attrTypes = orcsApi.tokenService().getAttributeTypes();
- ResultSet<? extends AttributeReadable<Object>> attributes = artifact.getAttributes();
- if (!attributes.isEmpty()) {
+ Collection<AttributeTypeToken> attrTypes = attributeTypes.getAll();
+ ResultSet<? extends AttributeReadable<Object>> attributes = artifact.getAttributes();
+ if (!attributes.isEmpty()) {
for (AttributeTypeGeneric<?> attrType : attrTypes) {
- if (artifact.isAttributeTypeValid(attrType)) {
- List<Object> attributeValues = artifact.getAttributeValues(attrType);
- if (!attributeValues.isEmpty()) {
+ if (artifact.isAttributeTypeValid(attrType)) {
+ List<Object> attributeValues = artifact.getAttributeValues(attrType);
+ if (!attributeValues.isEmpty()) {
- if (attributeValues.size() > 1) {
- writer.writeArrayFieldStart(attrType.getName());
- for (Object value : attributeValues) {
- writer.writeObject(value);
- }
- writer.writeEndArray();
- } else if (attributeValues.size() == 1) {
- Object value = attributeValues.iterator().next();
- writer.writeObjectField(attrType.getName(), value);
+ if (attributeValues.size() > 1) {
+ writer.writeArrayFieldStart(attrType.getName());
+ for (Object value : attributeValues) {
+ writer.writeObject(value);
}
-
+ writer.writeEndArray();
+ } else if (attributeValues.size() == 1) {
+ Object value = attributeValues.iterator().next();
+ writer.writeObjectField(attrType.getName(), value);
}
+
}
}
}

Back to the top