Refactors the way queries are generated

This commit is contained in:
ikalyvas 2019-05-21 18:17:41 +03:00
parent d15cbd6d9e
commit fd30cc9a94
38 changed files with 2863 additions and 2113 deletions

View File

@ -1,5 +1,6 @@
package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
@ -14,140 +15,141 @@ import java.util.UUID;
@Table(name = "\"Content\"")
public class Content implements DataEntity<Content, UUID> {
public enum ParentType {
PROJECT(0);
public enum ParentType {
PROJECT(0);
private int value;
private int value;
private ParentType(int value) {
this.value = value;
}
private ParentType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public int getValue() {
return value;
}
public static ParentType fromInteger(int value) {
switch (value) {
case 0:
return PROJECT;
default:
throw new RuntimeException("Unsupported Content Parent Type Status");
}
}
}
public static ParentType fromInteger(int value) {
switch (value) {
case 0:
return PROJECT;
default:
throw new RuntimeException("Unsupported Content Parent Type Status");
}
}
}
public enum LocationType {
EXTERNAL(0), INTERNAL(1);
public enum LocationType {
EXTERNAL(0), INTERNAL(1);
private Integer value;
private Integer value;
private LocationType(Integer value) {
this.value = value;
}
private LocationType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public Integer getValue() {
return value;
}
public static LocationType fromInteger(int value) {
switch (value) {
case 0:
return EXTERNAL;
case 1:
return INTERNAL;
default:
throw new RuntimeException("Unsupported Content Location Type");
}
}
}
public static LocationType fromInteger(int value) {
switch (value) {
case 0:
return EXTERNAL;
case 1:
return INTERNAL;
default:
throw new RuntimeException("Unsupported Content Location Type");
}
}
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Filename\"", nullable = false)
private String label;
@Column(name = "\"Filename\"", nullable = false)
private String label;
@Column(name = "\"Extension\"", nullable = false)
private String extension;
@Column(name = "\"Extension\"", nullable = false)
private String extension;
@Column(name = "\"ParentType\"", nullable = false)
private Integer parentType;
@Column(name = "\"ParentType\"", nullable = false)
private Integer parentType;
@Column(name = "\"Uri\"", nullable = false)
private String uri;
@Column(name = "\"Uri\"", nullable = false)
private String uri;
@Column(name = "\"LocationType\"", nullable = false)
private Integer locationType;
@Column(name = "\"LocationType\"", nullable = false)
private Integer locationType;
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setLabel(String label) {
this.label = label;
}
public String getExtension() {
return extension;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public Integer getParentType() {
return parentType;
}
public Integer getParentType() {
return parentType;
}
public void setParentType(Integer parentType) {
this.parentType = parentType;
}
public void setParentType(Integer parentType) {
this.parentType = parentType;
}
public String getUri() {
return uri;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public Integer getLocationType() {
return locationType;
}
public Integer getLocationType() {
return locationType;
}
public void setLocationType(Integer locationType) {
this.locationType = locationType;
}
public void setLocationType(Integer locationType) {
this.locationType = locationType;
}
@Override
public void update(Content entity) {
this.extension = entity.getExtension();
this.label = entity.getLabel();
this.locationType = entity.getLocationType();
this.parentType = entity.getParentType();
this.uri = entity.getUri();
}
@Override
public void update(Content entity) {
this.extension = entity.getExtension();
this.label = entity.getLabel();
this.locationType = entity.getLocationType();
this.parentType = entity.getParentType();
this.uri = entity.getUri();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Content buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public Content buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import javax.persistence.*;
@ -12,144 +13,145 @@ import java.util.UUID;
@Entity
@Table(name = "\"Credential\"")
@NamedEntityGraphs({
@NamedEntityGraph(
name = "credentialUserInfo",
attributeNodes = {@NamedAttributeNode("userInfo")})
@NamedEntityGraph(
name = "credentialUserInfo",
attributeNodes = {@NamedAttributeNode("userInfo")})
})
public class Credential implements DataEntity<Credential,UUID> {
public class Credential implements DataEntity<Credential, UUID> {
@Id
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@ManyToOne
@JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo userInfo;
@ManyToOne
@JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo userInfo;
@Column(name = "\"Status\"", nullable = false)
private Integer status;
@Column(name = "\"Status\"", nullable = false)
private Integer status;
@Column(name = "\"Provider\"", nullable = false)
private Integer provider;
@Column(name = "\"Public\"", nullable = false)
private String publicValue;
@Column(name = "\"Secret\"", nullable = false)
private String secret;
@Column(name = "\"Provider\"", nullable = false)
private Integer provider;
@Column(name = "\"Public\"", nullable = false)
private String publicValue;
@Column(name = "\"Secret\"", nullable = false)
private String secret;
@Column(name = "\"CreationTime\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date creationTime;
@Column(name = "\"CreationTime\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date creationTime;
@Column(name = "\"LastUpdateTime\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date lastUpdateTime;
@Column(name = "\"LastUpdateTime\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date lastUpdateTime;
@Column(name = "\"ExternalId\"", nullable = false)
private String externalId;
@Column(name = "\"ExternalId\"", nullable = false)
private String externalId;
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public UserInfo getUserInfo() {
return userInfo;
}
public UserInfo getUserInfo() {
return userInfo;
}
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
public Integer getStatus() {
return status;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public void setStatus(Integer status) {
this.status = status;
}
public Integer getProvider() {
return provider;
}
public Integer getProvider() {
return provider;
}
public void setProvider(Integer provider) {
this.provider = provider;
}
public void setProvider(Integer provider) {
this.provider = provider;
}
public String getPublicValue() {
return publicValue;
}
public String getPublicValue() {
return publicValue;
}
public void setPublicValue(String publicValue) {
this.publicValue = publicValue;
}
public void setPublicValue(String publicValue) {
this.publicValue = publicValue;
}
public String getSecret() {
return secret;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public Date getCreationTime() {
return creationTime;
}
public Date getCreationTime() {
return creationTime;
}
public void setCreationTime(Date creationTime) {
this.creationTime = creationTime;
}
public void setCreationTime(Date creationTime) {
this.creationTime = creationTime;
}
public Date getLastUpdateTime() {
return lastUpdateTime;
}
public Date getLastUpdateTime() {
return lastUpdateTime;
}
public void setLastUpdateTime(Date lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public void setLastUpdateTime(Date lastUpdateTime) {
this.lastUpdateTime = lastUpdateTime;
}
public String getExternalId() {
return externalId;
}
public String getExternalId() {
return externalId;
}
public void setExternalId(String externalId) {
this.externalId = externalId;
}
public void setExternalId(String externalId) {
this.externalId = externalId;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Credential that = (Credential) o;
Credential that = (Credential) o;
return provider.intValue() == that.provider.intValue();
}
return provider.intValue() == that.provider.intValue();
}
@Override
public int hashCode() {
return provider.intValue();
}
@Override
public int hashCode() {
return provider.intValue();
}
@Override
public void update(Credential entity) {
this.status = entity.status;
this.publicValue = entity.getPublicValue();
this.secret = entity.getSecret();
this.lastUpdateTime = new Date();
}
@Override
public void update(Credential entity) {
this.status = entity.status;
this.publicValue = entity.getPublicValue();
this.secret = entity.getSecret();
this.lastUpdateTime = new Date();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Credential buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public Credential buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -2,6 +2,7 @@ package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -14,297 +15,317 @@ import java.util.stream.Collectors;
@Entity
@Table(name = "\"DMP\"")
@NamedEntityGraphs({
@NamedEntityGraph(
name = "dataManagementPlanListingModel",
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"),
@NamedAttributeNode("project"), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")},
subgraphs = {
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
}
),
@NamedEntityGraph(
name = "fullyDetailed",
attributeNodes = {
@NamedAttributeNode("project"), @NamedAttributeNode("profile"),
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}),
@NamedEntityGraph(
name = "dmpRecentActivity",
attributeNodes = {
@NamedAttributeNode("users"), @NamedAttributeNode("creator")})
@NamedEntityGraph(
name = "dataManagementPlanListingModel",
attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"),
@NamedAttributeNode("project"), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode("dataset")},
subgraphs = {
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
}
),
@NamedEntityGraph(
name = "fullyDetailed",
attributeNodes = {
@NamedAttributeNode("project"), @NamedAttributeNode("profile"),
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")}),
@NamedEntityGraph(
name = "dmpRecentActivity",
attributeNodes = {
@NamedAttributeNode("users"), @NamedAttributeNode("creator")})
})
public class DMP implements DataEntity<DMP, UUID> {
public enum DMPStatus {
ACTIVE((short) 0), FINALISED((short) 1),DELETED((short) 99);
public enum DMPStatus {
ACTIVE((short) 0), FINALISED((short) 1), DELETED((short) 99);
private short value;
private short value;
private DMPStatus(short value) {
this.value = value;
}
private DMPStatus(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public short getValue() {
return value;
}
public static DMPStatus fromInteger(short value) {
switch (value) {
case 0:
return ACTIVE;
case 1:
return FINALISED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported DMP Status");
}
}
}
public static DMPStatus fromInteger(short value) {
switch (value) {
case 0:
return ACTIVE;
case 1:
return FINALISED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported DMP Status");
}
}
}
public static Set<String> getHints() {
return hints;
}
public static Set<String> getHints() {
return hints;
}
private static final Set<String> hints = new HashSet<>(Arrays.asList("dataManagementPlanListingModel", "fullyDetailed"));
private static final Set<String> hints = new HashSet<>(Arrays.asList("dataManagementPlanListingModel", "fullyDetailed"));
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"GroupId\"", columnDefinition = "BINARY(16)")
private UUID groupId;
@Column(name = "\"GroupId\"", columnDefinition = "BINARY(16)")
private UUID groupId;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Version\"")
private Integer version;
@Column(name = "\"Version\"")
private Integer version;
@OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
private Set<Dataset> dataset;
@OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
private Set<Dataset> dataset;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Project\"")
private Project project;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Project\"")
private Project project;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
private String associatedDmps;
@Type(type = "eu.eudat.configurations.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.LAZY)
@JoinColumn(name = "\"Profile\"")
private DMPProfile profile;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Creator\"")
private UserInfo creator;
@ManyToOne(fetch = FetchType.LAZY)
@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 = "\"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 = "\"DMPResearcher\"",
joinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")}
)
private Set<Researcher> researchers;
@OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
@OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
/*@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"UserDMP\"",
joinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")}
)*/
private Set<UserDMP> users;
private Set<UserDMP> users;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Properties\"")
private String properties;
@Column(name = "\"Properties\"")
private String properties;
@Column(name = "\"DmpProperties\"")
private String dmpProperties;
@Column(name = "\"DmpProperties\"")
private String dmpProperties;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
@Column(name = "\"Description\"")
private String description;
@Column(name = "\"Description\"")
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public UserInfo getCreator() {
return creator;
}
public void setCreator(UserInfo creator) {
this.creator = creator;
}
public void setDescription(String description) {
this.description = description;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public UserInfo getCreator() {
return creator;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public void setCreator(UserInfo creator) {
this.creator = creator;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public Short getStatus() {
return status;
}
public Set<UserDMP> getUsers() {
return users;
}
public void setUsers(Set<UserDMP> users) {
this.users = users;
}
public void setStatus(Short status) {
this.status = status;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Date getCreated() {
return created;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public void setCreated(Date created) {
this.created = created;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public Date getModified() {
return modified;
}
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
public void setModified(Date modified) {
this.modified = modified;
}
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
public Set<UserDMP> getUsers() {
return users;
}
public String getAssociatedDmps() {
return associatedDmps;
}
public void setAssociatedDmps(String associatedDmps) {
this.associatedDmps = associatedDmps;
}
public void setUsers(Set<UserDMP> users) {
this.users = users;
}
public DMPProfile getProfile() {
return profile;
}
public void setProfile(DMPProfile profile) {
this.profile = profile;
}
public UUID getId() {
return id;
}
public Set<Dataset> getDataset() {
return dataset;
}
public void setDataset(Set<Dataset> dataset) {
this.dataset = dataset;
}
public void setId(UUID id) {
this.id = id;
}
public Set<Organisation> getOrganisations() {
return organisations;
}
public void setOrganisations(Set<Organisation> organisations) {
this.organisations = organisations;
}
public UUID getGroupId() {
return groupId;
}
public Set<Researcher> getResearchers() {
return researchers;
}
public void setResearchers(Set<Researcher> researchers) {
this.researchers = researchers;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public String getLabel() {
return label;
}
public String getDmpProperties() {
return dmpProperties;
}
public void setDmpProperties(String dmpProperties) {
this.dmpProperties = dmpProperties;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public void update(DMP entity) {
this.associatedDmps = entity.associatedDmps;
this.label = entity.getLabel();
this.profile = entity.getProfile();
this.status = entity.getStatus();
this.created = entity.created;
this.properties = entity.getProperties();
this.project = entity.getProject();
this.description = entity.getDescription();
this.researchers = entity.getResearchers();
this.organisations = entity.getOrganisations();
this.dmpProperties = entity.getDmpProperties();
this.setModified(new Date());
if (entity.getUsers() != null) this.users = entity.getUsers();
}
public Integer getVersion() {
return version;
}
@Override
public UUID getKeys() {
return this.id;
}
public void setVersion(Integer version) {
this.version = version;
}
@Override
public DMP buildFromTuple(List<Tuple> tuple, String base) {
this.id = tuple.get(0).get(base.isEmpty() ? "id" : base + "." + "id", UUID.class);
this.dataset = tuple.stream().map(x -> new Dataset().buildFromTuple(tuple, base.isEmpty() ? "dataset" : base + "." + "dataset")).collect(Collectors.toSet());
this.creator = tuple.stream().map(x -> new UserInfo().buildFromTuple(tuple, base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0);
return this;
}
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;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public String getDmpProperties() {
return dmpProperties;
}
public void setDmpProperties(String dmpProperties) {
this.dmpProperties = dmpProperties;
}
@Override
public void update(DMP entity) {
this.associatedDmps = entity.associatedDmps;
this.label = entity.getLabel();
this.profile = entity.getProfile();
this.status = entity.getStatus();
this.created = entity.created;
this.properties = entity.getProperties();
this.project = entity.getProject();
this.description = entity.getDescription();
this.researchers = entity.getResearchers();
this.organisations = entity.getOrganisations();
this.dmpProperties = entity.getDmpProperties();
this.setModified(new Date());
if (entity.getUsers() != null) this.users = entity.getUsers();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DMP buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
this.dataset = tuple.stream().map(x -> new Dataset().buildFromTuple(tuple, fields, currentBase + "dataset")).collect(Collectors.toSet());
this.creator = tuple.stream().map(x -> new UserInfo().buildFromTuple(tuple, fields, currentBase + "creator")).collect(Collectors.toList()).get(0);
this.project = tuple.stream().map(x -> new Project().buildFromTuple(tuple, fields, currentBase + "project")).collect(Collectors.toList()).get(0);
return this;
}
}

View File

@ -2,6 +2,7 @@ package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -145,8 +146,9 @@ public class DMPProfile implements DataEntity<DMPProfile, UUID> {
}
@Override
public DMPProfile buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
public DMPProfile buildFromTuple(List<Tuple> tuple,List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -14,144 +15,145 @@ import java.util.UUID;
@Entity
@Table(name = "\"DataRepository\"")
public class DataRepository implements Serializable, DataEntity<DataRepository,UUID> {
public class DataRepository implements Serializable, DataEntity<DataRepository, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Abbreviation\"")
private String abbreviation;
@Column(name = "\"Abbreviation\"")
private String abbreviation;
@Column(name = "\"Reference\"", nullable = false)
private String reference;
@Column(name = "\"Reference\"", nullable = false)
private String reference;
@Column(name = "\"Uri\"")
private String uri;
@Column(name = "\"Uri\"")
private String uri;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@OneToMany(mappedBy = "dataRepository", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetDataRepository> datasetDataRepositories;
@OneToMany(mappedBy = "dataRepository", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetDataRepository> datasetDataRepositories;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
@Column(name = "\"Modified\"")
private Date modified = new Date();
public Short getStatus() {
return status;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public void setStatus(Short status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setLabel(String label) {
this.label = label;
}
public String getAbbreviation() {
return abbreviation;
}
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getReference() {
return reference;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public String getUri() {
return uri;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDefinition() {
return definition;
}
public String getDefinition() {
return definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public Set<DatasetDataRepository> getDatasetDataRepositories() {
return datasetDataRepositories;
}
public Set<DatasetDataRepository> getDatasetDataRepositories() {
return datasetDataRepositories;
}
public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) {
this.datasetDataRepositories = datasetDataRepositories;
}
public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) {
this.datasetDataRepositories = datasetDataRepositories;
}
@Override
public void update(DataRepository entity) {
@Override
public void update(DataRepository entity) {
}
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DataRepository buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public DataRepository buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -2,6 +2,7 @@ package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -13,326 +14,327 @@ import java.util.stream.Collectors;
@Entity
@Table(name = "\"Dataset\"")
@NamedEntityGraphs({
@NamedEntityGraph(
name = "datasetListingModel",
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"),
@NamedAttributeNode(value = "datasetExternalDatasets", subgraph = "datasetExternalDatasets"), @NamedAttributeNode("registries"),
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
subgraphs = {
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("project"), @NamedAttributeNode("organisations")}),
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}),
@NamedSubgraph(name = "datasetExternalDatasets", attributeNodes = {@NamedAttributeNode("externalDataset")})
}),
@NamedEntityGraph(
name = "datasetListingModel",
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"),
@NamedAttributeNode(value = "datasetExternalDatasets", subgraph = "datasetExternalDatasets"), @NamedAttributeNode("registries"),
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
subgraphs = {
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("project"), @NamedAttributeNode("organisations")}),
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}),
@NamedSubgraph(name = "datasetExternalDatasets", attributeNodes = {@NamedAttributeNode("externalDataset")})
}),
@NamedEntityGraph(
name = "datasetWizardModel",
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"),
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}),
@NamedEntityGraph(
name = "datasetRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp")},
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("users")})),
@NamedEntityGraph(
name = "datasetDataRepositories",
attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("creator")},
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")}))
@NamedEntityGraph(
name = "datasetWizardModel",
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"),
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}),
@NamedEntityGraph(
name = "datasetRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp")},
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("users")})),
@NamedEntityGraph(
name = "datasetDataRepositories",
attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("creator")},
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")}))
})
public class Dataset implements DataEntity<Dataset, UUID> {
public static Set<String> getHints() {
return hints;
}
public static Set<String> getHints() {
return hints;
}
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
public enum Status {
SAVED((short) 0), FINALISED((short) 1), DELETED((short) 99);
public enum Status {
SAVED((short) 0), FINALISED((short) 1), DELETED((short) 99);
private short value;
private short value;
private Status(short value) {
this.value = value;
}
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return SAVED;
case 1:
return FINALISED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Dataset Status");
}
}
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return SAVED;
case 1:
return FINALISED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Dataset Status");
}
}
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Label\"")
private String label;
@ManyToOne(fetch = FetchType.LAZY)
@ManyToOne(fetch = FetchType.LAZY)
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"DMP\"", nullable = false)
private DMP dmp;
@JoinColumn(name = "\"DMP\"", nullable = false)
private DMP dmp;
@Column(name = "\"Uri\"")
private String uri;
@Column(name = "\"Uri\"")
private String uri;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
private String properties;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
private String properties;
@ManyToOne(fetch = FetchType.LAZY)
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"Profile\"", nullable = true)
private DatasetProfile profile;
@ManyToOne(fetch = FetchType.LAZY)
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
@JoinColumn(name = "\"Profile\"", nullable = true)
private DatasetProfile profile;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DatasetRegistry\"",
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")}
)
private Set<Registry> registries;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DatasetRegistry\"",
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")}
)
private Set<Registry> registries;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetDataRepository> datasetDataRepositories;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetDataRepository> datasetDataRepositories;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetService> services;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetService> services;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetExternalDataset> datasetExternalDatasets;
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetExternalDataset> datasetExternalDatasets;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"IsPublic\"", nullable = false)
private boolean isPublic;
@Column(name = "\"IsPublic\"", nullable = false)
private boolean isPublic;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Creator\"", nullable = true)
private UserInfo creator;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Creator\"", nullable = true)
private UserInfo creator;
@Column(name = "\"Description\"")
private String description;
@Column(name = "\"Description\"")
private String description;
public String getDescription() {
return description;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void setDescription(String description) {
this.description = description;
}
public UserInfo getCreator() {
return creator;
}
public UserInfo getCreator() {
return creator;
}
public void setCreator(UserInfo creator) {
this.creator = creator;
}
public void setCreator(UserInfo creator) {
this.creator = creator;
}
public Short getStatus() {
return status;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public void setStatus(Short status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public Set<Registry> getRegistries() {
return registries;
}
public Set<Registry> getRegistries() {
return registries;
}
public void setRegistries(Set<Registry> registries) {
this.registries = registries;
}
public void setRegistries(Set<Registry> registries) {
this.registries = registries;
}
public Set<DatasetService> getServices() {
return services;
}
public Set<DatasetService> getServices() {
return services;
}
public void setServices(Set<DatasetService> services) {
this.services = services;
}
public void setServices(Set<DatasetService> services) {
this.services = services;
}
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setLabel(String label) {
this.label = label;
}
public DMP getDmp() {
return dmp;
}
public DMP getDmp() {
return dmp;
}
public void setDmp(DMP dmp) {
this.dmp = dmp;
}
public void setDmp(DMP dmp) {
this.dmp = dmp;
}
public String getUri() {
return uri;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getProperties() {
return properties;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public DatasetProfile getProfile() {
return profile;
}
public DatasetProfile getProfile() {
return profile;
}
public void setProfile(DatasetProfile profile) {
this.profile = profile;
}
public void setProfile(DatasetProfile profile) {
this.profile = profile;
}
public Set<DatasetDataRepository> getDatasetDataRepositories() {
return datasetDataRepositories;
}
public Set<DatasetDataRepository> getDatasetDataRepositories() {
return datasetDataRepositories;
}
public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) {
this.datasetDataRepositories = datasetDataRepositories;
}
public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) {
this.datasetDataRepositories = datasetDataRepositories;
}
public String getReference() {
return reference;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public Set<DatasetExternalDataset> getDatasetExternalDatasets() {
return datasetExternalDatasets;
}
public Set<DatasetExternalDataset> getDatasetExternalDatasets() {
return datasetExternalDatasets;
}
public void setDatasetExternalDatasets(Set<DatasetExternalDataset> datasetExternalDatasets) {
this.datasetExternalDatasets = datasetExternalDatasets;
}
public void setDatasetExternalDatasets(Set<DatasetExternalDataset> datasetExternalDatasets) {
this.datasetExternalDatasets = datasetExternalDatasets;
}
public boolean isPublic() {
return isPublic;
}
public boolean isPublic() {
return isPublic;
}
public void setPublic(boolean aPublic) {
isPublic = aPublic;
}
public void setPublic(boolean aPublic) {
isPublic = aPublic;
}
@Override
public void update(Dataset entity) {
this.setRegistries(entity.getRegistries());
if (this.getDatasetDataRepositories() == null) this.setDatasetDataRepositories(new HashSet<>());
if (!this.getDatasetDataRepositories().containsAll(entity.getDatasetDataRepositories())) {
this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().map(item -> {
item.setDataset(this);
return item;
}).collect(Collectors.toList()));
}
this.setDescription(entity.getDescription());
this.setLabel(entity.getLabel());
this.setProperties(entity.getProperties());
if (this.getDatasetExternalDatasets() == null) this.setDatasetExternalDatasets(new HashSet<>());
if (!this.getDatasetExternalDatasets().containsAll(entity.getDatasetExternalDatasets())) {
this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().map(item -> {
item.setDataset(this);
return item;
}).collect(Collectors.toList()));
}
this.setStatus(entity.getStatus());
this.setProfile(entity.getProfile());
this.setModified(new Date());
if (entity.getCreator() != null) this.creator = entity.getCreator();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Dataset buildFromTuple(List<Tuple> tuple, String base) {
this.id = (UUID) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id");
return this;
}
@Override
public void update(Dataset entity) {
this.setRegistries(entity.getRegistries());
if (this.getDatasetDataRepositories() == null) this.setDatasetDataRepositories(new HashSet<>());
if (!this.getDatasetDataRepositories().containsAll(entity.getDatasetDataRepositories())) {
this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().map(item -> {
item.setDataset(this);
return item;
}).collect(Collectors.toList()));
}
this.setDescription(entity.getDescription());
this.setLabel(entity.getLabel());
this.setProperties(entity.getProperties());
if (this.getDatasetExternalDatasets() == null) this.setDatasetExternalDatasets(new HashSet<>());
if (!this.getDatasetExternalDatasets().containsAll(entity.getDatasetExternalDatasets())) {
this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().map(item -> {
item.setDataset(this);
return item;
}).collect(Collectors.toList()));
}
this.setStatus(entity.getStatus());
this.setProfile(entity.getProfile());
this.setModified(new Date());
if (entity.getCreator() != null) this.creator = entity.getCreator();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Dataset buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -1,8 +1,8 @@
package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.List;
@ -14,83 +14,84 @@ import java.util.UUID;
@Entity
@Table(name = "\"DatasetDataRepository\"")
public class DatasetDataRepository implements DataEntity<DatasetDataRepository,UUID> {
public class DatasetDataRepository implements DataEntity<DatasetDataRepository, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset;
@ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset;
@ManyToOne
@JoinColumn(name = "\"DataRepository\"", nullable = false)
private DataRepository dataRepository;
@ManyToOne
@JoinColumn(name = "\"DataRepository\"", nullable = false)
private DataRepository dataRepository;
@Column(name = "\"Role\"")
private Integer role;
@Column(name = "\"Role\"")
private Integer role;
@Column(name = "\"Data\"")
private String data;
@Column(name = "\"Data\"")
private String data;
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public Dataset getDataset() {
return dataset;
}
public Dataset getDataset() {
return dataset;
}
public void setDataset(Dataset dataset) {
this.dataset = dataset;
}
public void setDataset(Dataset dataset) {
this.dataset = dataset;
}
public DataRepository getDataRepository() {
return dataRepository;
}
public DataRepository getDataRepository() {
return dataRepository;
}
public void setDataRepository(DataRepository dataRepository) {
this.dataRepository = dataRepository;
}
public void setDataRepository(DataRepository dataRepository) {
this.dataRepository = dataRepository;
}
public Integer getRole() {
return role;
}
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
public void setRole(Integer role) {
this.role = role;
}
public String getData() {
return data;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public void setData(String data) {
this.data = data;
}
@Override
public void update(DatasetDataRepository entity) {
this.dataset = entity.getDataset();
this.dataRepository = entity.getDataRepository();
this.role = entity.getRole();
}
@Override
public void update(DatasetDataRepository entity) {
this.dataset = entity.getDataset();
this.dataRepository = entity.getDataRepository();
this.role = entity.getRole();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DatasetDataRepository buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public DatasetDataRepository buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -1,8 +1,8 @@
package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.util.List;
@ -11,84 +11,85 @@ import java.util.UUID;
@Entity
@Table(name = "\"DatasetExternalDataset\"")
public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset,UUID> {
public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset;
@ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset;
@ManyToOne
@JoinColumn(name = "\"ExternalDataset\"", nullable = false)
private ExternalDataset externalDataset;
@ManyToOne
@JoinColumn(name = "\"ExternalDataset\"", nullable = false)
private ExternalDataset externalDataset;
@Column(name = "\"Role\"")
private Integer role;
@Column(name = "\"Role\"")
private Integer role;
@Column(name = "\"Data\"")
private String data;
@Column(name = "\"Data\"")
private String data;
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public Dataset getDataset() {
return dataset;
}
public Dataset getDataset() {
return dataset;
}
public void setDataset(Dataset dataset) {
this.dataset = dataset;
}
public void setDataset(Dataset dataset) {
this.dataset = dataset;
}
public ExternalDataset getExternalDataset() {
return externalDataset;
}
public ExternalDataset getExternalDataset() {
return externalDataset;
}
public void setExternalDataset(ExternalDataset externalDataset) {
this.externalDataset = externalDataset;
}
public void setExternalDataset(ExternalDataset externalDataset) {
this.externalDataset = externalDataset;
}
public Integer getRole() {
return role;
}
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
public void setRole(Integer role) {
this.role = role;
}
public String getData() {
return data;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public void setData(String data) {
this.data = data;
}
@Override
public void update(DatasetExternalDataset entity) {
this.dataset = entity.getDataset();
this.externalDataset = entity.getExternalDataset();
this.role = entity.getRole();
}
@Override
public void update(DatasetExternalDataset entity) {
this.dataset = entity.getDataset();
this.externalDataset = entity.getExternalDataset();
this.role = entity.getRole();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DatasetExternalDataset buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public DatasetExternalDataset buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -2,6 +2,7 @@ package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -15,148 +16,170 @@ import java.util.UUID;
@Entity
@Table(name = "\"DatasetProfile\"")
public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
public class DatasetProfile implements DataEntity<DatasetProfile, UUID> {
public enum Status {
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
public enum Status {
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
private short value;
private short value;
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
private Status(short value) {
this.value = value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return SAVED;
case 1:
return FINALIZED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Dataset Profile Status");
}
}
}
public short getValue() {
return value;
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
public static Status fromInteger(int value) {
switch (value) {
case 0:
return SAVED;
case 1:
return FINALIZED;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Dataset Profile Status");
}
}
}
@Column(name = "\"Label\"")
private String label;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "profile")
private Set<Dataset> dataset;
@Column(name = "\"Label\"")
private String label;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
private String definition;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "profile")
private Set<Dataset> dataset;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
private String definition;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created;
@Column(name = "\"Description\"")
private String description;
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
@Column(name = "\"GroupId\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID groupId;
@Column(name = "\"Description\"")
private String description;
@Column(name = "\"Version\"", nullable = false)
private Short version;
@Column(name = "\"GroupId\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID groupId;
@Column(name = "\"Version\"", nullable = false)
private Short version;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDescription() {
return description;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public void setDescription(String description) {
this.description = description;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Short getStatus() {
return status;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public void setStatus(Short status) {
this.status = status;
}
public UUID getId() {
return id;
}
public void setId(UUID id) { this.id = id;}
public Date getCreated() {
return created;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setCreated(Date created) {
this.created = created;
}
public String getDefinition() {
return definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public Date getModified() {
return modified;
}
public Set<Dataset> getDataset() {
return dataset;
}
public void setDataset(Set<Dataset> dataset) {
this.dataset = dataset;
}
public void setModified(Date modified) {
this.modified = modified;
}
public UUID getGroupId() { return groupId; }
public void setGroupId(UUID groupId) { this.groupId = groupId;}
public UUID getId() {
return id;
}
public Short getVersion() { return version; }
public void setVersion(Short version) { this.version = version; }
public void setId(UUID id) {
this.id = id;
}
@Override
public String toString() {
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + "]";
}
public String getLabel() {
return label;
}
@Override
public void update(DatasetProfile entity) {
}
public void setLabel(String label) {
this.label = label;
}
@Override
public UUID getKeys() {
return this.id;
}
public String getDefinition() {
return definition;
}
@Override
public DatasetProfile buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public Set<Dataset> getDataset() {
return dataset;
}
public void setDataset(Set<Dataset> dataset) {
this.dataset = dataset;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public Short getVersion() {
return version;
}
public void setVersion(Short version) {
this.version = version;
}
@Override
public String toString() {
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + "]";
}
@Override
public void update(DatasetProfile entity) {
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DatasetProfile buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -3,10 +3,8 @@ package eu.eudat.data.entities;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
@ -15,83 +13,84 @@ import java.util.UUID;
@Table(name = "\"DatasetService\"")
public class DatasetService implements DataEntity<DatasetService, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset;
@ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset;
@ManyToOne
@JoinColumn(name = "\"Service\"", nullable = false)
private Service service;
@ManyToOne
@JoinColumn(name = "\"Service\"", nullable = false)
private Service service;
@Column(name = "\"Role\"")
private Integer role;
@Column(name = "\"Role\"")
private Integer role;
@Column(name = "\"Data\"")
private String data;
@Column(name = "\"Data\"")
private String data;
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public Dataset getDataset() {
return dataset;
}
public Dataset getDataset() {
return dataset;
}
public void setDataset(Dataset dataset) {
this.dataset = dataset;
}
public void setDataset(Dataset dataset) {
this.dataset = dataset;
}
public Service getService() {
return service;
}
public Service getService() {
return service;
}
public void setService(Service service) {
this.service = service;
}
public void setService(Service service) {
this.service = service;
}
public Integer getRole() {
return role;
}
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
public void setRole(Integer role) {
this.role = role;
}
public String getData() {
return data;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
public void setData(String data) {
this.data = data;
}
@Override
public void update(DatasetService entity) {
this.dataset = entity.getDataset();
this.service = entity.getService();
this.role = entity.getRole();
}
@Override
public void update(DatasetService entity) {
this.dataset = entity.getDataset();
this.service = entity.getService();
this.role = entity.getRole();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DatasetService buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public DatasetService buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if(fields.contains(currentBase + "id")) this.id = UUID.fromString((String) tuple.get(0).get(currentBase + "id"));
return this;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
@ -108,8 +109,9 @@ public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
}
@Override
public ExternalDataset buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
public ExternalDataset buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -1,5 +1,6 @@
package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -11,104 +12,105 @@ import java.util.UUID;
@Entity
@Table(name = "\"Invitation\"")
public class Invitation implements DataEntity<Invitation,UUID> {
public class Invitation implements DataEntity<Invitation, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false)
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false)
private UUID id;
@Column(name = "\"InvitationEmail\"", nullable = false)
private String invitationEmail;
@Column(name = "\"InvitationEmail\"", nullable = false)
private String invitationEmail;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"CreationUser\"", nullable = false)
private UserInfo user;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"CreationUser\"", nullable = false)
private UserInfo user;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"Dmp\"", nullable = false)
private DMP dmp;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"Dmp\"", nullable = false)
private DMP dmp;
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token;
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token;
@Column(name = "\"AcceptedInvitation\"", nullable = false)
private boolean acceptedInvitation;
@Column(name = "\"AcceptedInvitation\"", nullable = false)
private boolean acceptedInvitation;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
private String properties;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Properties\"", columnDefinition = "xml", nullable = true)
private String properties;
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public String getInvitationEmail() {
return invitationEmail;
}
public String getInvitationEmail() {
return invitationEmail;
}
public void setInvitationEmail(String invitationEmail) {
this.invitationEmail = invitationEmail;
}
public void setInvitationEmail(String invitationEmail) {
this.invitationEmail = invitationEmail;
}
public UserInfo getUser() {
return user;
}
public UserInfo getUser() {
return user;
}
public void setUser(UserInfo user) {
this.user = user;
}
public void setUser(UserInfo user) {
this.user = user;
}
public DMP getDmp() {
return dmp;
}
public DMP getDmp() {
return dmp;
}
public void setDmp(DMP dmp) {
this.dmp = dmp;
}
public void setDmp(DMP dmp) {
this.dmp = dmp;
}
public UUID getToken() {
return token;
}
public UUID getToken() {
return token;
}
public void setToken(UUID token) {
this.token = token;
}
public void setToken(UUID token) {
this.token = token;
}
public String getProperties() {
return properties;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public boolean getAcceptedInvitation() {
return acceptedInvitation;
}
public boolean getAcceptedInvitation() {
return acceptedInvitation;
}
public void setAcceptedInvitation(boolean acceptedInvitation) {
this.acceptedInvitation = acceptedInvitation;
}
public void setAcceptedInvitation(boolean acceptedInvitation) {
this.acceptedInvitation = acceptedInvitation;
}
@Override
public void update(Invitation entity) {
@Override
public void update(Invitation entity) {
}
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Invitation buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public Invitation buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -145,8 +146,9 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
}
@Override
public Organisation buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
public Organisation buildFromTuple(List<Tuple> tuple,List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -2,6 +2,7 @@ package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -17,297 +18,301 @@ import java.util.stream.Collectors;
@Entity
@Table(name = "\"Project\"")
@NamedEntityGraphs({
@NamedEntityGraph(
name = "projectRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps")},
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("users")})
),
@NamedEntityGraph(
name = "projectListingItem",
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps"), @NamedAttributeNode(value = "content")},
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"),@NamedAttributeNode("project"), @NamedAttributeNode("users")})
)
@NamedEntityGraph(
name = "projectRecentActivity",
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps")},
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("users")})
),
@NamedEntityGraph(
name = "projectListingItem",
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps"), @NamedAttributeNode(value = "content")},
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("project"), @NamedAttributeNode("users")})
)
})
public class Project implements DataEntity<Project, UUID> {
public enum Status {
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
public enum Status {
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
private short value;
private short value;
private Status(short value) {
this.value = value;
}
private Status(short value) {
this.value = value;
}
public short getValue() {
return value;
}
public short getValue() {
return value;
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return INACTIVE;
case 1:
return ACTIVE;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Project Status");
}
}
}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return INACTIVE;
case 1:
return ACTIVE;
case 99:
return DELETED;
default:
throw new RuntimeException("Unsupported Project Status");
}
}
}
public enum ProjectType {
EXTERNAL(0), INTERNAL(1);
public enum ProjectType {
EXTERNAL(0), INTERNAL(1);
private Integer value;
private Integer value;
private ProjectType(Integer value) {
this.value = value;
}
private ProjectType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public Integer getValue() {
return value;
}
public static ProjectType fromInteger(int value) {
switch (value) {
case 0:
return EXTERNAL;
case 1:
return INTERNAL;
default:
throw new RuntimeException("Unsupported Project Type");
}
}
}
public static ProjectType fromInteger(int value) {
switch (value) {
case 0:
return EXTERNAL;
case 1:
return INTERNAL;
default:
throw new RuntimeException("Unsupported Project Type");
}
}
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@OneToMany(mappedBy = "project")
private Set<DMP> dmps;
@OneToMany(mappedBy = "project")
private Set<DMP> dmps;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Abbreviation\"")
private String abbreviation;
@Column(name = "\"Abbreviation\"")
private String abbreviation;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@Column(name = "\"Uri\"")
private String uri;
@Column(name = "\"Uri\"")
private String uri;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@Column(name = "\"StartDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date startdate = null;
@Column(name = "\"StartDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date startdate = null;
@Column(name = "\"EndDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date enddate = null;
@Column(name = "\"EndDate\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date enddate = null;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"CreationUser\"", nullable = true)
private UserInfo creationUser;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"CreationUser\"", nullable = true)
private UserInfo creationUser;
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
@Column(name = "\"Modified\"")
private Date modified = new Date();
@Column(name = "\"Description\"")
private String description;
@Column(name = "\"Description\"")
private String description;
@Column(name = "\"Type\"")
private Integer type;
@Column(name = "\"Type\"")
private Integer type;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Content\"")
private Content content;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "\"Content\"")
private Content content;
public Project() {
}
public Project() {
}
public Project(Project project) {
this.id = project.getId();
}
public Project(Project project) {
this.id = project.getId();
}
public String getDescription() {
return description;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void setDescription(String description) {
this.description = description;
}
public Short getStatus() {
return status;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public void setStatus(Short status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public Date getStartdate() {
return startdate;
}
public Date getStartdate() {
return startdate;
}
public void setStartdate(Date startdate) {
this.startdate = startdate;
}
public void setStartdate(Date startdate) {
this.startdate = startdate;
}
public Date getEnddate() {
return enddate;
}
public Date getEnddate() {
return enddate;
}
public void setEnddate(Date enddate) {
this.enddate = enddate;
}
public void setEnddate(Date enddate) {
this.enddate = enddate;
}
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setLabel(String label) {
this.label = label;
}
public String getAbbreviation() {
return abbreviation;
}
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getReference() {
return reference;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public String getUri() {
return uri;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDefinition() {
return definition;
}
public String getDefinition() {
return definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public Set<DMP> getDmps() {
return dmps;
}
public Set<DMP> getDmps() {
return dmps;
}
public void setDmps(Set<DMP> dmps) {
this.dmps = dmps;
}
public UserInfo getCreationUser() {
return creationUser;
}
public void setCreationUser(UserInfo creationUser) {
this.creationUser = creationUser;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Content getContent() {
return content;
}
public void setContent(Content content) {
this.content = content;
}
@Override
public void update(Project entity) {
this.description = entity.getDescription();
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.created = entity.getCreated();
this.definition = entity.getDefinition();
this.dmps = entity.getDmps();
this.enddate = entity.getEnddate();
this.modified = new Date();
if (entity.getContent() != null) this.content = entity.getContent();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Project buildFromTuple(List<Tuple> tuple, String base) {
this.id = (UUID) tuple.get(0).get(base.isEmpty() ? "id" : base + "." + "id" );
this.dmps = tuple.stream().map(x-> new DMP().buildFromTuple(tuple,"dmps")).collect(Collectors.toSet());
return this;
}
public void setDmps(Set<DMP> dmps) {
this.dmps = dmps;
}
public UserInfo getCreationUser() {
return creationUser;
}
public void setCreationUser(UserInfo creationUser) {
this.creationUser = creationUser;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Content getContent() {
return content;
}
public void setContent(Content content) {
this.content = content;
}
@Override
public void update(Project entity) {
this.description = entity.getDescription();
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.created = entity.getCreated();
this.definition = entity.getDefinition();
this.dmps = entity.getDmps();
this.enddate = entity.getEnddate();
this.modified = new Date();
if (entity.getContent() != null) this.content = entity.getContent();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Project buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
if (fields.contains(currentBase + "dmps"))
this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(tuple, fields, currentBase + "dmps")).collect(Collectors.toSet());
if (fields.contains(currentBase + "creationUser"))
this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(tuple, fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
return this;
}
}

View File

@ -2,8 +2,8 @@ package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import javax.persistence.*;
@ -15,150 +15,151 @@ import java.util.UUID;
@Entity
@Table(name = "\"Registry\"")
public class Registry implements DataEntity<Registry,UUID> {
public class Registry implements DataEntity<Registry, UUID> {
@Id
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Abbreviation\"")
private String abbreviation;
@Column(name = "\"Abbreviation\"")
private String abbreviation;
@Column(name = "\"Reference\"", nullable = true)
private String reference;
@Column(name = "\"Reference\"", nullable = true)
private String reference;
@Column(name = "\"Uri\"")
private String uri;
@Column(name = "\"Uri\"")
private String uri;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DatasetRegistry\"",
joinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")}
)
private Set<Dataset> datasets;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DatasetRegistry\"",
joinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")}
)
private Set<Dataset> datasets;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
public Short getStatus() {
return status;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public void setStatus(Short status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setLabel(String label) {
this.label = label;
}
public String getAbbreviation() {
return abbreviation;
}
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getReference() {
return reference;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public String getUri() {
return uri;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDefinition() {
return definition;
}
public String getDefinition() {
return definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public Set<Dataset> getDatasets() {
return datasets;
}
public Set<Dataset> getDatasets() {
return datasets;
}
public void setDatasets(Set<Dataset> datasets) {
this.datasets = datasets;
}
public void setDatasets(Set<Dataset> datasets) {
this.datasets = datasets;
}
@Override
public void update(Registry entity) {
@Override
public void update(Registry entity) {
}
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Registry buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public Registry buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -2,6 +2,7 @@ package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -15,153 +16,154 @@ import java.util.UUID;
@Entity
@Table(name = "\"Researcher\"")
public class Researcher implements DataEntity<Researcher,UUID> {
public class Researcher implements DataEntity<Researcher, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Uri\"")
private String uri;
@Column(name = "\"Uri\"")
private String uri;
@Column(name = "\"PrimaryEmail\"")
private String primaryEmail;
@Column(name = "\"PrimaryEmail\"")
private String primaryEmail;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true)
private String definition;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Reference\"", columnDefinition = "xml", nullable = true)
private String reference;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPResearcher\"",
joinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
)
private Set<DMP> dMPs;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"DMPResearcher\"",
joinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")},
inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
)
private Set<DMP> dMPs;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
public Short getStatus() {
return status;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public void setStatus(Short status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setLabel(String label) {
this.label = label;
}
public String getPrimaryEmail() {
return primaryEmail;
}
public String getPrimaryEmail() {
return primaryEmail;
}
public void setPrimaryEmail(String primaryEmail) {
this.primaryEmail = primaryEmail;
}
public void setPrimaryEmail(String primaryEmail) {
this.primaryEmail = primaryEmail;
}
public String getReference() {
return reference;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public String getUri() {
return uri;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDefinition() {
return definition;
}
public String getDefinition() {
return definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public Set<DMP> getdMPs() {
return dMPs;
}
public Set<DMP> getdMPs() {
return dMPs;
}
public void setdMPs(Set<DMP> dMPs) {
this.dMPs = dMPs;
}
public void setdMPs(Set<DMP> dMPs) {
this.dMPs = dMPs;
}
@Override
public void update(Researcher entity) {
@Override
public void update(Researcher entity) {
}
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Researcher buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public Researcher buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -16,144 +16,145 @@ import java.util.UUID;
@Table(name = "\"Service\"")
public class Service implements DataEntity<Service, UUID> {
@Id
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Label\"")
private String label;
@Column(name = "\"Abbreviation\"")
private String abbreviation;
@Column(name = "\"Abbreviation\"")
private String abbreviation;
@Column(name = "\"Reference\"", nullable = true)
private String reference;
@Column(name = "\"Reference\"", nullable = true)
private String reference;
@Column(name = "\"Uri\"")
private String uri;
@Column(name = "\"Uri\"")
private String uri;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
private String definition;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
private String definition;
@OneToMany(mappedBy = "service", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetService> services;
@OneToMany(mappedBy = "service", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetService> services;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Created\"")
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
@Column(name = "\"Modified\"")
@Convert(converter = DateToUTCConverter.class)
private Date modified = new Date();
public Short getStatus() {
return status;
}
public Short getStatus() {
return status;
}
public void setStatus(Short status) {
this.status = status;
}
public void setStatus(Short status) {
this.status = status;
}
public Date getCreated() {
return created;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public void setLabel(String label) {
this.label = label;
}
public String getAbbreviation() {
return abbreviation;
}
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getReference() {
return reference;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public String getUri() {
return uri;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDefinition() {
return definition;
}
public String getDefinition() {
return definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public Set<DatasetService> getServices() {
return services;
}
public Set<DatasetService> getServices() {
return services;
}
public void setServices(Set<DatasetService> services) {
this.services = services;
}
public void setServices(Set<DatasetService> services) {
this.services = services;
}
@Override
public void update(Service entity) {
@Override
public void update(Service entity) {
}
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public Service buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public Service buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = UUID.fromString((String) tuple.get(0).get(currentBase + "id"));
return this;
}
}

View File

@ -1,5 +1,6 @@
package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
@ -11,94 +12,95 @@ import java.util.UUID;
@Table(name = "\"UserDMP\"")
public class UserDMP implements DataEntity<UserDMP, UUID> {
public enum UserDMPRoles {
OWNER(0), USER(1);
public enum UserDMPRoles {
OWNER(0), USER(1);
private Integer value;
private Integer value;
private UserDMPRoles(Integer value) {
this.value = value;
}
private UserDMPRoles(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public Integer getValue() {
return value;
}
public static UserDMPRoles fromInteger(Integer value) {
switch (value) {
case 0:
return OWNER;
case 1:
return USER;
default:
throw new RuntimeException("Unsupported User Dmp Role Message Code");
}
}
}
public static UserDMPRoles fromInteger(Integer value) {
switch (value) {
case 0:
return OWNER;
case 1:
return USER;
default:
throw new RuntimeException("Unsupported User Dmp Role Message Code");
}
}
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "usr")
private UserInfo user;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "usr")
private UserInfo user;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "dmp")
private DMP dmp;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "dmp")
private DMP dmp;
@Column(name = "role")
private Integer role;
@Column(name = "role")
private Integer role;
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public UserInfo getUser() {
return user;
}
public UserInfo getUser() {
return user;
}
public void setUser(UserInfo user) {
this.user = user;
}
public void setUser(UserInfo user) {
this.user = user;
}
public DMP getDmp() {
return dmp;
}
public DMP getDmp() {
return dmp;
}
public void setDmp(DMP dmp) {
this.dmp = dmp;
}
public void setDmp(DMP dmp) {
this.dmp = dmp;
}
public Integer getRole() {
return role;
}
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
public void setRole(Integer role) {
this.role = role;
}
@Override
public void update(UserDMP entity) {
this.role = entity.getRole();
}
@Override
public void update(UserDMP entity) {
this.role = entity.getRole();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UserDMP buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public UserDMP buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -12,175 +13,176 @@ import java.util.*;
@Entity
@Table(name = "\"UserInfo\"")
@NamedEntityGraphs({
@NamedEntityGraph(
name = "userInfo",
attributeNodes = {@NamedAttributeNode("userRoles"), @NamedAttributeNode("credentials")}),
@NamedEntityGraph(
name = "userInfo",
attributeNodes = {@NamedAttributeNode("userRoles"), @NamedAttributeNode("credentials")}),
})
public class UserInfo implements DataEntity<UserInfo, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "email", nullable = false)
private String email = null;
@Column(name = "email", nullable = false)
private String email = null;
@Column(name = "authorization_level", nullable = false)
private Short authorization_level; //0 admin, 1 user
@Column(name = "authorization_level", nullable = false)
private Short authorization_level; //0 admin, 1 user
@Column(name = "usertype", nullable = false)
private Short usertype; // 0 internal, 1 external
@Column(name = "usertype", nullable = false)
private Short usertype; // 0 internal, 1 external
@Column(name = "verified_email", nullable = true)
private Boolean verified_email = null;
@Column(name = "verified_email", nullable = true)
private Boolean verified_email = null;
@Column(name = "name", nullable = true)
private String name = null;
@Column(name = "name", nullable = true)
private String name = null;
@Column(name = "created", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "created", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date created = null;
@Column(name = "lastloggedin", nullable = true)
@Convert(converter = DateToUTCConverter.class)
private Date lastloggedin = null;
@Column(name = "lastloggedin", nullable = true)
@Convert(converter = DateToUTCConverter.class)
private Date lastloggedin = null;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "additionalinfo", nullable = true)
private String additionalinfo;
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
@Column(name = "additionalinfo", nullable = true)
private String additionalinfo;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"UserDMP\"",
joinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")}
)
private Set<DMP> dmps;
@OneToMany(fetch = FetchType.LAZY)
@JoinTable(name = "\"UserDMP\"",
joinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")}
)
private Set<DMP> dmps;
@OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY)
private Set<Credential> credentials = new HashSet<>();
@OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY)
private Set<Credential> credentials = new HashSet<>();
@OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY)
private Set<UserRole> userRoles = new HashSet<>();
@OneToMany(mappedBy = "userInfo", fetch = FetchType.LAZY)
private Set<UserRole> userRoles = new HashSet<>();
public Set<DMP> getDmps() {
return dmps;
}
public Set<DMP> getDmps() {
return dmps;
}
public void setDmps(Set<DMP> dmps) {
this.dmps = dmps;
}
public void setDmps(Set<DMP> dmps) {
this.dmps = dmps;
}
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public Date getCreated() {
return created;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getLastloggedin() {
return lastloggedin;
}
public Date getLastloggedin() {
return lastloggedin;
}
public void setLastloggedin(Date lastloggedin) {
this.lastloggedin = lastloggedin;
}
public void setLastloggedin(Date lastloggedin) {
this.lastloggedin = lastloggedin;
}
public String getEmail() {
return email;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public void setEmail(String email) {
this.email = email;
}
public Short getAuthorization_level() {
return authorization_level;
}
public Short getAuthorization_level() {
return authorization_level;
}
public void setAuthorization_level(Short authorization_level) {
this.authorization_level = authorization_level;
}
public void setAuthorization_level(Short authorization_level) {
this.authorization_level = authorization_level;
}
public Short getUsertype() {
return usertype;
}
public Short getUsertype() {
return usertype;
}
public void setUsertype(Short usertype) {
this.usertype = usertype;
}
public void setUsertype(Short usertype) {
this.usertype = usertype;
}
public Boolean getVerified_email() {
return verified_email;
}
public Boolean getVerified_email() {
return verified_email;
}
public void setVerified_email(Boolean verified_email) {
this.verified_email = verified_email;
}
public void setVerified_email(Boolean verified_email) {
this.verified_email = verified_email;
}
public String getName() {
return name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setName(String name) {
this.name = name;
}
public String getAdditionalinfo() {
return additionalinfo;
}
public String getAdditionalinfo() {
return additionalinfo;
}
public void setAdditionalinfo(String additionalinfo) {
this.additionalinfo = additionalinfo;
}
public void setAdditionalinfo(String additionalinfo) {
this.additionalinfo = additionalinfo;
}
public Set<Credential> getCredentials() {
return credentials;
}
public Set<Credential> getCredentials() {
return credentials;
}
public void setCredentials(Set<Credential> credentials) {
this.credentials = credentials;
}
public void setCredentials(Set<Credential> credentials) {
this.credentials = credentials;
}
public Set<UserRole> getUserRoles() {
return userRoles;
}
public Set<UserRole> getUserRoles() {
return userRoles;
}
public void setUserRoles(Set<UserRole> userRoles) {
this.userRoles = userRoles;
}
public void setUserRoles(Set<UserRole> userRoles) {
this.userRoles = userRoles;
}
@Override
public void update(UserInfo entity) {
this.name = entity.getName();
this.email = entity.getEmail();
this.additionalinfo = entity.getAdditionalinfo();
this.lastloggedin = entity.getLastloggedin();
this.userRoles = entity.getUserRoles();
}
@Override
public void update(UserInfo entity) {
this.name = entity.getName();
this.email = entity.getEmail();
this.additionalinfo = entity.getAdditionalinfo();
this.lastloggedin = entity.getLastloggedin();
this.userRoles = entity.getUserRoles();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UserInfo buildFromTuple(List<Tuple> tuple, String base) {
this.id = (UUID) tuple.get(0).get(base.isEmpty() ? "id" : base + "." + "id" );
return this;
}
@Override
public UserInfo buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -1,5 +1,6 @@
package eu.eudat.data.entities;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
@ -12,56 +13,57 @@ import java.util.UUID;
@Table(name = "\"UserRole\"")
public class UserRole implements DataEntity<UserRole, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Role\"", nullable = false)
private int role;
@Column(name = "\"Role\"", nullable = false)
private int role;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo userInfo;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo userInfo;
public UUID getId() {
return id;
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public void setId(UUID id) {
this.id = id;
}
public int getRole() {
return role;
}
public int getRole() {
return role;
}
public void setRole(int role) {
this.role = role;
}
public void setRole(int role) {
this.role = role;
}
public UserInfo getUserInfo() {
return userInfo;
}
public UserInfo getUserInfo() {
return userInfo;
}
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
@Override
public void update(UserRole entity) {
@Override
public void update(UserRole entity) {
}
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public UserRole buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
@Override
public UserRole buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
return this;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.data.entities;
import eu.eudat.data.converters.DateToUTCConverter;
import eu.eudat.data.entities.helpers.EntityBinder;
import eu.eudat.queryable.queryableentity.DataEntity;
import javax.persistence.*;
@ -13,68 +14,69 @@ import java.util.UUID;
@Table(name = "\"UserToken\"")
public class UserToken implements DataEntity<UserToken, UUID> {
@Id
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token;
@Id
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID token;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo user;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "\"UserId\"", nullable = false)
private UserInfo user;
@Column(name = "\"IssuedAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date issuedAt = null;
@Column(name = "\"IssuedAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date issuedAt = null;
@Column(name = "\"ExpiresAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date expiresAt = null;
@Column(name = "\"ExpiresAt\"", nullable = false)
@Convert(converter = DateToUTCConverter.class)
private Date expiresAt = null;
public UUID getToken() {
return token;
}
public UUID getToken() {
return token;
}
public void setToken(UUID token) {
this.token = token;
}
public void setToken(UUID token) {
this.token = token;
}
public UserInfo getUser() {
return user;
}
public UserInfo getUser() {
return user;
}
public void setUser(UserInfo user) {
this.user = user;
}
public void setUser(UserInfo user) {
this.user = user;
}
public Date getIssuedAt() {
return issuedAt;
}
public Date getIssuedAt() {
return issuedAt;
}
public void setIssuedAt(Date issuedAt) {
this.issuedAt = issuedAt;
}
public void setIssuedAt(Date issuedAt) {
this.issuedAt = issuedAt;
}
public Date getExpiresAt() {
return expiresAt;
}
public Date getExpiresAt() {
return expiresAt;
}
public void setExpiresAt(Date expiresAt) {
this.expiresAt = expiresAt;
}
public void setExpiresAt(Date expiresAt) {
this.expiresAt = expiresAt;
}
@Override
public void update(UserToken entity) {
@Override
public void update(UserToken entity) {
}
}
@Override
public UUID getKeys() {
return this.token;
}
@Override
public UUID getKeys() {
return this.token;
}
@Override
public UserToken buildFromTuple(List<Tuple> tuple, String base) {
this.token = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "token" : "token"));
return this;
}
@Override
public UserToken buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if (fields.contains(currentBase + "token")) this.token = EntityBinder.fromTuple(tuple, currentBase + "token");
return this;
}
}

View File

@ -0,0 +1,14 @@
package eu.eudat.data.entities.helpers;
import javax.persistence.Tuple;
import java.util.List;
public class EntityBinder {
public static <T> T fromTuple(List<Tuple> tuple, String path) {
try {
return (T) tuple.get(0).get(path);
}catch (IllegalArgumentException illegalArgument){
return null;
}
}
}

View File

@ -0,0 +1,109 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.entities.Project;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.Subquery;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class DMPQuery extends Query<DMP, UUID> {
private UUID id;
private UUID groupId;
private String label;
private int version;
private ProjectQuery projectQuery;
private List<Integer> statuses;
private Date created;
private Date modified;
public DMPQuery(DatabaseAccessLayer<DMP, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
public ProjectQuery getProjectQuery() {
return projectQuery;
}
public void setProjectQuery(ProjectQuery projectQuery) {
this.projectQuery = projectQuery;
}
public List<Integer> getStatuses() {
return statuses;
}
public void setStatuses(List<Integer> statuses) {
statuses = statuses;
}
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 QueryableList<DMP> getQuery() {
QueryableList<DMP> query = this.databaseAccessLayer.asQueryable();
if (this.id != null) {
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
}
if(this.projectQuery != null){
Subquery<Project> projectQuery = this.projectQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
query.where((builder, root) -> root.get("project").get("id").in(projectQuery));
}
if(this.getStatuses() != null && !this.getStatuses().isEmpty()){
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
}
return query;
}
}

View File

@ -0,0 +1,7 @@
package eu.eudat.query;
import java.util.UUID;
public class DatasetProfileQuery {
}

View File

@ -0,0 +1,20 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.Dataset;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class DatasetQuery extends Query<Dataset, UUID> {
public DatasetQuery(DatabaseAccessLayer<Dataset, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
}
@Override
public QueryableList<Dataset> getQuery() {
return null;
}
}

View File

@ -0,0 +1,101 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.Project;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.types.FieldSelectionType;
import eu.eudat.queryable.types.SelectionField;
import javax.persistence.criteria.Subquery;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;
public class ProjectQuery extends Query<Project, UUID> {
private UUID id;
private List<UUID> ids;
private String label;
private List<Integer> statuses;
private Date created;
private Date modified;
private UserQuery userQuery;
public ProjectQuery(DatabaseAccessLayer<Project, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public List<UUID> getIds() {
return ids;
}
public void setIds(List<UUID> ids) {
this.ids = ids;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public List<Integer> getStatuses() {
return statuses;
}
public void setStatuses(List<Integer> statuses) {
statuses = statuses;
}
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 UserQuery getUserQuery() {
return userQuery;
}
public void setUserQuery(UserQuery userQuery) {
this.userQuery = userQuery;
}
@Override
public QueryableList<Project> getQuery() {
QueryableList<Project> query = this.databaseAccessLayer.asQueryable();
if (this.id != null)
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
if (this.ids != null && !this.ids.isEmpty())
query.where((builder, root) -> root.get("id").in(this.ids));
if (this.getStatuses() != null && !this.getStatuses().isEmpty())
query.where((builder, root) -> root.get("status").in(this.getStatuses()));
if (this.userQuery != null) {
Subquery<UserInfo> userInfoSubquery = this.userQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
query.where((builder, root) -> root.get("creationUser").get("id").in(userInfoSubquery));
}
return query;
}
}

View File

@ -0,0 +1,15 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.queryable.QueryableList;
import eu.eudat.queryable.queryableentity.DataEntity;
public abstract class Query<T extends DataEntity, K> {
protected DatabaseAccessLayer<T,K> databaseAccessLayer;
public Query(DatabaseAccessLayer<T, K> databaseAccessLayer) {
this.databaseAccessLayer = databaseAccessLayer;
}
public abstract QueryableList<T> getQuery();
}

View File

@ -0,0 +1,32 @@
package eu.eudat.query;
import eu.eudat.data.dao.DatabaseAccessLayer;
import eu.eudat.data.entities.UserInfo;
import eu.eudat.queryable.QueryableList;
import java.util.UUID;
public class UserQuery extends Query<UserInfo, UUID> {
private UUID id;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UserQuery(DatabaseAccessLayer<UserInfo, UUID> databaseAccessLayer) {
super(databaseAccessLayer);
}
@Override
public QueryableList<UserInfo> getQuery() {
QueryableList<UserInfo> query = this.databaseAccessLayer.asQueryable();
if (this.id != null)
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
return query;
}
}

View File

@ -4,6 +4,8 @@ import eu.eudat.queryable.jpa.predicates.*;
import eu.eudat.queryable.queryableentity.DataEntity;
import eu.eudat.queryable.types.SelectionField;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.Subquery;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@ -47,6 +49,8 @@ public interface QueryableList<T extends DataEntity> {
CompletableFuture<Long> countAsync();
Subquery<T> query(List<SelectionField> fields);
Subquery<T> subQuery(SinglePredicate<T> predicate, List<SelectionField> fields);
Subquery<T> subQuery(NestedQuerySinglePredicate<T> predicate, List<SelectionField> fields);

View File

@ -204,7 +204,7 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
.collect(Collectors.groupingBy(x -> x.get("id")));
return results.stream().map(x -> {
try {
return (T) this.tClass.newInstance().buildFromTuple(groupedResults.get(x.get("id")), "");
return (T) this.tClass.newInstance().buildFromTuple(groupedResults.get(x.get("id")), this.fields, "");
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
@ -243,7 +243,7 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
.collect(Collectors.groupingBy(x -> x.get("id")));
return CompletableFuture.supplyAsync(() -> results.stream().map(x -> {
try {
return (T) this.tClass.newInstance().buildFromTuple(groupedResults.get(x.get("id")), "");
return (T) this.tClass.newInstance().buildFromTuple(groupedResults.get(x.get("id")), this.fields, "");
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
@ -383,8 +383,7 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
}
@Override
public <U extends
Comparable> Subquery<U> subQueryMax(SinglePredicate<T> predicate, List<SelectionField> fields, Class<U> uClass) {
public <U extends Comparable> Subquery<U> subQueryMax(SinglePredicate<T> predicate, List<SelectionField> fields, Class<U> uClass) {
Subquery<U> subquery = this.manager.getCriteriaBuilder().createQuery().subquery(uClass);
this.nestedQueryRoot = subquery.from(this.tClass);
subquery.where(predicate.applyPredicate(this.manager.getCriteriaBuilder(), this.nestedQueryRoot));
@ -416,6 +415,21 @@ public class QueryableHibernateList<T extends DataEntity> implements QueryableLi
return this;
}
@Override
public Subquery<T> query(List<SelectionField> fields) {
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
Subquery<T> query = builder.createQuery().subquery(this.tClass);
this.root = query.from(this.tClass);
query.where(this.generateWherePredicates(this.singlePredicates, this.root, this.nestedPredicates, this.nestedQueryRoot));
if (fields.get(0).getType() == FieldSelectionType.FIELD)
query.select(this.root.get(fields.get(0).getField()));
else if (fields.get(0).getType() == FieldSelectionType.COMPOSITE_FIELD) {
query.select(this.root.get(fields.get(0).getField().split(":")[0]).get(fields.get(0).getField().split(":")[1]));
}
if (distinct) query.distinct(true);
return query;
}
@Override
public <V> void update(EntitySelectPredicate<T> selectPredicate, V value) {
CriteriaBuilder builder = this.manager

View File

@ -3,8 +3,10 @@ package eu.eudat.queryable.queryableentity;
import javax.persistence.Tuple;
import java.util.List;
public interface DataEntity<T,K> {
void update(T entity);
K getKeys();
T buildFromTuple(List<Tuple> tuple, String base);
public interface DataEntity<T, K> {
void update(T entity);
K getKeys();
T buildFromTuple(List<Tuple> tuple, List<String> fields, String base);
}

View File

@ -2,33 +2,33 @@ package eu.eudat.controllers;
import eu.eudat.configurations.dynamicproject.DynamicProjectConfiguration;
import eu.eudat.criteria.DMPCriteria;
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
import eu.eudat.data.dao.criteria.RequestItem;
import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.data.entities.DMP;
import eu.eudat.data.query.items.item.dmp.DataManagementPlanCriteriaRequest;
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
import eu.eudat.data.query.items.table.dmp.DataManagmentPlanPublicTableRequest;
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
import eu.eudat.exceptions.datamanagementplan.DMPWithDatasetsDeleteException;
import eu.eudat.logic.managers.DataManagementPlanManager;
import eu.eudat.logic.managers.DatasetManager;
import eu.eudat.logic.managers.FileManager;
import eu.eudat.logic.security.claims.ClaimedAuthorities;
import eu.eudat.logic.services.ApiContext;
import eu.eudat.logic.services.forms.VisibilityRuleService;
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
import eu.eudat.logic.services.operations.DatabaseRepository;
import eu.eudat.models.data.dmp.DataManagementPlan;
import eu.eudat.models.data.files.ContentFile;
import eu.eudat.models.data.helpermodels.Tuple;
import eu.eudat.models.data.helpers.common.DataTableData;
import eu.eudat.models.data.helpers.responses.ResponseItem;
import eu.eudat.models.data.listingmodels.DataManagementPlanListingModel;
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
import eu.eudat.models.data.security.Principal;
import eu.eudat.query.DMPQuery;
import eu.eudat.query.ProjectQuery;
import eu.eudat.query.UserQuery;
import eu.eudat.types.ApiMessageCode;
import eu.eudat.types.Authorities;
import org.apache.commons.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
@ -46,6 +46,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
@ -55,148 +56,163 @@ import java.util.UUID;
@RequestMapping(value = {"/api/dmps/"})
public class DMPs extends BaseController {
private DynamicProjectConfiguration dynamicProjectConfiguration;
private Environment environment;
private DataManagementPlanManager dataManagementPlanManager;
private DatasetManager datasetManager;
@Autowired
public DMPs(ApiContext apiContext, DynamicProjectConfiguration dynamicProjectConfiguration, Environment environment,
DataManagementPlanManager dataManagementPlanManager, DatasetManager datasetManager) {
super(apiContext);
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
this.environment = environment;
this.dataManagementPlanManager = dataManagementPlanManager;
this.datasetManager = datasetManager;
}
private DynamicProjectConfiguration dynamicProjectConfiguration;
private Environment environment;
private DataManagementPlanManager dataManagementPlanManager;
private DatasetManager datasetManager;
@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"{id}/unlock"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
this.dataManagementPlanManager.unlock(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
}
@Autowired
public DMPs(ApiContext apiContext, DynamicProjectConfiguration dynamicProjectConfiguration, Environment environment,
DataManagementPlanManager dataManagementPlanManager, DatasetManager datasetManager) {
super(apiContext);
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
this.environment = environment;
this.dataManagementPlanManager = dataManagementPlanManager;
this.datasetManager = datasetManager;
}
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest,@RequestParam String fieldsGroup, Principal principal) throws Exception {
DataTableData<DataManagementPlanListingModel> dataTable = this.dataManagementPlanManager.getPaged(dataManagementPlanTableRequest, principal, fieldsGroup);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@Transactional
@RequestMapping(method = RequestMethod.GET, value = {"{id}/unlock"}, produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
this.dataManagementPlanManager.unlock(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
}
@RequestMapping(method = RequestMethod.GET, value = {"{id}"})
public @ResponseBody
ResponseEntity getSingle(@PathVariable String id,@RequestHeader("Content-Type") String contentType, Principal principal) throws IllegalAccessException,InterruptedException, InstantiationException, IOException {
if(contentType.equals("application/xml") || contentType.equals("application/msword")){ //|| contentType.equals("application/pdf")
DMPDao dmpDao = this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao();
VisibilityRuleService visibilityRuleService = this.getApiContext().getUtilitiesService().getVisibilityRuleService();
ResponseEntity<byte[]> document = this.dataManagementPlanManager.getDocument(id, contentType);
return document;
}
else{
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, this.dynamicProjectConfiguration);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest, @RequestParam String fieldsGroup, Principal principal) throws Exception {
DataTableData<DataManagementPlanListingModel> dataTable = this.dataManagementPlanManager.getPaged(dataManagementPlanTableRequest, principal, fieldsGroup);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
public @ResponseBody
ResponseEntity getOverviewSingle(@PathVariable String id, Principal principal) throws IllegalAccessException,InterruptedException, InstantiationException, IOException {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
}
@RequestMapping(method = RequestMethod.GET, value = {"{id}"})
public @ResponseBody
ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType, Principal principal) throws IllegalAccessException, InterruptedException, InstantiationException, IOException {
if (contentType.equals("application/xml") || contentType.equals("application/msword")) { //|| contentType.equals("application/pdf")
DMPDao dmpDao = this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao();
VisibilityRuleService visibilityRuleService = this.getApiContext().getUtilitiesService().getVisibilityRuleService();
ResponseEntity<byte[]> document = this.dataManagementPlanManager.getDocument(id, contentType);
return document;
} else {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, this.dynamicProjectConfiguration);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"})
public @ResponseBody
ResponseEntity getSinglePublic(@PathVariable String id) throws IllegalAccessException,InterruptedException, InstantiationException, IOException {
try {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSinglePublic(id, this.dynamicProjectConfiguration);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
}
catch (Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
public @ResponseBody
ResponseEntity getOverviewSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InterruptedException, InstantiationException, IOException {
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
}
@Transactional
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> createOrUpdate(@RequestBody eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
this.dataManagementPlanManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"})
public @ResponseBody
ResponseEntity getSinglePublic(@PathVariable String id) throws IllegalAccessException, InterruptedException, InstantiationException, IOException {
try {
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSinglePublic(id, this.dynamicProjectConfiguration);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
} catch (Exception ex) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/new/{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id, @Valid @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
try {
this.dataManagementPlanManager.newVersion(id, dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
} catch (DMPNewVersionException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> createOrUpdate(@RequestBody eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
this.dataManagementPlanManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
}
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
this.dataManagementPlanManager.clone(id, dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"/new/{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id, @Valid @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
try {
this.dataManagementPlanManager.newVersion(id, dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
} catch (DMPNewVersionException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
}
}
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> delete(@PathVariable UUID id, Principal principal) {
try{
this.dataManagementPlanManager.delete(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Deleted Datamanagement Plan"));
}catch (DMPWithDatasetsDeleteException exception){
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
}
}
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
this.dataManagementPlanManager.clone(id, dataManagementPlan, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) throws InstantiationException, IllegalAccessException {
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicProjectConfiguration, criteriaRequestItem.getCriteria());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
@Transactional
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DMP>> delete(@PathVariable UUID id, Principal principal) {
try {
this.dataManagementPlanManager.delete(id);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Deleted Datamanagement Plan"));
} catch (DMPWithDatasetsDeleteException exception) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
}
}
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
public @ResponseBody
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
System.out.println(contentType);
File file = this.dataManagementPlanManager.getWordDocument(id);
File pdffile = datasetManager.convertToPDF(file, environment, file.getName());
InputStream resource = new FileInputStream(pdffile);
System.out.println("Mime Type of " + file.getName() + " is " +
new MimetypesFileTypeMap().getContentType(file));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(pdffile.length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + pdffile.getName());
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
@RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) throws InstantiationException, IllegalAccessException {
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicProjectConfiguration, criteriaRequestItem.getCriteria());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
}
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
return new ResponseEntity<>(content,
responseHeaders,
HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
public @ResponseBody
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
System.out.println(contentType);
File file = this.dataManagementPlanManager.getWordDocument(id);
File pdffile = datasetManager.convertToPDF(file, environment, file.getName());
InputStream resource = new FileInputStream(pdffile);
System.out.println("Mime Type of " + file.getName() + " is " +
new MimetypesFileTypeMap().getContentType(file));
HttpHeaders responseHeaders = new HttpHeaders();
responseHeaders.setContentLength(pdffile.length());
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
responseHeaders.set("Content-Disposition", "attachment;filename=" + pdffile.getName());
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
public ResponseEntity<ResponseItem> dmpXmlUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws IOException, JAXBException, Exception {
this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List>()
.status(ApiMessageCode.SUCCESS_MESSAGE));
}
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
return new ResponseEntity<>(content,
responseHeaders,
HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPublicPaged(@RequestBody DataManagmentPlanPublicTableRequest dmpTableRequest, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
DataTableData<DataManagementPlanListingModel> dmp = this.dataManagementPlanManager.getPaged(dmpTableRequest, "listing") ;
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
public ResponseEntity<ResponseItem> dmpXmlUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws IOException, JAXBException, Exception {
this.dataManagementPlanManager.createDmpFromXml(this.getApiContext(), files, principal);
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List>()
.status(ApiMessageCode.SUCCESS_MESSAGE));
}
@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPublicPaged(@RequestBody DataManagmentPlanPublicTableRequest dmpTableRequest, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
DataTableData<DataManagementPlanListingModel> dmp = this.dataManagementPlanManager.getPaged(dmpTableRequest, "listing");
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}
@RequestMapping(method = RequestMethod.POST, value = {"/test"}, consumes = "application/json", produces = "application/json")
public @ResponseBody
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> test(@RequestBody DMPCriteria criteria, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
DatabaseRepository dbRepo = this.getApiContext().getOperationsContext().getDatabaseRepository();
DMPQuery query = criteria.getQuery(dbRepo.getDmpDao());
ProjectQuery projectQuery = criteria.getProject().getQuery(dbRepo.getProjectDao());
UserQuery userQuery = criteria.getProject().getCreator().getQuery(dbRepo.getUserInfoDao());
projectQuery.setUserQuery(userQuery);
query.setProjectQuery(projectQuery);
List<DataManagementPlanListingModel> models = query.getQuery().withFields(Arrays.asList("id", "project.id", "dataset.id", "project.creationUser.id")).select(x -> new DataManagementPlanListingModel().fromDataModel(x));
DataTableData<DataManagementPlanListingModel> dmp = new DataTableData<>();
dmp.setData(models);
dmp.setTotalCount(query.getQuery().count());
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
}
}

View File

@ -0,0 +1,116 @@
package eu.eudat.criteria;
import eu.eudat.criteria.entities.Criteria;
import eu.eudat.criteria.entities.DateCriteria;
import eu.eudat.data.dao.entities.DMPDao;
import eu.eudat.query.DMPQuery;
import java.util.UUID;
public class DMPCriteria {
private Criteria<UUID> id;
private Criteria<UUID> groupId;
private Criteria<String> label;
private Criteria<Integer> version;
private ProjectCriteria project;
private DateCriteria created;
private DateCriteria modified;
public Criteria<UUID> getId() {
return id;
}
public void setId(Criteria<UUID> id) {
this.id = id;
}
public void setId(String id) {
Criteria<UUID> criteria = new Criteria<>();
criteria.setAs(id);
this.id = criteria;
}
public Criteria<UUID> getGroupId() {
return groupId;
}
public void setGroupId(Criteria<UUID> groupId) {
this.groupId = groupId;
}
public void setGroupId(String groupId) {
Criteria<UUID> criteria = new Criteria<>();
criteria.setAs(groupId);
this.groupId = criteria;
}
public Criteria<String> getLabel() {
return label;
}
public void setLabel(Criteria<String> label) {
this.label = label;
}
public void setLabel(String label) {
Criteria<String> criteria = new Criteria<>();
criteria.setAs(label);
this.label = criteria;
}
public Criteria<Integer> getVersion() {
return version;
}
public void setVersion(Criteria<Integer> version) {
this.version = version;
}
public void setVersion(String version) {
Criteria<Integer> criteria = new Criteria<>();
criteria.setAs(version);
this.version = criteria;
}
public ProjectCriteria getProject() {
return project;
}
public void setProject(ProjectCriteria project) {
this.project = project;
}
public DateCriteria getCreated() {
return created;
}
public void setCreated(DateCriteria created) {
this.created = created;
}
public void setCreated(String created) {
DateCriteria criteria = new DateCriteria();
criteria.setAs(created);
this.created = criteria;
}
public DateCriteria getModified() {
return modified;
}
public void setModified(DateCriteria modified) {
this.modified = modified;
}
public void setModified(String modified) {
DateCriteria criteria = new DateCriteria();
criteria.setAs(modified);
this.modified = criteria;
}
public DMPQuery getQuery(DMPDao dao) {
DMPQuery dmpQuery = new DMPQuery(dao);
dmpQuery.setId(this.id.getValue());
return dmpQuery;
}
}

View File

@ -0,0 +1,112 @@
package eu.eudat.criteria;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import eu.eudat.criteria.entities.Criteria;
import eu.eudat.criteria.entities.DateCriteria;
import eu.eudat.data.dao.entities.ProjectDao;
import eu.eudat.query.ProjectQuery;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
public class ProjectCriteria {
private Criteria<UUID> id;
private List<UUID> ids;
private Criteria<String> label;
private List<Integer> statuses;
private DateCriteria created;
private DateCriteria modified;
private UserCriteria creator;
public Criteria<UUID> getId() {
return id;
}
public void setId(JsonNode jsonNode) throws IOException {
if (jsonNode.getNodeType().equals(JsonNodeType.STRING)) {
Criteria<UUID> criteria = new Criteria<>();
criteria.setAs(jsonNode.asText());
this.id = criteria;
} else if (jsonNode.getNodeType().equals(JsonNodeType.OBJECT)) {
ObjectReader reader = new ObjectMapper().readerFor(new TypeReference<Criteria<UUID>>() {});
this.id = reader.readValue(jsonNode);
}
}
public List<UUID> getIds() {
return ids;
}
public void setIds(List<UUID> ids) {
this.ids = ids;
}
public Criteria<String> getLabel() {
return label;
}
public void setLabel(Criteria<String> label) {
this.label = label;
}
public void setLabel(String label) {
Criteria<String> criteria = new Criteria<>();
criteria.setAs(label);
this.label = criteria;
}
public List<Integer> getStatuses() {
return statuses;
}
public void setStatuses(List<Integer> statuses) {
this.statuses = statuses;
}
public DateCriteria getCreated() {
return created;
}
public void setCreated(DateCriteria created) {
this.created = created;
}
public void setCreated(String created) {
DateCriteria criteria = new DateCriteria();
criteria.setAs(created);
this.created = criteria;
}
public DateCriteria getModified() {
return modified;
}
public void setModified(DateCriteria modified) {
this.modified = modified;
}
public void setModified(String modified) {
DateCriteria criteria = new DateCriteria();
criteria.setAs(modified);
this.modified = criteria;
}
public UserCriteria getCreator() {
return creator;
}
public void setCreator(UserCriteria creator) {
this.creator = creator;
}
public ProjectQuery getQuery(ProjectDao dao) {
ProjectQuery query = new ProjectQuery(dao);
query.setId(this.id.getValue());
return query;
}
}

View File

@ -0,0 +1,38 @@
package eu.eudat.criteria;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import eu.eudat.criteria.entities.Criteria;
import eu.eudat.data.dao.entities.UserInfoDao;
import eu.eudat.query.UserQuery;
import java.io.IOException;
import java.util.UUID;
public class UserCriteria {
private Criteria<UUID> id;
public Criteria<UUID> getId() {
return id;
}
public void setId(JsonNode jsonNode) throws IOException {
if (jsonNode.getNodeType().equals(JsonNodeType.STRING)) {
Criteria<UUID> criteria = new Criteria<>();
criteria.setAs(jsonNode.asText());
this.id = criteria;
} else if (jsonNode.getNodeType().equals(JsonNodeType.OBJECT)) {
ObjectReader reader = new ObjectMapper().readerFor(new TypeReference<Criteria<UUID>>() {});
this.id = reader.readValue(jsonNode);
}
}
public UserQuery getQuery(UserInfoDao dao) {
UserQuery query = new UserQuery(dao);
query.setId(this.id.getValue());
return query;
}
}

View File

@ -0,0 +1,36 @@
package eu.eudat.criteria.entities;
enum BaseCriteriaType implements CriteriaType {
EQUALS,
NOT_EQUALS
}
public class Criteria<T> {
private String as;
private BaseCriteriaType type;
private T value;
public String getAs() {
return as;
}
public void setAs(String as) {
this.as = as;
}
public CriteriaType getType() {
return type;
}
public void setType(BaseCriteriaType type) {
this.type = type;
}
public T getValue() {
return value;
}
public void setValue(T value) {
this.value = value;
}
}

View File

@ -0,0 +1,4 @@
package eu.eudat.criteria.entities;
public interface CriteriaType {
}

View File

@ -0,0 +1,32 @@
package eu.eudat.criteria.entities;
import java.util.Date;
enum DateCriteriaType implements CriteriaType {
EQUALS,
NOT_EQUALS,
BEFORE,
BETWEEN,
AFTER
}
public class DateCriteria extends Criteria<Date> {
private Date values;
private CriteriaType type;
public Date getValues() {
return values;
}
public void setValues(Date values) {
this.values = values;
}
public CriteriaType getType() {
return type;
}
public void setType(DateCriteriaType type) {
this.type = type;
}
}