-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: Add bookmarks endpoint support
Using bookmarks, user can save custom data points where each corresponds to a specific time range. Each bookmark contains "name", "start", "end", and an optional "payload". The following endpoints are introduced: - [GET] Get all the bookmarks of an experiment - [GET] Get a specific bookmark of an experiment - [POST] Create a new bookmark for an experiment - [PUT] Update an old bookmark of an experiment - [DELETE] Delete a bookmark of an experiment [Added] Corresponding endpoints for bookmarks in trace server Signed-off-by: Kaveh Shahedi <kaveh.shahedi@ericsson.com>
- Loading branch information
1 parent
900690d
commit b3e3509
Showing
7 changed files
with
796 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
...eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/model/Bookmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Ericsson | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License 2.0 which | ||
* accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
|
||
package org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model; | ||
|
||
import java.util.UUID; | ||
|
||
import org.eclipse.jdt.annotation.NonNull; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
/** | ||
* Contributes to the model used for TSP swagger-core annotations. | ||
* | ||
* @author Kaveh Shahedi | ||
* @since 10.1 | ||
*/ | ||
public interface Bookmark { | ||
|
||
/** | ||
* @return The bookmark UUID. | ||
*/ | ||
@JsonProperty("UUID") | ||
@Schema(description = "The bookmark's unique identifier") | ||
UUID getUUID(); | ||
|
||
/** | ||
* @return The bookmark name. | ||
*/ | ||
@NonNull | ||
@Schema(description = "User defined name for the bookmark") | ||
String getName(); | ||
|
||
/** | ||
* @return The experiment ID. | ||
*/ | ||
@NonNull | ||
@Schema(description = "The experiment's unique identifier this bookmark belongs to") | ||
String getExperimentId(); | ||
|
||
/** | ||
* @return The start time. | ||
*/ | ||
@Schema(description = "The bookmark's start time") | ||
long getStart(); | ||
|
||
/** | ||
* @return The end time. | ||
*/ | ||
@Schema(description = "The bookmark's end time") | ||
long getEnd(); | ||
|
||
} |
55 changes: 55 additions & 0 deletions
55
...mpass/incubator/internal/trace/server/jersey/rest/core/model/BookmarkQueryParameters.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Ericsson | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License 2.0 which | ||
* accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
/** | ||
* Parameters for bookmark creation and update operations | ||
* | ||
* @author Kaveh Shahedi | ||
* @since 10.1 | ||
*/ | ||
public interface BookmarkQueryParameters { | ||
|
||
/** | ||
* @return The bookmark parameters | ||
*/ | ||
@JsonProperty("parameters") | ||
@Schema(description = "The bookmark parameters", required = true) | ||
BookmarkParameters getParameters(); | ||
|
||
|
||
interface BookmarkParameters { | ||
/** | ||
* @return The bookmark name | ||
*/ | ||
@JsonProperty("name") | ||
@Schema(description = "The name to give this bookmark", required = true) | ||
String getName(); | ||
|
||
/** | ||
* @return The start time | ||
*/ | ||
@JsonProperty("start") | ||
@Schema(description = "The bookmark's start time", required = true) | ||
long getStart(); | ||
|
||
/** | ||
* @return The end time | ||
*/ | ||
@JsonProperty("end") | ||
@Schema(description = "The bookmark's end time", required = true) | ||
long getEnd(); | ||
} | ||
} |
136 changes: 136 additions & 0 deletions
136
...ipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/Bookmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services; | ||
|
||
import java.io.Serializable; | ||
import java.util.UUID; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
/** | ||
* Bookmark model for TSP | ||
* | ||
* @author Kaveh Shahedi | ||
* @since 10.1 | ||
*/ | ||
public class Bookmark implements Serializable { | ||
private static final long serialVersionUID = -3626414315455912960L; | ||
private static final ObjectMapper MAPPER = new ObjectMapper(); | ||
|
||
private final UUID fUUID; | ||
private final String fName; | ||
private final String fExperimentId; | ||
private final long fStart; | ||
private final long fEnd; | ||
private final JsonNode fPayload; | ||
|
||
/** | ||
* {@link JsonCreator} Constructor for final fields | ||
* | ||
* @param uuid | ||
* the stub's UUID | ||
* @param name | ||
* bookmark name | ||
* @param experimentId | ||
* experiment id | ||
* @param start | ||
* start time | ||
* @param end | ||
* end time | ||
* @param payload | ||
* additional JSON data associated with the bookmark (optional) | ||
*/ | ||
@JsonCreator | ||
public Bookmark( | ||
@JsonProperty("UUID") UUID uuid, | ||
@JsonProperty("name") String name, | ||
@JsonProperty("experimentId") String experimentId, | ||
@JsonProperty("start") long start, | ||
@JsonProperty("end") long end, | ||
@JsonProperty(value = "payload", required = false) JsonNode payload) { | ||
fUUID = uuid; | ||
fName = name; | ||
fExperimentId = experimentId; | ||
fStart = start; | ||
fEnd = end; | ||
fPayload = (payload != null) ? payload : MAPPER.createObjectNode(); | ||
} | ||
|
||
/** | ||
* Constructor without payload | ||
* | ||
* @param uuid | ||
* the stub's UUID | ||
* @param name | ||
* bookmark name | ||
* @param experimentId | ||
* experiment id | ||
* @param start | ||
* start time | ||
* @param end | ||
* end time | ||
*/ | ||
public Bookmark(UUID uuid, String name, String experimentId, long start, long end) { | ||
this(uuid, name, experimentId, start, end, MAPPER.createObjectNode()); | ||
} | ||
|
||
/** | ||
* Get the UUID | ||
* | ||
* @return the UUID | ||
*/ | ||
public UUID getUUID() { | ||
return fUUID; | ||
} | ||
|
||
/** | ||
* Get the bookmark name | ||
* | ||
* @return the bookmark name | ||
*/ | ||
public String getName() { | ||
return fName; | ||
} | ||
|
||
/** | ||
* Get the experiment id | ||
* | ||
* @return the experiment id | ||
*/ | ||
public String getExperimentId() { | ||
return fExperimentId; | ||
} | ||
|
||
/** | ||
* Get the start time | ||
* | ||
* @return the start time | ||
*/ | ||
public long getStart() { | ||
return fStart; | ||
} | ||
|
||
/** | ||
* Get the end time | ||
* | ||
* @return the end time | ||
*/ | ||
public long getEnd() { | ||
return fEnd; | ||
} | ||
|
||
/** | ||
* Get the payload | ||
* | ||
* @return the JSON payload, empty JSON object if no payload was set | ||
*/ | ||
public JsonNode getPayload() { | ||
return fPayload; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Bookmark [fUUID=" + fUUID + ", fName=" + fName + ", fExperimentId=" + fExperimentId //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ | ||
+ ", fStart=" + fStart + ", fEnd=" + fEnd + ", fPayload=" + fPayload + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ | ||
} | ||
} |
Oops, something went wrong.