Commit f644e7d3 authored by Matija Obreza's avatar Matija Obreza
Browse files

KPI entities are SelfCleaning

- String properties trimmed to null
parent 3e8083ff
......@@ -24,6 +24,8 @@ import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
......@@ -31,6 +33,7 @@ import javax.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonView;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.model.JsonViews;
import org.genesys.blocks.model.SelfCleaning;
import org.genesys2.server.model.genesys.Parameter;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
......@@ -52,7 +55,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
@DiscriminatorColumn(name = "className", discriminatorType = DiscriminatorType.STRING, length = 100)
@Table(name = "kpidimension")
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "_fullClass")
public abstract class Dimension<T> extends AuditedVersionedModel {
public abstract class Dimension<T> extends AuditedVersionedModel implements SelfCleaning {
/**
*
......@@ -69,6 +72,12 @@ public abstract class Dimension<T> extends AuditedVersionedModel {
@Column(length = 100, unique = true, nullable = false)
private String title;
@PrePersist
@PreUpdate
private void preupdate() {
trimStringsToNull();
}
final public String getName() {
return name;
}
......
......@@ -26,11 +26,14 @@ import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.model.SelfCleaning;
import com.fasterxml.jackson.annotation.JsonIgnore;
......@@ -42,7 +45,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
*/
@Entity
@Table(name = "kpiexecution")
public class Execution extends AuditedVersionedModel {
public class Execution extends AuditedVersionedModel implements SelfCleaning {
/**
*
......@@ -65,7 +68,7 @@ public class Execution extends AuditedVersionedModel {
* This specifies the "key" under which observations are filed
*/
@NotNull
@Size(max = 100)
@Size(min = 1, max = 100)
@Column(length = 100, unique = true, nullable = false)
private String name;
......@@ -96,6 +99,12 @@ public class Execution extends AuditedVersionedModel {
@OneToMany(mappedBy="execution", orphanRemoval = true, fetch = FetchType.LAZY, cascade = { CascadeType.REMOVE })
private List<ExecutionRun> runs;
@PrePersist
@PreUpdate
private void preupdate() {
trimStringsToNull();
}
public String getName() {
return name;
}
......
......@@ -20,15 +20,19 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.genesys.blocks.model.BasicModel;
import org.genesys.blocks.model.SelfCleaning;
@Entity
@Table(name = "kpiexecutiondimension")
public class ExecutionDimension extends BasicModel {
public class ExecutionDimension extends BasicModel implements SelfCleaning {
/**
*
......@@ -42,14 +46,22 @@ public class ExecutionDimension extends BasicModel {
/** Linked entity from the Parameter to inner join directly (e.g. accession.institute) **/
@Size(max=100)
@Pattern(regexp = "[a-z][a-zA-Z0-9_\\.\\(\\)]*")
@Column(length = 100, nullable = true)
private String link;
/** Field in the Parameter (e.g. accession.instCode) or Linked entity ({@link #link} (e.g. accession.institute.code) **/
@Size(max=100)
@Pattern(regexp = "[_a-z][a-zA-Z0-9_\\.\\(\\)]*")
@Column(length = 100, nullable = false)
private String field;
@PrePersist
@PreUpdate
private void preupdate() {
trimStringsToNull();
}
public void setDimension(Dimension<?> dimension) {
this.dimension = dimension;
}
......
......@@ -19,12 +19,16 @@ package org.genesys2.server.model.kpi;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.model.SelfCleaning;
import org.hibernate.annotations.Type;
/**
......@@ -44,7 +48,7 @@ import org.hibernate.annotations.Type;
*/
@Entity
@Table(name = "kpiparameter", uniqueConstraints = { @UniqueConstraint(name = "UQ_kpiparameter_name", columnNames = { "name" }) })
public class KPIParameter extends AuditedVersionedModel {
public class KPIParameter extends AuditedVersionedModel implements SelfCleaning {
/**
*
......@@ -62,6 +66,7 @@ public class KPIParameter extends AuditedVersionedModel {
private String title;
@NotNull
@Pattern(regexp = "[a-z][a-zA-Z0-9_]*")
@Size(max = 100)
@Column(length = 100, nullable = false)
private String entity;
......@@ -74,6 +79,12 @@ public class KPIParameter extends AuditedVersionedModel {
@Type(type = "org.hibernate.type.TextType")
private String description;
@PrePersist
@PreUpdate
private void preupdate() {
trimStringsToNull();
}
public String getName() {
return name;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment