Skip to content

Commit

Permalink
removed json properties on DAO objects, MessageBus now use Change.Event
Browse files Browse the repository at this point in the history
  • Loading branch information
stalep authored and jesperpedersen committed Aug 15, 2023
1 parent 0fd8509 commit efcfa75
Show file tree
Hide file tree
Showing 41 changed files with 99 additions and 238 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,7 +17,6 @@ public class ExperimentComparison {
@NotNull
@ManyToOne(optional = false, fetch = FetchType.LAZY)
@JoinColumn(name = "variable_id")
@JsonIgnore
public VariableDAO variable;

@NotNull
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,7 +31,6 @@
@Entity(name = "ExperimentProfile")
@Table(name = "experiment_profile")
public class ExperimentProfileDAO extends PanacheEntityBase {
@JsonProperty(required = true)
@Id
@GenericGenerator(
name = "experimentProfileIdGenerator",
Expand All @@ -52,33 +48,28 @@ 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;

@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;

@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<ExperimentComparison> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

import org.jboss.logging.Logger;

import com.fasterxml.jackson.annotation.JsonProperty;

import io.quarkus.hibernate.orm.panache.PanacheEntityBase;

@MappedSuperclass
Expand All @@ -21,15 +19,13 @@ 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;

@NotNull
public int level;

@JsonProperty(required = true)
@NotNull
@Column(columnDefinition = "timestamp")
public Instant timestamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,23 @@

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;

@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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand All @@ -40,7 +36,6 @@ public class ChangeDAO extends PanacheEntityBase {

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "dataset_id")
@JsonIgnore
public DataSetDAO dataset;

@NotNull
Expand All @@ -52,7 +47,6 @@ public class ChangeDAO extends PanacheEntityBase {

public String description;

@JsonProperty("dataset")
public DataSetDAO.Info getDatasetId() {
if (dataset != null) {
return dataset.getInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -46,7 +44,6 @@ public class ChangeDetectionDAO extends PanacheEntityBase {

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "variable_id")
@JsonIgnore
public VariableDAO variable;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -36,7 +33,6 @@ public class DataPointDAO extends PanacheEntityBase {

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "dataset_id")
@JsonIgnore
public DataSetDAO dataset;

@NotNull
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -33,7 +31,6 @@
@Entity(name = "MissingDataRule")
@Table(name = "missingdata_rule")
public class MissingDataRuleDAO extends PanacheEntityBase {
@JsonProperty(required = true)
@Id
@GenericGenerator(
name = "mdrIdGenerator",
Expand All @@ -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")
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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() {
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,8 +31,8 @@
*
*/
@Entity(name = "variable")
@JsonIgnoreType
public class VariableDAO extends PanacheEntityBase {
@JsonProperty(required = true)
@Id
@GenericGenerator(
name = "variableIdGenerator",
Expand Down Expand Up @@ -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<ChangeDetectionDAO> changeDetection;

Expand Down
Loading

0 comments on commit efcfa75

Please sign in to comment.