Skip to content

Commit

Permalink
API / UI refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
stalep authored and jesperpedersen committed Oct 2, 2023
1 parent 899b12b commit 51eb6dc
Show file tree
Hide file tree
Showing 95 changed files with 827 additions and 340 deletions.
2 changes: 1 addition & 1 deletion horreum-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<inputSpec>${project.build.directory}/generated/openapi.yaml</inputSpec>
<output>${project.basedir}/../webapp/src/generated</output>
<generatorName>typescript-fetch</generatorName>
<skipValidateSpec>true</skipValidateSpec>
<skipValidateSpec>false</skipValidateSpec>
<typeMappings>Array=any</typeMappings>
<globalProperties>
<skipFormModel>false</skipFormModel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@

import jakarta.validation.constraints.NotNull;

import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;

@Schema(name = "ConditionConfig", type = SchemaType.OBJECT)
public class ConditionConfig {
@NotNull
public String name;
Expand Down Expand Up @@ -51,6 +53,7 @@ public class Component {
@NotNull
public String description;
@NotNull
@Schema( type = SchemaType.OBJECT, implementation = ComponentType.class)
public ComponentType type;
@NotNull
public Map<String, Object> properties = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

import java.time.Instant;
import java.util.Collection;
import java.util.Objects;

@Schema(name = "DataSet", type = SchemaType.OBJECT)
public class DataSet {
public Integer id;
@NotNull
Expand All @@ -25,8 +27,10 @@ public class DataSet {
public String owner;
@NotNull
@JsonProperty( required = true )
@Schema( type = SchemaType.INTEGER, implementation = Access.class)
public Access access;
@NotNull
@Schema(implementation = String.class)
public JsonNode data;
@NotNull
public int ordinal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

public class ExperimentComparison {

Expand All @@ -12,6 +13,7 @@ public class ExperimentComparison {
public String model;
@NotNull
@JsonProperty( required = true )
@Schema(implementation = String.class)
public JsonNode config;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

@Schema(name = "Extractor", type = SchemaType.OBJECT)
public class Extractor {
@NotNull
@JsonProperty( required = true )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

import java.io.Serializable;
import java.util.Collection;
Expand All @@ -27,6 +29,7 @@ public class Label {
@JsonProperty( required = true )
public String owner;
@JsonProperty( required = true )
@Schema( type = SchemaType.INTEGER, implementation = Access.class)
public Access access = Access.PUBLIC;
@NotNull
@JsonProperty( value = "schemaId", required = true )
Expand All @@ -38,6 +41,7 @@ public Label() {
public static class Value implements Serializable {
public int datasetId;
public int labelId;
@Schema(implementation = String.class)
public JsonNode value;

public Value() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,26 @@
import java.time.Instant;
import java.util.Collection;

@Schema(name = "Run", type = SchemaType.OBJECT,
description = "Data object that represents a test run entry")
public class Run {
@JsonProperty(required = true)
public Integer id;
@NotNull
@Schema(type = SchemaType.NUMBER, required = true)
@Schema(type = SchemaType.NUMBER, implementation = Instant.class)
public Instant start;
@NotNull
@Schema(type = SchemaType.NUMBER, required = true)
@Schema(type = SchemaType.NUMBER, implementation = Instant.class)
public Instant stop;
public String description;
@NotNull
@JsonProperty(required = true)
public Integer testid;
@NotNull
@Schema(implementation = JsonNode.class, type = SchemaType.STRING)
@JsonProperty(required = true)
public JsonNode data;
@Schema(implementation = JsonNode.class, type = SchemaType.STRING)
public JsonNode metadata;
@NotNull
@JsonProperty(required = true)
Expand All @@ -38,6 +42,7 @@ public class Run {
public String owner;
@NotNull
@JsonProperty(required = true)
@Schema( type = SchemaType.INTEGER, implementation = Access.class)
public Access access;

public Run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,32 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;

import java.util.Collection;

@org.eclipse.microprofile.openapi.annotations.media.Schema(name = "Schema",
description = "Data object that describes the schema definition for a test" )
public class Schema {

@org.eclipse.microprofile.openapi.annotations.media.Schema(required = true)
@JsonProperty(required = true)
public Integer id;
@NotNull
@org.eclipse.microprofile.openapi.annotations.media.Schema(required = true)
@JsonProperty(required = true)
public String uri;
@NotNull
@org.eclipse.microprofile.openapi.annotations.media.Schema(required = true)
@JsonProperty(required = true)
public String name;
public String description;
@org.eclipse.microprofile.openapi.annotations.media.Schema(implementation = String.class)
public JsonNode schema;
@org.eclipse.microprofile.openapi.annotations.media.Schema(required = true)
@JsonProperty(required = true)
public String owner;
@org.eclipse.microprofile.openapi.annotations.media.Schema( type = SchemaType.INTEGER, implementation = Access.class)
public Access access;
public String token;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

import java.util.Collection;
Expand All @@ -20,6 +21,7 @@ public class Test {
public String owner;
@NotNull
@JsonProperty(required = true)
@Schema( type = SchemaType.INTEGER, implementation = Access.class)
public Access access;
public Collection<TestToken> tokens;
@Schema(implementation = String[].class)
Expand All @@ -28,9 +30,6 @@ public class Test {
@Schema(implementation = String[].class)
public JsonNode fingerprintLabels;
public String fingerprintFilter;
@NotNull
@JsonProperty(required = true)
public Collection<View> views;
public String compareUrl;
public Collection<Transformer> transformers;
@NotNull
Expand All @@ -55,7 +54,6 @@ public String toString() {
", timelineFunction='" + timelineFunction + '\'' +
", fingerprintLabels=" + fingerprintLabels +
", fingerprintFilter='" + fingerprintFilter + '\'' +
", views=" + views +
", compareUrl='" + compareUrl + '\'' +
", transformers=" + transformers +
", notificationsEnabled=" + notificationsEnabled +
Expand All @@ -66,7 +64,5 @@ public void clearIds() {
id = null;
if(tokens != null)
tokens.stream().forEach( t -> t.clearId());
if(views != null)
views.stream().forEach( v -> v.clearId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

import java.util.Collection;

@Schema(name = "Transformer", type = SchemaType.OBJECT)
public class Transformer {
@JsonProperty(required = true)
public Integer id;
Expand Down Expand Up @@ -32,6 +35,8 @@ public class Transformer {
public String owner;

@NotNull
@JsonProperty(required = true)
@Schema( type = SchemaType.INTEGER, implementation = Access.class)
public Access access = Access.PUBLIC;

public Transformer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

public class ValidationError {
public int schemaId;
@NotNull
@JsonProperty(required = true)
@Schema(implementation = String.class)
//TODO: stalep, does this really need to be a JsonNode?
public JsonNode error;

public ValidationError() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.hyperfoil.tools.horreum.api.data.ValidationError;
import io.hyperfoil.tools.horreum.api.data.DataSet;
import io.hyperfoil.tools.horreum.api.data.Label;
import org.eclipse.microprofile.openapi.annotations.media.Content;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.parameters.RequestBody;
Expand All @@ -27,13 +28,23 @@
import com.fasterxml.jackson.databind.node.ObjectNode;

import io.hyperfoil.tools.horreum.api.data.Access;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponseSchema;

@Path("/api/dataset")
@Consumes({ MediaType.APPLICATION_JSON})
@Produces(MediaType.APPLICATION_JSON)
public interface DatasetService {
@Path("{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@APIResponse(
responseCode = "404",
description = "No Dataset with the given id was found",
content = @Content(mediaType = "application/json"))
@APIResponseSchema(value = DataSet.class,
responseDescription = "JVM system properties of a particular host.",
responseCode = "200")
DataSet getDataSet(@PathParam("id") int datasetId);

@Path("list/{testId}")
Expand All @@ -46,20 +57,14 @@ DatasetList listByTest(@PathParam("testId") int testId,
@QueryParam("direction") SortDirection direction,
@QueryParam("viewId") Integer viewId);

@Path("{id}/query")
@GET
QueryResult queryData(@PathParam("id") int datasetId,
@Parameter(required = true) @QueryParam("query") String jsonpath,
@QueryParam("array") @DefaultValue("false") boolean array,
@QueryParam("schemaUri") String schemaUri);

@GET
@Path("bySchema")
DatasetList listBySchema(@Parameter(required = true) @QueryParam("uri") String uri,
@QueryParam("limit") Integer limit,
@QueryParam("page") Integer page,
@QueryParam("sort") @DefaultValue("start") String sort,
@QueryParam("direction") @DefaultValue("Descending") SortDirection direction);
@QueryParam("direction") SortDirection direction);

@GET
@Path("{datasetId}/labelValues")
Expand Down Expand Up @@ -93,6 +98,7 @@ class DatasetSummary {
public String owner;
@Schema(required = true, implementation = Access.class)
public int access;
@Schema(implementation = String.class)
public ObjectNode view;
@JsonProperty(required = true)
public List<SchemaService.SchemaUsage> schemas;
Expand All @@ -114,10 +120,12 @@ class LabelValue {
public String name;
@NotNull
public SchemaService.SchemaDescriptor schema;
@Schema(implementation = String.class)
public JsonNode value;
}

class LabelPreview {
@Schema(implementation = String.class)
public JsonNode value;
public String output;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class ExperimentResult {
@JsonDeserialize(keyUsing = ExperimentComparisonDeserializer.class)
public Map<ExperimentComparison, ComparisonResult> results;

@Schema(implementation = String.class)
public JsonNode extraLabels;
public boolean notify;

Expand Down

This file was deleted.

Loading

0 comments on commit 51eb6dc

Please sign in to comment.