286 lines
6.7 KiB
Java
286 lines
6.7 KiB
Java
package eu.eudat.entities;
|
|
|
|
|
|
import java.io.Serializable;
|
|
import java.util.*;
|
|
|
|
import javax.persistence.*;
|
|
|
|
import org.hibernate.annotations.GenericGenerator;
|
|
import org.hibernate.annotations.Type;
|
|
|
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
|
|
|
|
|
@Entity
|
|
@Table(name = "\"DMP\"")
|
|
@NamedEntityGraphs({
|
|
@NamedEntityGraph(
|
|
name = "organisationsAndResearchers",
|
|
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}),
|
|
@NamedEntityGraph(
|
|
name = "fullyDetailed",
|
|
attributeNodes = {
|
|
@NamedAttributeNode("project"), @NamedAttributeNode("profile"),
|
|
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")})
|
|
})
|
|
public class DMP implements Serializable, DataEntity<DMP> {
|
|
|
|
public static Set<String> getHints() {
|
|
return hints;
|
|
}
|
|
|
|
private static final Set<String> hints = new HashSet<>(Arrays.asList("organisationsAndResearchers", "fullyDetailed"));
|
|
private static final long serialVersionUID = -8263056535208547615L;
|
|
|
|
|
|
@Id
|
|
@GeneratedValue
|
|
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
private UUID id;
|
|
|
|
@Type(type = "org.hibernate.type.PostgresUUIDType")
|
|
@Column(name = "\"Previous\"")
|
|
private UUID previous;
|
|
|
|
@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)
|
|
@JoinColumn(name = "\"Project\"")
|
|
private Project project;
|
|
|
|
|
|
@Type(type = "eu.eudat.typedefinition.XMLType")
|
|
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
|
|
private String associatedDmps;
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
|
@JoinColumn(name = "\"Profile\"")
|
|
private DMPProfile profile;
|
|
|
|
|
|
@ManyToOne(fetch = FetchType.EAGER)
|
|
@JoinColumn(name = "\"Creator\"")
|
|
private UserInfo creator;
|
|
|
|
|
|
@OneToMany(fetch = FetchType.LAZY)
|
|
@JoinTable(name = "\"DMPOrganisation\"",
|
|
joinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")},
|
|
inverseJoinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")}
|
|
)
|
|
private Set<Organisation> organisations;
|
|
|
|
|
|
@OneToMany(fetch = FetchType.LAZY)
|
|
@JoinTable(name = "\"DMPResearcher\"",
|
|
joinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")},
|
|
inverseJoinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")}
|
|
)
|
|
private Set<Researcher> researchers;
|
|
|
|
|
|
@OneToMany(fetch = FetchType.LAZY)
|
|
@JoinTable(name = "\"UserDMP\"",
|
|
joinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")},
|
|
inverseJoinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")}
|
|
)
|
|
private Set<UserInfo> users;
|
|
|
|
|
|
@Column(name = "\"Status\"", nullable = false)
|
|
private Short status;
|
|
|
|
|
|
@Column(name = "\"Created\"")
|
|
private Date created = null;
|
|
|
|
@Column(name = "\"Modified\"")
|
|
private Date modified = new Date();
|
|
|
|
|
|
@Column(name = "\"Description\"")
|
|
private String description;
|
|
|
|
|
|
public String getDescription() {
|
|
return description;
|
|
}
|
|
|
|
|
|
public void setDescription(String description) {
|
|
this.description = description;
|
|
}
|
|
|
|
|
|
public UserInfo getCreator() {
|
|
return creator;
|
|
}
|
|
|
|
|
|
public void setCreator(UserInfo creator) {
|
|
this.creator = creator;
|
|
}
|
|
|
|
|
|
public Short getStatus() {
|
|
return status;
|
|
}
|
|
|
|
|
|
public void setStatus(Short status) {
|
|
this.status = status;
|
|
}
|
|
|
|
|
|
public Date getCreated() {
|
|
return created;
|
|
}
|
|
|
|
|
|
public void setCreated(Date created) {
|
|
this.created = created;
|
|
}
|
|
|
|
|
|
public Date getModified() {
|
|
return modified;
|
|
}
|
|
|
|
|
|
public void setModified(Date modified) {
|
|
this.modified = modified;
|
|
}
|
|
|
|
|
|
public Set<UserInfo> getUsers() {
|
|
return users;
|
|
}
|
|
|
|
public void setUsers(Set<UserInfo> users) {
|
|
this.users = users;
|
|
}
|
|
|
|
|
|
public UUID getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(UUID id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public UUID getPrevious() {
|
|
return previous;
|
|
}
|
|
|
|
public void setPrevious(UUID previous) {
|
|
this.previous = previous;
|
|
}
|
|
|
|
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) {
|
|
this.setAssociatedDmps(entity.associatedDmps);
|
|
this.label = entity.getLabel();
|
|
this.status = entity.getStatus();
|
|
this.created = entity.created;
|
|
this.description = entity.getDescription();
|
|
this.researchers = entity.getResearchers();
|
|
this.organisations = entity.getOrganisations();
|
|
if (entity.getUsers() != null) this.users = entity.getUsers();
|
|
}
|
|
|
|
@Override
|
|
public Object[] getKeys() {
|
|
return new UUID[]{this.id == null ? null : this.id};
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
public String toString() {
|
|
try {
|
|
return new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).writeValueAsString(this);
|
|
} catch (JsonProcessingException e) {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
*/
|
|
|
|
}
|