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/ExperimentComparison.java index 30da1ba29..b490875ed 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/ExperimentComparison.java @@ -8,8 +8,6 @@ import org.hibernate.annotations.Type; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import io.hyperfoil.tools.horreum.entity.alerting.VariableDAO; @@ -19,7 +17,6 @@ public class ExperimentComparison { @NotNull @ManyToOne(optional = false, fetch = FetchType.LAZY) @JoinColumn(name = "variable_id") - @JsonIgnore public VariableDAO variable; @NotNull @@ -29,12 +26,10 @@ public class ExperimentComparison { @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") public JsonNode config; - @JsonProperty("variableId") public void setVariableId(Integer id) { variable = VariableDAO.getEntityManager().getReference(VariableDAO.class, id); } - @JsonProperty(value = "variableId", required = true) public int getVariableId() { return 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 fbac90ee1..82d8a1d1e 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 @@ -18,14 +18,11 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; -import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import io.hyperfoil.tools.horreum.entity.data.TestDAO; @@ -34,7 +31,6 @@ @Entity(name = "ExperimentProfile") @Table(name = "experiment_profile") public class ExperimentProfileDAO extends PanacheEntityBase { - @JsonProperty(required = true) @Id @GenericGenerator( name = "experimentProfileIdGenerator", @@ -52,10 +48,8 @@ public class ExperimentProfileDAO extends PanacheEntityBase { @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) - @JsonIgnore public TestDAO test; - @Schema(implementation = String[].class, required = true) @Column(name = "selector_labels") @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") public JsonNode selectorLabels; @@ -63,7 +57,6 @@ public class ExperimentProfileDAO extends PanacheEntityBase { @Column(name = "selector_filter") public String selectorFilter; - @Schema(implementation = String[].class, required = true) @Column(name = "baseline_labels") @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") public JsonNode baselineLabels; @@ -71,14 +64,12 @@ public class ExperimentProfileDAO extends PanacheEntityBase { @Column(name = "baseline_filter") public String baselineFilter; - @JsonProperty(required = true) @ElementCollection(fetch = FetchType.EAGER) @CollectionTable(name="experiment_comparisons", joinColumns=@JoinColumn(name="profile_id")) @OrderBy("variable_id, model") public Collection comparisons; /* These labels are not used in Horreum but are added to the result event */ - @Schema(implementation = String[].class) @Column(name = "extra_labels") @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") public JsonNode extraLabels; 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/PersistentLog.java index 94ad6481a..fa9f1a698 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/PersistentLog.java @@ -10,8 +10,6 @@ import org.jboss.logging.Logger; -import com.fasterxml.jackson.annotation.JsonProperty; - import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @MappedSuperclass @@ -21,7 +19,6 @@ public abstract class PersistentLog extends PanacheEntityBase { public static final int WARN = 2; public static final int ERROR = 3; - @JsonProperty(required = true) @Id @GeneratedValue public Long id; @@ -29,7 +26,6 @@ public abstract class PersistentLog extends PanacheEntityBase { @NotNull public int level; - @JsonProperty(required = true) @NotNull @Column(columnDefinition = "timestamp") public Instant timestamp; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ValidationErrorDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ValidationErrorDAO.java index 284bdabd4..c43665334 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ValidationErrorDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/ValidationErrorDAO.java @@ -7,8 +7,6 @@ import org.hibernate.annotations.Type; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import io.hyperfoil.tools.horreum.entity.data.SchemaDAO; @@ -16,19 +14,16 @@ @Embeddable public class ValidationErrorDAO { @ManyToOne(fetch = FetchType.LAZY, optional = false) - @JsonIgnore public SchemaDAO schema; @NotNull @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") public JsonNode error; - @JsonProperty(value = "schemaId", required = true) public void setSchema(int id) { schema = SchemaDAO.getEntityManager().getReference(SchemaDAO.class, id); } - @JsonProperty(value = "schemaId", required = true) public Integer getSchemaId() { return schema == null ? null : schema.id; } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDAO.java index e657b43e8..54d2e59c6 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDAO.java @@ -12,9 +12,6 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @@ -29,7 +26,6 @@ public class ChangeDAO extends PanacheEntityBase { public static final String EVENT_NEW = "change/new"; - @JsonProperty(required = true) @Id @GeneratedValue public int id; @@ -40,7 +36,6 @@ public class ChangeDAO extends PanacheEntityBase { @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "dataset_id") - @JsonIgnore public DataSetDAO dataset; @NotNull @@ -52,7 +47,6 @@ public class ChangeDAO extends PanacheEntityBase { public String description; - @JsonProperty("dataset") public DataSetDAO.Info getDatasetId() { if (dataset != null) { return dataset.getInfo(); diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDetectionDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDetectionDAO.java index 28c2041d6..3aa534968 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDetectionDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/ChangeDetectionDAO.java @@ -8,23 +8,21 @@ import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import javax.persistence.Table; import javax.validation.constraints.NotNull; +import com.fasterxml.jackson.annotation.JsonIgnoreType; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @Entity(name = "ChangeDetection") +@JsonIgnoreType public class ChangeDetectionDAO extends PanacheEntityBase { - @JsonProperty(required = true) @Id @GenericGenerator( name = "cdIdGenerator", @@ -46,7 +44,6 @@ public class ChangeDetectionDAO extends PanacheEntityBase { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "variable_id") - @JsonIgnore public VariableDAO variable; @Override 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 26226a559..dc5e16db1 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 @@ -13,9 +13,6 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @@ -36,7 +33,6 @@ public class DataPointDAO extends PanacheEntityBase { @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "dataset_id") - @JsonIgnore public DataSetDAO dataset; @NotNull @@ -60,12 +56,10 @@ public String toString() { @ManyToOne(fetch = FetchType.LAZY) public VariableDAO variable; - @JsonProperty("datasetId") public void setDatasetId(int datasetId) { dataset = DataSetDAO.getEntityManager().getReference(DataSetDAO.class, datasetId); } - @JsonProperty("datasetId") public int getDatasetId() { return dataset.id; } 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 3dd7b23f7..f0e8ada85 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,9 +8,6 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - import io.hyperfoil.tools.horreum.entity.PersistentLog; import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; import io.hyperfoil.tools.horreum.entity.data.RunDAO; @@ -25,12 +22,10 @@ public class DatasetLogDAO extends PersistentLog { @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "testid", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) - @JsonIgnore public TestDAO test; @ManyToOne(fetch = FetchType.EAGER, optional = false) @JoinColumn(name = "dataset_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) - @JsonIgnore public DataSetDAO dataset; @NotNull @@ -47,22 +42,18 @@ public DatasetLogDAO(TestDAO test, DataSetDAO dataset, int level, String source, this.source = source; } - @JsonProperty(value = "testId", required = true) private int getTestId() { return test.id; } - @JsonProperty(value = "runId", required = true) private int getRunId() { return dataset.run.id; } - @JsonProperty(value = "datasetId", required = true) private int getDatasetId() { return dataset.id; } - @JsonProperty(value = "datasetOrdinal", required = true) private int getDatasetOrdinal() { return dataset.ordinal; } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleDAO.java index 79394001d..8cf66f101 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/MissingDataRuleDAO.java @@ -20,8 +20,6 @@ import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.node.ArrayNode; import io.hyperfoil.tools.horreum.entity.data.TestDAO; @@ -33,7 +31,6 @@ @Entity(name = "MissingDataRule") @Table(name = "missingdata_rule") public class MissingDataRuleDAO extends PanacheEntityBase { - @JsonProperty(required = true) @Id @GenericGenerator( name = "mdrIdGenerator", @@ -50,7 +47,6 @@ public class MissingDataRuleDAO extends PanacheEntityBase { @ManyToOne(optional = false) @JoinColumn(name = "test_id", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) - @JsonIgnore public TestDAO test; @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") @@ -64,12 +60,10 @@ public class MissingDataRuleDAO extends PanacheEntityBase { @Column(name = "last_notification", columnDefinition = "timestamp") public Instant lastNotification; - @JsonProperty("testId") public int testId() { return test.id; } - @JsonProperty(value = "testId", required = true) public void setTestId(int testId) { this.test = TestDAO.getEntityManager().getReference(TestDAO.class, testId); } 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 dc00a773b..2dd1bac4b 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,9 +8,6 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - import io.hyperfoil.tools.horreum.entity.PersistentLog; import io.hyperfoil.tools.horreum.entity.data.RunDAO; import io.hyperfoil.tools.horreum.entity.data.TestDAO; @@ -20,12 +17,10 @@ public class TransformationLogDAO extends PersistentLog { @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "testid", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) - @JsonIgnore public TestDAO test; @ManyToOne(fetch = FetchType.LAZY, optional = false) @JoinColumn(name = "runid", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) - @JsonIgnore public RunDAO run; public TransformationLogDAO() { @@ -38,12 +33,10 @@ public TransformationLogDAO(TestDAO test, RunDAO run, int level, String message) this.run = run; } - @JsonProperty("testId") private int getTestId() { return test.id; } - @JsonProperty("runId") private int getRunId() { return run.id; } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/VariableDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/VariableDAO.java index cb6d58812..8303cf9b1 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/VariableDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/VariableDAO.java @@ -12,17 +12,14 @@ import javax.persistence.OneToMany; import javax.validation.constraints.NotNull; +import com.fasterxml.jackson.annotation.JsonIgnoreType; import io.hyperfoil.tools.horreum.entity.data.LabelDAO; import io.hyperfoil.tools.horreum.entity.data.RunDAO; -import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @@ -34,8 +31,8 @@ * */ @Entity(name = "variable") +@JsonIgnoreType public class VariableDAO extends PanacheEntityBase { - @JsonProperty(required = true) @Id @GenericGenerator( name = "variableIdGenerator", @@ -65,10 +62,8 @@ public class VariableDAO extends PanacheEntityBase { @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") public JsonNode labels; - @JsonInclude(Include.NON_NULL) public String calculation; - @Schema(required = true, implementation = ChangeDetectionDAO[].class) @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "variable") public Set changeDetection; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/WatchDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/WatchDAO.java index 5a11100a2..656c6c835 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/WatchDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/alerting/WatchDAO.java @@ -22,9 +22,6 @@ import org.hibernate.annotations.Parameter; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - import io.hyperfoil.tools.horreum.entity.data.TestDAO; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @@ -51,7 +48,6 @@ public class WatchDAO extends PanacheEntityBase { // We are not using foreign-key constraint as we propagate the test-deletion event (which should remove watches) // over eventbus and delete the watch in an independent transaction. @JoinColumn(name = "testid", foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT), updatable = false) - @JsonIgnore public TestDAO test; @NotNull @@ -69,12 +65,10 @@ public class WatchDAO extends PanacheEntityBase { @Fetch(FetchMode.SELECT) public List teams; - @JsonProperty(value = "testId", required = true) private Integer getTestId() { return test.id; } - @JsonProperty(value = "testId") private void setTestId(int id) { this.test = TestDAO.getEntityManager().getReference(TestDAO.class, id); } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonUserType.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonUserType.java index 292470e65..650599fda 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonUserType.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/converter/JsonUserType.java @@ -1,7 +1,6 @@ package io.hyperfoil.tools.horreum.entity.converter; import io.hyperfoil.tools.horreum.api.ApiUtil; -import io.quarkus.runtime.annotations.RegisterForReflection; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.usertype.UserType; @@ -15,7 +14,6 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; -@RegisterForReflection public class JsonUserType implements UserType { @Override public int[] sqlTypes() { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ActionDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ActionDAO.java index 13a1e20eb..3857fc786 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ActionDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ActionDAO.java @@ -1,7 +1,6 @@ package io.hyperfoil.tools.horreum.entity.data; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; -import io.quarkus.runtime.annotations.RegisterForReflection; import javax.persistence.*; import javax.validation.constraints.NotNull; @@ -11,16 +10,12 @@ import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; @Entity(name = "Action") -@RegisterForReflection public class ActionDAO extends PanacheEntityBase { - @JsonProperty(required = true) @Id @GenericGenerator( name = "actionSequence", @@ -49,7 +44,6 @@ public class ActionDAO extends PanacheEntityBase { @NotNull @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") @Column(name = "secrets") - @JsonIgnore public JsonNode secrets; @NotNull @@ -78,14 +72,12 @@ public ActionDAO(Integer id, String event, String type, JsonNode config, JsonNod this.runAlways = runAlways; } - @JsonProperty("secrets") public void setSecrets(JsonNode secrets) { this.secrets = secrets; } // Had we called this simply `getSecrets` Quarkus would rewrite (??!!) some property // accesses to use of that method - @JsonProperty("secrets") public JsonNode getMaskedSecrets() { if (secrets != null && secrets.isObject()) { ObjectNode masked = JsonNodeFactory.instance.objectNode(); diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/DataSetDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/DataSetDAO.java index 20f87a215..1181be3b8 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/DataSetDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/DataSetDAO.java @@ -19,26 +19,21 @@ import javax.persistence.ManyToOne; import javax.persistence.SequenceGenerator; -import org.eclipse.microprofile.openapi.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonIgnoreType; import org.hibernate.annotations.Type; import org.hibernate.query.NativeQuery; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import com.vladmihalcea.hibernate.type.json.JsonNodeBinaryType; -import io.hyperfoil.tools.horreum.api.ApiIgnore; import io.hyperfoil.tools.horreum.entity.ValidationErrorDAO; -import io.quarkus.runtime.annotations.RegisterForReflection; import io.smallrye.common.constraint.NotNull; -@Schema(name = "Dataset") -@Entity(name="dataset") -@RegisterForReflection /** * Purpose of this object is to represent derived run data. */ +@Entity(name="dataset") +@JsonIgnoreType public class DataSetDAO extends OwnedEntityBase { public static final String EVENT_NEW = "dataset/new"; public static final String EVENT_LABELS_UPDATED = "dataset/updatedlabels"; @@ -75,7 +70,6 @@ public class DataSetDAO extends OwnedEntityBase { @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY) @JoinColumn(name = "runid") - @JsonIgnore public RunDAO run; @NotNull @@ -85,18 +79,14 @@ public class DataSetDAO extends OwnedEntityBase { @ElementCollection public Collection validationErrors; - @JsonProperty("runId") public int getRunId() { return run.id; } - @JsonProperty("runId") public void setRunId(int runId) { run = getEntityManager().getReference(RunDAO.class, runId); } - @JsonIgnore - @ApiIgnore public String getFingerprint() { @SuppressWarnings("unchecked") List fingerprintList = getEntityManager() @@ -111,7 +101,6 @@ public String getFingerprint() { } } - @JsonIgnore public DataSetDAO.Info getInfo() { return new DataSetDAO.Info(id, run.id, ordinal, testid); } 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 356521516..ac1ad0883 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 @@ -22,17 +22,12 @@ import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; -import io.quarkus.runtime.annotations.RegisterForReflection; @Entity(name="label") -@RegisterForReflection public class LabelDAO extends OwnedEntityBase { - @JsonProperty(required = true) @Id @GenericGenerator( name = "labelIdGenerator", @@ -50,7 +45,6 @@ public class LabelDAO extends OwnedEntityBase { @ManyToOne(optional = false) @JoinColumn(name = "schema_id") - @JsonIgnore public SchemaDAO schema; @NotNull @@ -66,12 +60,10 @@ public class LabelDAO extends OwnedEntityBase { @NotNull public boolean metrics = true; - @JsonProperty(value = "schemaId", required = true) public int getSchemaId() { return schema.id; } - @JsonProperty("schemaId") public void setSchema(int schemaId) { schema = getEntityManager().getReference(SchemaDAO.class, schemaId); } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/OwnedEntityBase.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/OwnedEntityBase.java index 998fa5139..210d2003e 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/OwnedEntityBase.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/OwnedEntityBase.java @@ -5,9 +5,7 @@ import io.hyperfoil.tools.horreum.api.data.Access; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; -import io.quarkus.runtime.annotations.RegisterForReflection; -@RegisterForReflection @MappedSuperclass public class OwnedEntityBase extends PanacheEntityBase { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ProtectedBaseEntity.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ProtectedBaseEntity.java index 0674faf9d..916aca54b 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ProtectedBaseEntity.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ProtectedBaseEntity.java @@ -2,9 +2,6 @@ import javax.persistence.MappedSuperclass; -import io.quarkus.runtime.annotations.RegisterForReflection; - -@RegisterForReflection @MappedSuperclass public abstract class ProtectedBaseEntity extends OwnedEntityBase { diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/RunDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/RunDAO.java index acd084821..2c104dd25 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/RunDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/RunDAO.java @@ -1,10 +1,8 @@ package io.hyperfoil.tools.horreum.entity.data; +import com.fasterxml.jackson.annotation.JsonIgnoreType; import io.hyperfoil.tools.horreum.entity.ValidationErrorDAO; -import io.quarkus.runtime.annotations.RegisterForReflection; -import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; -import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.Type; @@ -22,19 +20,16 @@ import java.time.Instant; import java.util.Collection; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; @Entity(name = "run") -@RegisterForReflection @DynamicUpdate // We don't want to trigger schema analysis when trashing the run +@JsonIgnoreType public class RunDAO extends ProtectedBaseEntity { public static final String EVENT_NEW = "run/new"; public static final String EVENT_TRASHED = "run/trashed"; public static final String EVENT_VALIDATED = "run/validated"; - @JsonProperty(required = true) @Id @SequenceGenerator( name = "runSequence", @@ -43,12 +38,10 @@ public class RunDAO extends ProtectedBaseEntity { @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "runSequence") public Integer id; - @Schema(type = SchemaType.NUMBER) @NotNull @Column(name="start", columnDefinition = "timestamp") public Instant start; - @Schema(type = SchemaType.NUMBER) @NotNull @Column(name="stop", columnDefinition = "timestamp") public Instant stop; @@ -70,7 +63,6 @@ public class RunDAO extends ProtectedBaseEntity { public boolean trashed; @OneToMany(mappedBy = "run", cascade = CascadeType.ALL, orphanRemoval = true) - @JsonIgnore public Collection datasets; @CollectionTable diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/SchemaDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/SchemaDAO.java index c25426d1d..f9d44362b 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/SchemaDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/SchemaDAO.java @@ -2,8 +2,8 @@ import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonIgnoreType; import io.hyperfoil.tools.horreum.entity.ValidationErrorDAO; -import io.quarkus.runtime.annotations.RegisterForReflection; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; @@ -21,7 +21,6 @@ import javax.persistence.UniqueConstraint; import javax.validation.constraints.NotNull; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; @NamedNativeQueries({ @@ -52,11 +51,11 @@ }) @Entity(name = "Schema") -@RegisterForReflection @Table( name = "schema", uniqueConstraints = @UniqueConstraint(columnNames = {"owner", "uri"}) ) +@JsonIgnoreType public class SchemaDAO extends ProtectedBaseEntity { public static final String QUERY_1ST_LEVEL_BY_RUNID_TRANSFORMERID_SCHEMA_ID = "Schema.getFirstLevelExtractorsByRunIDTransIDSchemaID"; @@ -66,7 +65,6 @@ public class SchemaDAO extends ProtectedBaseEntity { public static final int TYPE_2ND_LEVEL = 1; public static final int TYPE_ARRAY_ELEMENT = 2; - @JsonProperty(required = true) @Id @GenericGenerator( name = "schemaIdGenerator", diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestDAO.java index 23d4c0630..a287f72a2 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestDAO.java @@ -2,9 +2,9 @@ import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonIgnoreType; import io.hyperfoil.tools.horreum.api.data.Access; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; -import io.quarkus.runtime.annotations.RegisterForReflection; import javax.persistence.CascadeType; import javax.persistence.Column; @@ -18,7 +18,6 @@ import javax.persistence.OneToMany; import javax.validation.constraints.NotNull; -import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.GenericGenerator; @@ -26,16 +25,14 @@ import org.hibernate.annotations.Type; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.JsonNode; @Entity(name="test") -@RegisterForReflection +@JsonIgnoreType public class TestDAO extends PanacheEntityBase { public static final String EVENT_NEW = "test/new"; public static final String EVENT_DELETED = "test/deleted"; - @JsonProperty(required = true) @Id @GenericGenerator( name = "testIdGenerator", @@ -67,7 +64,6 @@ public class TestDAO extends PanacheEntityBase { @OneToMany(mappedBy = "test", cascade = CascadeType.ALL, orphanRemoval = true) public Collection tokens; - @Schema(implementation = String[].class) @Column(name = "timeline_labels") @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") public JsonNode timelineLabels; @@ -75,7 +71,6 @@ public class TestDAO extends PanacheEntityBase { @Column(name = "timeline_function") public String timelineFunction; - @Schema(implementation = String[].class) @Column(name = "fingerprint_labels") @Type(type = "io.hyperfoil.tools.horreum.entity.converter.JsonUserType") public JsonNode fingerprintLabels; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestTokenDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestTokenDAO.java index d69578bd9..ca4694391 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestTokenDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/TestTokenDAO.java @@ -16,10 +16,6 @@ import org.hibernate.annotations.Parameter; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonGetter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonSetter; - @Entity(name = "test_token") public class TestTokenDAO { public static final int READ = 1; @@ -43,7 +39,6 @@ public class TestTokenDAO { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "test_id") - @JsonIgnore public TestDAO test; @SuppressWarnings({ "unused", "FieldCanBeLocal" }) @@ -58,12 +53,10 @@ public class TestTokenDAO { @NotNull public String description; - @JsonSetter("value") public void setValue(String value) { this.value = value; } - @JsonGetter("value") public String getValue() { return null; } 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 dacb30ee5..9ac3dcbb1 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 @@ -16,16 +16,14 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; +import com.fasterxml.jackson.annotation.JsonIgnoreType; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - @Entity(name = "Transformer") +@JsonIgnoreType public class TransformerDAO extends OwnedEntityBase implements Comparable { - @JsonProperty(required = true) @Id @GenericGenerator( name = "transformerIdGenerator", @@ -46,7 +44,6 @@ public class TransformerDAO extends OwnedEntityBase implements Comparablenull defaults to rendering as plain text. */ - @JsonInclude(JsonInclude.Include.NON_NULL) public String render; - public ViewComponent() { + public ViewComponentDAO() { } - public ViewComponent(String headerName, String render, String... labels) { + public ViewComponentDAO(String headerName, String render, String... labels) { this.headerName = headerName; ArrayNode labelsNode = JsonNodeFactory.instance.arrayNode(); for (String l : labels) { @@ -89,7 +85,7 @@ public ViewComponent(String headerName, String render, String... labels) { public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; - ViewComponent that = (ViewComponent) o; + ViewComponentDAO that = (ViewComponentDAO) o; return headerOrder == that.headerOrder && Objects.equals(id, that.id) && Objects.equals(headerName, that.headerName) && diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ViewDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ViewDAO.java index 300d5fa6a..e2c0a442b 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ViewDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/data/ViewDAO.java @@ -16,14 +16,11 @@ import javax.persistence.UniqueConstraint; import javax.validation.constraints.NotNull; +import com.fasterxml.jackson.annotation.JsonIgnoreType; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; import org.hibernate.id.enhanced.SequenceStyleGenerator; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.hyperfoil.tools.horreum.api.ApiIgnore; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; /** @@ -31,8 +28,8 @@ */ @Entity(name = "view") @Table(uniqueConstraints = @UniqueConstraint(columnNames = { "id", "name" })) +@JsonIgnoreType public class ViewDAO extends PanacheEntityBase { - @JsonProperty(required = true) @Id @GenericGenerator( name = "viewIdGenerator", @@ -51,13 +48,12 @@ public class ViewDAO extends PanacheEntityBase { // In the future we could make this ManyToMany, but then we'd have to maintain // ownership and access in this entity separately. @ManyToOne(fetch = FetchType.LAZY) - @JsonIgnore public TestDAO test; @NotNull @OneToMany(fetch = FetchType.EAGER, mappedBy = "view", orphanRemoval = true, cascade = CascadeType.ALL) @OrderBy("headerorder ASC") - public List components; + public List components; public ViewDAO() { } @@ -68,10 +64,9 @@ public ViewDAO(String name, TestDAO test) { this.components = Collections.emptyList(); } - @ApiIgnore public void ensureLinked() { if (components != null) { - for (ViewComponent c : components) { + for (ViewComponentDAO c : components) { if (c.id != null && c.id < 0) { c.id = null; } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportCommentDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportCommentDAO.java index 1e301c3d2..32a74f34c 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportCommentDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportCommentDAO.java @@ -9,8 +9,6 @@ import javax.persistence.ManyToOne; import javax.validation.constraints.NotNull; -import com.fasterxml.jackson.annotation.JsonIgnore; - import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @Entity(name = "ReportComment") @@ -19,7 +17,6 @@ public class ReportCommentDAO extends PanacheEntityBase { @GeneratedValue public Integer id; - @JsonIgnore @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "report_id", nullable = false) public TableReportDAO report; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportComponentDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportComponentDAO.java index 72e4003a0..ff2b86937 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportComponentDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/ReportComponentDAO.java @@ -12,7 +12,6 @@ import org.hibernate.annotations.Type; -import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.node.ArrayNode; @Entity(name = "ReportComponent") @@ -23,7 +22,6 @@ public class ReportComponentDAO { public Integer id; @ManyToOne(fetch = FetchType.LAZY) - @JsonIgnore @JoinColumn(name = "reportconfig_id") public TableReportConfigDAO report; 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 d0b42a630..acd4d6132 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,16 +4,12 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonProperty; - import io.hyperfoil.tools.horreum.entity.PersistentLog; @Entity(name = "ReportLog") public class ReportLogDAO extends PersistentLog { @ManyToOne(optional = false) @JoinColumn(name = "report_id") - @JsonIgnore TableReportDAO report; public ReportLogDAO() { @@ -25,7 +21,6 @@ public ReportLogDAO(TableReportDAO report, int level, String message) { this.report = report; } - @JsonProperty(required = true, value = "reportId") public int getReportId() { if (report == null || report.id == null) { return -1; @@ -33,7 +28,6 @@ public int getReportId() { return report.id; } - @JsonProperty("reportId") public void setReportId(int reportId) { report = getEntityManager().getReference(TableReportDAO.class, reportId); } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/TableReportConfigDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/TableReportConfigDAO.java index 262b3191d..ccf2fa4b6 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/TableReportConfigDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/TableReportConfigDAO.java @@ -29,7 +29,6 @@ @Entity(name = "TableReportConfig") @Table(name = "tablereportconfig") public class TableReportConfigDAO extends PanacheEntityBase { - @JsonProperty(required = true) @Id @GeneratedValue public Integer id; diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/TableReportDAO.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/TableReportDAO.java index 726648e7e..f57812ac2 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/TableReportDAO.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/entity/report/TableReportDAO.java @@ -19,13 +19,10 @@ import javax.persistence.Table; import javax.validation.constraints.NotNull; -import org.eclipse.microprofile.openapi.annotations.enums.SchemaType; -import org.eclipse.microprofile.openapi.annotations.media.Schema; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.Type; -import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.node.ArrayNode; import io.quarkus.hibernate.orm.panache.PanacheEntityBase; @@ -33,17 +30,14 @@ @Entity(name = "TableReport") @Table(name = "tablereport") public class TableReportDAO extends PanacheEntityBase { - @JsonProperty(required = true) @Id @GeneratedValue public Integer id; - @JsonProperty(required = true) @OneToOne(fetch = FetchType.EAGER) @JoinColumn(name = "config_id") public TableReportConfigDAO config; - @Schema(required = true, type = SchemaType.NUMBER) @NotNull public Instant created; @@ -63,7 +57,6 @@ public class TableReportDAO extends PanacheEntityBase { @Fetch(FetchMode.SELECT) public Collection logs = new ArrayList<>(); - @Schema(name = "TableReportData") @Embeddable public static class Data { @NotNull diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/events/DatasetChanges.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/events/DatasetChanges.java index 12e769e39..976a581f2 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/events/DatasetChanges.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/events/DatasetChanges.java @@ -5,6 +5,8 @@ import java.util.List; import java.util.Objects; +import io.hyperfoil.tools.horreum.api.alerting.Change; +import io.hyperfoil.tools.horreum.api.data.DataSet; import io.hyperfoil.tools.horreum.entity.alerting.ChangeDAO; import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; @@ -12,23 +14,23 @@ public class DatasetChanges { public static final String EVENT_NEW = "datasetChanges/new"; private static final long EMIT_DELAY = 1000; - public DataSetDAO.Info dataset; + public DataSet.Info dataset; public String fingerprint; public String testName; private boolean notify; - private final List changes = new ArrayList<>(); + private final List changes = new ArrayList<>(); private long emitTimestamp = Long.MIN_VALUE; public DatasetChanges() {} - public DatasetChanges(DataSetDAO.Info dataset, String fingerprint, String testName, boolean notify) { + public DatasetChanges(DataSet.Info dataset, String fingerprint, String testName, boolean notify) { this.dataset = Objects.requireNonNull(dataset); this.fingerprint = fingerprint; this.testName = Objects.requireNonNull(testName); this.notify = notify; } - public synchronized void addChange(ChangeDAO.Event event) { + public synchronized void addChange(Change.Event event) { if (!event.dataset.equals(dataset) || !event.testName.equals(testName)) { throw new IllegalStateException(); } @@ -41,7 +43,7 @@ public boolean isNotify() { return notify; } - public List changes() { + public List changes() { return Collections.unmodifiableList(changes); } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ChangeMapper.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ChangeMapper.java index e0c432013..64b697fcc 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ChangeMapper.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ChangeMapper.java @@ -17,4 +17,16 @@ public static Change from(ChangeDAO c) { return dto; } + public static ChangeDAO to(Change c) { + ChangeDAO dao = new ChangeDAO(); + dao.id = c.id; + dao.variable = VariableMapper.to(c.variable); + dao.dataset = DataSetMapper.to(c.dataset, null); + + dao.timestamp = c.timestamp; + dao.confirmed = c.confirmed; + dao.description = c.description; + + return dao; + } } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/DataSetMapper.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/DataSetMapper.java index 563451025..9f9531fff 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/DataSetMapper.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/DataSetMapper.java @@ -29,7 +29,13 @@ public static DataSet from(DataSetDAO ds) { } public static DataSetDAO to(DataSet dto, RunDAO run) { - DataSetDAO ds = new DataSetDAO(run, dto.ordinal, dto.description, dto.data); + DataSetDAO ds; + if(run != null) { + ds = new DataSetDAO(run, dto.ordinal, dto.description, dto.data); + } + else { + ds = new DataSetDAO(); + } ds.id = dto.id; return ds; } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ViewMapper.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ViewMapper.java index d15cf93f9..22c761c20 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ViewMapper.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/mapper/ViewMapper.java @@ -18,7 +18,7 @@ public static View from(ViewDAO v) { return dto; } - public static io.hyperfoil.tools.horreum.api.data.ViewComponent fromViewComponent(ViewComponent vc) { + public static io.hyperfoil.tools.horreum.api.data.ViewComponent fromViewComponent(ViewComponentDAO vc) { io.hyperfoil.tools.horreum.api.data.ViewComponent dto = new io.hyperfoil.tools.horreum.api.data.ViewComponent(); dto.id = vc.id; dto.headerName = vc.headerName; @@ -43,8 +43,8 @@ public static ViewDAO to(View dto) { return v; } - private static ViewComponent toViewComponent(io.hyperfoil.tools.horreum.api.data.ViewComponent dto, ViewDAO view) { - ViewComponent vc = new ViewComponent(); + private static ViewComponentDAO toViewComponent(io.hyperfoil.tools.horreum.api.data.ViewComponent dto, ViewDAO view) { + ViewComponentDAO vc = new ViewComponentDAO(); vc.id = dto.id; vc.headerName = dto.headerName; vc.headerOrder = dto.headerOrder; 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 b444b4c48..2c2231be7 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 @@ -75,7 +75,7 @@ public void postConstruct(){ messageBus.subscribe(TestDAO.EVENT_NEW, "ActionService", TestDAO.class, this::onNewTest); messageBus.subscribe(TestDAO.EVENT_DELETED, "ActionService", TestDAO.class, this::onTestDelete); messageBus.subscribe(RunDAO.EVENT_NEW, "ActionService", RunDAO.class, this::onNewRun); - messageBus.subscribe(Change.EVENT_NEW, "ActionService", ChangeDAO.Event.class, this::onNewChange); + messageBus.subscribe(Change.EVENT_NEW, "ActionService", Change.Event.class, this::onNewChange); messageBus.subscribe(ExperimentService.ExperimentResult.NEW_RESULT, "ActionService", ExperimentService.ExperimentResult.class, this::onNewExperimentResult); } @@ -149,10 +149,10 @@ public void onNewRun(RunDAO run) { @WithRoles(extras = Roles.HORREUM_SYSTEM) @Transactional - public void onNewChange(ChangeDAO.Event changeEvent) { + public void onNewChange(Change.Event changeEvent) { int testId = em.createQuery("SELECT testid FROM run WHERE id = ?1", Integer.class) .setParameter(1, changeEvent.dataset.runId).getResultStream().findFirst().orElse(-1); - executeActions(ChangeDAO.EVENT_NEW, testId, changeEvent, changeEvent.notify); + executeActions(Change.EVENT_NEW, testId, changeEvent, changeEvent.notify); } void validate(Action action) { 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 057153a90..2deab18cd 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 @@ -652,8 +652,8 @@ private void runChangeDetection(VariableDAO variable, JsonNode fingerprint, bool em.persist(change); Hibernate.initialize(change.dataset.run.id); String testName = TestDAO.findByIdOptional(variable.testId).map(test -> test.name).orElse(""); - messageBus.publish(ChangeDAO.EVENT_NEW, change.dataset.testid, - new ChangeDAO.Event(change, testName, info, notify)); + messageBus.publish(Change.EVENT_NEW, change.dataset.testid, + new Change.Event(ChangeMapper.from(change), testName, DataSetMapper.fromInfo(info), notify)); }); } } diff --git a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/EventAggregator.java b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/EventAggregator.java index 20da8dab5..674495581 100644 --- a/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/EventAggregator.java +++ b/horreum-backend/src/main/java/io/hyperfoil/tools/horreum/svc/EventAggregator.java @@ -8,6 +8,7 @@ import javax.inject.Inject; import javax.transaction.Transactional; +import io.hyperfoil.tools.horreum.api.alerting.Change; import io.hyperfoil.tools.horreum.bus.MessageBus; import io.hyperfoil.tools.horreum.entity.alerting.ChangeDAO; import io.hyperfoil.tools.horreum.entity.data.DataSetDAO; @@ -31,12 +32,12 @@ public class EventAggregator { @PostConstruct void init() { - messageBus.subscribe(ChangeDAO.EVENT_NEW, "EventAggregator", ChangeDAO.Event.class, this::onNewChange); + messageBus.subscribe(Change.EVENT_NEW, "EventAggregator", Change.Event.class, this::onNewChange); } @WithRoles(extras = Roles.HORREUM_SYSTEM) @Transactional - public synchronized void onNewChange(ChangeDAO.Event event) { + public synchronized void onNewChange(Change.Event event) { datasetChanges.computeIfAbsent(event.dataset.id, id -> { String fingerprint = DataSetDAO.getEntityManager().getReference(DataSetDAO.class, event.dataset.id).getFingerprint(); return new DatasetChanges(event.dataset, fingerprint, event.testName, event.notify); diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/AlertingServiceTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/AlertingServiceTest.java index 22c7fda84..bfb1db16f 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/AlertingServiceTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/AlertingServiceTest.java @@ -21,6 +21,7 @@ import javax.inject.Inject; +import io.hyperfoil.tools.horreum.api.alerting.Change; import io.hyperfoil.tools.horreum.api.data.Extractor; import io.hyperfoil.tools.horreum.api.data.Label; import io.hyperfoil.tools.horreum.api.data.Schema; @@ -144,7 +145,7 @@ public void testChangeDetection(TestInfo info) throws InterruptedException { ChangeDetectionDAO cd = addChangeDetectionVariable(test); BlockingQueue datapointQueue = eventConsumerQueue(DataPointDAO.Event.class, DataPointDAO.EVENT_NEW, e -> e.testId == test.id); - BlockingQueue changeQueue = eventConsumerQueue(ChangeDAO.Event.class, ChangeDAO.EVENT_NEW, e -> e.dataset.testId == test.id); + BlockingQueue changeQueue = eventConsumerQueue(Change.Event.class, Change.EVENT_NEW, e -> e.dataset.testId == test.id); long ts = System.currentTimeMillis(); uploadRun(ts, ts, runWithValue(1, schema), test.name); @@ -161,11 +162,11 @@ public void testChangeDetection(TestInfo info) throws InterruptedException { uploadRun(ts + 4, ts + 4, runWithValue(3, schema), test.name); assertValue(datapointQueue, 3); - ChangeDAO.Event changeEvent1 = changeQueue.poll(10, TimeUnit.SECONDS); + Change.Event changeEvent1 = changeQueue.poll(10, TimeUnit.SECONDS); assertNotNull(changeEvent1); - testSerialization(changeEvent1, ChangeDAO.Event.class); + testSerialization(changeEvent1, Change.Event.class); // The change is detected already at run 4 because it's > than the previous mean - assertEquals(run4, changeEvent1.change.dataset.run.id); + assertEquals(run4, changeEvent1.change.dataset.runId); ((ObjectNode) cd.config).put("filter", "min"); setTestVariables(test, "Value", "value", cd); @@ -178,9 +179,9 @@ public void testChangeDetection(TestInfo info) throws InterruptedException { } // now we'll find a change already at run3 - ChangeDAO.Event changeEvent2 = changeQueue.poll(10, TimeUnit.SECONDS); + Change.Event changeEvent2 = changeQueue.poll(10, TimeUnit.SECONDS); assertNotNull(changeEvent2); - assertEquals(run3, changeEvent2.change.dataset.run.id); + assertEquals(run3, changeEvent2.change.dataset.runId); int run6 = uploadRun(ts + 5, ts + 5, runWithValue(1.5, schema), test.name); assertValue(datapointQueue, 1.5); @@ -192,9 +193,9 @@ public void testChangeDetection(TestInfo info) throws InterruptedException { assertValue(datapointQueue, 2); // mean of previous is 2, the last value doesn't matter (1.5 is lower than 2 - 10%) - ChangeDAO.Event changeEvent3 = changeQueue.poll(10, TimeUnit.SECONDS); + Change.Event changeEvent3 = changeQueue.poll(10, TimeUnit.SECONDS); assertNotNull(changeEvent3); - assertEquals(run6, changeEvent3.change.dataset.run.id); + assertEquals(run6, changeEvent3.change.dataset.runId); } private void testSerialization(T event, Class eventClass) { @@ -219,7 +220,7 @@ public void testChangeDetectionWithFingerprint(TestInfo info) throws Interrupted addChangeDetectionVariable(test); BlockingQueue datapointQueue = eventConsumerQueue(DataPointDAO.Event.class, DataPointDAO.EVENT_NEW, e -> e.testId == testId); - BlockingQueue changeQueue = eventConsumerQueue(ChangeDAO.Event.class, ChangeDAO.EVENT_NEW, e -> e.dataset.testId == testId); + BlockingQueue changeQueue = eventConsumerQueue(Change.Event.class, Change.EVENT_NEW, e -> e.dataset.testId == testId); long ts = System.currentTimeMillis(); for (int i = 0; i < 12; i += 3) { @@ -233,15 +234,15 @@ public void testChangeDetectionWithFingerprint(TestInfo info) throws Interrupted assertNull(changeQueue.poll(50, TimeUnit.MILLISECONDS)); int run13 = uploadRun(ts + 12, ts + 12, runWithValue(2, schema).put("config", "foo"), test.name); - ChangeDAO.Event changeEvent1 = changeQueue.poll(10, TimeUnit.SECONDS); + Change.Event changeEvent1 = changeQueue.poll(10, TimeUnit.SECONDS); assertNotNull(changeEvent1); - assertEquals(run13, changeEvent1.change.dataset.run.id); + assertEquals(run13, changeEvent1.change.dataset.runId); assertEquals(run13, changeEvent1.dataset.runId); int run14 = uploadRun(ts + 13, ts + 13, runWithValue(2, schema), test.name); - ChangeDAO.Event changeEvent2 = changeQueue.poll(10, TimeUnit.SECONDS); + Change.Event changeEvent2 = changeQueue.poll(10, TimeUnit.SECONDS); assertNotNull(changeEvent2); - assertEquals(run14, changeEvent2.change.dataset.run.id); + assertEquals(run14, changeEvent2.change.dataset.runId); assertEquals(run14, changeEvent2.dataset.runId); } @@ -603,7 +604,7 @@ public void testFixedThresholds(TestInfo info) throws InterruptedException { setTestVariables(test, "Value", "value", rd); BlockingQueue datapointQueue = eventConsumerQueue(DataPointDAO.Event.class, DataPointDAO.EVENT_NEW, e -> e.testId == test.id); - BlockingQueue changeQueue = eventConsumerQueue(ChangeDAO.Event.class, ChangeDAO.EVENT_NEW, e -> e.dataset.testId == test.id); + BlockingQueue changeQueue = eventConsumerQueue(Change.Event.class, Change.EVENT_NEW, e -> e.dataset.testId == test.id); long ts = System.currentTimeMillis(); uploadRun(ts, ts, runWithValue(4, schema), test.name); @@ -615,15 +616,15 @@ public void testFixedThresholds(TestInfo info) throws InterruptedException { int run3 = uploadRun(ts + 2, ts + 2, runWithValue(2, schema), test.name); assertValue(datapointQueue, 2); - ChangeDAO.Event changeEvent1 = changeQueue.poll(10, TimeUnit.SECONDS); + Change.Event changeEvent1 = changeQueue.poll(10, TimeUnit.SECONDS); assertNotNull(changeEvent1); - assertEquals(run3, changeEvent1.change.dataset.run.id); + assertEquals(run3, changeEvent1.change.dataset.runId); int run4 = uploadRun(ts + 3, ts + 3, runWithValue(6, schema), test.name); assertValue(datapointQueue, 6); - ChangeDAO.Event changeEvent2 = changeQueue.poll(10, TimeUnit.SECONDS); + Change.Event changeEvent2 = changeQueue.poll(10, TimeUnit.SECONDS); assertNotNull(changeEvent2); - assertEquals(run4, changeEvent2.change.dataset.run.id); + assertEquals(run4, changeEvent2.change.dataset.runId); } @org.junit.jupiter.api.Test @@ -710,7 +711,7 @@ public void testRandomOrder(TestInfo info) throws InterruptedException { setChangeDetectionTimeline(test, Collections.singletonList("timestamp"), null); BlockingQueue datapointQueue = eventConsumerQueue(DataPointDAO.Event.class, DataPointDAO.EVENT_NEW, e -> e.testId == test.id); - BlockingQueue changeQueue = eventConsumerQueue(ChangeDAO.Event.class, ChangeDAO.EVENT_NEW, e -> e.dataset.testId == test.id); + BlockingQueue changeQueue = eventConsumerQueue(Change.Event.class, Change.EVENT_NEW, e -> e.dataset.testId == test.id); int[] order = new int[] { 5, 0, 1, 7, 4, 8, 2, 3, 9, 6 }; double[] values = new double[] { 1, 2, 2, 2, 1, 1, 2, 1, 1, 2}; @@ -752,10 +753,10 @@ private void drainQueue(BlockingQueue datapointQueue, int ex } } - private void drainQueue(BlockingQueue changeQueue) throws InterruptedException { + private void drainQueue(BlockingQueue changeQueue) throws InterruptedException { // we don't know exactly how many changes are going to be created and deleted for (;;) { - ChangeDAO.Event changeEvent = changeQueue.poll(100, TimeUnit.MILLISECONDS); + Change.Event changeEvent = changeQueue.poll(100, TimeUnit.MILLISECONDS); if (changeEvent == null && TestUtil.isMessageBusEmpty(tm, em)) { return; } diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/BaseServiceTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/BaseServiceTest.java index 97548565d..f13c54768 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/BaseServiceTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/BaseServiceTest.java @@ -37,7 +37,7 @@ import io.hyperfoil.tools.horreum.api.data.Extractor; import io.hyperfoil.tools.horreum.entity.alerting.*; import io.hyperfoil.tools.horreum.entity.data.*; -import io.hyperfoil.tools.horreum.entity.data.ViewComponent; +import io.hyperfoil.tools.horreum.entity.data.ViewComponentDAO; import org.hibernate.query.NativeQuery; import org.jboss.logging.Logger; import org.junit.jupiter.api.AfterEach; @@ -156,7 +156,7 @@ protected void dropAllViewsAndTests() { Util.withTx(tm, () -> { try (CloseMe ignored = roleManager.withRoles(Stream.concat(Stream.of(TESTER_ROLES), Stream.of(Roles.HORREUM_SYSTEM, Roles.ADMIN)) .collect(Collectors.toList()))) { - ViewComponent.deleteAll(); + ViewComponentDAO.deleteAll(); ViewDAO.deleteAll(); em.createNativeQuery("DELETE FROM test_transformers").executeUpdate(); diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/DatasetServiceTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/DatasetServiceTest.java index 2936be1ad..59b9c28ba 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/DatasetServiceTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/DatasetServiceTest.java @@ -27,7 +27,7 @@ import io.hyperfoil.tools.horreum.api.data.*; import io.hyperfoil.tools.horreum.api.data.Extractor; import io.hyperfoil.tools.horreum.entity.data.*; -import io.hyperfoil.tools.horreum.entity.data.ViewComponent; +import io.hyperfoil.tools.horreum.entity.data.ViewComponentDAO; import io.hyperfoil.tools.horreum.mapper.LabelMapper; import io.hyperfoil.tools.horreum.api.services.DatasetService; import io.hyperfoil.tools.horreum.api.services.QueryResult; @@ -271,12 +271,12 @@ public void testDatasetView() { try (CloseMe ignored = roleManager.withRoles(Arrays.asList(TESTER_ROLES))) { ViewDAO view = ViewDAO.findById(test.views.iterator().next().id); view.components.clear(); - ViewComponent vc1 = new ViewComponent(); + ViewComponentDAO vc1 = new ViewComponentDAO(); vc1.view = view; vc1.headerName = "X"; vc1.labels = jsonArray("a"); view.components.add(vc1); - ViewComponent vc2 = new ViewComponent(); + ViewComponentDAO vc2 = new ViewComponentDAO(); vc2.view = view; vc2.headerName = "Y"; vc2.headerOrder = 1; diff --git a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/NotificationPluginTest.java b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/NotificationPluginTest.java index afb49eeb3..07839723f 100644 --- a/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/NotificationPluginTest.java +++ b/horreum-backend/src/test/java/io/hyperfoil/tools/horreum/svc/NotificationPluginTest.java @@ -9,6 +9,9 @@ import javax.enterprise.inject.Instance; import javax.inject.Inject; +import io.hyperfoil.tools.horreum.api.alerting.Change; +import io.hyperfoil.tools.horreum.api.alerting.Variable; +import io.hyperfoil.tools.horreum.api.data.DataSet; import io.hyperfoil.tools.horreum.test.HorreumTestProfile; import org.junit.jupiter.api.Test; @@ -32,20 +35,20 @@ public class NotificationPluginTest { @Test public void testDatasetChanges() { - DatasetChanges dc1 = new DatasetChanges(new DataSetDAO.Info(1, 1, 0, 1), null, "Dummy Test", true); - ChangeDAO c1 = new ChangeDAO(); + DatasetChanges dc1 = new DatasetChanges(new DataSet.Info(1, 1, 0, 1), null, "Dummy Test", true); + Change c1 = new Change(); c1.timestamp = Instant.now(); c1.description = "foobar"; - c1.variable = new VariableDAO(); + c1.variable = new Variable(); c1.variable.name = "some var"; - ChangeDAO c2 = new ChangeDAO(); + Change c2 = new Change(); c2.timestamp = Instant.now(); - c2.variable = new VariableDAO(); + c2.variable = new Variable(); c2.variable.group = "some group"; c2.variable.name = "another var"; - dc1.addChange(new ChangeDAO.Event(c1, dc1.testName, dc1.dataset, true)); - dc1.addChange(new ChangeDAO.Event(c2, dc1.testName, dc1.dataset, true)); + dc1.addChange(new Change.Event(c1, dc1.testName, dc1.dataset, true)); + dc1.addChange(new Change.Event(c2, dc1.testName, dc1.dataset, true)); withAllPlugins(notification -> notification.notifyChanges(dc1)); }