diff --git a/horreum-api/pom.xml b/horreum-api/pom.xml index 57ed325a3..50bfa486a 100644 --- a/horreum-api/pom.xml +++ b/horreum-api/pom.xml @@ -84,7 +84,7 @@ org.openapitools openapi-generator-maven-plugin - 6.0.0 + 7.0.1 package diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Change.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Change.java index de550c16a..3ed1d93b1 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Change.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Change.java @@ -4,17 +4,21 @@ import com.fasterxml.jackson.annotation.JsonProperty; import io.hyperfoil.tools.horreum.api.data.DataSet; +import jakarta.validation.constraints.NotNull; import java.time.Instant; public class Change { @JsonProperty( required = true ) public int id; + @NotNull @JsonProperty( required = true ) public Variable variable; @JsonIgnore public DataSet dataset; + @NotNull @JsonProperty( required = true ) public Instant timestamp; + @NotNull @JsonProperty( required = true ) public boolean confirmed; public String description; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/ChangeDetection.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/ChangeDetection.java index 73fa3511d..6f42e2402 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/ChangeDetection.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/ChangeDetection.java @@ -2,12 +2,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import jakarta.validation.constraints.NotNull; public class ChangeDetection { @JsonProperty( required = true ) public Integer id; @JsonProperty( required = true ) public String model; + @NotNull @JsonProperty( required = true ) public JsonNode config; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/DataPoint.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/DataPoint.java index f82bd613c..2bf00acc8 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/DataPoint.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/DataPoint.java @@ -2,15 +2,20 @@ import com.fasterxml.jackson.annotation.JsonProperty; import io.hyperfoil.tools.horreum.api.data.DataSet; +import jakarta.validation.constraints.NotNull; import java.time.Instant; public class DataPoint { public Integer id; + @NotNull public Instant timestamp; + @NotNull public double value; + @NotNull public Variable variable; + @NotNull @JsonProperty("datasetId") public Integer datasetId; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/DatasetLog.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/DatasetLog.java index c78f55dac..57dd76419 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/DatasetLog.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/DatasetLog.java @@ -2,8 +2,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; import io.hyperfoil.tools.horreum.api.data.PersistentLog; +import jakarta.validation.constraints.NotNull; public class DatasetLog extends PersistentLog { + @NotNull @JsonProperty( required = true ) public String source; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/MissingDataRule.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/MissingDataRule.java index 45f974480..2a53849c7 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/MissingDataRule.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/MissingDataRule.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.node.ArrayNode; +import jakarta.validation.constraints.NotNull; import java.time.Instant; import java.util.Objects; @@ -12,6 +13,7 @@ public class MissingDataRule { public String name; public ArrayNode labels; public String condition; + @NotNull @JsonProperty( required = true ) public long maxStaleness; public Instant lastNotification; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/MissingDataRuleResult.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/MissingDataRuleResult.java index 9587df16b..3ff2de695 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/MissingDataRuleResult.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/MissingDataRuleResult.java @@ -1,11 +1,14 @@ package io.hyperfoil.tools.horreum.api.alerting; +import jakarta.validation.constraints.NotNull; + import java.time.Instant; import java.io.Serializable; import java.util.Objects; public class MissingDataRuleResult { private Pk pk; + @NotNull public Instant timestamp; public MissingDataRule rule; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/NotificationSettings.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/NotificationSettings.java index 7256a42ee..e24e11f21 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/NotificationSettings.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/NotificationSettings.java @@ -1,16 +1,20 @@ package io.hyperfoil.tools.horreum.api.alerting; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; public class NotificationSettings { public Integer id; + @NotNull @JsonProperty( required = true ) public String name; @JsonProperty( required = true ) public boolean isTeam; + @NotNull @JsonProperty( required = true ) public String method; public String data; + @NotNull @JsonProperty( required = true ) public boolean disabled; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/RunExpectation.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/RunExpectation.java index 9db5d8fc6..255903f08 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/RunExpectation.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/RunExpectation.java @@ -1,13 +1,16 @@ package io.hyperfoil.tools.horreum.api.alerting; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; import java.time.Instant; public class RunExpectation { public Long id; + @NotNull @JsonProperty(required = true) public int testId; + @NotNull @JsonProperty(required = true) public Instant expectedBefore; public String expectedBy; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Variable.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Variable.java index fe75b2f5b..2fa4f1ed8 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Variable.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Variable.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonInclude; 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; import java.util.Set; @@ -10,13 +11,17 @@ public class Variable { @JsonProperty( required = true ) public Integer id; + @NotNull @JsonProperty(required = true) public int testId; + @NotNull @JsonProperty(required = true) public String name; public String group; + @NotNull @JsonProperty(required = true) public int order; + @NotNull @JsonProperty(required = true) public JsonNode labels; @JsonInclude(JsonInclude.Include.NON_NULL) diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Watch.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Watch.java index 0ef8468bf..378b52f7d 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Watch.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/alerting/Watch.java @@ -1,15 +1,19 @@ package io.hyperfoil.tools.horreum.api.alerting; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; import java.util.List; public class Watch { public Integer id; + @NotNull @JsonProperty( required = true ) public List users; + @NotNull @JsonProperty( required = true ) public List optout; + @NotNull @JsonProperty( required = true ) public List teams; @JsonProperty( value = "testId", required = true ) diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Action.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Action.java index fa2d213b6..572054ff1 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Action.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Action.java @@ -5,22 +5,30 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; +import jakarta.validation.constraints.NotNull; public class Action { @JsonProperty( required = true ) public Integer id; + @NotNull @JsonProperty( required = true ) public String event; + @NotNull @JsonProperty( required = true ) public String type; + @NotNull @JsonProperty( required = true ) public JsonNode config; + @NotNull @JsonIgnore public JsonNode secrets; + @NotNull @JsonProperty( required = true ) public Integer testId; + @NotNull @JsonProperty( required = true ) public boolean active = true; + @NotNull @JsonProperty( required = true ) public boolean runAlways; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ActionLog.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ActionLog.java index ab79af6ac..48ec31204 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ActionLog.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ActionLog.java @@ -1,10 +1,13 @@ package io.hyperfoil.tools.horreum.api.data; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; public class ActionLog extends PersistentLog { + @NotNull @JsonProperty( required = true ) public int testId; + @NotNull @JsonProperty( required = true ) public String event; public String type; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/AllowedSite.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/AllowedSite.java index 486447236..71d6f69bf 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/AllowedSite.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/AllowedSite.java @@ -1,10 +1,12 @@ package io.hyperfoil.tools.horreum.api.data; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; public class AllowedSite { public Long id; + @NotNull @JsonProperty(required = true) public String prefix; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Banner.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Banner.java index 1252e4bbf..de1871078 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Banner.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Banner.java @@ -1,6 +1,8 @@ package io.hyperfoil.tools.horreum.api.data; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; + import java.time.Instant; public class Banner { @@ -9,11 +11,14 @@ public class Banner { public Instant created; + @NotNull @JsonProperty( required = true ) public boolean active; + @NotNull @JsonProperty(required = true) public String severity; + @NotNull @JsonProperty(required = true) public String title; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/DataSet.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/DataSet.java index 3a3845c6c..81296d5b3 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/DataSet.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/DataSet.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; 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; import java.time.Instant; @@ -11,16 +12,23 @@ public class DataSet { public Integer id; + @NotNull public Instant start; + @NotNull public Instant stop; public String description; + @NotNull public Integer testid; + @NotNull @JsonProperty( required = true ) public String owner; + @NotNull @JsonProperty( required = true ) public Access access; + @NotNull public JsonNode data; + @NotNull public int ordinal; public Collection validationErrors; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ExperimentComparison.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ExperimentComparison.java index 129f8b319..0013357cd 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ExperimentComparison.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ExperimentComparison.java @@ -3,14 +3,18 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import jakarta.validation.constraints.NotNull; public class ExperimentComparison { + @NotNull @JsonProperty( required = true ) public String model; + @NotNull @JsonProperty( required = true ) public JsonNode config; + @NotNull @JsonProperty(value = "variableId") public Integer variableId; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ExperimentProfile.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ExperimentProfile.java index ccd19afde..0ec207ff7 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ExperimentProfile.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ExperimentProfile.java @@ -2,6 +2,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; import java.util.Collection; @@ -9,8 +10,12 @@ public class ExperimentProfile { @JsonProperty(required = true ) public Integer id; + @NotNull public String name; + //@NotNull - we can not enforce this check until we have clean workflows in the UI + // atm it is possible to have a new test in the UI and create an experiment profile + // before the test is saved, therefore the test might not have an ID public Integer testId; @Schema(implementation = String[].class, required = true ) public JsonNode selectorLabels; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Extractor.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Extractor.java index 85aa2623d..1e88ffe1b 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Extractor.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Extractor.java @@ -1,12 +1,16 @@ package io.hyperfoil.tools.horreum.api.data; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; public class Extractor { + @NotNull @JsonProperty( required = true ) public String name; + @NotNull @JsonProperty( required = true ) public String jsonpath; + @NotNull @JsonProperty(required = true) public boolean array; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Label.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Label.java index 9597efdfb..89bdd09e3 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Label.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Label.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import jakarta.validation.constraints.NotNull; import java.io.Serializable; import java.util.Collection; @@ -10,26 +11,30 @@ public class Label { @JsonProperty( required = true ) public Integer id; + @NotNull @JsonProperty( required = true ) public String name; + @NotNull @JsonProperty( required = true ) public Collection extractors; public String function; + @NotNull @JsonProperty( required = true ) public boolean filtering = true; + @NotNull @JsonProperty( required = true ) public boolean metrics = true; @JsonProperty( required = true ) public String owner; @JsonProperty( required = true ) public Access access = Access.PUBLIC; + @NotNull + @JsonProperty( value = "schemaId", required = true ) + public int schemaId; public Label() { } - @JsonProperty( value = "schemaId", required = true ) - public int schemaId; - public static class Value implements Serializable { public int datasetId; public int labelId; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/PersistentLog.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/PersistentLog.java index 492ce057e..efb1724be 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/PersistentLog.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/PersistentLog.java @@ -1,5 +1,6 @@ package io.hyperfoil.tools.horreum.api.data; +import jakarta.validation.constraints.NotNull; import org.jboss.logging.Logger; import com.fasterxml.jackson.annotation.JsonProperty; @@ -15,12 +16,15 @@ public abstract class PersistentLog { @JsonProperty(required = true) public Long id; + @NotNull @JsonProperty(required = true) public int level; + @NotNull @JsonProperty(required = true) public Instant timestamp; + @NotNull @JsonProperty(required = true) public String message; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Run.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Run.java index 3bbb66551..c06aa3606 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Run.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Run.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; 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; @@ -12,23 +13,30 @@ public class Run { @JsonProperty(required = true) public Integer id; + @NotNull @Schema(type = SchemaType.NUMBER, required = true) public Instant start; + @NotNull @Schema(type = SchemaType.NUMBER, required = true) public Instant stop; public String description; + @NotNull @JsonProperty(required = true) public Integer testid; + @NotNull @JsonProperty(required = true) public JsonNode data; public JsonNode metadata; + @NotNull @JsonProperty(required = true) public boolean trashed; @JsonIgnore public Collection datasets; public Collection validationErrors; + @NotNull @JsonProperty(required = true) public String owner; + @NotNull @JsonProperty(required = true) public Access access; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Schema.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Schema.java index ec82b7290..271a84e95 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Schema.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Schema.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import jakarta.validation.constraints.NotNull; import java.util.Collection; @@ -9,8 +10,10 @@ public class Schema { @JsonProperty(required = true) public Integer id; + @NotNull @JsonProperty(required = true) public String uri; + @NotNull @JsonProperty(required = true) public String name; public String description; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Test.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Test.java index 51653d8ca..77d53d430 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Test.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Test.java @@ -2,6 +2,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; import java.util.Collection; @@ -9,12 +10,15 @@ public class Test { @JsonProperty(required = true) public Integer id; + @NotNull @JsonProperty(required = true) public String name; public String folder; public String description; + @NotNull @JsonProperty(required = true) public String owner; + @NotNull @JsonProperty(required = true) public Access access; public Collection tokens; @@ -24,10 +28,12 @@ public class Test { @Schema(implementation = String[].class) public JsonNode fingerprintLabels; public String fingerprintFilter; + @NotNull @JsonProperty(required = true) public Collection views; public String compareUrl; public Collection transformers; + @NotNull @JsonProperty(required = true) public Boolean notificationsEnabled; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/TestToken.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/TestToken.java index 92cc10cad..e8da72c26 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/TestToken.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/TestToken.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonSetter; +import jakarta.validation.constraints.NotNull; import java.util.function.Function; @@ -13,10 +14,13 @@ public class TestToken { @JsonProperty(required = true) public Integer id; public Integer testId; + @NotNull @JsonProperty(required = true) private String value; + @NotNull @JsonProperty(required = true) public int permissions; + @NotNull @JsonProperty(required = true) public String description; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Transformer.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Transformer.java index 7437557d8..0144dbd69 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Transformer.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/Transformer.java @@ -1,19 +1,23 @@ package io.hyperfoil.tools.horreum.api.data; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; import java.util.Collection; public class Transformer { @JsonProperty(required = true) public Integer id; + @NotNull @JsonProperty(required = true) public String name; public String description; public String targetSchemaUri; + @NotNull @JsonProperty(required = true) public Collection extractors; public String function; + @NotNull @JsonProperty(value = "schemaId", required = true) public Integer schemaId; @@ -23,9 +27,11 @@ public class Transformer { @JsonProperty(value = "schemaName", required = true) public String schemaName; + @NotNull @JsonProperty(required = true) public String owner; + @NotNull public Access access = Access.PUBLIC; public Transformer() { diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ValidationError.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ValidationError.java index a7a9d3c38..7493f4309 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ValidationError.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ValidationError.java @@ -2,9 +2,11 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; +import jakarta.validation.constraints.NotNull; public class ValidationError { public int schemaId; + @NotNull @JsonProperty(required = true) public JsonNode error; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/View.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/View.java index 05379fbee..85155ed14 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/View.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/View.java @@ -1,15 +1,21 @@ package io.hyperfoil.tools.horreum.api.data; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; import java.util.List; public class View { @JsonProperty(required = true) public Integer id; + @NotNull @JsonProperty(required = true) public String name; + //@NotNull - we can not enforce this check until we have clean workflows in the UI + // atm it is possible to have a new test in the UI and create an experiment profile + // before the test is saved, therefore the test might not have an ID public Integer testId; + @NotNull @JsonProperty(required = true) public List components; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ViewComponent.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ViewComponent.java index 95d736a6b..2bf11d47e 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ViewComponent.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/data/ViewComponent.java @@ -5,16 +5,20 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import jakarta.validation.constraints.NotNull; import java.util.Objects; public class ViewComponent { @JsonProperty(required = true) public Integer id; + @NotNull @JsonProperty(required = true) public int headerOrder; + @NotNull @JsonProperty(required = true) public String headerName; + @NotNull @JsonProperty(required = true) public JsonNode labels; @JsonInclude(JsonInclude.Include.NON_NULL) diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/ReportComment.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/ReportComment.java index b4d6f9175..789184ba6 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/ReportComment.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/ReportComment.java @@ -1,13 +1,16 @@ package io.hyperfoil.tools.horreum.api.report; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; public class ReportComment { public Integer id; + @NotNull @JsonProperty( required = true ) public int level; public String category; public int componentId; + @NotNull @JsonProperty( required = true ) public String comment; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/ReportComponent.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/ReportComponent.java index 1bb23e7dc..1405cde3b 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/ReportComponent.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/ReportComponent.java @@ -2,13 +2,17 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.node.ArrayNode; +import jakarta.validation.constraints.NotNull; public class ReportComponent { public Integer id; + @NotNull @JsonProperty( required = true ) public String name; + @NotNull @JsonProperty( required = true ) public int order; + @NotNull @JsonProperty( required = true ) public ArrayNode labels; public String function; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/TableReport.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/TableReport.java index 392d2f0ca..33497e8bc 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/TableReport.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/TableReport.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.node.ArrayNode; +import jakarta.validation.constraints.NotNull; import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; import org.eclipse.microprofile.openapi.annotations.media.Schema; @@ -11,14 +12,19 @@ public class TableReport { @JsonProperty(required = true) public Integer id; + @NotNull @JsonProperty(required = true) public TableReportConfig config; + @NotNull @Schema(required = true, type = SchemaType.NUMBER) public Instant created; + @NotNull @JsonProperty(required = true) public Collection comments; + @NotNull @JsonProperty(required = true) public Collection data; + @NotNull @JsonProperty(required = true) public Collection logs; @@ -39,18 +45,25 @@ public String toString() { @Schema(name = "TableReportData") public static class DataDTO { + @NotNull @JsonProperty(required = true) public int datasetId; + @NotNull @JsonProperty(required = true) public int runId; + @NotNull @JsonProperty(required = true) public int ordinal; + @NotNull @JsonProperty(required = true) public String category; + @NotNull @JsonProperty(required = true) public String series; + @NotNull @JsonProperty(required = true) public String scale; + @NotNull @JsonProperty(required = true) public ArrayNode values; diff --git a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/TableReportConfig.java b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/TableReportConfig.java index 02461af8d..82caf51d9 100644 --- a/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/TableReportConfig.java +++ b/horreum-api/src/main/java/io/hyperfoil/tools/horreum/api/report/TableReportConfig.java @@ -3,12 +3,14 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.node.ArrayNode; import io.hyperfoil.tools.horreum.api.data.Test; +import jakarta.validation.constraints.NotNull; import java.util.List; public class TableReportConfig { @JsonProperty(required = true) public Integer id; + @NotNull @JsonProperty(required = true) public String title; public Test test; @@ -17,6 +19,7 @@ public class TableReportConfig { public ArrayNode categoryLabels; public String categoryFunction; public String categoryFormatter; + @NotNull @JsonProperty(required = true) public ArrayNode seriesLabels; public String seriesFunction; @@ -25,6 +28,7 @@ public class TableReportConfig { public String scaleFunction; public String scaleFormatter; public String scaleDescription; + @NotNull @JsonProperty(required = true) public List components; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ActionLogDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ActionLogDAO.java index fe79cde07..3087b3ae0 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ActionLogDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ActionLogDAO.java @@ -4,7 +4,7 @@ import jakarta.validation.constraints.NotNull; @Entity(name = "ActionLog") -public class ActionLogDAO extends PersistentLog { +public class ActionLogDAO extends PersistentLogDAO { @NotNull public int testId; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentComparison.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentComparisonDAO.java similarity index 96% rename from horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentComparison.java rename to horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentComparisonDAO.java index d79a3882c..153998f97 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentComparison.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentComparisonDAO.java @@ -14,7 +14,7 @@ import org.hibernate.annotations.Type; @Embeddable -public class ExperimentComparison { +public class ExperimentComparisonDAO { @NotNull @ManyToOne(optional = false, fetch = FetchType.LAZY) @JoinColumn(name = "variable_id") diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentProfileDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentProfileDAO.java index a1a47684e..cc8727958 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentProfileDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ExperimentProfileDAO.java @@ -67,7 +67,7 @@ public class ExperimentProfileDAO extends PanacheEntityBase { @ElementCollection(fetch = FetchType.EAGER) @CollectionTable(name="experiment_comparisons", joinColumns=@JoinColumn(name="profile_id")) @OrderBy("variable_id, model") - public Collection comparisons; + public Collection comparisons; /* These labels are not used in Horreum but are added to the result event */ @Column(name = "extra_labels", columnDefinition = "jsonb") diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/PersistentLog.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/PersistentLogDAO.java similarity index 90% rename from horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/PersistentLog.java rename to horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/PersistentLogDAO.java index e138ad4e3..78659925d 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/PersistentLog.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/PersistentLogDAO.java @@ -13,7 +13,7 @@ import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @MappedSuperclass -public abstract class PersistentLog extends PanacheEntityBase { +public abstract class PersistentLogDAO extends PanacheEntityBase { public static final int DEBUG = 0; public static final int INFO = 1; public static final int WARN = 2; @@ -33,7 +33,7 @@ public abstract class PersistentLog extends PanacheEntityBase { @NotNull public String message; - public PersistentLog(int level, String message) { + public PersistentLogDAO(int level, String message) { this.level = level; this.message = message; this.timestamp = Instant.now(); diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DataPointDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DataPointDAO.java index cea46a57f..9a64f6a89 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DataPointDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DataPointDAO.java @@ -28,6 +28,7 @@ public class DataPointDAO extends PanacheEntityBase { @Column(columnDefinition = "SERIAL") public Integer id; + @NotNull @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "dataset_id") public DataSetDAO dataset; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DatasetLogDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DatasetLogDAO.java index 9e6eae44f..81cb45454 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DatasetLogDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/DatasetLogDAO.java @@ -8,7 +8,7 @@ import jakarta.persistence.ManyToOne; import jakarta.validation.constraints.NotNull; -import io.hyperfoil.tools.horreum.entity.PersistentLog; +import io.hyperfoil.tools.horreum.entity.PersistentLogDAO; import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; import io.hyperfoil.tools.horreum.entity.data.RunDAO; import io.hyperfoil.tools.horreum.entity.data.TestDAO; @@ -18,7 +18,7 @@ * as opposed to events related directly to {@link RunDAO runs}. */ @Entity(name = "DatasetLog") -public class DatasetLogDAO extends PersistentLog { +public class DatasetLogDAO extends PersistentLogDAO { @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "testid", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/TransformationLogDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/TransformationLogDAO.java index 14736b8f6..96a044165 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/TransformationLogDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/TransformationLogDAO.java @@ -8,12 +8,12 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; -import io.hyperfoil.tools.horreum.entity.PersistentLog; +import io.hyperfoil.tools.horreum.entity.PersistentLogDAO; import io.hyperfoil.tools.horreum.entity.data.RunDAO; import io.hyperfoil.tools.horreum.entity.data.TestDAO; @Entity(name = "TransformationLog") -public class TransformationLogDAO extends PersistentLog { +public class TransformationLogDAO extends PersistentLogDAO { @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "testid", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/Extractor.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ExtractorDAO.java similarity index 77% rename from horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/Extractor.java rename to horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ExtractorDAO.java index eb7f9ca50..514f5f9ea 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/Extractor.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ExtractorDAO.java @@ -5,7 +5,7 @@ import jakarta.validation.constraints.NotNull; @Embeddable -public class Extractor { +public class ExtractorDAO { @NotNull public String name; @@ -16,10 +16,10 @@ public class Extractor { @Column(name = "isarray") public boolean array; - public Extractor() { + public ExtractorDAO() { } - public Extractor(String name, String jsonpath, boolean array) { + public ExtractorDAO(String name, String jsonpath, boolean array) { this.name = name; this.jsonpath = jsonpath; this.array = array; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/LabelDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/LabelDAO.java index 5e6eb00c6..dc0d18b43 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/LabelDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/LabelDAO.java @@ -51,7 +51,7 @@ public class LabelDAO extends OwnedEntityBase { @NotNull @ElementCollection(fetch = FetchType.EAGER) @CollectionTable(name = "label_extractors") - public Collection extractors; + public Collection extractors; public String function; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TransformerDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TransformerDAO.java index 38de85762..2b9b11852 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TransformerDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TransformerDAO.java @@ -50,7 +50,7 @@ public class TransformerDAO extends OwnedEntityBase implements Comparable extractors; + public Collection extractors; public String function; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportLogDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportLogDAO.java index 604e075eb..00bbbc528 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportLogDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportLogDAO.java @@ -4,10 +4,10 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; -import io.hyperfoil.tools.horreum.entity.PersistentLog; +import io.hyperfoil.tools.horreum.entity.PersistentLogDAO; @Entity(name = "ReportLog") -public class ReportLogDAO extends PersistentLog { +public class ReportLogDAO extends PersistentLogDAO { @ManyToOne(optional = false) @JoinColumn(name = "report_id") TableReportDAO report; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ExperimentProfileMapper.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ExperimentProfileMapper.java index d2916c861..0a1960fdc 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ExperimentProfileMapper.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ExperimentProfileMapper.java @@ -1,6 +1,7 @@ package io.hyperfoil.tools.horreum.mapper; import io.hyperfoil.tools.horreum.api.data.ExperimentComparison; +import io.hyperfoil.tools.horreum.entity.ExperimentComparisonDAO; import io.hyperfoil.tools.horreum.entity.ExperimentProfileDAO; import io.hyperfoil.tools.horreum.api.data.ExperimentProfile; @@ -24,7 +25,7 @@ public static ExperimentProfile from(ExperimentProfileDAO ep) { return dto; } - public static ExperimentComparison fromExperimentComparison(io.hyperfoil.tools.horreum.entity.ExperimentComparison ec) { + public static ExperimentComparison fromExperimentComparison(ExperimentComparisonDAO ec) { ExperimentComparison dto = new ExperimentComparison(); dto.variableId = ec.getVariableId(); dto.variableName = ec.variable.name; @@ -49,8 +50,8 @@ public static ExperimentProfileDAO to(ExperimentProfile dto) { return ep; } - public static io.hyperfoil.tools.horreum.entity.ExperimentComparison toExperimentComparison(ExperimentComparison dto) { - io.hyperfoil.tools.horreum.entity.ExperimentComparison ec = new io.hyperfoil.tools.horreum.entity.ExperimentComparison(); + public static ExperimentComparisonDAO toExperimentComparison(ExperimentComparison dto) { + ExperimentComparisonDAO ec = new ExperimentComparisonDAO(); ec.config = dto.config; ec.model = dto.model; if(dto.variableId != null && dto.variableId > 0) diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ExtractorMapper.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ExtractorMapper.java index 4b1733c33..06ebdea4a 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ExtractorMapper.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ExtractorMapper.java @@ -1,10 +1,11 @@ package io.hyperfoil.tools.horreum.mapper; import io.hyperfoil.tools.horreum.api.data.Extractor; +import io.hyperfoil.tools.horreum.entity.data.ExtractorDAO; public class ExtractorMapper { - public static Extractor from(io.hyperfoil.tools.horreum.entity.data.Extractor e) { + public static Extractor from(ExtractorDAO e) { Extractor dto = new Extractor(); dto.name = e.name; dto.array = e.array; @@ -13,8 +14,8 @@ public static Extractor from(io.hyperfoil.tools.horreum.entity.data.Extractor e) return dto; } - public static io.hyperfoil.tools.horreum.entity.data.Extractor to(Extractor dto) { - io.hyperfoil.tools.horreum.entity.data.Extractor e = new io.hyperfoil.tools.horreum.entity.data.Extractor(); + public static ExtractorDAO to(Extractor dto) { + ExtractorDAO e = new ExtractorDAO(); e.name = dto.name; e.array = dto.array; e.jsonpath = dto.jsonpath; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ActionServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ActionServiceImpl.java index 55c5e212b..983634fd4 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ActionServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ActionServiceImpl.java @@ -5,7 +5,6 @@ import io.hyperfoil.tools.horreum.api.data.Run; import io.hyperfoil.tools.horreum.api.data.Test; import io.hyperfoil.tools.horreum.bus.MessageBusChannels; -import io.hyperfoil.tools.horreum.entity.alerting.ChangeDAO; import io.hyperfoil.tools.horreum.api.alerting.Change; import io.hyperfoil.tools.horreum.entity.data.*; import io.hyperfoil.tools.horreum.mapper.ActionMapper; @@ -15,7 +14,7 @@ import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.bus.MessageBus; import io.hyperfoil.tools.horreum.entity.ActionLogDAO; -import io.hyperfoil.tools.horreum.entity.PersistentLog; +import io.hyperfoil.tools.horreum.entity.PersistentLogDAO; import io.hyperfoil.tools.horreum.action.ActionPlugin; import io.hyperfoil.tools.horreum.server.EncryptionManager; import io.hyperfoil.tools.horreum.server.WithRoles; @@ -85,7 +84,7 @@ public void postConstruct(){ private void executeActions(MessageBusChannels event, int testId, Object payload, boolean notify){ List actions = getActions(event.name(), testId); if (actions.isEmpty()) { - new ActionLogDAO(PersistentLog.DEBUG, testId, event.name(), null, "No actions found.").persist(); + new ActionLogDAO(PersistentLogDAO.DEBUG, testId, event.name(), null, "No actions found.").persist(); return; } for (ActionDAO action : actions) { @@ -97,15 +96,15 @@ private void executeActions(MessageBusChannels event, int testId, Object payload ActionPlugin plugin = plugins.get(action.type); if (plugin == null) { log.errorf("No plugin for action type %s", action.type); - new ActionLogDAO(PersistentLog.ERROR, testId, event.name(), action.type, "No plugin for action type " + action.type).persist(); + new ActionLogDAO(PersistentLogDAO.ERROR, testId, event.name(), action.type, "No plugin for action type " + action.type).persist(); continue; } plugin.execute(action.config, action.secrets, payload).subscribe() .with(item -> {}, throwable -> logActionError(testId, event.name(), action.type, throwable)); } catch (Exception e) { log.errorf(e, "Failed to invoke action %d", action.id); - new ActionLogDAO(PersistentLog.ERROR, testId, event.name(), action.type, "Failed to invoke: " + e.getMessage()).persist(); - new ActionLogDAO(PersistentLog.DEBUG, testId, event.name(), action.type, + new ActionLogDAO(PersistentLogDAO.ERROR, testId, event.name(), action.type, "Failed to invoke: " + e.getMessage()).persist(); + new ActionLogDAO(PersistentLogDAO.DEBUG, testId, event.name(), action.type, "Configuration:
\n" + action.config.toPrettyString() +
                   "\n
Payload:
\n" + Util.OBJECT_MAPPER.valueToTree(payload).toPrettyString() +
                   "\n
").persist(); @@ -128,7 +127,7 @@ void logActionError(int testId, String event, String type, Throwable throwable) @WithRoles(extras = Roles.HORREUM_SYSTEM) @Transactional(Transactional.TxType.REQUIRES_NEW) void doLogActionError(int testId, String event, String type, Throwable throwable) { - new ActionLogDAO(PersistentLog.ERROR, testId, event, type, throwable.getMessage()).persist(); + new ActionLogDAO(PersistentLogDAO.ERROR, testId, event, type, throwable.getMessage()).persist(); } @WithRoles(extras = Roles.HORREUM_SYSTEM) diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/AlertingServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/AlertingServiceImpl.java index 3764ddd04..5fd3bbc7e 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/AlertingServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/AlertingServiceImpl.java @@ -52,7 +52,7 @@ import io.hyperfoil.tools.horreum.bus.MessageBus; import io.hyperfoil.tools.horreum.changedetection.FixedThresholdModel; import io.hyperfoil.tools.horreum.entity.FingerprintDAO; -import io.hyperfoil.tools.horreum.entity.PersistentLog; +import io.hyperfoil.tools.horreum.entity.PersistentLogDAO; import io.hyperfoil.tools.horreum.entity.alerting.*; import io.hyperfoil.tools.horreum.changedetection.ChangeDetectionModel; import io.hyperfoil.tools.horreum.changedetection.RelativeDifferenceChangeDetectionModel; @@ -254,14 +254,14 @@ private void recalculateMissingDataRules(DataSetDAO dataset) { createMissingDataRuleResult(dataset, ruleId); } } else { - logMissingDataMessage(dataset, PersistentLog.ERROR, + logMissingDataMessage(dataset, PersistentLogDAO.ERROR, "Result for missing data rule %d, dataset %d is not a boolean: %s", ruleId, dataset.id, result); } }, // Absence of condition means that this dataset is taken into account. This happens e.g. when value == NULL row -> createMissingDataRuleResult(dataset, (int) row[0]), - (row, exception, code) -> logMissingDataMessage(dataset, PersistentLog.ERROR, "Exception evaluating missing data rule %d, dataset %d: '%s' Code:
%s
", row[0], dataset.id, exception.getMessage(), code), - output -> logMissingDataMessage(dataset, PersistentLog.DEBUG, "Output while evaluating missing data rules for dataset %d: '%s'", dataset.id, output)); + (row, exception, code) -> logMissingDataMessage(dataset, PersistentLogDAO.ERROR, "Exception evaluating missing data rule %d, dataset %d: '%s' Code:
%s
", row[0], dataset.id, exception.getMessage(), code), + output -> logMissingDataMessage(dataset, PersistentLogDAO.DEBUG, "Output while evaluating missing data rules for dataset %d: '%s'", dataset.id, output)); } private void createMissingDataRuleResult(DataSetDAO dataset, int ruleId) { @@ -312,13 +312,13 @@ private boolean testFingerprint(DataSetDAO dataset, String filter) { } boolean testResult = Util.evaluateTest(filter, fingerprint, value -> { - logCalculationMessage(dataset, PersistentLog.ERROR, "Evaluation of fingerprint failed: '%s' is not a boolean", value); + logCalculationMessage(dataset, PersistentLogDAO.ERROR, "Evaluation of fingerprint failed: '%s' is not a boolean", value); return false; }, - (code, e) -> logCalculationMessage(dataset, PersistentLog.ERROR, "Evaluation of fingerprint filter failed: '%s' Code:
%s
", e.getMessage(), code), - output -> logCalculationMessage(dataset, PersistentLog.DEBUG, "Output while evaluating fingerprint filter:
%s
", output)); + (code, e) -> logCalculationMessage(dataset, PersistentLogDAO.ERROR, "Evaluation of fingerprint filter failed: '%s' Code:
%s
", e.getMessage(), code), + output -> logCalculationMessage(dataset, PersistentLogDAO.DEBUG, "Output while evaluating fingerprint filter:
%s
", output)); if (!testResult) { - logCalculationMessage(dataset, PersistentLog.DEBUG, "Fingerprint %s was filtered out.", fingerprint); + logCalculationMessage(dataset, PersistentLogDAO.DEBUG, "Fingerprint %s was filtered out.", fingerprint); } return testResult; } @@ -410,7 +410,7 @@ private void emitDatapoints(DataSetDAO dataset, boolean notify, boolean debug, R .getResultList(); if (debug) { for (VariableData data : values) { - logCalculationMessage(dataset, PersistentLog.DEBUG, "Fetched value for variable %s:
%s
", data.fullName(), data.value); + logCalculationMessage(dataset, PersistentLogDAO.DEBUG, "Fetched value for variable %s:
%s
", data.fullName(), data.value); } } @SuppressWarnings("unchecked") List timestampList = em.createNativeQuery(LOOKUP_TIMESTAMP) @@ -426,12 +426,12 @@ private void emitDatapoints(DataSetDAO dataset, boolean notify, boolean debug, R JsonNode value = (JsonNode) timestampList.get(0)[1]; if (timestampFunction != null && !timestampFunction.isBlank()) { value = Util.evaluateOnce(timestampFunction, value, Util::convertToJson, - (code, throwable) -> logCalculationMessage(dataset, PersistentLog.ERROR, "Evaluation of timestamp failed: '%s' Code:
%s
", throwable.getMessage(), code), - output -> logCalculationMessage(dataset, PersistentLog.DEBUG, "Output while calculating timestamp:
%s
", output)); + (code, throwable) -> logCalculationMessage(dataset, PersistentLogDAO.ERROR, "Evaluation of timestamp failed: '%s' Code:
%s
", throwable.getMessage(), code), + output -> logCalculationMessage(dataset, PersistentLogDAO.DEBUG, "Output while calculating timestamp:
%s
", output)); } timestamp = Util.toInstant(value); if (timestamp == null) { - logCalculationMessage(dataset, PersistentLog.ERROR, "Cannot parse timestamp, must be number or ISO-8601 timestamp: %s", value); + logCalculationMessage(dataset, PersistentLogDAO.ERROR, "Cannot parse timestamp, must be number or ISO-8601 timestamp: %s", value); timestamp = dataset.start; } } @@ -439,8 +439,8 @@ private void emitDatapoints(DataSetDAO dataset, boolean notify, boolean debug, R Util.evaluateMany(values, data -> data.calculation, data -> data.value, (data, result) -> { Double value = Util.toDoubleOrNull(result, - error -> logCalculationMessage(dataset, PersistentLog.ERROR, "Evaluation of variable %s failed: %s", data.fullName(), error), - info -> logCalculationMessage(dataset, PersistentLog.INFO, "Evaluation of variable %s: %s", data.fullName(), info)); + error -> logCalculationMessage(dataset, PersistentLogDAO.ERROR, "Evaluation of variable %s failed: %s", data.fullName(), error), + info -> logCalculationMessage(dataset, PersistentLogDAO.INFO, "Evaluation of variable %s: %s", data.fullName(), info)); if (value != null) { createDataPoint(dataset, finalTimestamp, data.variableId, value, notify); } else { @@ -452,10 +452,10 @@ private void emitDatapoints(DataSetDAO dataset, boolean notify, boolean debug, R }, data -> { if (data.numLabels > 1) { - logCalculationMessage(dataset, PersistentLog.WARN, "Variable %s has more than one label (%s) but no calculation function.", data.fullName(), data.value.fieldNames()); + logCalculationMessage(dataset, PersistentLogDAO.WARN, "Variable %s has more than one label (%s) but no calculation function.", data.fullName(), data.value.fieldNames()); } if (data.value == null || data.value.isNull()) { - logCalculationMessage(dataset, PersistentLog.INFO, "Null value for variable %s - datapoint is not created", data.fullName()); + logCalculationMessage(dataset, PersistentLogDAO.INFO, "Null value for variable %s - datapoint is not created", data.fullName()); if (recalculation != null) { recalculation.datasetsWithoutValue.put(dataset.id, dataset.getInfo()); } @@ -474,7 +474,7 @@ private void emitDatapoints(DataSetDAO dataset, boolean notify, boolean debug, R } } if (value == null) { - logCalculationMessage(dataset, PersistentLog.ERROR, "Cannot turn %s into a floating-point value for variable %s", data.value, data.fullName()); + logCalculationMessage(dataset, PersistentLogDAO.ERROR, "Cannot turn %s into a floating-point value for variable %s", data.value, data.fullName()); if (recalculation != null) { recalculation.errors++; } @@ -483,8 +483,8 @@ private void emitDatapoints(DataSetDAO dataset, boolean notify, boolean debug, R createDataPoint(dataset, finalTimestamp, data.variableId, value, notify); } }, - (data, exception, code) -> logCalculationMessage(dataset, PersistentLog.ERROR, "Evaluation of variable %s failed: '%s' Code:
%s
", data.fullName(), exception.getMessage(), code), - output -> logCalculationMessage(dataset, PersistentLog.DEBUG, "Output while calculating variable:
%s
", output) + (data, exception, code) -> logCalculationMessage(dataset, PersistentLogDAO.ERROR, "Evaluation of variable %s failed: '%s' Code:
%s
", data.fullName(), exception.getMessage(), code), + output -> logCalculationMessage(dataset, PersistentLogDAO.DEBUG, "Output while calculating variable:
%s
", output) ); if (!missingValueVariables.isEmpty()) { messageBus.publish(MessageBusChannels.DATASET_MISSING_VALUES, dataset.testid, new MissingValuesEvent(dataset.getInfo(), missingValueVariables, notify)); @@ -509,7 +509,7 @@ private void logCalculationMessage(DataSetDAO dataSet, int level, String format, private void logCalculationMessage(int testId, int datasetId, int level, String format, Object... args) { String msg = args.length == 0 ? format : String.format(format, args); - log.tracef("Logging %s for test %d, dataset %d: %s", PersistentLog.logLevel(level), testId, datasetId, msg); + log.tracef("Logging %s for test %d, dataset %d: %s", PersistentLogDAO.logLevel(level), testId, datasetId, msg); new DatasetLogDAO(em.getReference(TestDAO.class, testId), em.getReference(DataSetDAO.class, datasetId), level, "variables", msg).persist(); } @@ -520,14 +520,14 @@ private void logMissingDataMessage(DataSetDAO dataSet, int level, String format, private void logMissingDataMessage(int testId, int datasetId, int level, String format, Object... args) { String msg = args.length == 0 ? format : String.format(format, args); - log.tracef("Logging %s for test %d, dataset %d: %s", PersistentLog.logLevel(level), testId, datasetId, msg); + log.tracef("Logging %s for test %d, dataset %d: %s", PersistentLogDAO.logLevel(level), testId, datasetId, msg); new DatasetLogDAO(em.getReference(TestDAO.class, testId), em.getReference(DataSetDAO.class, datasetId), level, "missingdata", msg).persist(); } private void logChangeDetectionMessage(int testId, int datasetId, int level, String format, Object... args) { String msg = args.length == 0 ? format : String.format(format, args); - log.tracef("Logging %s for test %d, dataset %d: %s", PersistentLog.logLevel(level), testId, datasetId, msg); + log.tracef("Logging %s for test %d, dataset %d: %s", PersistentLogDAO.logLevel(level), testId, datasetId, msg); new DatasetLogDAO(em.getReference(TestDAO.class, testId), em.getReference(DataSetDAO.class, datasetId), level, "changes", msg).persist(); } @@ -641,11 +641,11 @@ private void runChangeDetection(VariableDAO variable, JsonNode fingerprint, bool for (ChangeDetectionDAO detection : ChangeDetectionDAO.find("variable", variable).list()) { ChangeDetectionModel model = MODELS.get(detection.model); if (model == null) { - logChangeDetectionMessage(variable.testId, datasetId, PersistentLog.ERROR, "Cannot find change detection model %s", detection.model); + logChangeDetectionMessage(variable.testId, datasetId, PersistentLogDAO.ERROR, "Cannot find change detection model %s", detection.model); continue; } model.analyze(dataPoints, detection.config, change -> { - logChangeDetectionMessage(variable.testId, datasetId, PersistentLog.DEBUG, + logChangeDetectionMessage(variable.testId, datasetId, PersistentLogDAO.DEBUG, "Change %s detected using datapoints %s", change, reversedAndLimited(dataPoints)); Query datasetQuery = em.createNativeQuery("SELECT id, runid as \"runId\", ordinal, testid as \"testId\" FROM dataset WHERE id = ?1"); SqlServiceImpl.setResultTransformer(datasetQuery, Transformers.aliasToBean(DataSetDAO.Info.class)); @@ -968,7 +968,7 @@ List getDatasetsForRecalculation(Integer testId, Long from, Long to) { ChangeDAO.delete("dataset.id in ?1 AND confirmed = false", ids); if (ids.size() > 0) { // Due to RLS policies we cannot add a record to a dataset we don't own - logCalculationMessage(testId, ids.get(0), PersistentLog.INFO, "Starting recalculation of %d runs.", ids.size()); + logCalculationMessage(testId, ids.get(0), PersistentLogDAO.INFO, "Starting recalculation of %d runs.", ids.size()); } return ids; } @@ -1183,13 +1183,13 @@ void recalculateMissingDataRule(int datasetId, Instant timestamp, MissingDataRul if (rule.condition != null && !rule.condition.isBlank()) { String ruleName = rule.name == null ? "#" + rule.id : rule.name; match = Util.evaluateTest(rule.condition, value, notBoolean -> { - logMissingDataMessage(rule.testId(), datasetId, PersistentLog.ERROR, + logMissingDataMessage(rule.testId(), datasetId, PersistentLogDAO.ERROR, "Missing data rule %s result is not a boolean: %s", ruleName, notBoolean); return true; }, - (code, exception) -> logMissingDataMessage(rule.testId(), datasetId, PersistentLog.ERROR, + (code, exception) -> logMissingDataMessage(rule.testId(), datasetId, PersistentLogDAO.ERROR, "Error evaluating missing data rule %s: '%s' Code:
%s
", ruleName, exception.getMessage(), code), - output -> logMissingDataMessage(rule.testId(), datasetId, PersistentLog.DEBUG, + output -> logMissingDataMessage(rule.testId(), datasetId, PersistentLogDAO.DEBUG, "Output while evaluating missing data rule %s: '%s'", ruleName, output) ); } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/DatasetServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/DatasetServiceImpl.java index 8ca17abec..8e5bc9419 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/DatasetServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/DatasetServiceImpl.java @@ -26,9 +26,7 @@ import org.hibernate.Hibernate; import org.hibernate.query.NativeQuery; import org.hibernate.transform.AliasToBeanResultTransformer; -import org.hibernate.type.CustomType; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; import com.fasterxml.jackson.core.JsonProcessingException; @@ -40,7 +38,7 @@ import io.hyperfoil.tools.horreum.api.services.QueryResult; import io.hyperfoil.tools.horreum.api.services.SchemaService; import io.hyperfoil.tools.horreum.bus.MessageBus; -import io.hyperfoil.tools.horreum.entity.PersistentLog; +import io.hyperfoil.tools.horreum.entity.PersistentLogDAO; import io.hyperfoil.tools.horreum.entity.alerting.DatasetLogDAO; import io.hyperfoil.tools.horreum.server.WithRoles; import io.hyperfoil.tools.horreum.server.WithToken; @@ -420,7 +418,7 @@ void calculateLabels(int testId, int datasetId, int queryLabelId, boolean isReca .addScalar("value", JsonBinaryType.INSTANCE) .getResultList(); } catch (PersistenceException e) { - logMessageInNewTx(datasetId, PersistentLog.ERROR, "Failed to extract data (JSONPath expression error?): " + Util.explainCauses(e)); + logMessageInNewTx(datasetId, PersistentLogDAO.ERROR, "Failed to extract data (JSONPath expression error?): " + Util.explainCauses(e)); findFailingExtractor(datasetId); return; } @@ -438,9 +436,9 @@ void calculateLabels(int testId, int datasetId, int queryLabelId, boolean isReca Util.evaluateMany(extracted, row -> (String) row[2], row -> (JsonNode) row[3], (row, result) -> createLabel(datasetId, (int) row[0], Util.convertToJson(result)), row -> createLabel(datasetId, (int) row[0], (JsonNode) row[3]), - (row, e, jsCode) -> logMessage(datasetId, PersistentLog.ERROR, + (row, e, jsCode) -> logMessage(datasetId, PersistentLogDAO.ERROR, "Evaluation of label %s failed: '%s' Code:
%s
", row[0], e.getMessage(), jsCode), - out -> logMessage(datasetId, PersistentLog.DEBUG, "Output while calculating labels:
%s
", out)); + out -> logMessage(datasetId, PersistentLogDAO.DEBUG, "Output while calculating labels:
%s
", out)); messageBus.publish(MessageBusChannels.DATASET_UPDATED_LABELS, testId, new DataSet.LabelsUpdatedEvent(testId, datasetId, isRecalculation)); } @@ -458,12 +456,12 @@ protected void findFailingExtractor(int datasetId) { em.createNativeQuery("SELECT jsonb_path_query_first(data -> (?1), (?2)::::jsonpath)#>>'{}' FROM dataset WHERE id = ?3") .setParameter(1, row[3]).setParameter(2, row[4]).setParameter(3, datasetId).getSingleResult(); } catch (PersistenceException e) { - logMessageInNewTx(datasetId, PersistentLog.ERROR, "There seems to be an error in schema %s label %s, extractor %s, JSONPath expression %s: %s", + logMessageInNewTx(datasetId, PersistentLogDAO.ERROR, "There seems to be an error in schema %s label %s, extractor %s, JSONPath expression %s: %s", row[0], row[1], row[2], row[4], Util.explainCauses(e)); return; } } - logMessage(datasetId, PersistentLog.DEBUG, "We thought there's an error in one of the JSONPaths but independent validation did not find any problems."); + logMessage(datasetId, PersistentLogDAO.DEBUG, "We thought there's an error in one of the JSONPaths but independent validation did not find any problems."); } private void createLabel(int datasetId, int labelId, JsonNode value) { @@ -497,7 +495,7 @@ private void logMessage(int datasetId, int level, String message, Object... para String msg = String.format(message, params); DataSetDAO dataset = DataSetDAO.findById(datasetId); if(dataset != null) { - log.tracef("Logging %s for test %d, dataset %d: %s", PersistentLog.logLevel(level), dataset.testid, datasetId, msg); + log.tracef("Logging %s for test %d, dataset %d: %s", PersistentLogDAO.logLevel(level), dataset.testid, datasetId, msg); new DatasetLogDAO(em.getReference(TestDAO.class, dataset.testid), em.getReference(DataSetDAO.class, datasetId), level, "labels", msg).persist(); } } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ExperimentServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ExperimentServiceImpl.java index ced304e3a..08ab09b25 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ExperimentServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ExperimentServiceImpl.java @@ -36,9 +36,7 @@ import org.hibernate.Hibernate; import org.hibernate.query.NativeQuery; import org.hibernate.transform.Transformers; -import org.hibernate.type.CustomType; import org.hibernate.type.StandardBasicTypes; -import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; import com.fasterxml.jackson.core.JsonProcessingException; @@ -159,7 +157,7 @@ public void onTestDeleted(Test test) { private void addLog(List logs, int testId, int datasetId, int level, String format, Object... args) { String msg = args.length == 0 ? format : String.format(format, args); - log.tracef("Logging %s for test %d, dataset %d: %s", PersistentLog.logLevel(level), testId, datasetId, msg); + log.tracef("Logging %s for test %d, dataset %d: %s", PersistentLogDAO.logLevel(level), testId, datasetId, msg); logs.add(new DatasetLogDAO(em.getReference(TestDAO.class, testId), em.getReference(DataSetDAO.class, datasetId), level, "experiment", msg)); } @@ -194,11 +192,11 @@ private void runExperiments(DataSet.Info info, Consumer result matchingProfile.add((Integer) r[0]); } }, (r, ex, code) -> addLog(logs, info.testId, info.id, - PersistentLog.ERROR, "Selector filter failed: %s Code: %s", ex.getMessage(), code), + PersistentLogDAO.ERROR, "Selector filter failed: %s Code: %s", ex.getMessage(), code), output -> addLog(logs, info.testId, info.id, - PersistentLog.DEBUG, "Selector filter output: %s", output)); + PersistentLogDAO.DEBUG, "Selector filter output: %s", output)); if (matchingProfile.isEmpty()) { - addLog(logs, info.testId, info.id, PersistentLog.INFO, "There are no matching experiment profiles."); + addLog(logs, info.testId, info.id, PersistentLogDAO.INFO, "There are no matching experiment profiles."); noProfileConsumer.accept(logs); return; } @@ -234,9 +232,9 @@ private void runExperiments(DataSet.Info info, Consumer result baselines.computeIfAbsent((Integer) r[0], profileId -> new ArrayList<>()).add((Integer) r[3]); } }, (r, ex, code) -> addLog(perProfileLogs.get((Integer) r[0]), info.testId, (Integer) r[3], - PersistentLog.ERROR, "Baseline filter failed: %s Code: %s", ex.getMessage(), code), + PersistentLogDAO.ERROR, "Baseline filter failed: %s Code: %s", ex.getMessage(), code), output -> perProfileLogs.forEach((profileId, pls)-> addLog(pls, info.testId, info.id, - PersistentLog.DEBUG, "Baseline filter output: %s", output))); + PersistentLogDAO.DEBUG, "Baseline filter output: %s", output))); Map datapoints = DataPointDAO.find("dataset_id = ?1", info.id) .stream().collect(Collectors.toMap(dp -> dp.variable.id, Function.identity(), @@ -249,7 +247,7 @@ private void runExperiments(DataSet.Info info, Consumer result List profileLogs = perProfileLogs.get(entry.getKey()); ExperimentProfileDAO profile = ExperimentProfileDAO.findById(entry.getKey()); Map> byVar = new HashMap<>(); - List variableIds = profile.comparisons.stream().map(io.hyperfoil.tools.horreum.entity.ExperimentComparison::getVariableId).collect(Collectors.toList()); + List variableIds = profile.comparisons.stream().map(ExperimentComparisonDAO::getVariableId).collect(Collectors.toList()); DataPointDAO.find("dataset_id IN ?1 AND variable_id IN ?2", Sort.descending("timestamp", "dataset_id"), entry.getValue(), variableIds) .stream().forEach(dp -> byVar.computeIfAbsent(dp.variable.id, v -> new ArrayList<>()).add(dp)); Map results = new HashMap<>(); @@ -257,17 +255,17 @@ private void runExperiments(DataSet.Info info, Consumer result Hibernate.initialize(comparison.variable); ExperimentConditionModel model = MODELS.get(comparison.model); if (model == null) { - addLog(profileLogs, info.testId, info.id, PersistentLog.ERROR, "Unknown experiment comparison model '%s' for variable %s in profile %s", comparison.model, comparison.variable.name, profile.name); + addLog(profileLogs, info.testId, info.id, PersistentLogDAO.ERROR, "Unknown experiment comparison model '%s' for variable %s in profile %s", comparison.model, comparison.variable.name, profile.name); continue; } List baseline = byVar.get(comparison.getVariableId()); if (baseline == null) { - addLog(profileLogs, info.testId, info.id, PersistentLog.INFO, "Baseline for comparison of variable %s in profile %s is empty (datapoints are not present)", comparison.variable.name, profile.name); + addLog(profileLogs, info.testId, info.id, PersistentLogDAO.INFO, "Baseline for comparison of variable %s in profile %s is empty (datapoints are not present)", comparison.variable.name, profile.name); continue; } DataPointDAO datapoint = datapoints.get(comparison.getVariableId()); if (datapoint == null) { - addLog(profileLogs, info.testId, info.id, PersistentLog.ERROR, "No datapoint for comparison of variable %s in profile %s", comparison.variable.name, profile.name); + addLog(profileLogs, info.testId, info.id, PersistentLogDAO.ERROR, "No datapoint for comparison of variable %s in profile %s", comparison.variable.name, profile.name); continue; } results.put(ExperimentProfileMapper.fromExperimentComparison(comparison), diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ReportServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ReportServiceImpl.java index f1c0f63f2..3e503afc5 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ReportServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/ReportServiceImpl.java @@ -47,7 +47,7 @@ import io.hyperfoil.tools.horreum.api.services.ReportService; import io.hyperfoil.tools.horreum.api.SortDirection; import io.hyperfoil.tools.horreum.bus.MessageBus; -import io.hyperfoil.tools.horreum.entity.PersistentLog; +import io.hyperfoil.tools.horreum.entity.PersistentLogDAO; import io.hyperfoil.tools.horreum.entity.data.TestDAO; import io.hyperfoil.tools.horreum.server.WithRoles; import io.quarkus.runtime.Startup; @@ -343,7 +343,7 @@ private TableReportDAO createTableReport(TableReportConfigDAO config, Integer re } timestampQuery = em.createNativeQuery("SELECT id, start FROM dataset WHERE id IN :datasets").setParameter("datasets", datasetIds); } else { - log(report, PersistentLog.DEBUG, "Table report %s(%d) includes all datasets for test %s(%d)", config.title, config.id, config.test.name, config.test.id); + log(report, PersistentLogDAO.DEBUG, "Table report %s(%d) includes all datasets for test %s(%d)", config.title, config.id, config.test.name, config.test.id); series = selectByTest(config.test.id, config.seriesLabels); log.debugf("Series: %s", rowsToMap(series)); if (!nullOrEmpty(config.scaleLabels)) { @@ -404,15 +404,15 @@ private TableReportDAO createTableReport(TableReportConfigDAO config, Integer re try { Value calculatedValue = context.eval("js", jsCode); Double maybeDouble = Util.toDoubleOrNull(calculatedValue, - err -> log(report, PersistentLog.ERROR, err), - info -> log(report, PersistentLog.INFO, info)); + err -> log(report, PersistentLogDAO.ERROR, err), + info -> log(report, PersistentLogDAO.INFO, info)); if (maybeDouble != null) { data.values.add(maybeDouble); } else { data.values.add(Util.convertToJson(calculatedValue)); } } catch (PolyglotException e) { - log(report, PersistentLog.ERROR, "Failed to run report %s(%d) label function on run %d. Offending code:
%s
", + log(report, PersistentLogDAO.ERROR, "Failed to run report %s(%d) label function on run %d. Offending code:
%s
", config.title, config.id, datasetId, jsCode); log.debug("Caused by exception", e); } @@ -458,7 +458,7 @@ private Map getData(TableReportConfigDAO config, T try { data.category = Util.convert(context.eval("js", jsCode)).toString(); } catch (PolyglotException e) { - log(report, PersistentLog.ERROR, "Failed to run report %s(%d) category function on dataset %d/%d (%d). Offending code:
%s
", + log(report, PersistentLogDAO.ERROR, "Failed to run report %s(%d) category function on dataset %d/%d (%d). Offending code:
%s
", config.title, config.id, data.runId, data.ordinal + 1, data.datasetId, jsCode); log.debug("Caused by exception", e); continue; @@ -473,7 +473,7 @@ private Map getData(TableReportConfigDAO config, T JsonNode value = (JsonNode) row[3]; TableReportDAO.Data data = datasetData.get(datasetId); if (data == null) { - log(report, PersistentLog.ERROR, "Missing values for dataset %d!", datasetId); + log(report, PersistentLogDAO.ERROR, "Missing values for dataset %d!", datasetId); continue; } if (nullOrEmpty(config.seriesFunction)) { @@ -483,7 +483,7 @@ private Map getData(TableReportConfigDAO config, T try { data.series = Util.convert(context.eval("js", jsCode)).toString(); } catch (PolyglotException e) { - log(report, PersistentLog.ERROR, "Failed to run report %s(%d) series function on run %d/%d (%d). Offending code:
%s
", config.title, config.id, runId, ordinal + 1, datasetId, jsCode); + log(report, PersistentLogDAO.ERROR, "Failed to run report %s(%d) series function on run %d/%d (%d). Offending code:
%s
", config.title, config.id, runId, ordinal + 1, datasetId, jsCode); log.debug("Caused by exception", e); } } @@ -495,7 +495,7 @@ private Map getData(TableReportConfigDAO config, T JsonNode value = (JsonNode) row[3]; TableReportDAO.Data data = datasetData.get(datasetId); if (data == null) { - log(report, PersistentLog.ERROR, "Missing values for dataset %d!", datasetId); + log(report, PersistentLogDAO.ERROR, "Missing values for dataset %d!", datasetId); continue; } if (nullOrEmpty(config.scaleFunction)) { @@ -505,7 +505,7 @@ private Map getData(TableReportConfigDAO config, T try { data.scale = Util.convert(context.eval("js", jsCode)).toString(); } catch (PolyglotException e) { - log(report, PersistentLog.ERROR, "Failed to run report %s(%d) label function on dataset %d/%d (%d). Offending code:
%s
", + log(report, PersistentLogDAO.ERROR, "Failed to run report %s(%d) label function on dataset %d/%d (%d). Offending code:
%s
", config.title, config.id, runId, ordinal + 1, datasetId, jsCode); log.debug("Caused by exception", e); } @@ -627,7 +627,7 @@ public int hashCode() { private List filterDatasetIds(TableReportConfigDAO config, TableReportDAO report) { List list = selectByTest(config.test.id, config.filterLabels); if (list.isEmpty()) { - log(report, PersistentLog.WARN, "There are no matching datasets for test %s (%d)", config.test.name, config.test.id); + log(report, PersistentLogDAO.WARN, "There are no matching datasets for test %s (%d)", config.test.name, config.test.id); } List datasetIds = new ArrayList<>(list.size()); if (nullOrEmpty(config.filterFunction)) { @@ -646,7 +646,7 @@ private List filterDatasetIds(TableReportConfigDAO config, TableReportD debugList.append("(filtered)"); } } - log(report, PersistentLog.DEBUG, "Datasets considered for report: %s", debugList); + log(report, PersistentLogDAO.DEBUG, "Datasets considered for report: %s", debugList); } else { executeInContext(config, context -> { StringBuilder debugList = new StringBuilder(); @@ -671,17 +671,17 @@ private List filterDatasetIds(TableReportConfigDAO config, TableReportD } } else { debugList.append("(filtered: not boolean)"); - log(report, PersistentLog.ERROR, "Report %s(%d) filter result for dataset %d/%d (%d) is not a boolean: %s. Offending code:
%s
", + log(report, PersistentLogDAO.ERROR, "Report %s(%d) filter result for dataset %d/%d (%d) is not a boolean: %s. Offending code:
%s
", config.title, config.id, runId, ordinal + 1, datasetId, value, jsCode); } } catch (PolyglotException e) { debugList.append("(filtered: JS error)"); - log(report, PersistentLog.ERROR, "Failed to run report %s(%d) filter function on dataset %d/%d (%d). Offending code:
%s
", + log(report, PersistentLogDAO.ERROR, "Failed to run report %s(%d) filter function on dataset %d/%d (%d). Offending code:
%s
", config.title, config.id, runId, ordinal + 1, datasetId, jsCode); log.debug("Caused by exception", e); } } - log(report, PersistentLog.DEBUG, "Datasets considered for report: %s", debugList); + log(report, PersistentLogDAO.DEBUG, "Datasets considered for report: %s", debugList); }); } return datasetIds; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/RunServiceImpl.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/RunServiceImpl.java index 99a1b8fd2..851bb68d8 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/RunServiceImpl.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/RunServiceImpl.java @@ -66,7 +66,7 @@ import io.hyperfoil.tools.horreum.api.services.SchemaService; import io.hyperfoil.tools.horreum.api.services.SqlService; import io.hyperfoil.tools.horreum.bus.MessageBus; -import io.hyperfoil.tools.horreum.entity.PersistentLog; +import io.hyperfoil.tools.horreum.entity.PersistentLogDAO; import io.hyperfoil.tools.horreum.entity.alerting.TransformationLogDAO; import io.hyperfoil.tools.horreum.server.WithRoles; import io.hyperfoil.tools.horreum.server.WithToken; @@ -1121,7 +1121,7 @@ int transform(int runId, boolean isRecalculation) { .getResultList()); } } catch (PersistenceException e) { - logMessage(run, PersistentLog.ERROR, "Failed to extract data (JSONPath expression error?): " + Util.explainCauses(e)); + logMessage(run, PersistentLogDAO.ERROR, "Failed to extract data (JSONPath expression error?): " + Util.explainCauses(e)); findFailingExtractor(runId); extractedData = Collections.emptyList(); } @@ -1137,13 +1137,13 @@ int transform(int runId, boolean isRecalculation) { root = root.iterator().next(); } } - logMessage(run, PersistentLog.DEBUG, "Run transformer %s/%s with input:
%s
, function:
%s
", + logMessage(run, PersistentLogDAO.DEBUG, "Run transformer %s/%s with input:
%s
, function:
%s
", uri, t.name, limitLength(root.toPrettyString()), t.function); if (t.function != null && !t.function.isBlank()) { result = Util.evaluateOnce(t.function, root, Util::convertToJson, - (code, e) -> logMessage(run, PersistentLog.ERROR, + (code, e) -> logMessage(run, PersistentLogDAO.ERROR, "Evaluation of transformer %s/%s failed: '%s' Code:
%s
", uri, t.name, e.getMessage(), code), - output -> logMessage(run, PersistentLog.DEBUG, "Output while running transformer %s/%s:
%s
", uri, t.name, output)); + output -> logMessage(run, PersistentLogDAO.DEBUG, "Output while running transformer %s/%s:
%s
", uri, t.name, output)); if (result == null) { // this happens upon error result = JsonNodeFactory.instance.nullNode(); @@ -1167,7 +1167,7 @@ int transform(int runId, boolean isRecalculation) { } } else if (!result.isContainerNode() || (result.isObject() && !result.has("$schema")) || (result.isArray() && StreamSupport.stream(result.spliterator(), false).anyMatch(item -> !item.has("$schema")))) { - logMessage(run, PersistentLog.WARN, "Dataset will contain element without a schema."); + logMessage(run, PersistentLogDAO.WARN, "Dataset will contain element without a schema."); } JsonNode existing = transformerResults.get(transformerId); if (existing == null) { @@ -1203,7 +1203,7 @@ int transform(int runId, boolean isRecalculation) { throw new IllegalStateException("Unknown type " + type); } nakedNodes.add(node); - logMessage(run, PersistentLog.DEBUG, "This test (%d) does not use any transformer for schema %s (key %s), passing as-is.", run.testid, uri, key); + logMessage(run, PersistentLogDAO.DEBUG, "This test (%d) does not use any transformer for schema %s (key %s), passing as-is.", run.testid, uri, key); } } if (schemasAndTransformers > 0) { @@ -1222,11 +1222,11 @@ int transform(int runId, boolean isRecalculation) { String message = String.format("Transformer %d produced an array of %d elements but other transformer " + "produced %d elements; dataset %d/%d might be missing some data.", entry.getKey(), node.size(), max, run.id, ordinal); - logMessage(run, PersistentLog.WARN, "%s", message); + logMessage(run, PersistentLogDAO.WARN, "%s", message); log.warnf(message); } } else { - logMessage(run, PersistentLog.WARN, "Unexpected result provided by one of the transformers: %s", node); + logMessage(run, PersistentLogDAO.WARN, "Unexpected result provided by one of the transformers: %s", node); log.warnf("Unexpected result provided by one of the transformers: %s", node); } } @@ -1236,7 +1236,7 @@ int transform(int runId, boolean isRecalculation) { } return ordinal; } else { - logMessage(run, PersistentLog.INFO, "No applicable schema, dataset will be empty."); + logMessage(run, PersistentLogDAO.INFO, "No applicable schema, dataset will be empty."); createDataset(new DataSetDAO( run, 0, "Empty DataSet for run data without any schema.", instance.arrayNode()), isRecalculation); @@ -1286,12 +1286,12 @@ protected void findFailingExtractor(int runId) { .setParameter(3, runId).getSingleResult(); } } catch (PersistenceException e) { - logMessage(em.getReference(RunDAO.class, runId), PersistentLog.ERROR, "There seems to be an error in schema %s transformer %s, extractor %s, JSONPath expression %s: %s", + logMessage(em.getReference(RunDAO.class, runId), PersistentLogDAO.ERROR, "There seems to be an error in schema %s transformer %s, extractor %s, JSONPath expression %s: %s", row[0], row[3], row[4], row[5], Util.explainCauses(e)); return; } } - logMessage(em.getReference(RunDAO.class, runId), PersistentLog.DEBUG, "We thought there's an error in one of the JSONPaths but independent validation did not find any problems."); + logMessage(em.getReference(RunDAO.class, runId), PersistentLogDAO.DEBUG, "We thought there's an error in one of the JSONPaths but independent validation did not find any problems."); } @@ -1313,7 +1313,7 @@ private void putIfAbsent(RunDAO run, String uri, ObjectNode node) { if (node.path("$schema").isMissingNode()) { node.put("$schema", uri); } else { - logMessage(run, PersistentLog.DEBUG, "$schema present (%s), not overriding with %s", node.path("$schema").asText(), uri); + logMessage(run, PersistentLogDAO.DEBUG, "$schema present (%s), not overriding with %s", node.path("$schema").asText(), uri); } } }