argos/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMPProfile.java

125 lines
2.7 KiB
Java
Raw Normal View History

2018-03-21 11:57:56 +01:00
package eu.eudat.data.entities;
2018-10-02 16:33:58 +02:00
import eu.eudat.data.converters.DateToUTCConverter;
2018-03-28 15:24:47 +02:00
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
2018-02-16 11:34:02 +01:00
import javax.persistence.*;
import java.util.Date;
2018-10-02 16:33:58 +02:00
import java.util.List;
2018-02-16 11:34:02 +01:00
import java.util.Set;
import java.util.UUID;
@Entity
2018-02-16 11:34:02 +01:00
@Table(name = "\"DMPProfile\"")
2018-03-28 15:24:47 +02:00
public class DMPProfile implements DataEntity<DMPProfile, UUID> {
2018-02-16 11:34:02 +01:00
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
2018-02-16 11:34:02 +01:00
private UUID id;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "profile")
private Set<DMP> dmps;
@Column(name = "\"Label\"")
2018-02-16 11:34:02 +01:00
private String label;
2018-06-27 12:29:21 +02:00
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
2018-02-16 11:34:02 +01:00
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@Column(name = "\"Status\"", nullable = false)
2018-03-28 15:24:47 +02:00
private int status;
2018-02-16 11:34:02 +01:00
@Column(name = "\"Created\"")
2018-10-02 16:33:58 +02:00
@Convert(converter = DateToUTCConverter.class)
2018-02-16 11:34:02 +01:00
private Date created = null;
@Column(name = "\"Modified\"")
2018-10-02 16:33:58 +02:00
@Convert(converter = DateToUTCConverter.class)
2018-02-16 11:34:02 +01:00
private Date modified = new Date();
2018-03-28 15:24:47 +02:00
public int getStatus() {
2018-02-16 11:34:02 +01:00
return status;
}
2018-03-28 15:24:47 +02:00
public void setStatus(int status) {
2018-02-16 11:34:02 +01:00
this.status = status;
}
2018-02-16 11:34:02 +01:00
public Date getCreated() {
return created;
}
2018-02-16 11:34:02 +01:00
public void setCreated(Date created) {
this.created = created;
}
2018-02-16 11:34:02 +01:00
public Date getModified() {
return modified;
}
2018-02-16 11:34:02 +01:00
public void setModified(Date modified) {
this.modified = modified;
}
2018-02-16 11:34:02 +01:00
public UUID getId() {
return id;
}
2018-02-16 11:34:02 +01:00
public void setId(UUID id) {
this.id = id;
}
2018-02-16 11:34:02 +01:00
public String getLabel() {
return label;
}
2018-02-16 11:34:02 +01:00
public void setLabel(String label) {
this.label = label;
}
2018-02-16 11:34:02 +01:00
public String getDefinition() {
return definition;
}
2018-02-16 11:34:02 +01:00
public void setDefinition(String definition) {
this.definition = definition;
}
2018-02-16 11:34:02 +01:00
public Set<DMP> getDmps() {
return dmps;
}
2018-02-16 11:34:02 +01:00
public void setDmps(Set<DMP> dmps) {
this.dmps = dmps;
}
2018-03-28 15:24:47 +02:00
@Override
public void update(DMPProfile entity) {
this.modified = new Date();
this.definition = entity.getDefinition();
this.label = entity.getLabel();
}
2018-03-28 15:24:47 +02:00
@Override
public UUID getKeys() {
return this.id;
}
2018-10-02 16:33:58 +02:00
@Override
public DMPProfile buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
}