2017-12-15 00:01:26 +01:00
|
|
|
package eu.eudat.entities;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
import org.hibernate.annotations.GenericGenerator;
|
|
|
|
import org.hibernate.annotations.Type;
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
import javax.persistence.*;
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.*;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
@Entity
|
2018-01-11 17:19:15 +01:00
|
|
|
@Table(name = "\"DMP\"")
|
2018-01-02 09:36:40 +01:00
|
|
|
@NamedEntityGraphs({
|
2018-01-11 17:19:15 +01:00
|
|
|
@NamedEntityGraph(
|
2018-01-19 10:31:05 +01:00
|
|
|
name = "dataManagementPlanListingModel",
|
|
|
|
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"),
|
2018-02-07 10:56:30 +01:00
|
|
|
@NamedAttributeNode("project"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")}
|
2018-01-19 10:31:05 +01:00
|
|
|
),
|
2018-01-11 17:19:15 +01:00
|
|
|
@NamedEntityGraph(
|
|
|
|
name = "fullyDetailed",
|
|
|
|
attributeNodes = {
|
|
|
|
@NamedAttributeNode("project"), @NamedAttributeNode("profile"),
|
|
|
|
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")})
|
2018-01-02 09:36:40 +01:00
|
|
|
})
|
2018-02-20 08:50:17 +01:00
|
|
|
public class DMP implements DataEntity<DMP,UUID> {
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-02-07 10:56:30 +01:00
|
|
|
public enum DMPStatus {
|
|
|
|
ACTIVE((short) 0), DELETED((short) 1);
|
|
|
|
|
|
|
|
private short value;
|
|
|
|
|
|
|
|
private DMPStatus(short value) {
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public short getValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static DMPStatus fromInteger(short value) {
|
|
|
|
switch (value) {
|
|
|
|
case 0:
|
|
|
|
return ACTIVE;
|
|
|
|
case 1:
|
|
|
|
return DELETED;
|
|
|
|
default:
|
|
|
|
throw new RuntimeException("Unsupported DMP Status");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public static Set<String> getHints() {
|
|
|
|
return hints;
|
|
|
|
}
|
2018-01-02 09:36:40 +01:00
|
|
|
|
2018-01-19 10:31:05 +01:00
|
|
|
private static final Set<String> hints = new HashSet<>(Arrays.asList("dataManagementPlanListingModel", "fullyDetailed"));
|
2018-01-11 17:19:15 +01:00
|
|
|
|
|
|
|
@Id
|
|
|
|
@GeneratedValue
|
2017-09-14 12:37:36 +02:00
|
|
|
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
|
|
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
2018-01-11 17:19:15 +01:00
|
|
|
private UUID id;
|
|
|
|
|
2018-02-08 09:42:02 +01:00
|
|
|
@Column(name = "\"GroupId\"", columnDefinition = "BINARY(16)")
|
|
|
|
private UUID groupId;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
@Column(name = "\"Label\"")
|
|
|
|
private String label;
|
|
|
|
|
|
|
|
@Column(name = "\"Version\"")
|
|
|
|
private Integer version;
|
|
|
|
|
|
|
|
@OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
|
|
|
|
private Set<Dataset> dataset;
|
|
|
|
|
|
|
|
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
2017-09-14 12:37:36 +02:00
|
|
|
@JoinColumn(name = "\"Project\"")
|
2018-01-11 17:19:15 +01:00
|
|
|
private Project project;
|
|
|
|
|
|
|
|
|
|
|
|
@Type(type = "eu.eudat.typedefinition.XMLType")
|
|
|
|
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
|
|
|
|
private String associatedDmps;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
2017-09-14 12:37:36 +02:00
|
|
|
@JoinColumn(name = "\"Profile\"")
|
2018-01-11 17:19:15 +01:00
|
|
|
private DMPProfile profile;
|
|
|
|
|
|
|
|
|
2017-11-17 20:03:17 +01:00
|
|
|
@ManyToOne(fetch = FetchType.EAGER)
|
|
|
|
@JoinColumn(name = "\"Creator\"")
|
2018-01-11 17:19:15 +01:00
|
|
|
private UserInfo creator;
|
|
|
|
|
|
|
|
|
|
|
|
@OneToMany(fetch = FetchType.LAZY)
|
|
|
|
@JoinTable(name = "\"DMPOrganisation\"",
|
|
|
|
joinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")},
|
|
|
|
inverseJoinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")}
|
|
|
|
)
|
2017-09-14 12:37:36 +02:00
|
|
|
private Set<Organisation> organisations;
|
2018-01-11 17:19:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
@OneToMany(fetch = FetchType.LAZY)
|
|
|
|
@JoinTable(name = "\"DMPResearcher\"",
|
|
|
|
joinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")},
|
|
|
|
inverseJoinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")}
|
|
|
|
)
|
2017-09-14 12:37:36 +02:00
|
|
|
private Set<Researcher> researchers;
|
2018-01-11 17:19:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
@OneToMany(fetch = FetchType.LAZY)
|
|
|
|
@JoinTable(name = "\"UserDMP\"",
|
|
|
|
joinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")},
|
|
|
|
inverseJoinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")}
|
2017-10-27 12:52:12 +02:00
|
|
|
)
|
|
|
|
private Set<UserInfo> users;
|
2017-11-07 13:20:13 +01:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
@Column(name = "\"Status\"", nullable = false)
|
|
|
|
private Short status;
|
2017-11-17 01:43:16 +01:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
@Column(name = "\"Created\"")
|
|
|
|
private Date created = null;
|
2017-11-17 01:43:16 +01:00
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
@Column(name = "\"Modified\"")
|
|
|
|
private Date modified = new Date();
|
2017-11-17 01:43:16 +01:00
|
|
|
|
2017-11-02 17:17:56 +01:00
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
@Column(name = "\"Description\"")
|
|
|
|
private String description;
|
2017-11-02 17:17:56 +01:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public String getDescription() {
|
|
|
|
return description;
|
|
|
|
}
|
2017-11-02 17:17:56 +01:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public void setDescription(String description) {
|
|
|
|
this.description = description;
|
|
|
|
}
|
2017-11-02 17:17:56 +01:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public UserInfo getCreator() {
|
|
|
|
return creator;
|
|
|
|
}
|
2017-11-02 17:17:56 +01:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public void setCreator(UserInfo creator) {
|
|
|
|
this.creator = creator;
|
|
|
|
}
|
2017-11-02 17:17:56 +01:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public Short getStatus() {
|
|
|
|
return status;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public void setStatus(Short status) {
|
|
|
|
this.status = status;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public Date getCreated() {
|
|
|
|
return created;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public void setCreated(Date created) {
|
|
|
|
this.created = created;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public Date getModified() {
|
|
|
|
return modified;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public void setModified(Date modified) {
|
|
|
|
this.modified = modified;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public Set<UserInfo> getUsers() {
|
|
|
|
return users;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public void setUsers(Set<UserInfo> users) {
|
|
|
|
this.users = users;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public UUID getId() {
|
|
|
|
return id;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public void setId(UUID id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-02-08 09:42:02 +01:00
|
|
|
public UUID getGroupId() {
|
|
|
|
return groupId;
|
2018-01-11 17:19:15 +01:00
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-02-08 09:42:02 +01:00
|
|
|
public void setGroupId(UUID groupId) {
|
|
|
|
this.groupId = groupId;
|
2018-01-11 17:19:15 +01:00
|
|
|
}
|
2017-12-17 22:34:24 +01:00
|
|
|
|
2018-01-11 17:19:15 +01:00
|
|
|
public String getLabel() {
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLabel(String label) {
|
|
|
|
this.label = label;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Integer getVersion() {
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setVersion(Integer version) {
|
|
|
|
this.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Project getProject() {
|
|
|
|
return project;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setProject(Project project) {
|
|
|
|
this.project = project;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getAssociatedDmps() {
|
|
|
|
return associatedDmps;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setAssociatedDmps(String associatedDmps) {
|
|
|
|
this.associatedDmps = associatedDmps;
|
|
|
|
}
|
|
|
|
|
|
|
|
public DMPProfile getProfile() {
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setProfile(DMPProfile profile) {
|
|
|
|
this.profile = profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<Dataset> getDataset() {
|
|
|
|
return dataset;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDataset(Set<Dataset> dataset) {
|
|
|
|
this.dataset = dataset;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<Organisation> getOrganisations() {
|
|
|
|
return organisations;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOrganisations(Set<Organisation> organisations) {
|
|
|
|
this.organisations = organisations;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<Researcher> getResearchers() {
|
|
|
|
return researchers;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setResearchers(Set<Researcher> researchers) {
|
|
|
|
this.researchers = researchers;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void update(DMP entity) {
|
2018-02-16 11:34:02 +01:00
|
|
|
this.associatedDmps = entity.associatedDmps;
|
2018-01-11 17:19:15 +01:00
|
|
|
this.label = entity.getLabel();
|
|
|
|
this.status = entity.getStatus();
|
|
|
|
this.created = entity.created;
|
2018-02-02 17:21:46 +01:00
|
|
|
this.project = entity.getProject();
|
2018-01-11 17:19:15 +01:00
|
|
|
this.description = entity.getDescription();
|
|
|
|
this.researchers = entity.getResearchers();
|
|
|
|
this.organisations = entity.getOrganisations();
|
|
|
|
if (entity.getUsers() != null) this.users = entity.getUsers();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-02-20 08:50:17 +01:00
|
|
|
public UUID getKeys() {
|
|
|
|
return this.id;
|
2018-01-11 17:19:15 +01:00
|
|
|
}
|
2017-12-17 22:34:24 +01:00
|
|
|
|
2017-09-14 12:37:36 +02:00
|
|
|
}
|