Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
trace-server: Support markerSetId for annotation categories
Browse files Browse the repository at this point in the history
[Added] markerSetId query parameter in GET annotations endpoint

Change-Id: Ia8c16ce1be8ad24a74d1d282dfeac12330709692
Signed-off-by: Patrick Tasse <[email protected]>
Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/182766
Tested-by: Trace Compass Bot <[email protected]>
Tested-by: Matthew Khouzam <[email protected]>
Reviewed-by: Matthew Khouzam <[email protected]>
  • Loading branch information
PatrickTasse committed Jul 9, 2021
1 parent 7d36f02 commit cf50709
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment;
import org.w3c.dom.Element;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;

/**
Expand Down Expand Up @@ -373,13 +374,16 @@ public Response getArrows(@PathParam("expUUID") UUID expUUID,
* desired experiment UUID
* @param outputId
* Eclipse extension point ID for the data provider to query
* @param markerSetId
* marker set ID
* @return {@link TmfModelResponse} containing {@link AnnotationCategoriesModel}
*/
@GET
@Path("/{outputId}/annotations")
@Produces(MediaType.APPLICATION_JSON)
public Response getAnnotationCategories(@PathParam("expUUID") UUID expUUID,
@PathParam("outputId") String outputId) {
@PathParam("outputId") String outputId,
@QueryParam("markerSetId") String markerSetId) {

if (outputId == null) {
return Response.status(Status.PRECONDITION_FAILED).entity(MISSING_OUTPUTID).build();
Expand All @@ -403,8 +407,11 @@ public Response getAnnotationCategories(@PathParam("expUUID") UUID expUUID,
AnnotationCategoriesModel model = null;
// Fetch trace annotation categories
TraceAnnotationProvider traceAnnotationProvider = ExperimentManagerService.getTraceAnnotationProvider(expUUID);
@NonNull Map<@NonNull String, @NonNull Object> params = Collections.emptyMap();
if (traceAnnotationProvider != null) {
// Parameter is only applicable for trace annotation provider
@NonNull Map<@NonNull String, @NonNull Object> params =
(markerSetId == null) ? Collections.emptyMap() :
ImmutableMap.of(DataProviderParameterUtils.REQUESTED_MARKER_SET_KEY, markerSetId);
TmfModelResponse<@NonNull AnnotationCategoriesModel> traceAnnotations = traceAnnotationProvider.fetchAnnotationCategories(params, null);
if (traceAnnotations.getStatus() == ITmfResponse.Status.CANCELLED || traceAnnotations.getStatus() == ITmfResponse.Status.FAILED) {
return Response.ok(new TmfModelResponse<>(new AnnotationCategoriesModel(Collections.emptyList()), traceAnnotations.getStatus(), traceAnnotations.getStatusMessage())).build();
Expand All @@ -414,7 +421,7 @@ public Response getAnnotationCategories(@PathParam("expUUID") UUID expUUID,
}
// Fetch data provider annotation categories
if (provider instanceof IOutputAnnotationProvider) {
TmfModelResponse<@NonNull AnnotationCategoriesModel> annotations = ((IOutputAnnotationProvider) provider).fetchAnnotationCategories(params, null);
TmfModelResponse<@NonNull AnnotationCategoriesModel> annotations = ((IOutputAnnotationProvider) provider).fetchAnnotationCategories(Collections.emptyMap(), null);
if (annotations.getStatus() == ITmfResponse.Status.CANCELLED || annotations.getStatus() == ITmfResponse.Status.FAILED) {
return Response.ok(new TmfModelResponse<>(new AnnotationCategoriesModel(Collections.emptyList()), annotations.getStatus(), annotations.getStatusMessage())).build();
}
Expand Down

0 comments on commit cf50709

Please sign in to comment.