Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: Add bookmarks endpoint support #102

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
kavehshahedi marked this conversation as resolved.
Show resolved Hide resolved

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
/*******************************************************************************
* 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.trace.server.jersey.rest.core.tests.stubs;

import java.io.Serializable;
import java.util.Objects;
import java.util.UUID;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* A Stub class for the bookmark model. It matches the trace server protocol's
* <code>BookmarkModel</code> schema
*
* @author Kaveh Shahedi
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class BookmarkModelStub implements Serializable {
private static final long serialVersionUID = -1945923534635091200L;

private final UUID fUUID;
private final String fName;
private final long fStart;
private final long fEnd;

/**
* {@link JsonCreator} Constructor for final fields
*
* @param uuid
* The bookmark's UUID
* @param name
* The bookmark name
* @param start
* The start time
* @param end
* The end time
*/
@JsonCreator
public BookmarkModelStub(
@JsonProperty("uuid") UUID uuid,
@JsonProperty("name") String name,
@JsonProperty("start") long start,
@JsonProperty("end") long end) {
fUUID = Objects.requireNonNull(uuid, "The 'UUID' json field was not set");
fName = Objects.requireNonNull(name, "The 'name' json field was not set");
fStart = start;
fEnd = end;
}

/**
* Constructor for comparing equality
*
* @param name
* bookmark name
* @param start
* start time
* @param end
* end time
*/
public BookmarkModelStub(String name, long start, long end) {
this(UUID.randomUUID(), name, start, end);
}

/**
* 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 start time
*
* @return The start time
*/
public long getStart() {
return fStart;
}

/**
* Get the end time
*
* @return The end time
*/
public long getEnd() {
return fEnd;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
BookmarkModelStub other = (BookmarkModelStub) obj;
if (fEnd != other.fEnd) {
return false;
}
if (fName == null) {
if (other.fName != null) {
return false;
}
} else if (!fName.equals(other.fName)) {
return false;
}
if (fStart != other.fStart) {
return false;
}
if (fUUID == null) {
if (other.fUUID != null) {
return false;
}
} else if (!fUUID.equals(other.fUUID)) {
return false;
}
return true;
}


@Override
public String toString() {
return "BookmarkModelStub [fUUID=" + fUUID + ", fName=" + fName + ", fStart=" + fStart + ", fEnd=" + fEnd + "]";
}

@Override
public int hashCode() {
return super.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

package org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core.tests.stubs.webapp;

import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.BookmarkManagerService;
import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.ConfigurationManagerService;
import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.ExperimentManagerService;
import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.FilterService;
Expand Down Expand Up @@ -52,5 +53,6 @@ protected void registerResourcesAndMappers(ResourceConfig rc) {
rc.register(CORSFilter.class);
rc.register(JacksonObjectMapperProvider.class);
rc.register(OpenApiResource.class);
rc.register(BookmarkManagerService.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public abstract class RestServerTest {
* Experiments endpoint path (relative to application).
*/
public static final String EXPERIMENTS = "experiments";
/**
* Bookmarks endpoint path (relative to application).
*/
public static final String BOOKMARKS = "bookmarks";

/**
* Outputs path segment
Expand Down
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 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
*/
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 start time.
*/
@Schema(description = "The bookmark's start time")
long getStart();

/**
* @return The end time.
*/
@Schema(description = "The bookmark's end time")
long getEnd();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*******************************************************************************
* 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;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;

/**
* Parameters for bookmark creation and update operations
*
* @author Kaveh Shahedi
*/
public interface BookmarkQueryParameters {
kavehshahedi marked this conversation as resolved.
Show resolved Hide resolved

/**
* @return The bookmark parameters
*/
@JsonProperty("parameters")
@Schema(description = "The bookmark parameters", requiredMode = RequiredMode.REQUIRED)
BookmarkParameters getParameters();


/**
* Bookmark parameters
*/
interface BookmarkParameters {
/**
* @return The bookmark name
*/
@JsonProperty("name")
@Schema(description = "The name to give this bookmark", requiredMode = RequiredMode.REQUIRED)
String getName();

/**
* @return The start time
*/
@JsonProperty("start")
@Schema(description = "The bookmark's start time", requiredMode = RequiredMode.REQUIRED)
long getStart();

/**
* @return The end time
*/
@JsonProperty("end")
@Schema(description = "The bookmark's end time", requiredMode = RequiredMode.REQUIRED)
long getEnd();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*******************************************************************************
* 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.services;
kavehshahedi marked this conversation as resolved.
Show resolved Hide resolved

import java.io.Serializable;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Bookmark model for TSP
*
* @author Kaveh Shahedi
*/
public class Bookmark implements Serializable {

private static final long serialVersionUID = 6126770413230064175L;

private final UUID fUUID;
private final String fName;
private final long fStart;
private final long fEnd;

kavehshahedi marked this conversation as resolved.
Show resolved Hide resolved
/**
* {@link JsonCreator} Constructor for final fields
*
* @param uuid
* the stub's UUID
* @param name
* bookmark name
* @param start
* start time
* @param end
* end time
*/
@JsonCreator
public Bookmark(
@JsonProperty("uuid") UUID uuid,
@JsonProperty("name") String name,
@JsonProperty("start") long start,
@JsonProperty("end") long end) {
fUUID = uuid;
fName = name;
fStart = start;
fEnd = end;
}

/**
* 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 start time
*
* @return the start time
*/
public long getStart() {
return fStart;
}

/**
* Get the end time
*
* @return the end time
*/
public long getEnd() {
return fEnd;
}

@Override
public String toString() {
return "Bookmark [fUUID=" + fUUID + ", fName=" + fName //$NON-NLS-1$ //$NON-NLS-2$
+ ", fStart=" + fStart + ", fEnd=" + fEnd + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
Loading
Loading