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