remove old data entities
This commit is contained in:
parent
7c8b385146
commit
dec8f6354c
|
@ -2,14 +2,16 @@ package eu.eudat.data;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||||
|
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"DmpDescriptionTemplate\"")
|
@Table(name = "\"DmpDescriptionTemplate\"")
|
||||||
public class DmpDescriptionTemplateEntity {
|
public class DmpDescriptionTemplateEntity implements DataEntity<DmpDescriptionTemplateEntity, UUID> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
|
@ -104,4 +106,18 @@ public class DmpDescriptionTemplateEntity {
|
||||||
this.isActive = isActive;
|
this.isActive = isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(DmpDescriptionTemplateEntity entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getKeys() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DmpDescriptionTemplateEntity buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,16 @@ import eu.eudat.data.converters.DateToUTCConverter;
|
||||||
import eu.eudat.data.converters.enums.DmpAccessTypeConverter;
|
import eu.eudat.data.converters.enums.DmpAccessTypeConverter;
|
||||||
import eu.eudat.data.converters.enums.DmpStatusConverter;
|
import eu.eudat.data.converters.enums.DmpStatusConverter;
|
||||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||||
|
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"Dmp\"")
|
@Table(name = "\"Dmp\"")
|
||||||
public class DmpEntity {
|
public class DmpEntity implements DataEntity<DmpEntity, UUID> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
|
@ -244,4 +246,20 @@ public class DmpEntity {
|
||||||
public void setVersionStatus(DmpVersionStatus versionStatus) {
|
public void setVersionStatus(DmpVersionStatus versionStatus) {
|
||||||
this.versionStatus = versionStatus;
|
this.versionStatus = versionStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(DmpEntity entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getKeys() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DmpEntity buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,16 @@ import eu.eudat.commons.enums.DmpUserRole;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.converters.enums.DmpUserRoleConverter;
|
import eu.eudat.data.converters.enums.DmpUserRoleConverter;
|
||||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||||
|
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"DmpUser\"")
|
@Table(name = "\"DmpUser\"")
|
||||||
public class DmpUserEntity {
|
public class DmpUserEntity implements DataEntity {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
|
@ -107,4 +109,18 @@ public class DmpUserEntity {
|
||||||
this.isActive = isActive;
|
this.isActive = isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Object entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getKeys() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object buildFromTuple(List tuple, List fields, String base) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,11 @@ package eu.eudat.data;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.EntityType;
|
import eu.eudat.commons.enums.EntityType;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
|
||||||
import eu.eudat.data.converters.enums.EntityTypeConverter;
|
import eu.eudat.data.converters.enums.EntityTypeConverter;
|
||||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
|
|
@ -1,401 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"DMP\"")
|
|
||||||
@NamedEntityGraphs({
|
|
||||||
@NamedEntityGraph(
|
|
||||||
name = "dataManagementPlanListingModel",
|
|
||||||
attributeNodes = {
|
|
||||||
@NamedAttributeNode("grant"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile")}/*,*/
|
|
||||||
/*subgraphs = {
|
|
||||||
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
|
|
||||||
}*/
|
|
||||||
),
|
|
||||||
@NamedEntityGraph(
|
|
||||||
name = "fullyDetailed",
|
|
||||||
attributeNodes = {
|
|
||||||
@NamedAttributeNode("grant"), @NamedAttributeNode("profile"),
|
|
||||||
@NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")
|
|
||||||
},
|
|
||||||
subgraphs = {
|
|
||||||
@NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")})
|
|
||||||
}
|
|
||||||
),
|
|
||||||
@NamedEntityGraph(
|
|
||||||
name = "dmpRecentActivity",
|
|
||||||
attributeNodes = {
|
|
||||||
@NamedAttributeNode("users"), @NamedAttributeNode("creator")}),
|
|
||||||
// @NamedEntityGraph(
|
|
||||||
// name = "recentDmpModel",
|
|
||||||
// attributeNodes = {@NamedAttributeNode("organisations"), @NamedAttributeNode("researchers"), @NamedAttributeNode("associatedDmps"),
|
|
||||||
// @NamedAttributeNode("grant"), @NamedAttributeNode(value = "users", subgraph = "users"), @NamedAttributeNode("creator"), @NamedAttributeNode("profile"), @NamedAttributeNode(value = "dataset", subgraph = "dataset")},
|
|
||||||
// subgraphs = {
|
|
||||||
// @NamedSubgraph(name = "users", attributeNodes = {@NamedAttributeNode("user")}),
|
|
||||||
// @NamedSubgraph(name = "dataset", attributeNodes = {@NamedAttributeNode("id"), @NamedAttributeNode("label")})
|
|
||||||
// }
|
|
||||||
// ),
|
|
||||||
@NamedEntityGraph(
|
|
||||||
name = "versionListingModel",
|
|
||||||
attributeNodes = {@NamedAttributeNode("id"), @NamedAttributeNode("groupId"), @NamedAttributeNode("version")}
|
|
||||||
)
|
|
||||||
|
|
||||||
})
|
|
||||||
public class DMP implements DataEntity<DMP, UUID> {
|
|
||||||
|
|
||||||
public enum DMPStatus {
|
|
||||||
ACTIVE((short) 0), FINALISED((short) 1),DELETED((short) 99);
|
|
||||||
|
|
||||||
private short value;
|
|
||||||
|
|
||||||
private DMPStatus(short value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static DMPStatus fromInteger(short value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
return ACTIVE;
|
|
||||||
case 1:
|
|
||||||
return FINALISED;
|
|
||||||
case 99:
|
|
||||||
return DELETED;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unsupported DMP Status");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Set<String> getHints() {
|
|
||||||
return hints;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Set<String> hints = new HashSet<>(Arrays.asList("dataManagementPlanListingModel", "fullyDetailed"));
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"GroupId\"", columnDefinition = "BINARY(16)")
|
|
||||||
private UUID groupId;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@Column(name = "\"Version\"")
|
|
||||||
private Integer version;
|
|
||||||
|
|
||||||
@Transient
|
|
||||||
private Set<DescriptionEntity> descriptionEntity;
|
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"Grant\"")
|
|
||||||
private Grant grant;
|
|
||||||
|
|
||||||
|
|
||||||
/*@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
|
||||||
@Column(name = "\"AssociatedDmps\"", columnDefinition = "xml", nullable = true)
|
|
||||||
private String associatedDmps;*/
|
|
||||||
@OneToMany(fetch = FetchType.LAZY, mappedBy = "dmp")
|
|
||||||
private Set<DMPDatasetProfile> associatedDmps;
|
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"Profile\"")
|
|
||||||
private DmpBlueprintEntity profile;
|
|
||||||
|
|
||||||
|
|
||||||
@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 = "\"DMPResearcher\"",
|
|
||||||
joinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")},
|
|
||||||
inverseJoinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")}
|
|
||||||
)
|
|
||||||
private Set<Researcher> researchers;
|
|
||||||
|
|
||||||
|
|
||||||
@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;
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
@Column(name = "\"Properties\"")
|
|
||||||
private String properties;
|
|
||||||
|
|
||||||
@Column(name = "\"DmpProperties\"")
|
|
||||||
private String dmpProperties;
|
|
||||||
|
|
||||||
@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 = "\"Description\"")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
@Column(name= "\"FinalizedAt\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date finalizedAt;
|
|
||||||
|
|
||||||
@Column(name = "\"isPublic\"", nullable = false)
|
|
||||||
private boolean isPublic;
|
|
||||||
|
|
||||||
@Column(name= "\"PublishedAt\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date publishedAt;
|
|
||||||
|
|
||||||
@Transient
|
|
||||||
private Set<EntityDoiEntity> dois;
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"Project\"")
|
|
||||||
private Project project;
|
|
||||||
|
|
||||||
@Column(name = "\"extraProperties\"")
|
|
||||||
private String extraProperties;
|
|
||||||
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserInfo getCreator() {
|
|
||||||
return creator;
|
|
||||||
}
|
|
||||||
public void setCreator(UserInfo creator) {
|
|
||||||
this.creator = creator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<UserDMP> getUsers() {
|
|
||||||
return users;
|
|
||||||
}
|
|
||||||
public void setUsers(Set<UserDMP> users) {
|
|
||||||
this.users = users;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 Integer getVersion() {
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
public void setVersion(Integer version) {
|
|
||||||
this.version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Grant getGrant() {
|
|
||||||
return grant;
|
|
||||||
}
|
|
||||||
public void setGrant(Grant grant) {
|
|
||||||
this.grant = grant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<DMPDatasetProfile> getAssociatedDmps() {
|
|
||||||
return associatedDmps;
|
|
||||||
}
|
|
||||||
public void setAssociatedDmps(Set<DMPDatasetProfile> associatedDmps) {
|
|
||||||
this.associatedDmps = associatedDmps;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DmpBlueprintEntity getProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
public void setProfile(DmpBlueprintEntity profile) {
|
|
||||||
this.profile = profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<DescriptionEntity> getDataset() {
|
|
||||||
return descriptionEntity;
|
|
||||||
}
|
|
||||||
public void setDataset(Set<DescriptionEntity> descriptionEntity) {
|
|
||||||
this.descriptionEntity = descriptionEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getFinalizedAt() {
|
|
||||||
return finalizedAt;
|
|
||||||
}
|
|
||||||
public void setFinalizedAt(Date finalizedAt) {
|
|
||||||
this.finalizedAt = finalizedAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isPublic() {
|
|
||||||
return isPublic;
|
|
||||||
}
|
|
||||||
public void setPublic(boolean aPublic) {
|
|
||||||
isPublic = aPublic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getPublishedAt() {
|
|
||||||
return publishedAt;
|
|
||||||
}
|
|
||||||
public void setPublishedAt(Date publishedAt) {
|
|
||||||
this.publishedAt = publishedAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<EntityDoiEntity> getDois() {
|
|
||||||
return dois;
|
|
||||||
}
|
|
||||||
public void setDois(Set<EntityDoiEntity> dois) {
|
|
||||||
this.dois = dois;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Project getProject() {
|
|
||||||
return project;
|
|
||||||
}
|
|
||||||
public void setProject(Project project) {
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExtraProperties() {
|
|
||||||
return extraProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExtraProperties(String extraProperties) {
|
|
||||||
this.extraProperties = extraProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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.grant = entity.getGrant();
|
|
||||||
this.description = entity.getDescription();
|
|
||||||
this.researchers = entity.getResearchers();
|
|
||||||
this.organisations = entity.getOrganisations();
|
|
||||||
this.dmpProperties = entity.getDmpProperties();
|
|
||||||
this.isPublic = entity.isPublic;
|
|
||||||
this.project = entity.getProject();
|
|
||||||
this.setModified(new Date());
|
|
||||||
if (entity.getStatus().equals(DMPStatus.FINALISED.getValue())) this.setFinalizedAt(new Date());
|
|
||||||
if (entity.isPublic) this.setPublishedAt(new Date());
|
|
||||||
if (entity.getUsers() != null) this.users = entity.getUsers();
|
|
||||||
this.dois = entity.getDois();
|
|
||||||
this.extraProperties = entity.getExtraProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DMP buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
|
||||||
this.id = tuple.get(0).get(base.isEmpty() ? "id" : base + "." + "id", UUID.class);
|
|
||||||
this.descriptionEntity = tuple.stream().map(x -> new DescriptionEntity().buildFromTuple(tuple, fields ,base.isEmpty() ? "dataset" : base + "." + "dataset")).collect(Collectors.toSet());
|
|
||||||
this.creator = tuple.stream().map(x -> new UserInfo().buildFromTuple(tuple, fields , base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"DMPDatasetProfile\"")
|
|
||||||
public class DMPDatasetProfile implements DataEntity<DMPDatasetProfile, UUID> {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "\"dmp\"")
|
|
||||||
private DMP dmp;
|
|
||||||
|
|
||||||
@ManyToOne
|
|
||||||
@JoinColumn(name = "\"datasetprofile\"")
|
|
||||||
private DescriptionTemplateEntity datasetprofile;
|
|
||||||
|
|
||||||
@Column(name = "\"data\"")
|
|
||||||
private String data;
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DMP getDmp() {
|
|
||||||
return dmp;
|
|
||||||
}
|
|
||||||
public void setDmp(DMP dmp) {
|
|
||||||
this.dmp = dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionTemplateEntity getDatasetprofile() {
|
|
||||||
return datasetprofile;
|
|
||||||
}
|
|
||||||
public void setDatasetprofile(DescriptionTemplateEntity datasetprofile) {
|
|
||||||
this.datasetprofile = datasetprofile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
public void setData(String data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(DMPDatasetProfile entity) {
|
|
||||||
this.dmp = entity.getDmp();
|
|
||||||
this.datasetprofile = entity.getDatasetprofile();
|
|
||||||
this.data = entity.getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DMPDatasetProfile buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
|
||||||
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"DMPOrganisation\"")
|
|
||||||
public class DMPOrganisation {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"DMP\"")
|
|
||||||
private UUID dmp;
|
|
||||||
|
|
||||||
@Column(name = "\"Organisation\"")
|
|
||||||
private UUID organisation;
|
|
||||||
|
|
||||||
@Column(name = "\"Role\"")
|
|
||||||
private Integer role;
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getDmp() {
|
|
||||||
return dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDmp(UUID dmp) {
|
|
||||||
this.dmp = dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getOrganisation() {
|
|
||||||
return organisation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrganisation(UUID organisation) {
|
|
||||||
this.organisation = organisation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getRole() {
|
|
||||||
return role;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRole(Integer role) {
|
|
||||||
this.role = role;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,60 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"DMPResearcher\"")
|
|
||||||
public class DMPResearcher {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"DMP\"")
|
|
||||||
private UUID dmp;
|
|
||||||
|
|
||||||
@Column(name = "\"Researcher\"")
|
|
||||||
private UUID researcher;
|
|
||||||
|
|
||||||
@Column(name = "\"Role\"")
|
|
||||||
private Integer role;
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getDmp() {
|
|
||||||
return dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDmp(UUID dmp) {
|
|
||||||
this.dmp = dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getResearcher() {
|
|
||||||
return researcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResearcher(UUID researcher) {
|
|
||||||
this.researcher = researcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getRole() {
|
|
||||||
return role;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRole(Integer role) {
|
|
||||||
this.role = role;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -12,18 +12,18 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"Grant\"")
|
@Table(name = "\"Grant\"")
|
||||||
@NamedEntityGraphs({
|
//@NamedEntityGraphs({
|
||||||
@NamedEntityGraph(
|
// @NamedEntityGraph(
|
||||||
name = "grantRecentActivity",
|
// name = "grantRecentActivity",
|
||||||
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps")},
|
// attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps")},
|
||||||
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("users")})
|
// subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("users")})
|
||||||
),
|
// ),
|
||||||
@NamedEntityGraph(
|
// @NamedEntityGraph(
|
||||||
name = "grantListingItem",
|
// name = "grantListingItem",
|
||||||
attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps"), @NamedAttributeNode(value = "content")},
|
// attributeNodes = {@NamedAttributeNode(value = "dmps", subgraph = "dmps"), @NamedAttributeNode(value = "content")},
|
||||||
subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("grant"), @NamedAttributeNode("users")})
|
// subgraphs = @NamedSubgraph(name = "dmps", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("grant"), @NamedAttributeNode("users")})
|
||||||
)
|
// )
|
||||||
})
|
//})
|
||||||
public class Grant implements DataEntity<Grant, UUID> {
|
public class Grant implements DataEntity<Grant, UUID> {
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
|
@ -85,8 +85,8 @@ public class Grant implements DataEntity<Grant, UUID> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "grant")
|
// @OneToMany(mappedBy = "grant")
|
||||||
private Set<DMP> dmps;
|
// private Set<DMP> dmps;
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
@Column(name = "\"Label\"")
|
||||||
private String label;
|
private String label;
|
||||||
|
@ -229,12 +229,12 @@ public class Grant implements DataEntity<Grant, UUID> {
|
||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<DMP> getDmps() {
|
// public Set<DMP> getDmps() {
|
||||||
return dmps;
|
// return dmps;
|
||||||
}
|
// }
|
||||||
public void setDmps(Set<DMP> dmps) {
|
// public void setDmps(Set<DMP> dmps) {
|
||||||
this.dmps = dmps;
|
// this.dmps = dmps;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public UserInfo getCreationUser() {
|
public UserInfo getCreationUser() {
|
||||||
return creationUser;
|
return creationUser;
|
||||||
|
@ -271,7 +271,7 @@ public class Grant implements DataEntity<Grant, UUID> {
|
||||||
this.abbreviation = entity.getAbbreviation();
|
this.abbreviation = entity.getAbbreviation();
|
||||||
this.created = entity.getCreated();
|
this.created = entity.getCreated();
|
||||||
this.definition = entity.getDefinition();
|
this.definition = entity.getDefinition();
|
||||||
this.dmps = entity.getDmps();
|
// this.dmps = entity.getDmps();
|
||||||
this.startdate = entity.getStartdate();
|
this.startdate = entity.getStartdate();
|
||||||
this.enddate = entity.getEnddate();
|
this.enddate = entity.getEnddate();
|
||||||
this.modified = new Date();
|
this.modified = new Date();
|
||||||
|
@ -289,8 +289,8 @@ public class Grant implements DataEntity<Grant, UUID> {
|
||||||
public Grant buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
public Grant buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||||
String currentBase = base.isEmpty() ? "" : base + ".";
|
String currentBase = base.isEmpty() ? "" : base + ".";
|
||||||
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
|
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
|
||||||
if (fields.contains(currentBase + "dmps"))
|
// if (fields.contains(currentBase + "dmps"))
|
||||||
this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
|
// this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
|
||||||
if (fields.contains(currentBase + "creationUser"))
|
if (fields.contains(currentBase + "creationUser"))
|
||||||
this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
|
this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -24,9 +24,9 @@ public class Invitation implements DataEntity<Invitation, UUID> {
|
||||||
@JoinColumn(name = "\"CreationUser\"", nullable = false)
|
@JoinColumn(name = "\"CreationUser\"", nullable = false)
|
||||||
private UserInfo user;
|
private UserInfo user;
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.EAGER)
|
// @OneToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "\"Dmp\"", nullable = false)
|
// @JoinColumn(name = "\"Dmp\"", nullable = false)
|
||||||
private DMP dmp;
|
// private DMP dmp;
|
||||||
|
|
||||||
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
private UUID token;
|
private UUID token;
|
||||||
|
@ -61,13 +61,13 @@ public class Invitation implements DataEntity<Invitation, UUID> {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DMP getDmp() {
|
// public DMP getDmp() {
|
||||||
return dmp;
|
// return dmp;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setDmp(DMP dmp) {
|
// public void setDmp(DMP dmp) {
|
||||||
this.dmp = dmp;
|
// this.dmp = dmp;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public UUID getToken() {
|
public UUID getToken() {
|
||||||
return token;
|
return token;
|
||||||
|
|
|
@ -12,13 +12,13 @@ import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"Organisation\"")
|
//@Table(name = "\"Organisation\"")
|
||||||
@NamedEntityGraphs({
|
//@NamedEntityGraphs({
|
||||||
@NamedEntityGraph(
|
// @NamedEntityGraph(
|
||||||
name = "organisationRecentActivity",
|
// name = "organisationRecentActivity",
|
||||||
attributeNodes = {@NamedAttributeNode(value = "dmps")}
|
// attributeNodes = {@NamedAttributeNode(value = "dmps")}
|
||||||
)
|
// )
|
||||||
})
|
//})
|
||||||
public class Organisation implements Serializable, DataEntity<Organisation,UUID> {
|
public class Organisation implements Serializable, DataEntity<Organisation,UUID> {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
|
@ -41,12 +41,12 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
|
||||||
@Column(name = "\"Definition\"", nullable = true)
|
@Column(name = "\"Definition\"", nullable = true)
|
||||||
private String definition;
|
private String definition;
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY)
|
// @OneToMany(fetch = FetchType.LAZY)
|
||||||
@JoinTable(name = "\"DMPOrganisation\"",
|
// @JoinTable(name = "\"DMPOrganisation\"",
|
||||||
joinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")},
|
// joinColumns = {@JoinColumn(name = "\"Organisation\"", referencedColumnName = "\"ID\"")},
|
||||||
inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
|
// inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
|
||||||
)
|
// )
|
||||||
private Set<DMP> dmps;
|
// private Set<DMP> dmps;
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
@Column(name = "\"Status\"", nullable = false)
|
||||||
private Short status;
|
private Short status;
|
||||||
|
@ -123,12 +123,12 @@ public class Organisation implements Serializable, DataEntity<Organisation,UUID>
|
||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<DMP> getDmps() {
|
// public Set<DMP> getDmps() {
|
||||||
return dmps;
|
// return dmps;
|
||||||
}
|
// }
|
||||||
public void setDmps(Set<DMP> dmps) {
|
// public void setDmps(Set<DMP> dmps) {
|
||||||
this.dmps = dmps;
|
// this.dmps = dmps;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Organisation entity) {
|
public void update(Organisation entity) {
|
||||||
|
|
|
@ -70,8 +70,8 @@ public class Project implements DataEntity<Project, UUID> {
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "project")
|
// @OneToMany(mappedBy = "project")
|
||||||
private Set<DMP> dmps;
|
// private Set<DMP> dmps;
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
@Column(name = "\"Label\"")
|
||||||
private String label;
|
private String label;
|
||||||
|
@ -131,12 +131,12 @@ public class Project implements DataEntity<Project, UUID> {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<DMP> getDmps() {
|
// public Set<DMP> getDmps() {
|
||||||
return dmps;
|
// return dmps;
|
||||||
}
|
// }
|
||||||
public void setDmps(Set<DMP> dmps) {
|
// public void setDmps(Set<DMP> dmps) {
|
||||||
this.dmps = dmps;
|
// this.dmps = dmps;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public String getLabel() {
|
public String getLabel() {
|
||||||
return label;
|
return label;
|
||||||
|
@ -243,7 +243,7 @@ public class Project implements DataEntity<Project, UUID> {
|
||||||
this.abbreviation = entity.getAbbreviation();
|
this.abbreviation = entity.getAbbreviation();
|
||||||
this.created = entity.getCreated();
|
this.created = entity.getCreated();
|
||||||
this.definition = entity.getDefinition();
|
this.definition = entity.getDefinition();
|
||||||
this.dmps = entity.getDmps();
|
// this.dmps = entity.getDmps();
|
||||||
this.startdate = entity.getStartdate();
|
this.startdate = entity.getStartdate();
|
||||||
this.enddate = entity.getEnddate();
|
this.enddate = entity.getEnddate();
|
||||||
this.modified = new Date();
|
this.modified = new Date();
|
||||||
|
@ -258,7 +258,7 @@ public class Project implements DataEntity<Project, UUID> {
|
||||||
project.setAbbreviation(grant.getAbbreviation());
|
project.setAbbreviation(grant.getAbbreviation());
|
||||||
project.setCreated(new Date());
|
project.setCreated(new Date());
|
||||||
project.setDefinition(grant.getDefinition());
|
project.setDefinition(grant.getDefinition());
|
||||||
project.setDmps(grant.getDmps());
|
// project.setDmps(grant.getDmps());
|
||||||
project.setStartdate(grant.getStartdate());
|
project.setStartdate(grant.getStartdate());
|
||||||
project.setEnddate(grant.getEnddate());
|
project.setEnddate(grant.getEnddate());
|
||||||
project.setModified(new Date());
|
project.setModified(new Date());
|
||||||
|
@ -279,8 +279,8 @@ public class Project implements DataEntity<Project, UUID> {
|
||||||
public Project buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
public Project buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||||
String currentBase = base.isEmpty() ? "" : base + ".";
|
String currentBase = base.isEmpty() ? "" : base + ".";
|
||||||
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
|
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
|
||||||
if (fields.contains(currentBase + "dmps"))
|
// if (fields.contains(currentBase + "dmps"))
|
||||||
this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
|
// this.dmps = tuple.stream().map(x -> new DMP().buildFromTuple(Arrays.asList(x), fields, currentBase + "dmps")).collect(Collectors.toSet());
|
||||||
if (fields.contains(currentBase + "creationUser"))
|
if (fields.contains(currentBase + "creationUser"))
|
||||||
this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
|
this.creationUser = tuple.stream().map(x -> new UserInfo().buildFromTuple(Arrays.asList(x), fields, currentBase + "creationUser")).collect(Collectors.toList()).get(0);
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -36,12 +36,12 @@ public class Researcher implements DataEntity<Researcher, UUID> {
|
||||||
private String reference;
|
private String reference;
|
||||||
|
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY)
|
// @OneToMany(fetch = FetchType.LAZY)
|
||||||
@JoinTable(name = "\"DMPResearcher\"",
|
// @JoinTable(name = "\"DMPResearcher\"",
|
||||||
joinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")},
|
// joinColumns = {@JoinColumn(name = "\"Researcher\"", referencedColumnName = "\"ID\"")},
|
||||||
inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
|
// inverseJoinColumns = {@JoinColumn(name = "\"DMP\"", referencedColumnName = "\"ID\"")}
|
||||||
)
|
// )
|
||||||
private Set<DMP> dMPs;
|
// private Set<DMP> dMPs;
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
@Column(name = "\"Status\"", nullable = false)
|
||||||
|
@ -123,12 +123,12 @@ public class Researcher implements DataEntity<Researcher, UUID> {
|
||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<DMP> getdMPs() {
|
// public Set<DMP> getdMPs() {
|
||||||
return dMPs;
|
// return dMPs;
|
||||||
}
|
// }
|
||||||
public void setdMPs(Set<DMP> dMPs) {
|
// public void setdMPs(Set<DMP> dMPs) {
|
||||||
this.dMPs = dMPs;
|
// this.dMPs = dMPs;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public UserInfo getCreationUser() {
|
public UserInfo getCreationUser() {
|
||||||
return creationUser;
|
return creationUser;
|
||||||
|
|
|
@ -1,113 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
import eu.eudat.data.old.helpers.EntityBinder;
|
|
||||||
import eu.eudat.data.old.queryableentity.DataEntity;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"UserDMP\"")
|
|
||||||
public class UserDMP implements DataEntity<UserDMP, UUID> {
|
|
||||||
|
|
||||||
public enum UserDMPRoles {
|
|
||||||
OWNER(0), USER(1);
|
|
||||||
|
|
||||||
private Integer value;
|
|
||||||
|
|
||||||
private UserDMPRoles(Integer value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<Integer> getAllValues() {
|
|
||||||
List<Integer> list = new LinkedList<>();
|
|
||||||
for (Enum en : UserDMP.UserDMPRoles.values()) {
|
|
||||||
list.add(((UserDMPRoles) en).value);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
@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 = "dmp")
|
|
||||||
private DMP dmp;
|
|
||||||
|
|
||||||
@Column(name = "role")
|
|
||||||
private Integer role;
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UserInfo getUser() {
|
|
||||||
return user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUser(UserInfo user) {
|
|
||||||
this.user = user;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DMP getDmp() {
|
|
||||||
return dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDmp(DMP dmp) {
|
|
||||||
this.dmp = dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getRole() {
|
|
||||||
return role;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRole(Integer role) {
|
|
||||||
this.role = role;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(UserDMP entity) {
|
|
||||||
this.role = entity.getRole();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -66,12 +66,12 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
|
||||||
private String additionalinfo;
|
private String additionalinfo;
|
||||||
public final static String _additionalinfo = "additionalinfo";
|
public final static String _additionalinfo = "additionalinfo";
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY)
|
// @OneToMany(fetch = FetchType.LAZY)
|
||||||
@JoinTable(name = "\"UserDMP\"",
|
// @JoinTable(name = "\"UserDMP\"",
|
||||||
joinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")},
|
// joinColumns = {@JoinColumn(name = "usr", referencedColumnName = "id")},
|
||||||
inverseJoinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")}
|
// inverseJoinColumns = {@JoinColumn(name = "dmp", referencedColumnName = "\"ID\"")}
|
||||||
)
|
// )
|
||||||
private Set<DMP> dmps;
|
// private Set<DMP> dmps;
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY)
|
@OneToMany(fetch = FetchType.LAZY)
|
||||||
@JoinColumn(name = "Id")
|
@JoinColumn(name = "Id")
|
||||||
|
@ -86,13 +86,13 @@ public class UserInfo implements DataEntity<UserInfo, UUID> {
|
||||||
@OneToMany(mappedBy = "userId", fetch = FetchType.LAZY)
|
@OneToMany(mappedBy = "userId", fetch = FetchType.LAZY)
|
||||||
private Set<Notification> notifications = new HashSet<>();
|
private Set<Notification> notifications = new HashSet<>();
|
||||||
|
|
||||||
public Set<DMP> getDmps() {
|
// public Set<DMP> getDmps() {
|
||||||
return dmps;
|
// return dmps;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public void setDmps(Set<DMP> dmps) {
|
// public void setDmps(Set<DMP> dmps) {
|
||||||
this.dmps = dmps;
|
// this.dmps = dmps;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package eu.eudat.model;
|
package eu.eudat.model;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.old.queryableentity.DataEntity;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DmpDescriptionTemplate{
|
public class DmpDescriptionTemplate{
|
||||||
|
@ -90,5 +92,4 @@ public class DmpDescriptionTemplate {
|
||||||
public void setIsActive(IsActive isActive) {
|
public void setIsActive(IsActive isActive) {
|
||||||
this.isActive = isActive;
|
this.isActive = isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ package eu.eudat.model.mapper.deposit;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.depositinterface.models.*;
|
import eu.eudat.depositinterface.models.*;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
|
@ -28,27 +30,27 @@ public class DMPToDepositMapper {
|
||||||
private static final ObjectMapper mapper = new ObjectMapper();
|
private static final ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public static DMPDepositModel fromDMP(DMP entity, FileEnvelope pdfFile, FileEnvelope jsonFile, File supportingFilesZip, String previousDOI) {
|
public static DMPDepositModel fromDMP(DmpEntity entity, FileEnvelope pdfFile, FileEnvelope jsonFile, File supportingFilesZip, String previousDOI) {
|
||||||
DMPDepositModel deposit = new DMPDepositModel();
|
DMPDepositModel deposit = new DMPDepositModel();
|
||||||
deposit.setId(entity.getId());
|
// deposit.setId(entity.getId());
|
||||||
deposit.setVersion(entity.getVersion());
|
// deposit.setVersion(entity.getVersion());
|
||||||
deposit.setLabel(entity.getLabel());
|
// deposit.setLabel(entity.getLabel());
|
||||||
deposit.setDescription(entity.getDescription());
|
// deposit.setDescription(entity.getDescription());
|
||||||
deposit.setPublic(entity.isPublic());
|
// deposit.setPublic(entity.isPublic());
|
||||||
deposit.setDatasets(entity.getDataset().stream().map(DMPToDepositMapper::fromDataset).collect(Collectors.toList()));
|
// deposit.setDatasets(entity.getDataset().stream().map(DMPToDepositMapper::fromDataset).collect(Collectors.toList()));
|
||||||
deposit.setUsers(entity.getUsers().stream().map(DMPToDepositMapper::fromUserDMP).collect(Collectors.toSet()));
|
// deposit.setUsers(entity.getUsers().stream().map(DMPToDepositMapper::fromUserDMP).collect(Collectors.toSet()));
|
||||||
deposit.setOrganisations(entity.getOrganisations().stream().map(DMPToDepositMapper::fromOrganisation).collect(Collectors.toSet()));
|
// deposit.setOrganisations(entity.getOrganisations().stream().map(DMPToDepositMapper::fromOrganisation).collect(Collectors.toSet()));
|
||||||
deposit.setResearchers(entity.getResearchers().stream().map(DMPToDepositMapper::fromResearcher).collect(Collectors.toSet()));
|
// deposit.setResearchers(entity.getResearchers().stream().map(DMPToDepositMapper::fromResearcher).collect(Collectors.toSet()));
|
||||||
if (entity.getGrant() != null) {
|
// if (entity.getGrant() != null) {
|
||||||
deposit.setGrant(fromGrant(entity.getGrant()));
|
// deposit.setGrant(fromGrant(entity.getGrant()));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
deposit.setPdfFile(pdfFile);
|
// deposit.setPdfFile(pdfFile);
|
||||||
deposit.setRdaJsonFile(jsonFile);
|
// deposit.setRdaJsonFile(jsonFile);
|
||||||
deposit.setSupportingFilesZip(supportingFilesZip);
|
// deposit.setSupportingFilesZip(supportingFilesZip);
|
||||||
deposit.setPreviousDOI(previousDOI);
|
// deposit.setPreviousDOI(previousDOI);
|
||||||
|
//
|
||||||
deposit.setExtraProperties(entity.getExtraProperties());
|
// deposit.setExtraProperties(entity.getExtraProperties());
|
||||||
return deposit;
|
return deposit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,12 +120,12 @@ public class DMPToDepositMapper {
|
||||||
return deposit;
|
return deposit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static UserDMPDepositModel fromUserDMP(UserDMP entity){
|
// private static UserDMPDepositModel fromUserDMP(DmpUserEntity entity){
|
||||||
UserDMPDepositModel deposit = new UserDMPDepositModel();
|
// UserDMPDepositModel deposit = new UserDMPDepositModel();
|
||||||
deposit.setUser(fromUserInfo(entity.getUser()));
|
// deposit.setUser(fromUserInfo(entity.getUser()));
|
||||||
deposit.setRole(entity.getRole());
|
// deposit.setRole(entity.getRole().getValue().intValue());
|
||||||
return deposit;
|
// return deposit;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private static UserInfoDepositModel fromUserInfo(UserInfo entity){
|
private static UserInfoDepositModel fromUserInfo(UserInfo entity){
|
||||||
UserInfoDepositModel deposit = new UserInfoDepositModel();
|
UserInfoDepositModel deposit = new UserInfoDepositModel();
|
||||||
|
|
|
@ -5,12 +5,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
import eu.eudat.data.*;
|
import eu.eudat.data.*;
|
||||||
import eu.eudat.data.old.UserDMP;
|
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.depositinterface.models.*;
|
import eu.eudat.depositinterface.models.*;
|
||||||
import eu.eudat.query.DescriptionQuery;
|
import eu.eudat.query.DescriptionQuery;
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
import eu.eudat.query.DmpDescriptionTemplateQuery;
|
||||||
|
import eu.eudat.query.DmpUserQuery;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import jakarta.persistence.EntityManager;
|
import jakarta.persistence.EntityManager;
|
||||||
import jakarta.persistence.criteria.*;
|
import jakarta.persistence.criteria.*;
|
||||||
|
@ -49,7 +49,7 @@ public class DmpEntityDepositMapper {
|
||||||
public DMPDepositModel toDeposit(DmpEntity dmpEntity, File zip, FileEnvelope pdf, FileEnvelope json, String previousDOI) {
|
public DMPDepositModel toDeposit(DmpEntity dmpEntity, File zip, FileEnvelope pdf, FileEnvelope json, String previousDOI) {
|
||||||
DMPDepositModel model = new DMPDepositModel();
|
DMPDepositModel model = new DMPDepositModel();
|
||||||
List<DescriptionEntity> desciptions = this.getDescriptions(dmpEntity.getId());
|
List<DescriptionEntity> desciptions = this.getDescriptions(dmpEntity.getId());
|
||||||
List<UserDMP> users = getUsers(dmpEntity.getId());
|
List<DmpUserEntity> users = getUsers(dmpEntity.getId());
|
||||||
model.setId(dmpEntity.getId());
|
model.setId(dmpEntity.getId());
|
||||||
model.setLabel(dmpEntity.getLabel());
|
model.setLabel(dmpEntity.getLabel());
|
||||||
model.setDescription(dmpEntity.getDescription());
|
model.setDescription(dmpEntity.getDescription());
|
||||||
|
@ -142,21 +142,17 @@ public class DmpEntityDepositMapper {
|
||||||
return deposit;
|
return deposit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<UserDMP> getUsers(UUID dmpId) {
|
private List<DmpUserEntity> getUsers(UUID dmpId) {
|
||||||
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
|
return this.queryFactory.query(DmpUserQuery.class).userIds(dmpId).collect();
|
||||||
CriteriaQuery<UserDMP> query = builder.createQuery(UserDMP.class);
|
|
||||||
Root<UserDMP> root = query.from(UserDMP.class);
|
|
||||||
Join<UserInfo, UserDMP> join = root.join("user").join("id");
|
|
||||||
query = query.multiselect(root.get("user"), root.get("role"));
|
|
||||||
return entityManager.createQuery(query).getResultList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserDMPDepositModel toUserDeposit(UserDMP user) {
|
private UserDMPDepositModel toUserDeposit(DmpUserEntity user) {
|
||||||
UserDMPDepositModel userDMPDepositModel = new UserDMPDepositModel();
|
UserDMPDepositModel userDMPDepositModel = new UserDMPDepositModel();
|
||||||
userDMPDepositModel.setUser(new UserInfoDepositModel());
|
userDMPDepositModel.setUser(new UserInfoDepositModel());
|
||||||
userDMPDepositModel.getUser().setName(user.getUser().getName());
|
UserInfo userInfo = this.entityManager.find(UserInfo.class, user.getUser());
|
||||||
userDMPDepositModel.getUser().setEmail(user.getUser().getEmail());
|
userDMPDepositModel.getUser().setName(userInfo.getName());
|
||||||
userDMPDepositModel.setRole(user.getRole());
|
userDMPDepositModel.getUser().setEmail(userInfo.getEmail());
|
||||||
|
userDMPDepositModel.setRole(user.getRole().getValue().intValue());
|
||||||
|
|
||||||
return userDMPDepositModel;
|
return userDMPDepositModel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import eu.eudat.commons.enums.EntityType;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.model.EntityDoi;
|
import eu.eudat.model.EntityDoi;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.query.FieldResolver;
|
import gr.cite.tools.data.query.FieldResolver;
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DataManagementPlanCriteria extends Criteria<DMP> {
|
public class DataManagementPlanCriteria extends Criteria<DmpEntity> {
|
||||||
private Date periodStart;
|
private Date periodStart;
|
||||||
private Date periodEnd;
|
private Date periodEnd;
|
||||||
private DmpBlueprintEntity profile;
|
private DmpBlueprintEntity profile;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.types.grant.GrantStateType;
|
import eu.eudat.types.grant.GrantStateType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DataManagementPlanPublicCriteria extends Criteria<DMP> {
|
public class DataManagementPlanPublicCriteria extends Criteria<DmpEntity> {
|
||||||
private GrantStateType grantStatus;
|
private GrantStateType grantStatus;
|
||||||
private List<UUID> grants;
|
private List<UUID> grants;
|
||||||
public List<UUID> datasetProfile;
|
public List<UUID> datasetProfile;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
|
||||||
public class DatasetWizardUserDmpCriteria extends Criteria<DMP> {
|
public class DatasetWizardUserDmpCriteria extends Criteria<DmpEntity> {
|
||||||
private UserInfo userInfo;
|
private UserInfo userInfo;
|
||||||
|
|
||||||
public UserInfo getUserInfo() {
|
public UserInfo getUserInfo() {
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface DMPDao extends DatabaseAccessLayer<DMP, UUID> {
|
public interface DMPDao extends DatabaseAccessLayer<DmpEntity, UUID> {
|
||||||
|
|
||||||
QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria);
|
QueryableList<DmpEntity> getWithCriteria(DataManagementPlanCriteria criteria);
|
||||||
|
|
||||||
QueryableList<DMP> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserInfo userInfo);
|
QueryableList<DmpEntity> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardAutocompleteRequest, UserInfo userInfo);
|
||||||
|
|
||||||
QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principalId, List<Integer> roles);
|
QueryableList<DmpEntity> getAuthenticated(QueryableList<DmpEntity> query, UUID principalId, List<Integer> roles);
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DmpStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
|
@ -25,16 +27,16 @@ import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Component("dMPDao")
|
@Component("dMPDao")
|
||||||
public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
public class DMPDaoImpl extends DatabaseAccess<DmpEntity> implements DMPDao {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DMPDaoImpl(DatabaseService<DMP> databaseService) {
|
public DMPDaoImpl(DatabaseService<DmpEntity> databaseService) {
|
||||||
super(databaseService);
|
super(databaseService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria) {
|
public QueryableList<DmpEntity> getWithCriteria(DataManagementPlanCriteria criteria) {
|
||||||
QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.getHints(), DMP.class);
|
QueryableList<DmpEntity> query = getDatabaseService().getQueryable(DmpEntity.class);
|
||||||
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
if (criteria.getLike() != null && !criteria.getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.or(
|
query.where((builder, root) -> builder.or(
|
||||||
builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%"),
|
||||||
|
@ -51,14 +53,14 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"),
|
||||||
query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(
|
query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(
|
||||||
builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")),
|
builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")),
|
||||||
builder1.notEqual(nestedRoot.get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), Integer.class)));
|
builder1.notEqual(nestedRoot.get("isActive"), IsActive.Inactive.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), Integer.class)));
|
||||||
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
||||||
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
query.where((builder, root) -> root.get("groupId").in(criteria.getGroupIds()));
|
||||||
if (criteria.getStatus() != null) {
|
if (criteria.getStatus() != null) {
|
||||||
if (criteria.getStatus() == DMP.DMPStatus.FINALISED.getValue()) {
|
if (criteria.getStatus() == DmpStatus.Finalized.getValue().intValue()) {
|
||||||
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
query.where((builder, root) -> builder.equal(root.get("status"), DmpStatus.Finalized.getValue()));
|
||||||
} else if (criteria.getStatus() == DMP.DMPStatus.ACTIVE.getValue()) {
|
} else if (criteria.getStatus() == DmpStatus.Draft.getValue().intValue()) {
|
||||||
query.where((builder, root) -> builder.equal(root.get("status"), DMP.DMPStatus.ACTIVE.getValue()));
|
query.where((builder, root) -> builder.equal(root.get("status"), DmpStatus.Draft.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (criteria.getIsPublic()) {
|
if (criteria.getIsPublic()) {
|
||||||
|
@ -92,11 +94,11 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
if (criteria.hasDoi()) {
|
if (criteria.hasDoi()) {
|
||||||
query.where((builder, root) -> builder.not(builder.isNull(root.join("dois").get("id"))));
|
query.where((builder, root) -> builder.not(builder.isNull(root.join("dois").get("id"))));
|
||||||
}
|
}
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UUID principal, List<Integer> roles) {
|
public QueryableList<DmpEntity> getAuthenticated(QueryableList<DmpEntity> query, UUID principal, List<Integer> roles) {
|
||||||
if (roles != null && !roles.isEmpty()) {
|
if (roles != null && !roles.isEmpty()) {
|
||||||
query.where((builder, root) -> {
|
query.where((builder, root) -> {
|
||||||
Join userJoin = root.join("users", JoinType.LEFT);
|
Join userJoin = root.join("users", JoinType.LEFT);
|
||||||
|
@ -111,18 +113,18 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public DMP createOrUpdate(DMP item) {
|
public DmpEntity createOrUpdate(DmpEntity item) {
|
||||||
return this.getDatabaseService().createOrUpdate(item, DMP.class);
|
return this.getDatabaseService().createOrUpdate(item, DmpEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP find(UUID id) throws InvalidApplicationException {
|
public DmpEntity find(UUID id) throws InvalidApplicationException {
|
||||||
return getDatabaseService().getQueryable(DMP.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
return getDatabaseService().getQueryable(DmpEntity.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardUserDmpCriteria, UserInfo userInfo) {
|
public QueryableList<DmpEntity> getUserDmps(DatasetWizardUserDmpCriteria datasetWizardUserDmpCriteria, UserInfo userInfo) {
|
||||||
QueryableList<DMP> query = getDatabaseService().getQueryable(DMP.class).where((builder, root) -> builder.or(builder.equal(root.get("creator"), userInfo), builder.isMember(userInfo, root.get("users"))));
|
QueryableList<DmpEntity> query = getDatabaseService().getQueryable(DmpEntity.class).where((builder, root) -> builder.or(builder.equal(root.get("creator"), userInfo), builder.isMember(userInfo, root.get("users"))));
|
||||||
if (datasetWizardUserDmpCriteria.getLike() != null && !datasetWizardUserDmpCriteria.getLike().isEmpty()) {
|
if (datasetWizardUserDmpCriteria.getLike() != null && !datasetWizardUserDmpCriteria.getLike().isEmpty()) {
|
||||||
query.where((builder, root) -> builder.like(root.get("label"), "%" + datasetWizardUserDmpCriteria.getLike() + "%"));
|
query.where((builder, root) -> builder.like(root.get("label"), "%" + datasetWizardUserDmpCriteria.getLike() + "%"));
|
||||||
}
|
}
|
||||||
|
@ -130,23 +132,23 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(DMP item) {
|
public void delete(DmpEntity item) {
|
||||||
this.getDatabaseService().delete(item);
|
this.getDatabaseService().delete(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> asQueryable() {
|
public QueryableList<DmpEntity> asQueryable() {
|
||||||
return this.getDatabaseService().getQueryable(DMP.class);
|
return this.getDatabaseService().getQueryable(DmpEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<DMP> createOrUpdateAsync(DMP item) {
|
public CompletableFuture<DmpEntity> createOrUpdateAsync(DmpEntity item) {
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP find(UUID id, String hint) {
|
public DmpEntity find(UUID id, String hint) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
@ -52,7 +52,7 @@ public class DatasetDaoImpl extends DatabaseAccess<DescriptionEntity> implements
|
||||||
if (criteria.getPeriodStart() != null)
|
if (criteria.getPeriodStart() != null)
|
||||||
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
query.where((builder, root) -> builder.greaterThan(root.get("created"), criteria.getPeriodStart()));
|
||||||
if (!criteria.getAllVersions())
|
if (!criteria.getAllVersions())
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), builder1.notEqual(nestedRoot.get("dmp").get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), Integer.class)));
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), builder1.notEqual(nestedRoot.get("dmp").get("isActive"), IsActive.Inactive.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), Integer.class)));
|
||||||
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
if (criteria.getGroupIds() != null && !criteria.getGroupIds().isEmpty())
|
||||||
query.where((builder, root) -> root.get("dmp").get("groupId").in(criteria.getGroupIds()));
|
query.where((builder, root) -> root.get("dmp").get("groupId").in(criteria.getGroupIds()));
|
||||||
if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty())
|
if (criteria.getDmpIds() != null && !criteria.getDmpIds().isEmpty())
|
||||||
|
@ -92,7 +92,7 @@ public class DatasetDaoImpl extends DatabaseAccess<DescriptionEntity> implements
|
||||||
|
|
||||||
query.where(((builder, root) -> root.get("id").in(ids)));
|
query.where(((builder, root) -> root.get("id").in(ids)));
|
||||||
if (!criteria.getAllVersions())
|
if (!criteria.getAllVersions())
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), builder1.notEqual(nestedRoot.get("dmp").get("status"), DMP.DMPStatus.DELETED.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), builder1.notEqual(nestedRoot.get("dmp").get("isActive"), IsActive.Inactive.getValue())), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.old.DMPDatasetProfile;
|
import eu.eudat.model.DmpDescriptionTemplate;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface DmpDatasetProfileDao extends DatabaseAccessLayer<DMPDatasetProfile, UUID> {
|
public interface DmpDatasetProfileDao extends DatabaseAccessLayer<DmpDescriptionTemplateEntity, UUID> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.old.DMPDatasetProfile;
|
import eu.eudat.model.DmpDescriptionTemplate;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
@ -13,40 +14,40 @@ import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Service("dmpDatasetProfileDao")
|
@Service("dmpDatasetProfileDao")
|
||||||
public class DmpDatasetProfileDaoImpl extends DatabaseAccess<DMPDatasetProfile> implements DmpDatasetProfileDao {
|
public class DmpDatasetProfileDaoImpl extends DatabaseAccess<DmpDescriptionTemplateEntity> implements DmpDatasetProfileDao {
|
||||||
@Autowired
|
@Autowired
|
||||||
public DmpDatasetProfileDaoImpl(DatabaseService<DMPDatasetProfile> databaseService) {
|
public DmpDatasetProfileDaoImpl(DatabaseService<DmpDescriptionTemplateEntity> databaseService) {
|
||||||
super(databaseService);
|
super(databaseService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMPDatasetProfile createOrUpdate(DMPDatasetProfile item) {
|
public DmpDescriptionTemplateEntity createOrUpdate(DmpDescriptionTemplateEntity item) {
|
||||||
return this.getDatabaseService().createOrUpdate(item, DMPDatasetProfile.class);
|
return this.getDatabaseService().createOrUpdate(item, DmpDescriptionTemplateEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Async
|
@Async
|
||||||
public CompletableFuture<DMPDatasetProfile> createOrUpdateAsync(DMPDatasetProfile item) {
|
public CompletableFuture<DmpDescriptionTemplateEntity> createOrUpdateAsync(DmpDescriptionTemplateEntity item) {
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMPDatasetProfile find(UUID id) throws InvalidApplicationException {
|
public DmpDescriptionTemplateEntity find(UUID id) throws InvalidApplicationException {
|
||||||
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
return this.getDatabaseService().getQueryable(DmpDescriptionTemplateEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMPDatasetProfile find(UUID id, String hint) {
|
public DmpDescriptionTemplateEntity find(UUID id, String hint) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(DMPDatasetProfile item) {
|
public void delete(DmpDescriptionTemplateEntity item) {
|
||||||
this.getDatabaseService().delete(item);
|
this.getDatabaseService().delete(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMPDatasetProfile> asQueryable() {
|
public QueryableList<DmpDescriptionTemplateEntity> asQueryable() {
|
||||||
return this.getDatabaseService().getQueryable(DMPDatasetProfile.class);
|
return this.getDatabaseService().getQueryable(DmpDescriptionTemplateEntity.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DmpStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
@ -51,11 +52,11 @@ public class GrantDaoImpl extends DatabaseAccess<Grant> implements GrantDao {
|
||||||
, builder.isNull(root.get("enddate"))));
|
, builder.isNull(root.get("enddate"))));
|
||||||
}
|
}
|
||||||
if (criteria.isPublic()) {
|
if (criteria.isPublic()) {
|
||||||
query.where((builder, root) -> builder.equal(root.join("dmps").get("status"), DMP.DMPStatus.FINALISED.getValue())).distinct();
|
query.where((builder, root) -> builder.equal(root.join("dmps").get("status"), DmpStatus.Finalized.getValue())).distinct();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.isActive()) {
|
if (criteria.isActive()) {
|
||||||
query.where((builder, root) -> builder.notEqual(root.join("dmps").get("status"), DMP.DMPStatus.DELETED.getValue())).distinct();
|
query.where((builder, root) -> builder.notEqual(root.join("dmps").get("isActive"), IsActive.Inactive.getValue())).distinct();
|
||||||
}
|
}
|
||||||
if (criteria.getFunderId() != null && !criteria.getFunderId().trim().isEmpty())
|
if (criteria.getFunderId() != null && !criteria.getFunderId().trim().isEmpty())
|
||||||
query.where((builder, root) -> builder.equal(root.get("funder").get("id"), UUID.fromString(criteria.getFunderId())));
|
query.where((builder, root) -> builder.equal(root.get("funder").get("id"), UUID.fromString(criteria.getFunderId())));
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DmpStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
import eu.eudat.data.dao.criteria.OrganisationCriteria;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.old.Organisation;
|
import eu.eudat.data.old.Organisation;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
@ -37,12 +38,12 @@ public class OrganisationDaoImpl extends DatabaseAccess<Organisation> implements
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLabelLike().toUpperCase() + "%"));
|
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLabelLike().toUpperCase() + "%"));
|
||||||
}
|
}
|
||||||
if (criteria.getPublic() != null && criteria.getPublic()) {
|
if (criteria.getPublic() != null && criteria.getPublic()) {
|
||||||
query.where((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).get("status"), DMP.DMPStatus.FINALISED.getValue()));
|
query.where((builder, root) -> builder.equal(root.join("dmps", JoinType.LEFT).get("status"), DmpStatus.Finalized.getValue()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (criteria.isActive()) {
|
if (criteria.isActive()) {
|
||||||
query.where((builder, root) -> builder.notEqual(root.join("dmps").get("status"), DMP.DMPStatus.DELETED.getValue())).distinct();
|
query.where((builder, root) -> builder.notEqual(root.join("dmps").get("isActive"), IsActive.Inactive.getValue())).distinct();
|
||||||
}
|
}
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.old.UserDMP;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 2/8/2018.
|
* Created by ikalyvas on 2/8/2018.
|
||||||
*/
|
*/
|
||||||
public interface UserDmpDao extends DatabaseAccessLayer<UserDMP, UUID> {
|
public interface UserDmpDao extends DatabaseAccessLayer<DmpUserEntity, UUID> {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.old.UserDMP;
|
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
@ -16,41 +16,41 @@ import java.util.concurrent.CompletableFuture;
|
||||||
* Created by ikalyvas on 2/8/2018.
|
* Created by ikalyvas on 2/8/2018.
|
||||||
*/
|
*/
|
||||||
@Component("userDmpDao")
|
@Component("userDmpDao")
|
||||||
public class UserDmpDaoImpl extends DatabaseAccess<UserDMP> implements UserDmpDao {
|
public class UserDmpDaoImpl extends DatabaseAccess<DmpUserEntity> implements UserDmpDao {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public UserDmpDaoImpl(DatabaseService<UserDMP> databaseService) {
|
public UserDmpDaoImpl(DatabaseService<DmpUserEntity> databaseService) {
|
||||||
super(databaseService);
|
super(databaseService);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDMP createOrUpdate(UserDMP item) {
|
public DmpUserEntity createOrUpdate(DmpUserEntity item) {
|
||||||
return this.getDatabaseService().createOrUpdate(item, UserDMP.class);
|
return this.getDatabaseService().createOrUpdate(item, DmpUserEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDMP find(UUID id) throws InvalidApplicationException {
|
public DmpUserEntity find(UUID id) throws InvalidApplicationException {
|
||||||
return this.getDatabaseService().getQueryable(UserDMP.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault();
|
return this.getDatabaseService().getQueryable(DmpUserEntity.class).where((builder, root) -> builder.equal(root.get("id"), id)).getSingleOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(UserDMP item) {
|
public void delete(DmpUserEntity item) {
|
||||||
this.getDatabaseService().delete(item);
|
this.getDatabaseService().delete(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<UserDMP> asQueryable() {
|
public QueryableList<DmpUserEntity> asQueryable() {
|
||||||
return this.getDatabaseService().getQueryable(UserDMP.class);
|
return this.getDatabaseService().getQueryable(DmpUserEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<UserDMP> createOrUpdateAsync(UserDMP item) {
|
public CompletableFuture<DmpUserEntity> createOrUpdateAsync(DmpUserEntity item) {
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDMP find(UUID id, String hint) {
|
public DmpUserEntity find(UUID id, String hint) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package eu.eudat.data.query.items.item.dataset;
|
package eu.eudat.data.query.items.item.dataset;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
import eu.eudat.data.dao.criteria.DatasetWizardUserDmpCriteria;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.query.definition.Query;
|
import eu.eudat.data.query.definition.Query;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
public class DatasetWizardAutocompleteRequest extends Query<DatasetWizardUserDmpCriteria, DMP> {
|
public class DatasetWizardAutocompleteRequest extends Query<DatasetWizardUserDmpCriteria, DmpEntity> {
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> applyCriteria() {
|
public QueryableList<DmpEntity> applyCriteria() {
|
||||||
QueryableList<DMP> query = this.getQuery().where((builder, root) -> builder.or(builder.equal(root.get("creator"), this.getCriteria().getUserInfo()), builder.isMember(this.getCriteria().getUserInfo(), root.get("users"))));
|
QueryableList<DmpEntity> query = this.getQuery().where((builder, root) -> builder.or(builder.equal(root.get("creator"), this.getCriteria().getUserInfo()), builder.isMember(this.getCriteria().getUserInfo(), root.get("users"))));
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) {
|
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) {
|
||||||
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.eudat.data.query.items.item.dmp;
|
package eu.eudat.data.query.items.item.dmp;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.query.definition.Query;
|
import eu.eudat.data.query.definition.Query;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
|
@ -9,10 +10,10 @@ import eu.eudat.queryable.types.SelectionField;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class DataManagementPlanCriteriaRequest extends Query<DataManagementPlanCriteria, DMP> {
|
public class DataManagementPlanCriteriaRequest extends Query<DataManagementPlanCriteria, DmpEntity> {
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> applyCriteria() {
|
public QueryableList<DmpEntity> applyCriteria() {
|
||||||
QueryableList<DMP> query = this.getQuery();
|
QueryableList<DmpEntity> query = this.getQuery();
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.or(
|
query.where((builder, root) -> builder.or(
|
||||||
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
|
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
|
||||||
|
@ -27,7 +28,7 @@ public class DataManagementPlanCriteriaRequest extends Query<DataManagementPlanC
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
||||||
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty())
|
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty())
|
||||||
query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
|
query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive.getValue()));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.eudat.data.query.items.table.dmp;
|
package eu.eudat.data.query.items.table.dmp;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.query.PaginationService;
|
import eu.eudat.data.query.PaginationService;
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
import eu.eudat.data.query.definition.TableQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
@ -11,10 +12,10 @@ import eu.eudat.queryable.types.SelectionField;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DataManagementPlanTableRequest extends TableQuery<DataManagementPlanCriteria, DMP, UUID> {
|
public class DataManagementPlanTableRequest extends TableQuery<DataManagementPlanCriteria, DmpEntity, UUID> {
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> applyCriteria() {
|
public QueryableList<DmpEntity> applyCriteria() {
|
||||||
QueryableList<DMP> query = this.getQuery();
|
QueryableList<DmpEntity> query = this.getQuery();
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.or(
|
query.where((builder, root) -> builder.or(
|
||||||
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
|
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
|
||||||
|
@ -29,12 +30,12 @@ public class DataManagementPlanTableRequest extends TableQuery<DataManagementPla
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("groupId"), nestedRoot.get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "version")), String.class)));
|
||||||
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty())
|
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty())
|
||||||
query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
|
query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive.getValue()));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> applyPaging(QueryableList<DMP> items) {
|
public QueryableList<DmpEntity> applyPaging(QueryableList<DmpEntity> items) {
|
||||||
return PaginationService.applyPaging(items, this);
|
return PaginationService.applyPaging(items, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.data.query.items.table.dmp;
|
package eu.eudat.data.query.items.table.dmp;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanPublicCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanPublicCriteria;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.query.PaginationService;
|
import eu.eudat.data.query.PaginationService;
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
import eu.eudat.data.query.definition.TableQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
@ -13,10 +13,10 @@ import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManagementPlanPublicCriteria, DMP, UUID> {
|
public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManagementPlanPublicCriteria, DmpEntity, UUID> {
|
||||||
|
|
||||||
public QueryableList<DMP> applyCriteria() {
|
public QueryableList<DmpEntity> applyCriteria() {
|
||||||
QueryableList<DMP> query = this.getQuery();
|
QueryableList<DmpEntity> query = this.getQuery();
|
||||||
query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
|
query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.or(
|
query.where((builder, root) -> builder.or(
|
||||||
|
@ -48,7 +48,7 @@ public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManageme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> applyPaging(QueryableList<DMP> items) {
|
public QueryableList<DmpEntity> applyPaging(QueryableList<DmpEntity> items) {
|
||||||
return PaginationService.applyPaging(items, this);
|
return PaginationService.applyPaging(items, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.query;
|
package eu.eudat.query;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
@ -17,7 +17,7 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DMPQuery extends Query<DMP, UUID> {
|
public class DMPQuery extends Query<DmpEntity, UUID> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
private String label;
|
private String label;
|
||||||
|
@ -29,11 +29,11 @@ public class DMPQuery extends Query<DMP, UUID> {
|
||||||
private Date created;
|
private Date created;
|
||||||
private Date modified;
|
private Date modified;
|
||||||
|
|
||||||
public DMPQuery(DatabaseAccessLayer<DMP, UUID> databaseAccessLayer) {
|
public DMPQuery(DatabaseAccessLayer<DmpEntity, UUID> databaseAccessLayer) {
|
||||||
super(databaseAccessLayer);
|
super(databaseAccessLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DMPQuery(DatabaseAccessLayer<DMP, UUID> databaseAccessLayer, List<String> selectionFields) {
|
public DMPQuery(DatabaseAccessLayer<DmpEntity, UUID> databaseAccessLayer, List<String> selectionFields) {
|
||||||
super(databaseAccessLayer, selectionFields);
|
super(databaseAccessLayer, selectionFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,8 +117,8 @@ public class DMPQuery extends Query<DMP, UUID> {
|
||||||
this.datasetQuery = datasetQuery;
|
this.datasetQuery = datasetQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<DMP> getQuery() throws InvalidApplicationException {
|
public QueryableList<DmpEntity> getQuery() throws InvalidApplicationException {
|
||||||
QueryableList<DMP> query = this.databaseAccessLayer.asQueryable();
|
QueryableList<DmpEntity> query = this.databaseAccessLayer.asQueryable();
|
||||||
if (this.id != null) {
|
if (this.id != null) {
|
||||||
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
|
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.query;
|
package eu.eudat.query;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
|
@ -59,7 +59,7 @@ public class DatasetQuery extends Query<DescriptionEntity, UUID> {
|
||||||
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
|
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
|
||||||
}
|
}
|
||||||
if (this.dmpQuery != null) {
|
if (this.dmpQuery != null) {
|
||||||
Subquery<DMP> dmpSubQuery = this.dmpQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
Subquery<DmpEntity> dmpSubQuery = this.dmpQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.FIELD, "id")));
|
||||||
query.where((builder, root) -> root.get("dmp").get("id").in(dmpSubQuery));
|
query.where((builder, root) -> root.get("dmp").get("id").in(dmpSubQuery));
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
|
|
|
@ -4,9 +4,9 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
||||||
import eu.eudat.criteria.DMPCriteria;
|
import eu.eudat.criteria.DMPCriteria;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
|
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
|
||||||
import eu.eudat.data.dao.criteria.RequestItem;
|
import eu.eudat.data.dao.criteria.RequestItem;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||||
|
@ -249,7 +249,7 @@ public class DMPs extends BaseController {
|
||||||
ResponseEntity<ResponseItem<eu.eudat.models.data.dmp.DataManagementPlan>> createOrUpdate(@RequestBody eu.eudat.models.data.dmp.DataManagementPlanEditorModel dataManagementPlanEditorModel) throws Exception {
|
ResponseEntity<ResponseItem<eu.eudat.models.data.dmp.DataManagementPlan>> createOrUpdate(@RequestBody eu.eudat.models.data.dmp.DataManagementPlanEditorModel dataManagementPlanEditorModel) throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
DMP dmp = this.dataManagementPlanManager.createOrUpdate(dataManagementPlanEditorModel);
|
DmpEntity dmp = this.dataManagementPlanManager.createOrUpdate(dataManagementPlanEditorModel);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.dmp.DataManagementPlan>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(new eu.eudat.models.data.dmp.DataManagementPlan().fromDataModel(dmp)));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.dmp.DataManagementPlan>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(new eu.eudat.models.data.dmp.DataManagementPlan().fromDataModel(dmp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,7 +259,7 @@ public class DMPs extends BaseController {
|
||||||
ResponseEntity<ResponseItem<UUID>> createOrUpdateWithDatasets(@RequestBody eu.eudat.models.data.dmp.DataManagementPlanEditorModel dataManagementPlanEditorModel) throws Exception {
|
ResponseEntity<ResponseItem<UUID>> createOrUpdateWithDatasets(@RequestBody eu.eudat.models.data.dmp.DataManagementPlanEditorModel dataManagementPlanEditorModel) throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
DMP dmp = this.dataManagementPlanManager.createOrUpdateWithDatasets(dataManagementPlanEditorModel);
|
DmpEntity dmp = this.dataManagementPlanManager.createOrUpdateWithDatasets(dataManagementPlanEditorModel);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(dmp.getId()));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(dmp.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,14 +286,14 @@ public class DMPs extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DMP>> delete(@PathVariable UUID id) {
|
ResponseEntity<ResponseItem<DmpEntity>> delete(@PathVariable UUID id) {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.dataManagementPlanManager.delete(id);
|
this.dataManagementPlanManager.delete(id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Deleted Datamanagement Plan"));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Deleted Datamanagement Plan"));
|
||||||
} catch (DMPWithDatasetsDeleteException | IOException | InvalidApplicationException exception) {
|
} catch (DMPWithDatasetsDeleteException | IOException | InvalidApplicationException exception) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,55 +313,55 @@ public class DMPs extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"})
|
||||||
public ResponseEntity<ResponseItem<DMP>> makePublic(@PathVariable String id) {
|
public ResponseEntity<ResponseItem<DmpEntity>> makePublic(@PathVariable String id) {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.dataManagementPlanManager.makePublic(UUID.fromString(id));
|
this.dataManagementPlanManager.makePublic(UUID.fromString(id));
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made public."));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made public."));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to make Data Management Plan public."));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to make Data Management Plan public."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/finalize/{id}"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/finalize/{id}"})
|
||||||
public ResponseEntity<ResponseItem<DMP>> makeFinalize(@PathVariable String id, @RequestBody DatasetsToBeFinalized datasetsToBeFinalized) {
|
public ResponseEntity<ResponseItem<DmpEntity>> makeFinalize(@PathVariable String id, @RequestBody DatasetsToBeFinalized datasetsToBeFinalized) {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.dataManagementPlanManager.makeFinalize(UUID.fromString(id), datasetsToBeFinalized);
|
this.dataManagementPlanManager.makeFinalize(UUID.fromString(id), datasetsToBeFinalized);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made finalized."));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made finalized."));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to finalize Data Management Plan."));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to finalize Data Management Plan."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/unfinalize/{id}"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/unfinalize/{id}"})
|
||||||
public ResponseEntity<ResponseItem<DMP>> undoFinalize(@PathVariable String id) {
|
public ResponseEntity<ResponseItem<DmpEntity>> undoFinalize(@PathVariable String id) {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.dataManagementPlanManager.undoFinalize(UUID.fromString(id));
|
this.dataManagementPlanManager.undoFinalize(UUID.fromString(id));
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made active."));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Data Datamanagement Plan made active."));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to unfinalize the Data Management Plan."));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to unfinalize the Data Management Plan."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/updateusers/{id}"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/updateusers/{id}"})
|
||||||
public ResponseEntity<ResponseItem<DMP>> updateUsers(@PathVariable String id, @RequestBody List<UserInfoListingModel> users) {
|
public ResponseEntity<ResponseItem<DmpEntity>> updateUsers(@PathVariable String id, @RequestBody List<UserInfoListingModel> users) {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.dataManagementPlanManager.updateUsers(UUID.fromString(id), users);
|
this.dataManagementPlanManager.updateUsers(UUID.fromString(id), users);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Updated Colaborators for Data Datamanagement Plan."));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Updated Colaborators for Data Datamanagement Plan."));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to update the users of Data Management Plan."));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DmpEntity>().status(ApiMessageCode.ERROR_MESSAGE).message("Failed to update the users of Data Management Plan."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
import eu.eudat.commons.enums.DmpAccessType;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
@ -11,7 +12,7 @@ import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.FileUpload;
|
import eu.eudat.data.old.FileUpload;
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.logic.managers.DatasetProfileManager;
|
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||||
|
@ -145,11 +146,14 @@ public class FileController {
|
||||||
throw new NoSuchElementException("No dataset with id " + fileUpload.getEntityId() + " found. This dataset was related to the file with id " + id);
|
throw new NoSuchElementException("No dataset with id " + fileUpload.getEntityId() + " found. This dataset was related to the file with id " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
|
|
||||||
if (!dmp.isPublic() && dmp.getUsers()
|
if (!dmp.getAccessType().equals(DmpAccessType.Public)
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
//TODO
|
||||||
.collect(Collectors.toList()).size() == 0)
|
// && dmp.getUsers()
|
||||||
|
// .stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
|
// .collect(Collectors.toList()).size() == 0
|
||||||
|
)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ package eu.eudat.controllers;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.Funder;
|
import eu.eudat.data.old.Funder;
|
||||||
import eu.eudat.data.old.Project;
|
import eu.eudat.data.old.Project;
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
|
@ -90,7 +90,7 @@ public class QuickWizardController extends BaseController {
|
||||||
|
|
||||||
//Create Dmp
|
//Create Dmp
|
||||||
DataManagementPlan dataManagementPlan = quickWizard.getDmp().toDataDmp(grantEntity, projectEntity, userScope);
|
DataManagementPlan dataManagementPlan = quickWizard.getDmp().toDataDmp(grantEntity, projectEntity, userScope);
|
||||||
DMP dmpEntity = this.quickWizardManager.createOrUpdate(dataManagementPlan, funderEntity);
|
DmpEntity dmpEntity = this.quickWizardManager.createOrUpdate(dataManagementPlan, funderEntity);
|
||||||
|
|
||||||
//Create Datasets
|
//Create Datasets
|
||||||
quickWizard.getDmp().setId(dmpEntity.getId());
|
quickWizard.getDmp().setId(dmpEntity.getId());
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.eudat.logic.builders.entity;
|
package eu.eudat.logic.builders.entity;
|
||||||
|
|
||||||
import eu.eudat.data.CredentialEntity;
|
import eu.eudat.data.CredentialEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.logic.builders.Builder;
|
import eu.eudat.logic.builders.Builder;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.data.old.UserRole;
|
import eu.eudat.data.old.UserRole;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public class UserInfoBuilder extends Builder<UserInfo> {
|
||||||
|
|
||||||
private String additionalinfo;
|
private String additionalinfo;
|
||||||
|
|
||||||
private Set<DMP> dmps;
|
private Set<DmpEntity> dmps;
|
||||||
|
|
||||||
private Set<CredentialEntity> credentials = new HashSet<>();
|
private Set<CredentialEntity> credentials = new HashSet<>();
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ public class UserInfoBuilder extends Builder<UserInfo> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserInfoBuilder dmps(Set<DMP> dmps) {
|
public UserInfoBuilder dmps(Set<DmpEntity> dmps) {
|
||||||
this.dmps = dmps;
|
this.dmps = dmps;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ public class UserInfoBuilder extends Builder<UserInfo> {
|
||||||
userInfo.setAdditionalinfo(additionalinfo);
|
userInfo.setAdditionalinfo(additionalinfo);
|
||||||
userInfo.setUserRoles(userRoles);
|
userInfo.setUserRoles(userRoles);
|
||||||
userInfo.setCredentials(credentials);
|
userInfo.setCredentials(credentials);
|
||||||
userInfo.setDmps(dmps);
|
// userInfo.setDmps(dmps); //TODO
|
||||||
userInfo.setVerified_email(verified_email);
|
userInfo.setVerified_email(verified_email);
|
||||||
userInfo.setUserStatus(userStatus);
|
userInfo.setUserStatus(userStatus);
|
||||||
return userInfo;
|
return userInfo;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.logic.managers;
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||||
|
@ -11,7 +12,6 @@ import eu.eudat.data.dao.entities.DMPDao;
|
||||||
import eu.eudat.data.dao.entities.DatasetDao;
|
import eu.eudat.data.dao.entities.DatasetDao;
|
||||||
import eu.eudat.data.dao.entities.GrantDao;
|
import eu.eudat.data.dao.entities.GrantDao;
|
||||||
import eu.eudat.data.dao.entities.OrganisationDao;
|
import eu.eudat.data.dao.entities.OrganisationDao;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
@ -86,7 +86,7 @@ public class DashBoardManager {
|
||||||
publicCriteria.setOnlyPublic(true);
|
publicCriteria.setOnlyPublic(true);
|
||||||
publicCriteria.setAllVersions(false);
|
publicCriteria.setAllVersions(false);
|
||||||
|
|
||||||
List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(publicCriteria).toList();
|
List<DmpEntity> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(publicCriteria).toList();
|
||||||
|
|
||||||
// DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
// DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
||||||
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
|
OrganisationCriteria organisationCriteria = new OrganisationCriteria();
|
||||||
|
@ -97,12 +97,12 @@ public class DashBoardManager {
|
||||||
// List<DMP> dmps = databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).toList();
|
// List<DMP> dmps = databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).toList();
|
||||||
long numberOfDatasets = 0;
|
long numberOfDatasets = 0;
|
||||||
LinkedList<Grant> grants = new LinkedList<>();
|
LinkedList<Grant> grants = new LinkedList<>();
|
||||||
for (DMP dmp : dmps) {
|
for (DmpEntity dmp : dmps) {
|
||||||
numberOfDatasets = numberOfDatasets + dmp.getDataset().stream()
|
// numberOfDatasets = numberOfDatasets + dmp.getDataset().stream() //TODO
|
||||||
.filter(item -> item.getStatus() == DescriptionStatus.Finalized).count();
|
// .filter(item -> item.getStatus() == DescriptionStatus.Finalized).count();
|
||||||
if (dmp.getGrant() != null) {
|
// if (dmp.getGrant() != null) {
|
||||||
grants.add(dmp.getGrant());
|
// grants.add(dmp.getGrant());
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
statistics.setTotalDataManagementPlanCount((long) dmps.size());
|
statistics.setTotalDataManagementPlanCount((long) dmps.size());
|
||||||
|
@ -201,7 +201,7 @@ public class DashBoardManager {
|
||||||
.withHint("dmpRecentActivity")
|
.withHint("dmpRecentActivity")
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
.take(numberofactivities)
|
.take(numberofactivities)
|
||||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(Date.from(item.getUpdatedAt())).id(item.getId().toString()).build())
|
||||||
.whenComplete((dmpActivities, throwable) -> activity.setRecentDmpActivities(dmpActivities));
|
.whenComplete((dmpActivities, throwable) -> activity.setRecentDmpActivities(dmpActivities));
|
||||||
|
|
||||||
CompletableFuture<List<RecentActivityData>> datasets = datasetRepository.getAuthenticated(datasetRepository.getWithCriteria(datasetCriteria), user, roles).distinct()
|
CompletableFuture<List<RecentActivityData>> datasets = datasetRepository.getAuthenticated(datasetRepository.getWithCriteria(datasetCriteria), user, roles).distinct()
|
||||||
|
@ -311,7 +311,7 @@ public class DashBoardManager {
|
||||||
|
|
||||||
CompletableFuture<List<SearchBarItem>> publicDmps = dataManagementPlanRepository.asQueryable()
|
CompletableFuture<List<SearchBarItem>> publicDmps = dataManagementPlanRepository.asQueryable()
|
||||||
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
||||||
.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))
|
.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive))
|
||||||
.where((builder, root) -> builder.equal(root.get("isPublic"), true))
|
.where((builder, root) -> builder.equal(root.get("isPublic"), true))
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DMP.getValue(), true))
|
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DMP.getValue(), true))
|
||||||
|
@ -329,7 +329,7 @@ public class DashBoardManager {
|
||||||
CompletableFuture<List<SearchBarItem>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.asQueryable(), this.userScope.getUserId(), roles)
|
CompletableFuture<List<SearchBarItem>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.asQueryable(), this.userScope.getUserId(), roles)
|
||||||
.withHint("dmpRecentActivity")
|
.withHint("dmpRecentActivity")
|
||||||
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
||||||
.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))
|
.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive))
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DMP.getValue(), false))
|
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DMP.getValue(), false))
|
||||||
.whenComplete((dmpItems, throwable) -> searchBarItems.addAll(dmpItems));
|
.whenComplete((dmpItems, throwable) -> searchBarItems.addAll(dmpItems));
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6,11 +6,11 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.DmpAccessType;
|
||||||
|
import eu.eudat.commons.enums.DmpStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.*;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
|
||||||
import eu.eudat.data.TagEntity;
|
|
||||||
import eu.eudat.data.dao.criteria.*;
|
import eu.eudat.data.dao.criteria.*;
|
||||||
import eu.eudat.data.dao.entities.DataRepositoryDao;
|
import eu.eudat.data.dao.entities.DataRepositoryDao;
|
||||||
import eu.eudat.data.dao.entities.DatasetDao;
|
import eu.eudat.data.dao.entities.DatasetDao;
|
||||||
|
@ -300,10 +300,13 @@ public class DatasetManager {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
;
|
;
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
if (dmp.getUsers()
|
if (
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
//TODO
|
||||||
.collect(Collectors.toList()).size() == 0 && !dmp.isPublic())
|
// dmp.getUsers()
|
||||||
|
// .stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
|
// .collect(Collectors.toList()).size() == 0 &&
|
||||||
|
!dmp.getAccessType().equals(DmpAccessType.Public))
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
|
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
|
||||||
dataset.fromDataModel(descriptionEntityEntity);
|
dataset.fromDataModel(descriptionEntityEntity);
|
||||||
|
@ -365,8 +368,8 @@ public class DatasetManager {
|
||||||
public DatasetWizardModel getSinglePublic(String id) throws Exception {
|
public DatasetWizardModel getSinglePublic(String id) throws Exception {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().isPublicDataset(UUID.fromString(id));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().isPublicDataset(UUID.fromString(id));
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getId()).isActive(IsActive.Active).first().getDmpId());
|
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
if (descriptionEntityEntity != null && descriptionEntityEntity.getStatus() == DescriptionStatus.Finalized && dmp.getStatus() == 1) {
|
if (descriptionEntityEntity != null && descriptionEntityEntity.getStatus() == DescriptionStatus.Finalized && dmp.getStatus().getValue() == 1) {
|
||||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
|
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
|
||||||
dataset.fromDataModel(descriptionEntityEntity);
|
dataset.fromDataModel(descriptionEntityEntity);
|
||||||
return dataset;
|
return dataset;
|
||||||
|
@ -380,14 +383,17 @@ public class DatasetManager {
|
||||||
if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) {
|
if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) {
|
||||||
throw new Exception("Dataset is deleted.");
|
throw new Exception("Dataset is deleted.");
|
||||||
}
|
}
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
if (!isPublic && !this.userScope.isSet()) {
|
if (!isPublic && !this.userScope.isSet()) {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
} else
|
} else
|
||||||
if (!isPublic && dmp.getUsers()
|
if (!isPublic
|
||||||
.stream().noneMatch(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))) {
|
//TODO
|
||||||
|
// && dmp.getUsers()
|
||||||
|
// .stream().noneMatch(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
|
) {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
} else if (isPublic && !dmp.isPublic()) {
|
} else if (isPublic && !dmp.getAccessType().equals(DmpAccessType.Public)) {
|
||||||
throw new ForbiddenException("Selected Dataset is not public");
|
throw new ForbiddenException("Selected Dataset is not public");
|
||||||
}
|
}
|
||||||
DatasetOverviewModel dataset = new DatasetOverviewModel();
|
DatasetOverviewModel dataset = new DatasetOverviewModel();
|
||||||
|
@ -418,8 +424,11 @@ public class DatasetManager {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
XWPFDocument document = configLoader.getDatasetDocument();
|
XWPFDocument document = configLoader.getDatasetDocument();
|
||||||
|
|
||||||
DMP dmpEntity = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
DmpEntity dmpEntity = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())).collect(Collectors.toList()).size() == 0)
|
if (!dmpEntity.getAccessType().equals(DmpAccessType.Public)
|
||||||
|
//TODO
|
||||||
|
// && dmpEntity.getUsers().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())).collect(Collectors.toList()).size() == 0
|
||||||
|
)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
|
|
||||||
wordBuilder.fillFirstPage(dmpEntity, descriptionEntityEntity, document, true);
|
wordBuilder.fillFirstPage(dmpEntity, descriptionEntityEntity, document, true);
|
||||||
|
@ -556,10 +565,13 @@ public class DatasetManager {
|
||||||
|
|
||||||
public FileEnvelope getWordDocumentFile(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService) throws IOException, InvalidApplicationException {
|
public FileEnvelope getWordDocumentFile(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService) throws IOException, InvalidApplicationException {
|
||||||
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
if (!dmp.isPublic() && dmp.getUsers()
|
if (!dmp.getAccessType().equals(DmpAccessType.Public)
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
//TODO
|
||||||
.collect(Collectors.toList()).size() == 0)
|
// && dmp.getUsers()
|
||||||
|
// .stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
|
// .collect(Collectors.toList()).size() == 0
|
||||||
|
)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
String label = descriptionEntityEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
String label = descriptionEntityEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
||||||
FileEnvelope exportEnvelope = new FileEnvelope();
|
FileEnvelope exportEnvelope = new FileEnvelope();
|
||||||
|
@ -586,10 +598,13 @@ public class DatasetManager {
|
||||||
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
|
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
DmpEntity dmp = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
if (!dmp.isPublic() && dmp.getUsers()
|
if (!dmp.getAccessType().equals(DmpAccessType.Public)
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
//TODO
|
||||||
.collect(Collectors.toList()).size() == 0)
|
// && dmp.getUsers()
|
||||||
|
// .stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
|
// .collect(Collectors.toList()).size() == 0
|
||||||
|
)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (descriptionEntityEntity.getProperties() != null) {
|
if (descriptionEntityEntity.getProperties() != null) {
|
||||||
|
@ -610,7 +625,7 @@ public class DatasetManager {
|
||||||
public DescriptionEntity createOrUpdate(DatasetWizardModel datasetWizardModel) throws Exception {
|
public DescriptionEntity createOrUpdate(DatasetWizardModel datasetWizardModel) throws Exception {
|
||||||
Boolean sendNotification = false;
|
Boolean sendNotification = false;
|
||||||
DescriptionEntity tempDescriptionEntity = null;
|
DescriptionEntity tempDescriptionEntity = null;
|
||||||
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(datasetWizardModel.getDmp().getId());
|
DmpEntity dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(datasetWizardModel.getDmp().getId());
|
||||||
if (datasetWizardModel.getId() != null) {
|
if (datasetWizardModel.getId() != null) {
|
||||||
tempDescriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(datasetWizardModel.getId());
|
tempDescriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(datasetWizardModel.getId());
|
||||||
if (tempDescriptionEntity != null) {
|
if (tempDescriptionEntity != null) {
|
||||||
|
@ -625,7 +640,7 @@ public class DatasetManager {
|
||||||
} else {
|
} else {
|
||||||
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.DRAFT);
|
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.DRAFT);
|
||||||
}
|
}
|
||||||
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()) && datasetWizardModel.getId() != null)
|
if (dmp.getStatus().equals(DmpStatus.Finalized) && datasetWizardModel.getId() != null)
|
||||||
throw new Exception("DMP is finalized, therefore Dataset cannot be edited.");
|
throw new Exception("DMP is finalized, therefore Dataset cannot be edited.");
|
||||||
DescriptionEntity descriptionEntity = datasetWizardModel.toDataModel();
|
DescriptionEntity descriptionEntity = datasetWizardModel.toDataModel();
|
||||||
// descriptionEntity.setDmpId(dmp.getId()); //TODO
|
// descriptionEntity.setDmpId(dmp.getId()); //TODO
|
||||||
|
@ -649,15 +664,15 @@ public class DatasetManager {
|
||||||
DescriptionEntity descriptionEntity1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
DescriptionEntity descriptionEntity1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
||||||
datasetWizardModel.setId(descriptionEntity1.getId());
|
datasetWizardModel.setId(descriptionEntity1.getId());
|
||||||
if (datasetWizardModel.getDmp().getGrant() == null) {
|
if (datasetWizardModel.getDmp().getGrant() == null) {
|
||||||
DMP dmp1 = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
DmpEntity dmp1 = databaseRepository.getDmpDao().find(this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId());
|
||||||
|
|
||||||
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
||||||
}
|
}
|
||||||
// descriptionEntity1.setDescriptionTemplateId(datasetWizardModel.getProfile().getId()); //TODO
|
// descriptionEntity1.setDescriptionTemplateId(datasetWizardModel.getProfile().getId()); //TODO
|
||||||
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
||||||
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
|
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity1.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
|
||||||
DMP dmp1 = databaseRepository.getDmpDao().find(dmpId);
|
DmpEntity dmp1 = databaseRepository.getDmpDao().find(dmpId);
|
||||||
dmp1.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
// dmp1.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));//TODO
|
||||||
//updateTags(descriptionEntity1, datasetWizardModel.getTags()); //TODO
|
//updateTags(descriptionEntity1, datasetWizardModel.getTags()); //TODO
|
||||||
if (sendNotification) {
|
if (sendNotification) {
|
||||||
if (descriptionEntity1.getStatus() != DescriptionStatus.Finalized) {
|
if (descriptionEntity1.getStatus() != DescriptionStatus.Finalized) {
|
||||||
|
@ -711,17 +726,17 @@ public class DatasetManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendNotification(DescriptionEntity descriptionEntity, DMP dmp, UserInfo user, NotificationType notificationType) throws InvalidApplicationException {
|
private void sendNotification(DescriptionEntity descriptionEntity, DmpEntity dmp, UserInfo user, NotificationType notificationType) throws InvalidApplicationException {
|
||||||
List<UserDMP> userDMPS = databaseRepository.getUserDmpDao().asQueryable().where(((builder, root) -> builder.equal(root.get("dmp").get("id"), dmp.getId()))).toList();
|
List<DmpUserEntity> userDMPS = databaseRepository.getUserDmpDao().asQueryable().where(((builder, root) -> builder.equal(root.get("dmp").get("id"), dmp.getId()))).toList();
|
||||||
for (UserDMP userDMP : userDMPS) {
|
for (DmpUserEntity userDMP : userDMPS) {
|
||||||
if (!userDMP.getUser().getId().equals(user.getId())) {
|
if (!userDMP.getUser().equals(user.getId())) {
|
||||||
Notification notification = new Notification();
|
Notification notification = new Notification();
|
||||||
notification.setUserId(user);
|
notification.setUserId(user);
|
||||||
notification.setType(notificationType);
|
notification.setType(notificationType);
|
||||||
notification.setNotifyState(NotifyState.PENDING);
|
notification.setNotifyState(NotifyState.PENDING);
|
||||||
notification.setIsActive(ActiveStatus.ACTIVE);
|
notification.setIsActive(ActiveStatus.ACTIVE);
|
||||||
notification.setData("{" +
|
notification.setData("{" +
|
||||||
"\"userId\": \"" + userDMP.getUser().getId() + "\"" +
|
"\"userId\": \"" + userDMP.getUser() + "\"" +
|
||||||
", \"id\": \"" + descriptionEntity.getId() + "\"" +
|
", \"id\": \"" + descriptionEntity.getId() + "\"" +
|
||||||
", \"name\": \"" + descriptionEntity.getLabel() + "\"" +
|
", \"name\": \"" + descriptionEntity.getLabel() + "\"" +
|
||||||
", \"path\": \"" + notificationPaths.get(notificationType) + "\"" +
|
", \"path\": \"" + notificationPaths.get(notificationType) + "\"" +
|
||||||
|
@ -729,7 +744,7 @@ public class DatasetManager {
|
||||||
notification.setCreatedAt(new Date());
|
notification.setCreatedAt(new Date());
|
||||||
notification.setUpdatedAt(notification.getCreatedAt());
|
notification.setUpdatedAt(notification.getCreatedAt());
|
||||||
notification.setContactTypeHint(ContactType.EMAIL);
|
notification.setContactTypeHint(ContactType.EMAIL);
|
||||||
notification.setContactHint(userDMP.getUser().getEmail());
|
notification.setContactHint(databaseRepository.getUserInfoDao().find(userDMP.getUser()).getEmail());
|
||||||
databaseRepository.getNotificationDao().createOrUpdate(notification);
|
databaseRepository.getNotificationDao().createOrUpdate(notification);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1029,7 +1044,7 @@ public class DatasetManager {
|
||||||
DescriptionEntity entity = new DescriptionEntity();
|
DescriptionEntity entity = new DescriptionEntity();
|
||||||
entity.setProperties(jsonDatasetProperties.toString());
|
entity.setProperties(jsonDatasetProperties.toString());
|
||||||
entity.setLabel(importFile.getOriginalFilename());
|
entity.setLabel(importFile.getOriginalFilename());
|
||||||
DMP dmp = new DMP();
|
DmpEntity dmp = new DmpEntity();
|
||||||
dmp.setId(UUID.fromString(dmpId));
|
dmp.setId(UUID.fromString(dmpId));
|
||||||
// entity.setDmpId(dmp.getId()); //TODO
|
// entity.setDmpId(dmp.getId()); //TODO
|
||||||
entity.setStatus(DescriptionStatus.Draft);
|
entity.setStatus(DescriptionStatus.Draft);
|
||||||
|
@ -1091,8 +1106,8 @@ public class DatasetManager {
|
||||||
descriptionEntityEntities.forEach(datasetEntity -> {
|
descriptionEntityEntities.forEach(datasetEntity -> {
|
||||||
try {
|
try {
|
||||||
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(datasetEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
|
UUID dmpId = this.queryFactory.query(DmpDescriptionTemplateQuery.class).ids(datasetEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDmpId();
|
||||||
DMP dmp = databaseRepository.getDmpDao().find(dmpId);
|
DmpEntity dmp = databaseRepository.getDmpDao().find(dmpId);
|
||||||
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
//dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList())); //TODO
|
||||||
// eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(datasetEntity.getId().toString()); //TODO
|
// eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(datasetEntity.getId().toString()); //TODO
|
||||||
// updateTags(datasetEntity, dataset != null ? dataset.getTags() : null);
|
// updateTags(datasetEntity, dataset != null ? dataset.getTags() : null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.DmpStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||||
import eu.eudat.data.dao.entities.DMPDao;
|
import eu.eudat.data.dao.entities.DMPDao;
|
||||||
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
@ -34,7 +35,7 @@ public class DatasetWizardManager {
|
||||||
public static List<DataManagentPlanListingModel> getUserDmps(DMPDao dmpRepository, DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, UserScope userScope) throws InstantiationException, IllegalAccessException, InvalidApplicationException {
|
public static List<DataManagentPlanListingModel> getUserDmps(DMPDao dmpRepository, DatasetWizardAutocompleteRequest datasetWizardAutocompleteRequest, UserScope userScope) throws InstantiationException, IllegalAccessException, InvalidApplicationException {
|
||||||
UserInfo userInfo = new UserInfo();
|
UserInfo userInfo = new UserInfo();
|
||||||
userInfo.setId(userScope.getUserId());
|
userInfo.setId(userScope.getUserId());
|
||||||
QueryableList<DMP> items = dmpRepository.getUserDmps(datasetWizardAutocompleteRequest.getCriteria(), userInfo);
|
QueryableList<DmpEntity> items = dmpRepository.getUserDmps(datasetWizardAutocompleteRequest.getCriteria(), userInfo);
|
||||||
List<DataManagentPlanListingModel> dataManagementPlans = items.select(item -> new DataManagentPlanListingModel().fromDataModel(item));
|
List<DataManagentPlanListingModel> dataManagementPlans = items.select(item -> new DataManagentPlanListingModel().fromDataModel(item));
|
||||||
return dataManagementPlans;
|
return dataManagementPlans;
|
||||||
}
|
}
|
||||||
|
@ -56,8 +57,8 @@ public class DatasetWizardManager {
|
||||||
|
|
||||||
public void unlock(ApiContext apiContext, QueryFactory queryFactory, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
|
public void unlock(ApiContext apiContext, QueryFactory queryFactory, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
|
||||||
DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
||||||
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId());
|
DmpEntity dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(queryFactory.query(DmpDescriptionTemplateQuery.class).ids(descriptionEntity.getDmpDescriptionTemplateId()).isActive(IsActive.Active).first().getDescriptionTemplateId());
|
||||||
if(dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue()) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
|
if(dmp.getStatus().equals(DmpStatus.Finalized)) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
|
||||||
descriptionEntity.setStatus(DescriptionStatus.Draft);
|
descriptionEntity.setStatus(DescriptionStatus.Draft);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import eu.eudat.data.query.items.table.grant.GrantTableRequest;
|
||||||
import eu.eudat.exceptions.grant.GrantWithDMPsDeleteException;
|
import eu.eudat.exceptions.grant.GrantWithDMPsDeleteException;
|
||||||
import eu.eudat.logic.builders.model.models.GrantBuilder;
|
import eu.eudat.logic.builders.model.models.GrantBuilder;
|
||||||
import eu.eudat.data.dao.entities.GrantDao;
|
import eu.eudat.data.dao.entities.GrantDao;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
import eu.eudat.logic.proxy.config.ExternalUrlCriteria;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.logic.utilities.helpers.ListHelper;
|
import eu.eudat.logic.utilities.helpers.ListHelper;
|
||||||
|
@ -180,9 +179,10 @@ public class GrantManager {
|
||||||
|
|
||||||
public void delete(UUID uuid) throws InvalidApplicationException {
|
public void delete(UUID uuid) throws InvalidApplicationException {
|
||||||
eu.eudat.data.old.Grant oldGrant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().find(uuid);
|
eu.eudat.data.old.Grant oldGrant = apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().find(uuid);
|
||||||
if (oldGrant.getDmps().size() > 0)
|
//TODO
|
||||||
throw new GrantWithDMPsDeleteException("You cannot Remove Grants with DMPs");
|
// if (oldGrant.getDmps().size() > 0)
|
||||||
oldGrant.setStatus(DMP.DMPStatus.DELETED.getValue());
|
// throw new GrantWithDMPsDeleteException("You cannot Remove Grants with DMPs");
|
||||||
|
// oldGrant.setStatus(DMP.DMPStatus.DELETED.getValue());
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(oldGrant);
|
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(oldGrant);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DmpUserRole;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.UserDMP;
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
|
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
||||||
|
import eu.eudat.model.DmpUser;
|
||||||
import eu.eudat.models.data.invitation.Invitation;
|
import eu.eudat.models.data.invitation.Invitation;
|
||||||
import eu.eudat.models.data.invitation.Properties;
|
import eu.eudat.models.data.invitation.Properties;
|
||||||
import eu.eudat.models.data.userinfo.UserInfoInvitationModel;
|
import eu.eudat.models.data.userinfo.UserInfoInvitationModel;
|
||||||
|
@ -56,11 +59,11 @@ public class InvitationsManager {
|
||||||
});
|
});
|
||||||
List<UserInfoInvitationModel> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
|
List<UserInfoInvitationModel> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
|
||||||
List<UserInfo> alreadySignedInUsersEntities = alreadySignedInUsers.stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList());
|
List<UserInfo> alreadySignedInUsersEntities = alreadySignedInUsers.stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList());
|
||||||
List<UserDMP> userInfoToUserDmp = new LinkedList<>();
|
List<DmpUserEntity> userInfoToUserDmp = new LinkedList<>();
|
||||||
for (UserInfo userInfo : alreadySignedInUsersEntities) {
|
for (UserInfo userInfo : alreadySignedInUsersEntities) {
|
||||||
UserDMP userDMP = new UserDMP();
|
DmpUserEntity userDMP = new DmpUserEntity();
|
||||||
userDMP.setUser(userInfo);
|
userDMP.setUser(userInfo.getId());
|
||||||
userDMP.setRole(invitation.getRole());
|
userDMP.setRole(DmpUserRole.of(invitation.getRole().shortValue()));
|
||||||
userInfoToUserDmp.add(userDMP);
|
userInfoToUserDmp.add(userDMP);
|
||||||
/*if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(principalUser, userInfo)) {
|
/*if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(principalUser, userInfo)) {
|
||||||
UserAssociation userAssociation = new UserAssociation();
|
UserAssociation userAssociation = new UserAssociation();
|
||||||
|
@ -69,7 +72,7 @@ public class InvitationsManager {
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
|
apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
DMP dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
|
DmpEntity dataManagementPlan = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(invitation.getDataManagementPlan());
|
||||||
apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()), dataManagementPlan, invitation.getRole(), principalUser);
|
apiContext.getUtilitiesService().getInvitationService().createInvitations(apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao(), apiContext.getUtilitiesService().getMailService(), invitation.getUsers().stream().map(UserInfoInvitationModel::toDataModel).collect(Collectors.toList()), dataManagementPlan, invitation.getRole(), principalUser);
|
||||||
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dataManagementPlan);
|
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userInfoToUserDmp, dataManagementPlan);
|
||||||
}
|
}
|
||||||
|
@ -83,80 +86,86 @@ public class InvitationsManager {
|
||||||
return userAssociation.getFirstUser();
|
return userAssociation.getFirstUser();
|
||||||
}
|
}
|
||||||
}).collect(Collectors.toList());*/
|
}).collect(Collectors.toList());*/
|
||||||
List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
|
List<UserInfo> users = new ArrayList<>();
|
||||||
.getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable()
|
//TODO
|
||||||
.where(((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList()))
|
// apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
|
||||||
.toList().stream().map(DMP::getUsers).flatMap(Collection::stream).map(UserDMP::getUser)
|
// .getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable()
|
||||||
.filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId)).collect(Collectors.toList());
|
// .where(((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList()))
|
||||||
|
// .toList().stream().map(DmpEntity::getUsers).flatMap(Collection::stream).map(DmpUser::getUser)
|
||||||
|
// .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId)).collect(Collectors.toList());
|
||||||
List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList());
|
List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList());
|
||||||
return userModels;
|
return userModels;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<UserInfoInvitationModel> getUsersWithCriteria(UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
|
public List<UserInfoInvitationModel> getUsersWithCriteria(UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException, InvalidApplicationException {
|
||||||
List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
|
//TODO
|
||||||
.getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable()
|
// List<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
|
||||||
.where(((builder, root) ->
|
// .getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable()
|
||||||
builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList()))
|
// .where(((builder, root) ->
|
||||||
.toList().stream().map(DMP::getUsers).flatMap(Collection::stream).map(UserDMP::getUser)
|
// builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()))), this.userScope.getUserId(), Stream.of(0, 1).collect(Collectors.toList()))
|
||||||
.filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId))
|
// .toList().stream().map(DMP::getUsers).flatMap(Collection::stream).map(UserDMP::getUser)
|
||||||
.filter(userInfo -> (userInfoRequestItem == null || userInfoRequestItem.getCriteria() == null || userInfoRequestItem.getCriteria().getLike() == null
|
// .filter(userInfo -> !userInfo.getId().equals(this.userScope.getUserIdSafe())).filter(StreamDistinctBy.distinctByKey(UserInfo::getId))
|
||||||
|| userInfo.getName().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase())
|
// .filter(userInfo -> (userInfoRequestItem == null || userInfoRequestItem.getCriteria() == null || userInfoRequestItem.getCriteria().getLike() == null
|
||||||
|| (userInfo.getEmail().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase()))))
|
// || userInfo.getName().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase())
|
||||||
.collect(Collectors.toList());
|
// || (userInfo.getEmail().toLowerCase().contains(userInfoRequestItem.getCriteria().getLike().toLowerCase()))))
|
||||||
// .where((builder, root) -> builder.like(builder.upper(root.get("name")), "%" + userInfoRequestItem.getCriteria().getLike().toUpperCase() + "%"))
|
// .collect(Collectors.toList());
|
||||||
|
//// .where((builder, root) -> builder.like(builder.upper(root.get("name")), "%" + userInfoRequestItem.getCriteria().getLike().toUpperCase() + "%"))
|
||||||
List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList());
|
//
|
||||||
return userModels;
|
// List<UserInfoInvitationModel> userModels = users.stream().map(userInfo -> new UserInfoInvitationModel().fromDataModel(userInfo)).collect(Collectors.toList());
|
||||||
|
// return userModels;
|
||||||
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID assignUserAcceptedInvitation(UUID invitationID) throws UnauthorisedException, JAXBException, IOException, InvalidApplicationException {
|
public UUID assignUserAcceptedInvitation(UUID invitationID) throws UnauthorisedException, JAXBException, IOException, InvalidApplicationException {
|
||||||
eu.eudat.data.old.Invitation invitation = apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().find(invitationID);
|
//TODO
|
||||||
if (invitation == null)
|
// eu.eudat.data.old.Invitation invitation = apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().find(invitationID);
|
||||||
throw new UnauthorisedException("There is no Data Management Plan assigned to this Link");
|
// if (invitation == null)
|
||||||
if (invitation.getAcceptedInvitation()) return invitation.getDmp().getId(); //throw new UnauthorisedException("This Url Has Expired");
|
// throw new UnauthorisedException("There is no Data Management Plan assigned to this Link");
|
||||||
JAXBContext context = JAXBContext.newInstance(Properties.class);
|
// if (invitation.getAcceptedInvitation()) return invitation.getDmp().getId(); //throw new UnauthorisedException("This Url Has Expired");
|
||||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
// JAXBContext context = JAXBContext.newInstance(Properties.class);
|
||||||
Properties properties = (Properties) unmarshaller.unmarshal(new StringReader(invitation.getProperties()));
|
// Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||||
UserInfo invitedUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId());
|
// Properties properties = (Properties) unmarshaller.unmarshal(new StringReader(invitation.getProperties()));
|
||||||
QueryableList<UserDMP> userDMPQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where(((builder, root) -> builder.and(builder.equal(root.get("dmp").get("id"), invitation.getDmp().getId()), builder.equal(root.get("user").get("id"), invitedUser.getId()))));
|
// UserInfo invitedUser = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId());
|
||||||
UserDMP existingUserDMP = userDMPQueryableList.getSingleOrDefault();
|
// QueryableList<UserDMP> userDMPQueryableList = apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where(((builder, root) -> builder.and(builder.equal(root.get("dmp").get("id"), invitation.getDmp().getId()), builder.equal(root.get("user").get("id"), invitedUser.getId()))));
|
||||||
if (existingUserDMP != null) {
|
// UserDMP existingUserDMP = userDMPQueryableList.getSingleOrDefault();
|
||||||
if (properties.getRole() != null && existingUserDMP.getRole() > properties.getRole()) {
|
// if (existingUserDMP != null) {
|
||||||
existingUserDMP.setRole(properties.getRole());
|
// if (properties.getRole() != null && existingUserDMP.getRole() > properties.getRole()) {
|
||||||
DMP datamanagementPlan = invitation.getDmp();
|
// existingUserDMP.setRole(properties.getRole());
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(existingUserDMP);
|
// DMP datamanagementPlan = invitation.getDmp();
|
||||||
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), existingUserDMP, datamanagementPlan);
|
// apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(existingUserDMP);
|
||||||
invitation.setAcceptedInvitation(true);
|
// apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), existingUserDMP, datamanagementPlan);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().createOrUpdate(invitation);
|
// invitation.setAcceptedInvitation(true);
|
||||||
datamanagementPlan.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), datamanagementPlan.getId())).toList()));
|
// apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().createOrUpdate(invitation);
|
||||||
//dataManagementPlanManager.updateIndex(datamanagementPlan); //TODO
|
// datamanagementPlan.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), datamanagementPlan.getId())).toList()));
|
||||||
return datamanagementPlan.getId();
|
// //dataManagementPlanManager.updateIndex(datamanagementPlan); //TODO
|
||||||
}
|
// return datamanagementPlan.getId();
|
||||||
} else {
|
// }
|
||||||
UserDMP userDMP = new UserDMP();
|
// } else {
|
||||||
userDMP.setUser(invitedUser);
|
// UserDMP userDMP = new UserDMP();
|
||||||
userDMP.setDmp(invitation.getDmp());
|
// userDMP.setUser(invitedUser);
|
||||||
|
// userDMP.setDmp(invitation.getDmp());
|
||||||
if (properties.getRole() != null) {
|
//
|
||||||
userDMP.setRole(properties.getRole());
|
// if (properties.getRole() != null) {
|
||||||
} else {
|
// userDMP.setRole(properties.getRole());
|
||||||
userDMP.setRole(UserDMP.UserDMPRoles.USER.getValue());
|
// } else {
|
||||||
}
|
// userDMP.setRole(UserDMP.UserDMPRoles.USER.getValue());
|
||||||
/*if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(invitedUser, invitation.getUser())) {
|
// }
|
||||||
UserAssociation userAssociation = new UserAssociation();
|
// /*if (!apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().areAssociated(invitedUser, invitation.getUser())) {
|
||||||
userAssociation.setFirstUser(invitedUser);
|
// UserAssociation userAssociation = new UserAssociation();
|
||||||
userAssociation.setSecondUser(invitation.getUser());
|
// userAssociation.setFirstUser(invitedUser);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
|
// userAssociation.setSecondUser(invitation.getUser());
|
||||||
}*/
|
// apiContext.getOperationsContext().getDatabaseRepository().getUserAssociationDao().createOrUpdate(userAssociation);
|
||||||
DMP datamanagementPlan = invitation.getDmp();
|
// }*/
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
|
// DmpEntity datamanagementPlan = invitation.getDmp();
|
||||||
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userDMP, datamanagementPlan);
|
// apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
|
||||||
invitation.setAcceptedInvitation(true);
|
// apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), userDMP, datamanagementPlan);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().createOrUpdate(invitation);
|
// invitation.setAcceptedInvitation(true);
|
||||||
datamanagementPlan.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), datamanagementPlan.getId())).toList()));
|
// apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().createOrUpdate(invitation);
|
||||||
// dataManagementPlanManager.updateIndex(datamanagementPlan); //TODo
|
// datamanagementPlan.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), datamanagementPlan.getId())).toList()));
|
||||||
return datamanagementPlan.getId();
|
//// dataManagementPlanManager.updateIndex(datamanagementPlan); //TODo
|
||||||
}
|
// return datamanagementPlan.getId();
|
||||||
return invitation.getDmp().getId();
|
// }
|
||||||
|
// return invitation.getDmp().getId();
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.CredentialEntity;
|
import eu.eudat.data.CredentialEntity;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.old.EmailConfirmation;
|
import eu.eudat.data.old.EmailConfirmation;
|
||||||
import eu.eudat.data.old.UserDMP;
|
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
|
import eu.eudat.exceptions.emailconfirmation.HasConfirmedEmailException;
|
||||||
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
|
import eu.eudat.exceptions.emailconfirmation.TokenExpiredException;
|
||||||
|
@ -20,7 +20,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
|
@ -88,9 +87,9 @@ public class MergeEmailConfirmationManager {
|
||||||
CredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.and(builder.equal(root.get("userId"), oldUser.getId()), builder.equal(root.get("provider"), provider))).getSingle();
|
CredentialEntity credential = databaseRepository.getCredentialDao().asQueryable().where((builder, root) -> builder.and(builder.equal(root.get("userId"), oldUser.getId()), builder.equal(root.get("provider"), provider))).getSingle();
|
||||||
credential.setUserId(newUser.getId());
|
credential.setUserId(newUser.getId());
|
||||||
databaseRepository.getCredentialDao().createOrUpdate(credential);
|
databaseRepository.getCredentialDao().createOrUpdate(credential);
|
||||||
List<UserDMP> userDmps = databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("user"), oldUser)).toList();
|
List<DmpUserEntity> userDmps = databaseRepository.getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("user"), oldUser)).toList();
|
||||||
userDmps.forEach(userDmp -> {
|
userDmps.forEach(userDmp -> {
|
||||||
userDmp.setUser(newUser);
|
userDmp.setUser(newUser.getId());
|
||||||
databaseRepository.getUserDmpDao().createOrUpdate(userDmp);
|
databaseRepository.getUserDmpDao().createOrUpdate(userDmp);
|
||||||
});
|
});
|
||||||
//TODO
|
//TODO
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DmpUserRole;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.dao.criteria.FunderCriteria;
|
import eu.eudat.data.dao.criteria.FunderCriteria;
|
||||||
import eu.eudat.data.dao.criteria.GrantCriteria;
|
import eu.eudat.data.dao.criteria.GrantCriteria;
|
||||||
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
import eu.eudat.data.dao.criteria.ProjectCriteria;
|
||||||
|
@ -50,22 +53,25 @@ public class QuickWizardManager {
|
||||||
return databaseRepository.getProjectDao().createOrUpdate(projectEntity);
|
return databaseRepository.getProjectDao().createOrUpdate(projectEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DMP createOrUpdate(DataManagementPlan dataManagementPlan, Funder funderEntity) throws Exception {
|
public DmpEntity createOrUpdate(DataManagementPlan dataManagementPlan, Funder funderEntity) throws Exception {
|
||||||
DMP newDmp = dataManagementPlan.toDataModel();
|
DmpEntity newDmp = dataManagementPlan.toDataModel();
|
||||||
if (funderEntity != null) {
|
if (funderEntity != null) {
|
||||||
newDmp.getGrant().setFunder(funderEntity);
|
//TODO
|
||||||
|
//newDmp.getGrant().setFunder(funderEntity);
|
||||||
}
|
}
|
||||||
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId());
|
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId());
|
||||||
createFunderIfItDoesntExist(newDmp, user);
|
createFunderIfItDoesntExist(newDmp, user);
|
||||||
createGrantIfItDoesntExist(newDmp, user);
|
createGrantIfItDoesntExist(newDmp, user);
|
||||||
if (newDmp.getProject() == null) {
|
//TODO
|
||||||
newDmp.setProject(new Project());
|
// if (newDmp.getProject() == null) {
|
||||||
newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
|
// newDmp.setProject(new Project());
|
||||||
}
|
// newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
|
||||||
|
// }
|
||||||
createProjectIfItDoesntExist(newDmp, user);
|
createProjectIfItDoesntExist(newDmp, user);
|
||||||
|
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
|
//TODO
|
||||||
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
//apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant());
|
||||||
|
DmpEntity dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||||
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
if (dataManagementPlan.getAssociatedUsers().size() == 0)
|
||||||
assignUser(newDmp, user, apiContext);
|
assignUser(newDmp, user, apiContext);
|
||||||
|
|
||||||
|
@ -80,54 +86,54 @@ public class QuickWizardManager {
|
||||||
// apiContext.getOperationsContext().getElasticRepository().getDmpRepository().createOrUpdate(elastic);
|
// apiContext.getOperationsContext().getElasticRepository().getDmpRepository().createOrUpdate(elastic);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private void assignUser(DMP dmp, UserInfo userInfo, ApiContext apiContext) {
|
private void assignUser(DmpEntity dmp, UserInfo userInfo, ApiContext apiContext) {
|
||||||
UserDMP userDMP = new UserDMP();
|
DmpUserEntity userDMP = new DmpUserEntity();
|
||||||
userDMP.setDmp(dmp);
|
userDMP.setDmp(dmp.getId());
|
||||||
userDMP.setUser(userInfo);
|
userDMP.setUser(userInfo.getId());
|
||||||
userDMP.setRole(UserDMP.UserDMPRoles.OWNER.getValue());
|
userDMP.setRole(DmpUserRole.User);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
|
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGrantIfItDoesntExist(DMP newDmp, UserInfo userInfo) throws InvalidApplicationException {
|
private void createGrantIfItDoesntExist(DmpEntity newDmp, UserInfo userInfo) throws InvalidApplicationException {
|
||||||
if (newDmp.getGrant() != null) {
|
// if (newDmp.getGrant() != null) {
|
||||||
Grant grant = newDmp.getGrant();
|
// Grant grant = newDmp.getGrant();
|
||||||
GrantCriteria criteria = new GrantCriteria();
|
// GrantCriteria criteria = new GrantCriteria();
|
||||||
criteria.setReference(grant.getReference());
|
// criteria.setReference(grant.getReference());
|
||||||
Grant grantEntity = databaseRepository.getGrantDao().getWithCriteria(criteria).getSingleOrDefault();
|
// Grant grantEntity = databaseRepository.getGrantDao().getWithCriteria(criteria).getSingleOrDefault();
|
||||||
if (grantEntity != null) grant.setId(grantEntity.getId());
|
// if (grantEntity != null) grant.setId(grantEntity.getId());
|
||||||
else {
|
// else {
|
||||||
grant.setType(Grant.GrantType.EXTERNAL.getValue());
|
// grant.setType(Grant.GrantType.EXTERNAL.getValue());
|
||||||
databaseRepository.getGrantDao().createOrUpdate(grant);
|
// databaseRepository.getGrantDao().createOrUpdate(grant);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createFunderIfItDoesntExist(DMP newDmp, UserInfo userInfo) throws InvalidApplicationException {
|
private void createFunderIfItDoesntExist(DmpEntity newDmp, UserInfo userInfo) throws InvalidApplicationException {
|
||||||
if (newDmp.getGrant().getFunder() != null) {
|
// if (newDmp.getGrant().getFunder() != null) { //TODO
|
||||||
Funder funder = newDmp.getGrant().getFunder();
|
// Funder funder = newDmp.getGrant().getFunder();
|
||||||
FunderCriteria criteria = new FunderCriteria();
|
// FunderCriteria criteria = new FunderCriteria();
|
||||||
criteria.setReference(funder.getReference());
|
// criteria.setReference(funder.getReference());
|
||||||
Funder funderEntity = databaseRepository.getFunderDao().getWithCritetia(criteria).getSingleOrDefault();
|
// Funder funderEntity = databaseRepository.getFunderDao().getWithCritetia(criteria).getSingleOrDefault();
|
||||||
if (funderEntity != null) funder.setId(funderEntity.getId());
|
// if (funderEntity != null) funder.setId(funderEntity.getId());
|
||||||
else {
|
// else {
|
||||||
funder.setType(Funder.FunderType.EXTERNAL.getValue());
|
// funder.setType(Funder.FunderType.EXTERNAL.getValue());
|
||||||
databaseRepository.getFunderDao().createOrUpdate(funder);
|
// databaseRepository.getFunderDao().createOrUpdate(funder);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createProjectIfItDoesntExist(DMP newDmp, UserInfo userInfo) throws InvalidApplicationException {
|
private void createProjectIfItDoesntExist(DmpEntity newDmp, UserInfo userInfo) throws InvalidApplicationException {
|
||||||
if (newDmp.getProject() != null) {
|
// if (newDmp.getProject() != null) { //TODO
|
||||||
Project project = newDmp.getProject();
|
// Project project = newDmp.getProject();
|
||||||
ProjectCriteria criteria = new ProjectCriteria();
|
// ProjectCriteria criteria = new ProjectCriteria();
|
||||||
criteria.setReference(project.getReference());
|
// criteria.setReference(project.getReference());
|
||||||
Project projectEntity = databaseRepository.getProjectDao().getWithCritetia(criteria).getSingleOrDefault();
|
// Project projectEntity = databaseRepository.getProjectDao().getWithCritetia(criteria).getSingleOrDefault();
|
||||||
if (projectEntity != null) project.setId(projectEntity.getId());
|
// if (projectEntity != null) project.setId(projectEntity.getId());
|
||||||
else {
|
// else {
|
||||||
if (project.getId() == null) project.setId(UUID.randomUUID());
|
// if (project.getId() == null) project.setId(UUID.randomUUID());
|
||||||
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
// project.setType(Project.ProjectType.EXTERNAL.getValue());
|
||||||
databaseRepository.getProjectDao().createOrUpdate(project);
|
// databaseRepository.getProjectDao().createOrUpdate(project);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.logic.managers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.models.rda.Dmp;
|
import eu.eudat.models.rda.Dmp;
|
||||||
import eu.eudat.models.rda.RDAModel;
|
import eu.eudat.models.rda.RDAModel;
|
||||||
import eu.eudat.models.rda.mapper.DmpRDAMapper;
|
import eu.eudat.models.rda.mapper.DmpRDAMapper;
|
||||||
|
@ -26,7 +26,7 @@ public class RDAManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public String convertToRDA(DMP dmp) throws JsonProcessingException, InvalidApplicationException {
|
public String convertToRDA(DmpEntity dmp) throws JsonProcessingException, InvalidApplicationException {
|
||||||
String result = "";
|
String result = "";
|
||||||
|
|
||||||
Dmp rdaDmp = dmpRDAMapper.toRDA(dmp);
|
Dmp rdaDmp = dmpRDAMapper.toRDA(dmp);
|
||||||
|
@ -41,7 +41,7 @@ public class RDAManager {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DMP convertToEntity(String json, String[] profiles) throws IOException, InvalidApplicationException {
|
public DmpEntity convertToEntity(String json, String[] profiles) throws IOException, InvalidApplicationException {
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
|
||||||
Dmp rda = mapper.readValue(json, RDAModel.class).getDmp();
|
Dmp rda = mapper.readValue(json, RDAModel.class).getDmp();
|
||||||
|
|
|
@ -5,9 +5,9 @@ import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
import eu.eudat.data.CredentialEntity;
|
import eu.eudat.data.CredentialEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.dao.entities.UserInfoDao;
|
import eu.eudat.data.dao.entities.UserInfoDao;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.data.old.UserRole;
|
import eu.eudat.data.old.UserRole;
|
||||||
|
@ -98,8 +98,8 @@ public class UserManager {
|
||||||
List<Integer> roles = new LinkedList<>();
|
List<Integer> roles = new LinkedList<>();
|
||||||
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
|
DataManagementPlanCriteria criteria = new DataManagementPlanCriteria();
|
||||||
criteria.setAllVersions(false);
|
criteria.setAllVersions(false);
|
||||||
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria);
|
QueryableList<DmpEntity> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(criteria);
|
||||||
List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, userId, roles).take(5).toList();
|
List<DmpEntity> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(items, userId, roles).take(5).toList();
|
||||||
profile.setAssociatedDmps(dmps.stream().map(x -> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList()));
|
profile.setAssociatedDmps(dmps.stream().map(x -> new DataManagementPlan().fromDataModel(x)).collect(Collectors.toList()));
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package eu.eudat.logic.services.utilities;
|
package eu.eudat.logic.services.utilities;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.dao.entities.DMPDao;
|
import eu.eudat.data.dao.entities.DMPDao;
|
||||||
import eu.eudat.data.dao.entities.InvitationDao;
|
import eu.eudat.data.dao.entities.InvitationDao;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.old.Invitation;
|
import eu.eudat.data.old.Invitation;
|
||||||
|
|
||||||
import eu.eudat.data.old.UserDMP;
|
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
import eu.eudat.models.rda.Dmp;
|
||||||
import eu.eudat.service.mail.MailService;
|
import eu.eudat.service.mail.MailService;
|
||||||
import jakarta.mail.MessagingException;
|
import jakarta.mail.MessagingException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -15,11 +16,11 @@ import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
|
||||||
public interface InvitationService {
|
public interface InvitationService {
|
||||||
void assignToDmp(DMPDao dmpDao, List<UserDMP> users, DMP dmp);
|
void assignToDmp(DMPDao dmpDao, List<DmpUserEntity> users, DmpEntity dmp);
|
||||||
|
|
||||||
void assignToDmp(DMPDao dmpDao, UserDMP user, DMP dmp);
|
void assignToDmp(DMPDao dmpDao, DmpUserEntity user, DmpEntity dmp);
|
||||||
|
|
||||||
void createInvitations(InvitationDao invitationDao, MailService mailService, List<UserInfo> users, DMP dmp, Integer role, UserInfo creator) throws MessagingException;
|
void createInvitations(InvitationDao invitationDao, MailService mailService, List<UserInfo> users, DmpEntity dmp, Integer role, UserInfo creator) throws MessagingException;
|
||||||
|
|
||||||
CompletableFuture sendInvitationAsync(DMP dmp, Invitation invitation, String recipient, MailService mailService, Integer role) throws MessagingException;
|
CompletableFuture sendInvitationAsync(DmpEntity dmp, Invitation invitation, String recipient, MailService mailService, Integer role) throws MessagingException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
package eu.eudat.logic.services.utilities;
|
package eu.eudat.logic.services.utilities;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.dao.entities.DMPDao;
|
import eu.eudat.data.dao.entities.DMPDao;
|
||||||
import eu.eudat.data.dao.entities.InvitationDao;
|
import eu.eudat.data.dao.entities.InvitationDao;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.old.Invitation;
|
import eu.eudat.data.old.Invitation;
|
||||||
import eu.eudat.data.old.UserDMP;
|
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.models.data.invitation.Properties;
|
import eu.eudat.models.data.invitation.Properties;
|
||||||
import eu.eudat.service.mail.MailService;
|
import eu.eudat.service.mail.MailService;
|
||||||
|
@ -37,26 +37,26 @@ public class InvitationServiceImpl implements InvitationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignToDmp(DMPDao dmpDao, List<UserDMP> users, DMP dmp) {
|
public void assignToDmp(DMPDao dmpDao, List<DmpUserEntity> users, DmpEntity dmp) {
|
||||||
for (UserDMP user : users) {
|
// for (DmpUserEntity user : users) {
|
||||||
dmp.getUsers().add(user);
|
// dmp.getUsers().add(user);
|
||||||
}
|
// } //TODO
|
||||||
dmpDao.createOrUpdate(dmp);
|
dmpDao.createOrUpdate(dmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void assignToDmp(DMPDao dmpDao, UserDMP user, DMP dmp) {
|
public void assignToDmp(DMPDao dmpDao, DmpUserEntity user, DmpEntity dmp) {
|
||||||
if (!dmp.getUsers().stream().map(x -> x.getUser().getId()).collect(Collectors.toList()).contains(user.getId())) {
|
// if (!dmp.getUsers().stream().map(x -> x.getUser().getId()).collect(Collectors.toList()).contains(user.getId())) {
|
||||||
dmp.getUsers().add(user);
|
// dmp.getUsers().add(user);
|
||||||
dmpDao.createOrUpdate(dmp);
|
// dmpDao.createOrUpdate(dmp);
|
||||||
}
|
// } //TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createInvitations(InvitationDao invitationDao, MailService mailService, List<UserInfo> users, DMP dmp, Integer role, UserInfo creator) throws MessagingException {
|
public void createInvitations(InvitationDao invitationDao, MailService mailService, List<UserInfo> users, DmpEntity dmp, Integer role, UserInfo creator) throws MessagingException {
|
||||||
for (UserInfo userInfo : users) {
|
for (UserInfo userInfo : users) {
|
||||||
Invitation invitation = new Invitation();
|
Invitation invitation = new Invitation();
|
||||||
invitation.setDmp(dmp);
|
// invitation.setDmp(dmp); //TODO
|
||||||
invitation.setInvitationEmail(userInfo.getEmail());
|
invitation.setInvitationEmail(userInfo.getEmail());
|
||||||
invitation.setUser(creator);
|
invitation.setUser(creator);
|
||||||
invitation.setToken(UUID.randomUUID());
|
invitation.setToken(UUID.randomUUID());
|
||||||
|
@ -78,7 +78,7 @@ public class InvitationServiceImpl implements InvitationService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture sendInvitationAsync(DMP dmp, Invitation invitation, String recipient, MailService mailService, Integer role) {
|
public CompletableFuture sendInvitationAsync(DmpEntity dmp, Invitation invitation, String recipient, MailService mailService, Integer role) {
|
||||||
return CompletableFuture.runAsync(() -> {
|
return CompletableFuture.runAsync(() -> {
|
||||||
SimpleMail mail = new SimpleMail();
|
SimpleMail mail = new SimpleMail();
|
||||||
mail.setSubject(createSubject(dmp, mailService.getMailTemplateSubject()));
|
mail.setSubject(createSubject(dmp, mailService.getMailTemplateSubject()));
|
||||||
|
@ -92,17 +92,17 @@ public class InvitationServiceImpl implements InvitationService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createSubject(DMP dmp, String templateSubject) {
|
private String createSubject(DmpEntity dmp, String templateSubject) {
|
||||||
String subject = templateSubject.replace("{dmpname}", dmp.getLabel());
|
String subject = templateSubject.replace("{dmpname}", dmp.getLabel());
|
||||||
return subject;
|
return subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createContent(UUID invitationID, DMP dmp, String recipient, String templateContent, Integer role) {
|
private String createContent(UUID invitationID, DmpEntity dmp, String recipient, String templateContent, Integer role) {
|
||||||
String content = templateContent.replace("{dmpname}", dmp.getLabel());
|
String content = templateContent.replace("{dmpname}", dmp.getLabel());
|
||||||
content = content.replace("{invitationID}", invitationID.toString());
|
content = content.replace("{invitationID}", invitationID.toString());
|
||||||
content = content.replace("{recipient}", recipient);
|
content = content.replace("{recipient}", recipient);
|
||||||
content = content.replace("{host}", this.environment.getProperty("dmp.domain"));
|
content = content.replace("{host}", this.environment.getProperty("dmp.domain"));
|
||||||
content = content.replace("{dmprole}", UserDMP.UserDMPRoles.fromInteger(role).name());
|
// content = content.replace("{dmprole}", UserDMP.UserDMPRoles.fromInteger(role).name()); //TODO
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.commons.enums.FieldDataComboBoxType;
|
import eu.eudat.commons.enums.FieldDataComboBoxType;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.Organisation;
|
import eu.eudat.data.old.Organisation;
|
||||||
import eu.eudat.data.old.Researcher;
|
import eu.eudat.data.old.Researcher;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
|
@ -1014,7 +1014,7 @@ public class WordBuilder {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillFirstPage(DMP dmpEntity, DescriptionEntity descriptionEntityEntity, XWPFDocument document, boolean isDataset) {
|
public void fillFirstPage(DmpEntity dmpEntity, DescriptionEntity descriptionEntityEntity, XWPFDocument document, boolean isDataset) {
|
||||||
int parPos = 0;
|
int parPos = 0;
|
||||||
int descrParPos = -1;
|
int descrParPos = -1;
|
||||||
XWPFParagraph descrPar = null;
|
XWPFParagraph descrPar = null;
|
||||||
|
@ -1046,23 +1046,25 @@ public class WordBuilder {
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
} else if(text.equals("{ARGOS.DMP.RESEARCHERS}")) {
|
} else if(text.equals("{ARGOS.DMP.RESEARCHERS}")) {
|
||||||
String researchersNames = "";
|
String researchersNames = "";
|
||||||
Set<Researcher> researchers = dmpEntity.getResearchers();
|
//TODO
|
||||||
int i = 0;
|
// Set<Researcher> researchers = dmpEntity.getResearchers();
|
||||||
for(Researcher researcher : researchers){
|
// int i = 0;
|
||||||
i++;
|
// for(Researcher researcher : researchers){
|
||||||
researchersNames += researcher.getLabel() + (i < researchers.size() ? ", " : "");
|
// i++;
|
||||||
}
|
// researchersNames += researcher.getLabel() + (i < researchers.size() ? ", " : "");
|
||||||
|
// }
|
||||||
text = text.replace("{ARGOS.DMP.RESEARCHERS}", researchersNames);
|
text = text.replace("{ARGOS.DMP.RESEARCHERS}", researchersNames);
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
r.setFontSize(17);
|
r.setFontSize(17);
|
||||||
} else if(text.equals("{ARGOS.DMP.ORGANIZATIONS}")) {
|
} else if(text.equals("{ARGOS.DMP.ORGANIZATIONS}")) {
|
||||||
String organisationsNames = "";
|
String organisationsNames = "";
|
||||||
Set<Organisation> organisations = dmpEntity.getOrganisations();
|
//TODO
|
||||||
int i = 0;
|
// Set<Organisation> organisations = dmpEntity.getOrganisations();
|
||||||
for(Organisation organisation : organisations){
|
// int i = 0;
|
||||||
i++;
|
// for(Organisation organisation : organisations){
|
||||||
organisationsNames += organisation.getLabel() + (i < organisations.size() ? ", " : "");
|
// i++;
|
||||||
}
|
// organisationsNames += organisation.getLabel() + (i < organisations.size() ? ", " : "");
|
||||||
|
// }
|
||||||
text = text.replace("{ARGOS.DMP.ORGANIZATIONS}", organisationsNames);
|
text = text.replace("{ARGOS.DMP.ORGANIZATIONS}", organisationsNames);
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
r.setFontSize(17);
|
r.setFontSize(17);
|
||||||
|
@ -1092,31 +1094,32 @@ public class WordBuilder {
|
||||||
XWPFTable tbl = document.getTables().get(0);
|
XWPFTable tbl = document.getTables().get(0);
|
||||||
Iterator<XWPFTableRow> it = tbl.getRows().iterator();
|
Iterator<XWPFTableRow> it = tbl.getRows().iterator();
|
||||||
it.next(); // skip first row
|
it.next(); // skip first row
|
||||||
if(it.hasNext() && dmpEntity.getGrant() != null){
|
//TODO
|
||||||
XWPFParagraph p = it.next().getCell(0).getParagraphs().get(0);
|
// if(it.hasNext() && dmpEntity.getGrant() != null){
|
||||||
XWPFRun run = p.createRun();
|
// XWPFParagraph p = it.next().getCell(0).getParagraphs().get(0);
|
||||||
run.setText(dmpEntity.getGrant().getFunder().getLabel());
|
// XWPFRun run = p.createRun();
|
||||||
run.setFontSize(17);
|
// run.setText(dmpEntity.getGrant().getFunder().getLabel());
|
||||||
p.setAlignment(ParagraphAlignment.CENTER);
|
// run.setFontSize(17);
|
||||||
}
|
// p.setAlignment(ParagraphAlignment.CENTER);
|
||||||
it = tbl.getRows().iterator();
|
// }
|
||||||
it.next();
|
// it = tbl.getRows().iterator();
|
||||||
if(it.hasNext() && dmpEntity.getGrant() != null){
|
// it.next();
|
||||||
XWPFParagraph p = it.next().getCell(1).getParagraphs().get(0);
|
// if(it.hasNext() && dmpEntity.getGrant() != null){
|
||||||
XWPFRun run = p.createRun();
|
// XWPFParagraph p = it.next().getCell(1).getParagraphs().get(0);
|
||||||
String text = dmpEntity.getGrant().getLabel();
|
// XWPFRun run = p.createRun();
|
||||||
String reference = dmpEntity.getGrant().getReference();
|
// String text = dmpEntity.getGrant().getLabel();
|
||||||
if(reference != null) {
|
// String reference = dmpEntity.getGrant().getReference();
|
||||||
String[] parts = reference.split("::");
|
// if(reference != null) {
|
||||||
text += parts.length > 1 ? "/ No "+parts[parts.length - 1] : "";
|
// String[] parts = reference.split("::");
|
||||||
}
|
// text += parts.length > 1 ? "/ No "+parts[parts.length - 1] : "";
|
||||||
run.setText(text);
|
// }
|
||||||
run.setFontSize(17);
|
// run.setText(text);
|
||||||
p.setAlignment(ParagraphAlignment.CENTER);
|
// run.setFontSize(17);
|
||||||
}
|
// p.setAlignment(ParagraphAlignment.CENTER);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillFooter(DMP dmpEntity, DescriptionEntity descriptionEntityEntity, XWPFDocument document, boolean isDataset) {
|
public void fillFooter(DmpEntity dmpEntity, DescriptionEntity descriptionEntityEntity, XWPFDocument document, boolean isDataset) {
|
||||||
document.getFooterList().forEach(xwpfFooter -> {
|
document.getFooterList().forEach(xwpfFooter -> {
|
||||||
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
||||||
if(runs != null){
|
if(runs != null){
|
||||||
|
@ -1131,26 +1134,27 @@ public class WordBuilder {
|
||||||
text = text.replace("{ARGOS.DATASET.TITLE}", descriptionEntityEntity.getLabel());
|
text = text.replace("{ARGOS.DATASET.TITLE}", descriptionEntityEntity.getLabel());
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
}
|
}
|
||||||
if(text.contains("{ARGOS.DMP.LICENSE}")){
|
//TODO
|
||||||
try{
|
// if(text.contains("{ARGOS.DMP.LICENSE}")){
|
||||||
Map<String, String> license = ((Map<String, String>) mapper.readValue(dmpEntity.getExtraProperties(), Map.class).get("license"));
|
// try{
|
||||||
text = text.replace("{ARGOS.DMP.LICENSE}", license.get("pid"));
|
// Map<String, String> license = ((Map<String, String>) mapper.readValue(dmpEntity.getExtraProperties(), Map.class).get("license"));
|
||||||
}
|
// text = text.replace("{ARGOS.DMP.LICENSE}", license.get("pid"));
|
||||||
catch (JsonProcessingException | NullPointerException e){
|
// }
|
||||||
text = text.replace("{ARGOS.DMP.LICENSE}", "License: -");
|
// catch (JsonProcessingException | NullPointerException e){
|
||||||
}
|
// text = text.replace("{ARGOS.DMP.LICENSE}", "License: -");
|
||||||
r.setText(text, 0);
|
// }
|
||||||
}
|
// r.setText(text, 0);
|
||||||
if(text.contains("{ARGOS.DMP.DOI}")){
|
// }
|
||||||
if(dmpEntity.getDois() != null && !dmpEntity.getDois().isEmpty())
|
// if(text.contains("{ARGOS.DMP.DOI}")){
|
||||||
text = text.replace("{ARGOS.DMP.DOI}", dmpEntity.getDois().iterator().next().getDoi());
|
// if(dmpEntity.getDois() != null && !dmpEntity.getDois().isEmpty())
|
||||||
else
|
// text = text.replace("{ARGOS.DMP.DOI}", dmpEntity.getDois().iterator().next().getDoi());
|
||||||
text = text.replace("{ARGOS.DMP.DOI}", "-");
|
// else
|
||||||
r.setText(text, 0);
|
// text = text.replace("{ARGOS.DMP.DOI}", "-");
|
||||||
}
|
// r.setText(text, 0);
|
||||||
|
// }
|
||||||
if(text.contains("{ARGOS.DMP.LAST_MODIFIED}")){
|
if(text.contains("{ARGOS.DMP.LAST_MODIFIED}")){
|
||||||
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
|
||||||
text = text.replace("{ARGOS.DMP.LAST_MODIFIED}", formatter.format(dmpEntity.getModified()));
|
text = text.replace("{ARGOS.DMP.LAST_MODIFIED}", formatter.format(dmpEntity.getUpdatedAt()));
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.models.data.dashboard.recent.model;
|
package eu.eudat.models.data.dashboard.recent.model;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||||
import eu.eudat.models.data.urls.DatasetUrlListing;
|
import eu.eudat.models.data.urls.DatasetUrlListing;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class RecentDmpModel extends RecentActivityModel<DMP, RecentDmpModel> {
|
public class RecentDmpModel extends RecentActivityModel<DmpEntity, RecentDmpModel> {
|
||||||
private Map<String, Object> extraProperties;
|
private Map<String, Object> extraProperties;
|
||||||
private List<DatasetUrlListing> datasets;
|
private List<DatasetUrlListing> datasets;
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
|
@ -41,33 +41,33 @@ public class RecentDmpModel extends RecentActivityModel<DMP, RecentDmpModel> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public RecentActivityModel fromEntity(DMP entity) {
|
public RecentActivityModel fromEntity(DmpEntity entity) {
|
||||||
this.setType(RecentActivityType.DMP.getIndex());
|
this.setType(RecentActivityType.DMP.getIndex());
|
||||||
this.setId(entity.getId().toString());
|
this.setId(entity.getId().toString());
|
||||||
this.setTitle(entity.getLabel());
|
this.setTitle(entity.getLabel()); //TODO
|
||||||
this.setCreated(entity.getCreated());
|
// this.setCreated(entity.getCreated());
|
||||||
this.setModified(entity.getModified());
|
// this.setModified(entity.getModified());
|
||||||
this.setStatus(entity.getStatus());
|
// this.setStatus(entity.getStatus());
|
||||||
this.setVersion(entity.getVersion());
|
// this.setVersion(entity.getVersion());
|
||||||
this.datasets = entity.getDataset().stream().map(dataset -> new DatasetUrlListing().fromDataModel(dataset)).collect(Collectors.toList());
|
// this.datasets = entity.getDataset().stream().map(dataset -> new DatasetUrlListing().fromDataModel(dataset)).collect(Collectors.toList());
|
||||||
this.setFinalizedAt(entity.getFinalizedAt());
|
// this.setFinalizedAt(entity.getFinalizedAt());
|
||||||
if (entity.getGrant() != null) {
|
// if (entity.getGrant() != null) {
|
||||||
this.setGrant(entity.getGrant().getLabel());
|
// this.setGrant(entity.getGrant().getLabel());
|
||||||
}
|
// }
|
||||||
this.groupId = entity.getGroupId();
|
// this.groupId = entity.getGroupId();
|
||||||
this.setPublic(entity.isPublic());
|
// this.setPublic(entity.isPublic());
|
||||||
this.setPublishedAt(entity.getPublishedAt());
|
// this.setPublishedAt(entity.getPublishedAt());
|
||||||
this.setUsers(entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()));
|
// this.setUsers(entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecentDmpModel fromDataModel(DMP entity) {
|
public RecentDmpModel fromDataModel(DmpEntity entity) {
|
||||||
return (RecentDmpModel) this.fromEntity(entity);
|
return (RecentDmpModel) this.fromEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() throws Exception {
|
public DmpEntity toDataModel() throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package eu.eudat.models.data.datasetwizard;
|
package eu.eudat.models.data.datasetwizard;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
|
||||||
|
|
||||||
public class DataManagentPlanListingModel implements DataModel<DMP, DataManagentPlanListingModel> {
|
public class DataManagentPlanListingModel implements DataModel<DmpEntity, DataManagentPlanListingModel> {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
private String label;
|
private String label;
|
||||||
|
@ -26,14 +26,14 @@ public class DataManagentPlanListingModel implements DataModel<DMP, DataManagent
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagentPlanListingModel fromDataModel(DMP entity) {
|
public DataManagentPlanListingModel fromDataModel(DmpEntity entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() {
|
public DmpEntity toDataModel() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.model.doi.Doi;
|
import eu.eudat.model.doi.Doi;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
@ -21,7 +22,7 @@ import net.minidev.json.JSONObject;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
public class DataManagementPlan implements DataModel<DmpEntity, DataManagementPlan> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
|
@ -235,204 +236,205 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlan fromDataModel(DMP entity) {
|
public DataManagementPlan fromDataModel(DmpEntity entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
//TODO
|
||||||
this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
||||||
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
|
// this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.version = entity.getVersion();
|
// this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
|
||||||
this.groupId = this.groupId == null ? null : entity.getGroupId();
|
// this.version = entity.getVersion();
|
||||||
this.label = entity.getLabel();
|
// this.groupId = this.groupId == null ? null : entity.getGroupId();
|
||||||
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
// this.label = entity.getLabel();
|
||||||
if(entity.getGrant() != null) {
|
// this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
||||||
this.grant = new Grant();
|
// if(entity.getGrant() != null) {
|
||||||
this.grant.fromDataModel(entity.getGrant());
|
// this.grant = new Grant();
|
||||||
}
|
// this.grant.fromDataModel(entity.getGrant());
|
||||||
else {
|
// }
|
||||||
this.grant = null;
|
// else {
|
||||||
}
|
// this.grant = null;
|
||||||
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
// }
|
||||||
this.groupId = entity.getGroupId();
|
// this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
||||||
this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
|
// this.groupId = entity.getGroupId();
|
||||||
if (this.properties != null) {
|
// this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
|
||||||
this.extraFields = new ArrayList<>();
|
// if (this.properties != null) {
|
||||||
this.properties.forEach((id, value) -> {
|
// this.extraFields = new ArrayList<>();
|
||||||
if (value != null) {
|
// this.properties.forEach((id, value) -> {
|
||||||
ExtraFieldModel extraField = new ExtraFieldModel();
|
// if (value != null) {
|
||||||
extraField.setId(id);
|
// ExtraFieldModel extraField = new ExtraFieldModel();
|
||||||
extraField.setValue(value.toString());
|
// extraField.setId(id);
|
||||||
this.extraFields.add(extraField);
|
// extraField.setValue(value.toString());
|
||||||
}
|
// this.extraFields.add(extraField);
|
||||||
});
|
// }
|
||||||
}
|
// });
|
||||||
if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
// }
|
||||||
this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
// if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
||||||
|
// this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
//
|
||||||
this.profiles = new LinkedList<>();
|
// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
|
// this.profiles = new LinkedList<>();
|
||||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
|
// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
|
||||||
associatedProfile.setId(dmpDescriptionProfile.getId());
|
// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
|
||||||
try {
|
// associatedProfile.setId(dmpDescriptionProfile.getId());
|
||||||
associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
|
// try {
|
||||||
}
|
// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
|
||||||
catch (Exception e) {
|
// }
|
||||||
associatedProfile.setData(null);
|
// catch (Exception e) {
|
||||||
}
|
// associatedProfile.setData(null);
|
||||||
this.profiles.add(associatedProfile);
|
// }
|
||||||
}
|
// this.profiles.add(associatedProfile);
|
||||||
}
|
// }
|
||||||
if (entity.getDataset() != null) {
|
// }
|
||||||
if (entity.isPublic()) {
|
// if (entity.getDataset() != null) {
|
||||||
this.datasets = entity.getDataset().stream()
|
// if (entity.isPublic()) {
|
||||||
.filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled) && !dataset.getStatus().equals(DescriptionStatus.Draft))
|
// this.datasets = entity.getDataset().stream()
|
||||||
.map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
// .filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled) && !dataset.getStatus().equals(DescriptionStatus.Draft))
|
||||||
} else {
|
// .map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
||||||
this.datasets = entity.getDataset().stream()
|
// } else {
|
||||||
.filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Draft))
|
// this.datasets = entity.getDataset().stream()
|
||||||
.map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
// .filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Draft))
|
||||||
}
|
// .map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
this.modified = entity.getModified();
|
// }
|
||||||
this.created = entity.getCreated();
|
// this.modified = entity.getModified();
|
||||||
this.description = entity.getDescription();
|
// this.created = entity.getCreated();
|
||||||
this.status = entity.getStatus();
|
// this.description = entity.getDescription();
|
||||||
this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
|
// this.status = entity.getStatus();
|
||||||
this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.dois = entity.getDois() != null ? entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
|
// this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
|
// this.dois = entity.getDois() != null ? entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
|
||||||
if (entity.getProject() != null) {
|
//
|
||||||
this.project = new Project();
|
// if (entity.getProject() != null) {
|
||||||
this.project = new Project().fromDataModel(entity.getProject());
|
// this.project = new Project();
|
||||||
}
|
// this.project = new Project().fromDataModel(entity.getProject());
|
||||||
|
// }
|
||||||
if (entity.getGrant() != null && entity.getGrant().getFunder() != null) {
|
//
|
||||||
this.funder = new Funder();
|
// if (entity.getGrant() != null && entity.getGrant().getFunder() != null) {
|
||||||
this.funder.fromDataModel(entity.getGrant().getFunder());
|
// this.funder = new Funder();
|
||||||
}
|
// this.funder.fromDataModel(entity.getGrant().getFunder());
|
||||||
this.isPublic = entity.isPublic();
|
// }
|
||||||
|
// this.isPublic = entity.isPublic();
|
||||||
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
//
|
||||||
|
// this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() throws Exception {
|
public DmpEntity toDataModel() throws Exception {
|
||||||
DMP dataManagementPlanEntity = new DMP();
|
DmpEntity dataManagementPlanEntity = new DmpEntity(); //TODO
|
||||||
if (this.profile != null) {
|
// if (this.profile != null) {
|
||||||
DmpBlueprintEntity dmpBlueprint = new DmpBlueprintEntity();
|
// DmpBlueprintEntity dmpBlueprint = new DmpBlueprintEntity();
|
||||||
dmpBlueprint.setId(this.profile.getId());
|
// dmpBlueprint.setId(this.profile.getId());
|
||||||
dataManagementPlanEntity.setProfile(dmpBlueprint);
|
// dataManagementPlanEntity.setProfile(dmpBlueprint);
|
||||||
}
|
// }
|
||||||
dataManagementPlanEntity.setId(this.id);
|
// dataManagementPlanEntity.setId(this.id);
|
||||||
if (this.organisations != null && !this.organisations.isEmpty())
|
// if (this.organisations != null && !this.organisations.isEmpty())
|
||||||
dataManagementPlanEntity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
// dataManagementPlanEntity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||||
if (this.researchers != null && !this.researchers.isEmpty())
|
// if (this.researchers != null && !this.researchers.isEmpty())
|
||||||
dataManagementPlanEntity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
// dataManagementPlanEntity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||||
dataManagementPlanEntity.setVersion(this.version);
|
// dataManagementPlanEntity.setVersion(this.version);
|
||||||
dataManagementPlanEntity.setLabel(this.label);
|
// dataManagementPlanEntity.setLabel(this.label);
|
||||||
if (this.grant != null) dataManagementPlanEntity.setGrant(this.grant.toDataModel());
|
// if (this.grant != null) dataManagementPlanEntity.setGrant(this.grant.toDataModel());
|
||||||
dataManagementPlanEntity.setStatus((short) this.status);
|
// dataManagementPlanEntity.setStatus((short) this.status);
|
||||||
dataManagementPlanEntity.setDescription(this.description);
|
// dataManagementPlanEntity.setDescription(this.description);
|
||||||
if (this.project != null) {
|
// if (this.project != null) {
|
||||||
dataManagementPlanEntity.setProject(this.project.toDataModel());
|
// dataManagementPlanEntity.setProject(this.project.toDataModel());
|
||||||
}
|
// }
|
||||||
if (this.profiles != null) {
|
// if (this.profiles != null) {
|
||||||
Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
|
// Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
|
||||||
for (AssociatedProfile profile : this.profiles) {
|
// for (AssociatedProfile profile : this.profiles) {
|
||||||
DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
|
// DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
|
||||||
dmpDatasetProfile.setId(profile.getId());
|
// dmpDatasetProfile.setId(profile.getId());
|
||||||
dmpDatasetProfile.setDmp(dataManagementPlanEntity);
|
// dmpDatasetProfile.setDmp(dataManagementPlanEntity);
|
||||||
dmpDatasetProfile.setDatasetprofile(profile.toData());
|
// dmpDatasetProfile.setDatasetprofile(profile.toData());
|
||||||
dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
|
// dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
|
||||||
dmpDatasetProfiles.add(dmpDatasetProfile);
|
// dmpDatasetProfiles.add(dmpDatasetProfile);
|
||||||
}
|
// }
|
||||||
dataManagementPlanEntity.setAssociatedDmps(dmpDatasetProfiles);
|
// dataManagementPlanEntity.setAssociatedDmps(dmpDatasetProfiles);
|
||||||
}
|
// }
|
||||||
if(this.extraFields != null) {
|
// if(this.extraFields != null) {
|
||||||
this.properties = this.extraFields.stream().collect(Collectors.toMap(ExtraFieldModel::getId, ExtraFieldModel::getValue));
|
// this.properties = this.extraFields.stream().collect(Collectors.toMap(ExtraFieldModel::getId, ExtraFieldModel::getValue));
|
||||||
}
|
// }
|
||||||
dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null);
|
// dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null);
|
||||||
dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
|
// dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
|
||||||
dataManagementPlanEntity.setModified(this.modified != null ? this.modified : new Date());
|
// dataManagementPlanEntity.setModified(this.modified != null ? this.modified : new Date());
|
||||||
dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
|
// dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
|
||||||
if (this.dynamicFields != null)
|
// if (this.dynamicFields != null)
|
||||||
dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
|
// dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
|
||||||
|
//
|
||||||
if (this.isPublic != null) {
|
// if (this.isPublic != null) {
|
||||||
dataManagementPlanEntity.setPublic(this.isPublic);
|
// dataManagementPlanEntity.setPublic(this.isPublic);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
dataManagementPlanEntity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
|
// dataManagementPlanEntity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
|
||||||
return dataManagementPlanEntity;
|
return dataManagementPlanEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlan fromDataModelNoDatasets(DMP entity) {
|
public DataManagementPlan fromDataModelNoDatasets(DmpEntity entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getId(); //TODO
|
||||||
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
// this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
||||||
this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.organisations = entity.getOrganisations() != null ? entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().filter(Objects::nonNull).map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().filter(Objects::nonNull).map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.version = entity.getVersion();
|
// this.version = entity.getVersion();
|
||||||
this.label = entity.getLabel();
|
// this.label = entity.getLabel();
|
||||||
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
// this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
||||||
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
// this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
||||||
this.groupId = entity.getGroupId();
|
// this.groupId = entity.getGroupId();
|
||||||
this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
|
// this.lockable = entity.getDataset() != null && entity.getDataset().stream().findAny().isPresent();
|
||||||
if (this.properties != null) {
|
// if (this.properties != null) {
|
||||||
this.extraFields = new ArrayList<>();
|
// this.extraFields = new ArrayList<>();
|
||||||
this.properties.forEach((id, value) -> {
|
// this.properties.forEach((id, value) -> {
|
||||||
if (value != null) {
|
// if (value != null) {
|
||||||
ExtraFieldModel extraField = new ExtraFieldModel();
|
// ExtraFieldModel extraField = new ExtraFieldModel();
|
||||||
extraField.setId(id);
|
// extraField.setId(id);
|
||||||
extraField.setValue(value.toString());
|
// extraField.setValue(value.toString());
|
||||||
this.extraFields.add(extraField);
|
// this.extraFields.add(extraField);
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
// if (entity.getUsers() != null && entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
||||||
this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
// this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
||||||
|
//
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
this.profiles = new LinkedList<>();
|
// this.profiles = new LinkedList<>();
|
||||||
for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
|
// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
|
||||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
|
// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
|
||||||
associatedProfile.setId(dmpDescriptionProfile.getId());
|
// associatedProfile.setId(dmpDescriptionProfile.getId());
|
||||||
try {
|
// try {
|
||||||
associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
|
// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
|
||||||
}
|
// }
|
||||||
catch (Exception e) {
|
// catch (Exception e) {
|
||||||
associatedProfile.setData(null);
|
// associatedProfile.setData(null);
|
||||||
}
|
// }
|
||||||
this.profiles.add(associatedProfile);
|
// this.profiles.add(associatedProfile);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
this.modified = entity.getModified();
|
// this.modified = entity.getModified();
|
||||||
this.created = entity.getCreated();
|
// this.created = entity.getCreated();
|
||||||
this.description = entity.getDescription();
|
// this.description = entity.getDescription();
|
||||||
this.status = entity.getStatus();
|
// this.status = entity.getStatus();
|
||||||
this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
|
// this.associatedUsers = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.users = entity.getUsers() != null ? entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.dois = entity.getDois() != null ? entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
|
// this.dois = entity.getDois() != null ? entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList()): new ArrayList<>();
|
||||||
if(entity.getGrant() != null) {
|
// if(entity.getGrant() != null) {
|
||||||
this.grant = new Grant();
|
// this.grant = new Grant();
|
||||||
this.grant.fromDataModel(entity.getGrant());
|
// this.grant.fromDataModel(entity.getGrant());
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
this.grant = null;
|
// this.grant = null;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (entity.getProject() != null) {
|
// if (entity.getProject() != null) {
|
||||||
this.project = new Project();
|
// this.project = new Project();
|
||||||
this.project = new Project().fromDataModel(entity.getProject());
|
// this.project = new Project().fromDataModel(entity.getProject());
|
||||||
}
|
// }
|
||||||
if (entity.getGrant() != null && entity.getGrant().getFunder() != null) {
|
// if (entity.getGrant() != null && entity.getGrant().getFunder() != null) {
|
||||||
this.funder = new Funder();
|
// this.funder = new Funder();
|
||||||
this.funder.fromDataModel(entity.getGrant().getFunder());
|
// this.funder.fromDataModel(entity.getGrant().getFunder());
|
||||||
}
|
// }
|
||||||
this.isPublic = entity.isPublic();
|
// this.isPublic = entity.isPublic();
|
||||||
|
//
|
||||||
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
// this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.data.dmp;
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
|
@ -18,7 +19,7 @@ import net.minidev.json.JSONObject;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagementPlanEditorModel> {
|
public class DataManagementPlanEditorModel implements DataModel<DmpEntity, DataManagementPlanEditorModel> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private UUID groupId;
|
private UUID groupId;
|
||||||
|
@ -223,171 +224,171 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlanEditorModel fromDataModel(DMP entity) {
|
public DataManagementPlanEditorModel fromDataModel(DmpEntity entity) {
|
||||||
this.id = entity.getId();
|
this.id = entity.getId();
|
||||||
this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null;
|
// this.profile = entity.getProfile() != null ? new Tuple<UUID, String>(entity.getProfile().getId(), entity.getProfile().getLabel()) : null; //TODO
|
||||||
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
// this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
// this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.version = entity.getVersion();
|
// this.version = entity.getVersion();
|
||||||
this.groupId = this.groupId == null ? null : entity.getGroupId();
|
// this.groupId = this.groupId == null ? null : entity.getGroupId();
|
||||||
this.label = entity.getLabel();
|
// this.label = entity.getLabel();
|
||||||
this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
// this.properties = entity.getProperties() != null ? new org.json.JSONObject(entity.getProperties()).toMap() : null;
|
||||||
if (entity.getGrant() != null) {
|
// if (entity.getGrant() != null) {
|
||||||
this.grant = new GrantDMPEditorModel();
|
// this.grant = new GrantDMPEditorModel();
|
||||||
this.grant.getExistGrant().fromDataModel(entity.getGrant());
|
// this.grant.getExistGrant().fromDataModel(entity.getGrant());
|
||||||
this.grant.getExistGrant().setSource("");
|
// this.grant.getExistGrant().setSource("");
|
||||||
}
|
// }
|
||||||
this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
// this.creator = new eu.eudat.models.data.userinfo.UserInfo();
|
||||||
this.groupId = entity.getGroupId();
|
// this.groupId = entity.getGroupId();
|
||||||
this.lockable = entity.getDataset().stream().findAny().isPresent();
|
// this.lockable = entity.getDataset().stream().findAny().isPresent();
|
||||||
if (this.properties != null) {
|
// if (this.properties != null) {
|
||||||
this.extraFields = new ArrayList<>();
|
// this.extraFields = new ArrayList<>();
|
||||||
this.properties.forEach((id, value) -> {
|
// this.properties.forEach((id, value) -> {
|
||||||
ExtraFieldModel extraField = new ExtraFieldModel();
|
// ExtraFieldModel extraField = new ExtraFieldModel();
|
||||||
extraField.setId(id);
|
// extraField.setId(id);
|
||||||
extraField.setValue(value.toString());
|
// extraField.setValue(value.toString());
|
||||||
this.extraFields.add(extraField);
|
// this.extraFields.add(extraField);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
if (entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
// if (entity.getUsers().stream().anyMatch(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())))
|
||||||
this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
// this.creator.fromDataModel(entity.getUsers().stream().filter(user -> user.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
||||||
|
//
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
this.profiles = new LinkedList<>();
|
// this.profiles = new LinkedList<>();
|
||||||
for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
|
// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
|
||||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
|
// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
|
||||||
try {
|
// try {
|
||||||
associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
|
// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
|
||||||
}
|
// }
|
||||||
catch (Exception e) {
|
// catch (Exception e) {
|
||||||
associatedProfile.setData(null);
|
// associatedProfile.setData(null);
|
||||||
}
|
// }
|
||||||
this.profiles.add(associatedProfile);
|
// this.profiles.add(associatedProfile);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
this.datasets = entity.getDataset().stream().map(item -> new DatasetWizardModel().fromDataModelNoDmp(item)).collect(Collectors.toList());
|
// this.datasets = entity.getDataset().stream().map(item -> new DatasetWizardModel().fromDataModelNoDmp(item)).collect(Collectors.toList());
|
||||||
this.modified = entity.getModified();
|
// this.modified = entity.getModified();
|
||||||
this.created = entity.getCreated();
|
// this.created = entity.getCreated();
|
||||||
this.description = entity.getDescription();
|
// this.description = entity.getDescription();
|
||||||
this.status = entity.getStatus();
|
// this.status = entity.getStatus();
|
||||||
this.project = new ProjectDMPEditorModel();
|
// this.project = new ProjectDMPEditorModel();
|
||||||
this.project.getExistProject().fromDataModel(entity.getProject());
|
// this.project.getExistProject().fromDataModel(entity.getProject());
|
||||||
this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
|
// this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
|
||||||
this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
|
// this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||||
if (entity.getGrant() != null) {
|
// if (entity.getGrant() != null) {
|
||||||
this.funder = new FunderDMPEditorModel();
|
// this.funder = new FunderDMPEditorModel();
|
||||||
this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder());
|
// this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder());
|
||||||
}
|
// }
|
||||||
this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
// this.extraProperties = entity.getExtraProperties() != null ? new org.json.JSONObject(entity.getExtraProperties()).toMap() : null;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() throws Exception {
|
public DmpEntity toDataModel() throws Exception {
|
||||||
DMP dataManagementPlanEntity = new DMP();
|
DmpEntity dataManagementPlanEntity = new DmpEntity();//TODO
|
||||||
if (this.profile != null) {
|
// if (this.profile != null) {
|
||||||
DmpBlueprintEntity dmpBlueprint = new DmpBlueprintEntity();
|
// DmpBlueprintEntity dmpBlueprint = new DmpBlueprintEntity();
|
||||||
dmpBlueprint.setId(this.profile.getId());
|
// dmpBlueprint.setId(this.profile.getId());
|
||||||
dataManagementPlanEntity.setProfile(dmpBlueprint);
|
// dataManagementPlanEntity.setProfile(dmpBlueprint);
|
||||||
}
|
// }
|
||||||
dataManagementPlanEntity.setId(this.id);
|
// dataManagementPlanEntity.setId(this.id);
|
||||||
if (this.organisations != null && !this.organisations.isEmpty())
|
// if (this.organisations != null && !this.organisations.isEmpty())
|
||||||
dataManagementPlanEntity.setOrganisations(new HashSet<>(this.organisations.stream().map(Organisation::toDataModel).collect(Collectors.toList())));
|
// dataManagementPlanEntity.setOrganisations(new HashSet<>(this.organisations.stream().map(Organisation::toDataModel).collect(Collectors.toList())));
|
||||||
if (this.researchers != null && !this.researchers.isEmpty())
|
// if (this.researchers != null && !this.researchers.isEmpty())
|
||||||
dataManagementPlanEntity.setResearchers(new HashSet<>(this.researchers.stream().map(Researcher::toDataModel).collect(Collectors.toList())));
|
// dataManagementPlanEntity.setResearchers(new HashSet<>(this.researchers.stream().map(Researcher::toDataModel).collect(Collectors.toList())));
|
||||||
dataManagementPlanEntity.setVersion(this.version);
|
// dataManagementPlanEntity.setVersion(this.version);
|
||||||
dataManagementPlanEntity.setLabel(this.label);
|
// dataManagementPlanEntity.setLabel(this.label);
|
||||||
if (this.grant != null) {
|
// if (this.grant != null) {
|
||||||
if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
|
// if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
|
||||||
dataManagementPlanEntity.setGrant(this.grant.getExistGrant().toDataModel());
|
// dataManagementPlanEntity.setGrant(this.grant.getExistGrant().toDataModel());
|
||||||
else if (this.grant.getLabel() != null) {
|
// else if (this.grant.getLabel() != null) {
|
||||||
Grant grant = new Grant();
|
// Grant grant = new Grant();
|
||||||
grant.setId(UUID.randomUUID());
|
// grant.setId(UUID.randomUUID());
|
||||||
grant.setAbbreviation("");
|
// grant.setAbbreviation("");
|
||||||
grant.setLabel(this.grant.getLabel());
|
// grant.setLabel(this.grant.getLabel());
|
||||||
grant.setType(Grant.GrantType.INTERNAL.getValue());
|
// grant.setType(Grant.GrantType.INTERNAL.getValue());
|
||||||
grant.setReference("dmp:" + (this.grant.getReference() != null ? this.grant.getReference() : grant.getId()));
|
// grant.setReference("dmp:" + (this.grant.getReference() != null ? this.grant.getReference() : grant.getId()));
|
||||||
grant.setUri("");
|
// grant.setUri("");
|
||||||
grant.setDefinition("");
|
// grant.setDefinition("");
|
||||||
grant.setCreated(new Date());
|
// grant.setCreated(new Date());
|
||||||
grant.setStatus(Grant.Status.ACTIVE.getValue());
|
// grant.setStatus(Grant.Status.ACTIVE.getValue());
|
||||||
grant.setModified(new Date());
|
// grant.setModified(new Date());
|
||||||
grant.setDescription(this.grant.getDescription());
|
// grant.setDescription(this.grant.getDescription());
|
||||||
|
//
|
||||||
dataManagementPlanEntity.setGrant(grant);
|
// dataManagementPlanEntity.setGrant(grant);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (this.funder != null) {
|
// if (this.funder != null) {
|
||||||
if (this.funder.getLabel() != null) {
|
// if (this.funder.getLabel() != null) {
|
||||||
Funder funder = new Funder();
|
// Funder funder = new Funder();
|
||||||
funder.setId(UUID.randomUUID());
|
// funder.setId(UUID.randomUUID());
|
||||||
funder.setLabel(this.funder.getLabel());
|
// funder.setLabel(this.funder.getLabel());
|
||||||
funder.setType(Funder.FunderType.INTERNAL.getValue());
|
// funder.setType(Funder.FunderType.INTERNAL.getValue());
|
||||||
funder.setReference("dmp:" + (this.funder.getReference() != null ? this.funder.getReference() : funder.getId()));
|
// funder.setReference("dmp:" + (this.funder.getReference() != null ? this.funder.getReference() : funder.getId()));
|
||||||
funder.setDefinition("");
|
// funder.setDefinition("");
|
||||||
funder.setCreated(new Date());
|
// funder.setCreated(new Date());
|
||||||
funder.setStatus(Funder.Status.ACTIVE.getValue());
|
// funder.setStatus(Funder.Status.ACTIVE.getValue());
|
||||||
funder.setModified(new Date());
|
// funder.setModified(new Date());
|
||||||
|
//
|
||||||
dataManagementPlanEntity.getGrant().setFunder(funder);
|
// dataManagementPlanEntity.getGrant().setFunder(funder);
|
||||||
} else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null){
|
// } else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null){
|
||||||
dataManagementPlanEntity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
|
// dataManagementPlanEntity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
|
||||||
dataManagementPlanEntity.getGrant().getFunder().setType(Funder.FunderType.EXTERNAL.getValue());
|
// dataManagementPlanEntity.getGrant().getFunder().setType(Funder.FunderType.EXTERNAL.getValue());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (this.project != null) {
|
// if (this.project != null) {
|
||||||
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
// if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
||||||
dataManagementPlanEntity.setProject(this.project.getExistProject().toDataModel());
|
// dataManagementPlanEntity.setProject(this.project.getExistProject().toDataModel());
|
||||||
else if (this.project.getLabel() != null) {
|
// else if (this.project.getLabel() != null) {
|
||||||
Project project = new Project();
|
// Project project = new Project();
|
||||||
project.setId(UUID.randomUUID());
|
// project.setId(UUID.randomUUID());
|
||||||
project.setAbbreviation("");
|
// project.setAbbreviation("");
|
||||||
project.setLabel(this.project.getLabel());
|
// project.setLabel(this.project.getLabel());
|
||||||
project.setType(Project.ProjectType.INTERNAL.getValue());
|
// project.setType(Project.ProjectType.INTERNAL.getValue());
|
||||||
project.setReference("dmp:" + (this.project.getReference() != null ? this.project.getReference() : project.getId()));
|
// project.setReference("dmp:" + (this.project.getReference() != null ? this.project.getReference() : project.getId()));
|
||||||
project.setUri("");
|
// project.setUri("");
|
||||||
project.setDefinition("");
|
// project.setDefinition("");
|
||||||
project.setCreated(new Date());
|
// project.setCreated(new Date());
|
||||||
project.setStatus(Project.Status.ACTIVE.getValue());
|
// project.setStatus(Project.Status.ACTIVE.getValue());
|
||||||
project.setModified(new Date());
|
// project.setModified(new Date());
|
||||||
project.setDescription(this.project.getDescription());
|
// project.setDescription(this.project.getDescription());
|
||||||
|
//
|
||||||
dataManagementPlanEntity.setProject(project);
|
// dataManagementPlanEntity.setProject(project);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
dataManagementPlanEntity.setStatus((short) this.status);
|
// dataManagementPlanEntity.setStatus((short) this.status);
|
||||||
if (this.status == (int) DMP.DMPStatus.FINALISED.getValue()) {
|
// if (this.status == (int) DMP.DMPStatus.FINALISED.getValue()) {
|
||||||
dataManagementPlanEntity.setFinalizedAt(new Date());
|
// dataManagementPlanEntity.setFinalizedAt(new Date());
|
||||||
}
|
// }
|
||||||
dataManagementPlanEntity.setDescription(this.description);
|
// dataManagementPlanEntity.setDescription(this.description);
|
||||||
if (this.profiles != null) {
|
// if (this.profiles != null) {
|
||||||
Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
|
// Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
|
||||||
for (AssociatedProfile profile : this.profiles) {
|
// for (AssociatedProfile profile : this.profiles) {
|
||||||
DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
|
// DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
|
||||||
dmpDatasetProfile.setId(profile.getId());
|
// dmpDatasetProfile.setId(profile.getId());
|
||||||
dmpDatasetProfile.setDmp(dataManagementPlanEntity);
|
// dmpDatasetProfile.setDmp(dataManagementPlanEntity);
|
||||||
dmpDatasetProfile.setDatasetprofile(profile.toData());
|
// dmpDatasetProfile.setDatasetprofile(profile.toData());
|
||||||
dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
|
// dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
|
||||||
dmpDatasetProfiles.add(dmpDatasetProfile);
|
// dmpDatasetProfiles.add(dmpDatasetProfile);
|
||||||
}
|
// }
|
||||||
dataManagementPlanEntity.setAssociatedDmps(dmpDatasetProfiles);
|
// dataManagementPlanEntity.setAssociatedDmps(dmpDatasetProfiles);
|
||||||
}
|
// }
|
||||||
if(this.extraFields != null) {
|
// if(this.extraFields != null) {
|
||||||
this.properties = new HashMap<>();
|
// this.properties = new HashMap<>();
|
||||||
this.extraFields.forEach((extraField) -> this.properties.put(extraField.getId(), extraField.getValue()));
|
// this.extraFields.forEach((extraField) -> this.properties.put(extraField.getId(), extraField.getValue()));
|
||||||
}
|
// }
|
||||||
dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null);
|
// dataManagementPlanEntity.setProperties(this.properties != null ? JSONObject.toJSONString(this.properties) : null);
|
||||||
dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
|
// dataManagementPlanEntity.setGroupId(this.groupId != null ? this.groupId : UUID.randomUUID());
|
||||||
dataManagementPlanEntity.setModified(this.modified != null ? this.modified : new Date());
|
// dataManagementPlanEntity.setModified(this.modified != null ? this.modified : new Date());
|
||||||
dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
|
// dataManagementPlanEntity.setCreated(this.created != null ? this.created : new Date());
|
||||||
if (this.dynamicFields != null)
|
// if (this.dynamicFields != null)
|
||||||
dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
|
// dataManagementPlanEntity.setDmpProperties(JSONObject.toJSONString(this.dynamicFields.stream().filter(item -> item.getValue() != null).collect(Collectors.toMap(DynamicFieldWithValue::getId, DynamicFieldWithValue::getValue))));
|
||||||
|
//
|
||||||
dataManagementPlanEntity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
|
// dataManagementPlanEntity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
|
||||||
|
|
||||||
return dataManagementPlanEntity;
|
return dataManagementPlanEntity;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package eu.eudat.models.data.dmp;
|
package eu.eudat.models.data.dmp;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.DmpStatus;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.dataset.Dataset;
|
import eu.eudat.models.data.dataset.Dataset;
|
||||||
|
@ -14,13 +17,14 @@ import net.minidev.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 2/5/2018.
|
* Created by ikalyvas on 2/5/2018.
|
||||||
*/
|
*/
|
||||||
public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataManagementPlanNewVersionModel> {
|
public class DataManagementPlanNewVersionModel implements DataModel<DmpEntity, DataManagementPlanNewVersionModel> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanNewVersionModel.class);
|
private static final Logger logger = LoggerFactory.getLogger(DataManagementPlanNewVersionModel.class);
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
@ -162,112 +166,112 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlanNewVersionModel fromDataModel(DMP entity) {
|
public DataManagementPlanNewVersionModel fromDataModel(DmpEntity entity) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() throws Exception {
|
public DmpEntity toDataModel() throws Exception {
|
||||||
DMP entity = new DMP();
|
DmpEntity entity = new DmpEntity();
|
||||||
entity.setId(this.id);
|
entity.setId(this.id);
|
||||||
// entity.setUsers(new HashSet<>(new ArrayList<>(this.associatedUsers)));
|
// entity.setUsers(new HashSet<>(new ArrayList<>(this.associatedUsers)));
|
||||||
entity.setDescription(this.description);
|
entity.setDescription(this.description);
|
||||||
entity.setStatus((short) this.status);
|
entity.setStatus(DmpStatus.of((short)this.status));
|
||||||
entity.setGroupId(this.groupId == null ? UUID.randomUUID() : this.groupId);
|
entity.setGroupId(this.groupId == null ? UUID.randomUUID() : this.groupId);
|
||||||
entity.setCreated(new Date());
|
entity.setCreatedAt(Instant.now());
|
||||||
|
entity.setUpdatedAt(Instant.now());
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setModified(new Date());
|
List<DescriptionEntity> descriptionEntities = new LinkedList<>();//TODO
|
||||||
List<DescriptionEntity> descriptionEntities = new LinkedList<>();
|
// if (this.datasets != null) {
|
||||||
if (this.datasets != null) {
|
// for (Dataset dataset : this.datasets) {
|
||||||
for (Dataset dataset : this.datasets) {
|
// DescriptionEntity entityDescriptionEntity = new DescriptionEntity();
|
||||||
DescriptionEntity entityDescriptionEntity = new DescriptionEntity();
|
// entityDescriptionEntity.setId(dataset.getId());
|
||||||
entityDescriptionEntity.setId(dataset.getId());
|
// descriptionEntities.add(entityDescriptionEntity);
|
||||||
descriptionEntities.add(entityDescriptionEntity);
|
// }
|
||||||
}
|
// entity.setDataset(new HashSet<>(descriptionEntities));
|
||||||
entity.setDataset(new HashSet<>(descriptionEntities));
|
// }
|
||||||
}
|
// if (this.organisations != null && !this.organisations.isEmpty())
|
||||||
if (this.organisations != null && !this.organisations.isEmpty())
|
// entity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||||
entity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
// if (this.researchers != null && !this.researchers.isEmpty())
|
||||||
if (this.researchers != null && !this.researchers.isEmpty())
|
// entity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||||
entity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
// /*if (this.grant != null) {
|
||||||
/*if (this.grant != null) {
|
// entity.setGrant(this.grant.toDataModel());
|
||||||
entity.setGrant(this.grant.toDataModel());
|
// }*/
|
||||||
}*/
|
//
|
||||||
|
// if (this.grant != null) {
|
||||||
|
// if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
|
||||||
|
// entity.setGrant(this.grant.getExistGrant().toDataModel());
|
||||||
|
// else if (this.grant.getLabel() != null) {
|
||||||
|
// Grant grant = new Grant();
|
||||||
|
// grant.setId(UUID.randomUUID());
|
||||||
|
// grant.setAbbreviation("");
|
||||||
|
// grant.setLabel(this.grant.getLabel());
|
||||||
|
// grant.setType(Grant.GrantType.INTERNAL.getValue());
|
||||||
|
// grant.setReference("dmp:" + (this.grant.getReference() != null ? this.grant.getReference() : grant.getId()));
|
||||||
|
// grant.setUri("");
|
||||||
|
// grant.setDefinition("");
|
||||||
|
// grant.setCreated(new Date());
|
||||||
|
// grant.setStatus(Grant.Status.ACTIVE.getValue());
|
||||||
|
// grant.setModified(new Date());
|
||||||
|
// grant.setDescription(this.grant.getDescription());
|
||||||
|
//
|
||||||
|
// entity.setGrant(grant);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (this.funder != null) {
|
||||||
|
// if (this.funder.getLabel() != null) {
|
||||||
|
// Funder funder = new Funder();
|
||||||
|
// funder.setId(UUID.randomUUID());
|
||||||
|
// funder.setLabel(this.funder.getLabel());
|
||||||
|
// funder.setType(Funder.FunderType.INTERNAL.getValue());
|
||||||
|
// funder.setReference("dmp:" + (this.funder.getReference() != null ? this.funder.getReference() : funder.getId()));
|
||||||
|
// funder.setDefinition("");
|
||||||
|
// funder.setCreated(new Date());
|
||||||
|
// funder.setStatus(Funder.Status.ACTIVE.getValue());
|
||||||
|
// funder.setModified(new Date());
|
||||||
|
//
|
||||||
|
// entity.getGrant().setFunder(funder);
|
||||||
|
// } else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null) {
|
||||||
|
// entity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
|
||||||
|
// entity.getGrant().getFunder().setType(Funder.FunderType.EXTERNAL.getValue());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
if (this.grant != null) {
|
// if (this.project != null) {
|
||||||
if (this.grant.getExistGrant() != null && this.grant.getLabel() == null && this.grant.getDescription() == null)
|
// if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
||||||
entity.setGrant(this.grant.getExistGrant().toDataModel());
|
// entity.setProject(this.project.getExistProject().toDataModel());
|
||||||
else if (this.grant.getLabel() != null) {
|
// else if (this.project.getLabel() != null) {
|
||||||
Grant grant = new Grant();
|
// Project project = new Project();
|
||||||
grant.setId(UUID.randomUUID());
|
// project.setId(UUID.randomUUID());
|
||||||
grant.setAbbreviation("");
|
// project.setAbbreviation("");
|
||||||
grant.setLabel(this.grant.getLabel());
|
// project.setLabel(this.project.getLabel());
|
||||||
grant.setType(Grant.GrantType.INTERNAL.getValue());
|
// project.setType(Project.ProjectType.INTERNAL.getValue());
|
||||||
grant.setReference("dmp:" + (this.grant.getReference() != null ? this.grant.getReference() : grant.getId()));
|
// project.setReference("dmp:" + (this.project.getReference() != null ? this.project.getReference() : project.getId()));
|
||||||
grant.setUri("");
|
// project.setUri("");
|
||||||
grant.setDefinition("");
|
// project.setDefinition("");
|
||||||
grant.setCreated(new Date());
|
// project.setCreated(new Date());
|
||||||
grant.setStatus(Grant.Status.ACTIVE.getValue());
|
// project.setStatus(Project.Status.ACTIVE.getValue());
|
||||||
grant.setModified(new Date());
|
// project.setModified(new Date());
|
||||||
grant.setDescription(this.grant.getDescription());
|
// project.setDescription(this.project.getDescription());
|
||||||
|
//
|
||||||
entity.setGrant(grant);
|
// entity.setProject(project);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (this.funder != null) {
|
// entity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
|
||||||
if (this.funder.getLabel() != null) {
|
// if (this.profiles != null) {
|
||||||
Funder funder = new Funder();
|
// Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
|
||||||
funder.setId(UUID.randomUUID());
|
// for (AssociatedProfile profile : this.profiles) {
|
||||||
funder.setLabel(this.funder.getLabel());
|
// DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
|
||||||
funder.setType(Funder.FunderType.INTERNAL.getValue());
|
// dmpDatasetProfile.setId(null);
|
||||||
funder.setReference("dmp:" + (this.funder.getReference() != null ? this.funder.getReference() : funder.getId()));
|
// dmpDatasetProfile.setDmp(entity);
|
||||||
funder.setDefinition("");
|
// dmpDatasetProfile.setDatasetprofile(profile.toData());
|
||||||
funder.setCreated(new Date());
|
// dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
|
||||||
funder.setStatus(Funder.Status.ACTIVE.getValue());
|
// dmpDatasetProfiles.add(dmpDatasetProfile);
|
||||||
funder.setModified(new Date());
|
// }
|
||||||
|
// entity.setAssociatedDmps(dmpDatasetProfiles);
|
||||||
entity.getGrant().setFunder(funder);
|
// }
|
||||||
} else if (this.funder.getExistFunder() != null && this.funder.getLabel() == null) {
|
|
||||||
entity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
|
|
||||||
entity.getGrant().getFunder().setType(Funder.FunderType.EXTERNAL.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.project != null) {
|
|
||||||
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
|
||||||
entity.setProject(this.project.getExistProject().toDataModel());
|
|
||||||
else if (this.project.getLabel() != null) {
|
|
||||||
Project project = new Project();
|
|
||||||
project.setId(UUID.randomUUID());
|
|
||||||
project.setAbbreviation("");
|
|
||||||
project.setLabel(this.project.getLabel());
|
|
||||||
project.setType(Project.ProjectType.INTERNAL.getValue());
|
|
||||||
project.setReference("dmp:" + (this.project.getReference() != null ? this.project.getReference() : project.getId()));
|
|
||||||
project.setUri("");
|
|
||||||
project.setDefinition("");
|
|
||||||
project.setCreated(new Date());
|
|
||||||
project.setStatus(Project.Status.ACTIVE.getValue());
|
|
||||||
project.setModified(new Date());
|
|
||||||
project.setDescription(this.project.getDescription());
|
|
||||||
|
|
||||||
entity.setProject(project);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.setExtraProperties(this.extraProperties != null ? JSONObject.toJSONString(this.extraProperties) : null);
|
|
||||||
if (this.profiles != null) {
|
|
||||||
Set<DMPDatasetProfile> dmpDatasetProfiles = new HashSet<>();
|
|
||||||
for (AssociatedProfile profile : this.profiles) {
|
|
||||||
DMPDatasetProfile dmpDatasetProfile = new DMPDatasetProfile();
|
|
||||||
dmpDatasetProfile.setId(null);
|
|
||||||
dmpDatasetProfile.setDmp(entity);
|
|
||||||
dmpDatasetProfile.setDatasetprofile(profile.toData());
|
|
||||||
dmpDatasetProfile.setData(new ObjectMapper().writeValueAsString(profile.getData()));
|
|
||||||
dmpDatasetProfiles.add(dmpDatasetProfile);
|
|
||||||
}
|
|
||||||
entity.setAssociatedDmps(dmpDatasetProfiles);
|
|
||||||
}
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ public class GrantListingModel implements DataModel<eu.eudat.data.old.Grant, Gra
|
||||||
this.modified = entity.getModified();
|
this.modified = entity.getModified();
|
||||||
this.description = entity.getDescription();
|
this.description = entity.getDescription();
|
||||||
this.files = entity.getContent() != null ? Arrays.asList(new ContentFile(entity.getContent().getLabel(), UUID.fromString(entity.getContent().getUri().split(":")[1]), "final", entity.getContent().getExtension())) : Arrays.asList(new ContentFile("default.png", null, null, null));
|
this.files = entity.getContent() != null ? Arrays.asList(new ContentFile(entity.getContent().getLabel(), UUID.fromString(entity.getContent().getUri().split(":")[1]), "final", entity.getContent().getExtension())) : Arrays.asList(new ContentFile("default.png", null, null, null));
|
||||||
this.dmps = entity.getDmps().stream().map(item -> new DataManagementPlanUrlListing().fromDataModel(item)).collect(Collectors.toList());
|
//this.dmps = entity.getDmps().stream().map(item -> new DataManagementPlanUrlListing().fromDataModel(item)).collect(Collectors.toList()); //TODO
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.models.data.listingmodels;
|
package eu.eudat.models.data.listingmodels;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.urls.DatasetUrlListing;
|
import eu.eudat.models.data.urls.DatasetUrlListing;
|
||||||
|
@ -12,7 +12,7 @@ import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
public class DataManagementPlanListingModel implements DataModel<DMP, DataManagementPlanListingModel> {
|
public class DataManagementPlanListingModel implements DataModel<DmpEntity, DataManagementPlanListingModel> {
|
||||||
private String id;
|
private String id;
|
||||||
private String label;
|
private String label;
|
||||||
private String grant;
|
private String grant;
|
||||||
|
@ -120,66 +120,66 @@ public class DataManagementPlanListingModel implements DataModel<DMP, DataManage
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlanListingModel fromDataModel(DMP entity) {
|
public DataManagementPlanListingModel fromDataModel(DmpEntity entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlanListingModel fromDataModelAssociatedProfiles(DMP entity) {
|
public DataManagementPlanListingModel fromDataModelAssociatedProfiles(DmpEntity entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
this.creationTime = entity.getCreated();
|
this.creationTime = Date.from(entity.getCreatedAt());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlanListingModel fromDataModelAutoComplete(DMP entity) {
|
public DataManagementPlanListingModel fromDataModelAutoComplete(DmpEntity entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
this.creationTime = entity.getCreated();
|
this.creationTime = Date.from(entity.getCreatedAt());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlanListingModel fromDataModelDatasets(DMP entity) {
|
public DataManagementPlanListingModel fromDataModelDatasets(DmpEntity entity) {
|
||||||
this.fromDataModel(entity);
|
this.fromDataModel(entity);
|
||||||
this.status = entity.getStatus();
|
this.status = entity.getStatus().getValue();
|
||||||
this.version = entity.getVersion();
|
this.version = entity.getVersion();
|
||||||
this.grant = (entity.getGrant() != null) ? entity.getGrant().getLabel() : null;
|
this.creationTime = Date.from(entity.getCreatedAt());
|
||||||
this.creationTime = entity.getCreated();
|
this.modifiedTime = Date.from(entity.getUpdatedAt());
|
||||||
this.modifiedTime = entity.getModified();
|
this.finalizedAt = Date.from(entity.getFinalizedAt());
|
||||||
this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
|
// this.grant = (entity.getGrant() != null) ? entity.getGrant().getLabel() : null; //TODO
|
||||||
this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
// this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
|
||||||
this.finalizedAt = entity.getFinalizedAt();
|
// this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
||||||
this.isPublic = entity.isPublic();
|
// this.isPublic = entity.isPublic();
|
||||||
this.publishedAt = entity.getPublishedAt();
|
// this.publishedAt = entity.getPublishedAt();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() {
|
public DmpEntity toDataModel() {
|
||||||
DMP entity = new DMP();
|
DmpEntity entity = new DmpEntity();
|
||||||
entity.setId(UUID.fromString(this.getId()));
|
entity.setId(UUID.fromString(this.getId()));
|
||||||
entity.setLabel(this.getLabel());
|
entity.setLabel(this.getLabel());
|
||||||
entity.setGroupId(this.getGroupId());
|
entity.setGroupId(this.getGroupId());
|
||||||
entity.setStatus(Integer.valueOf(this.getStatus()).shortValue());
|
// entity.setStatus(Integer.valueOf(this.getStatus()).shortValue()); //TODO
|
||||||
entity.setCreated(this.getCreationTime());
|
// entity.setCreated(this.getCreationTime());
|
||||||
entity.setFinalizedAt(this.getFinalizedAt());
|
// entity.setFinalizedAt(this.getFinalizedAt());
|
||||||
entity.setModified(this.getModifiedTime());
|
// entity.setModified(this.getModifiedTime());
|
||||||
entity.setPublic(this.getPublic());
|
// entity.setPublic(this.getPublic());
|
||||||
entity.setPublishedAt(this.getPublishedAt());
|
// entity.setPublishedAt(this.getPublishedAt());
|
||||||
entity.setVersion(this.getVersion());
|
// entity.setVersion(this.getVersion());
|
||||||
|
//
|
||||||
entity.setDataset(this.getDatasets().stream().map(DatasetUrlListing::toDataModel).collect(Collectors.toCollection(LinkedHashSet::new)));
|
// entity.setDataset(this.getDatasets().stream().map(DatasetUrlListing::toDataModel).collect(Collectors.toCollection(LinkedHashSet::new)));
|
||||||
if (this.getGrant() != null && !this.getGrant().isEmpty()) {
|
// if (this.getGrant() != null && !this.getGrant().isEmpty()) {
|
||||||
Grant grant = new Grant();
|
// Grant grant = new Grant();
|
||||||
grant.setLabel(this.getGrant());
|
// grant.setLabel(this.getGrant());
|
||||||
entity.setGrant(grant);
|
// entity.setGrant(grant);
|
||||||
}
|
// }
|
||||||
entity.setUsers(this.getUsers().stream().map(UserInfoListingModel::toDataModel).collect(Collectors.toSet()));
|
// entity.setUsers(this.getUsers().stream().map(UserInfoListingModel::toDataModel).collect(Collectors.toSet()));
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.DMPDatasetProfile;
|
|
||||||
import eu.eudat.model.doi.Doi;
|
import eu.eudat.model.doi.Doi;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
||||||
|
@ -14,10 +13,11 @@ import eu.eudat.models.data.dmp.Organisation;
|
||||||
import eu.eudat.models.data.dmp.Researcher;
|
import eu.eudat.models.data.dmp.Researcher;
|
||||||
import eu.eudat.models.data.grant.GrantOverviewModel;
|
import eu.eudat.models.data.grant.GrantOverviewModel;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManagementPlanOverviewModel> {
|
public class DataManagementPlanOverviewModel implements DataModel<DmpEntity, DataManagementPlanOverviewModel> {
|
||||||
private String id;
|
private String id;
|
||||||
private String label;
|
private String label;
|
||||||
private String profile;
|
private String profile;
|
||||||
|
@ -173,62 +173,62 @@ public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManag
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlanOverviewModel fromDataModel(DMP entity) {
|
public DataManagementPlanOverviewModel fromDataModel(DmpEntity entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
this.status = entity.getStatus();
|
this.status = entity.getStatus().getValue();
|
||||||
if (entity.getResearchers() != null) {
|
// if (entity.getResearchers() != null) { //TODO
|
||||||
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
// this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
if(entity.getDois() != null){
|
// if(entity.getDois() != null){
|
||||||
this.dois = entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList());
|
// this.dois = entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlanOverviewModel fromDataModelDatasets(DMP entity) {
|
public DataManagementPlanOverviewModel fromDataModelDatasets(DmpEntity entity) {
|
||||||
this.fromDataModel(entity);
|
this.fromDataModel(entity);
|
||||||
this.version = entity.getVersion();
|
this.version = entity.getVersion();
|
||||||
if (entity.getGrant() != null) this.grant = new GrantOverviewModel().fromDataModel(entity.getGrant());
|
// if (entity.getGrant() != null) this.grant = new GrantOverviewModel().fromDataModel(entity.getGrant());
|
||||||
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
// if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
||||||
this.creationTime = entity.getCreated();
|
this.creationTime = Date.from(entity.getCreatedAt());
|
||||||
this.modifiedTime = entity.getModified();
|
this.modifiedTime = Date.from(entity.getUpdatedAt());
|
||||||
this.finalizedAt = entity.getFinalizedAt();
|
this.finalizedAt = Date.from(entity.getFinalizedAt());
|
||||||
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
// this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled)).map(x-> new DatasetOverviewModel().fromDataModel(x)).collect(Collectors.toList());
|
// this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled)).map(x-> new DatasetOverviewModel().fromDataModel(x)).collect(Collectors.toList());
|
||||||
this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
// this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
||||||
this.description = entity.getDescription();
|
// this.description = entity.getDescription();
|
||||||
if (entity.getResearchers() != null) {
|
// if (entity.getResearchers() != null) {
|
||||||
this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
// this.researchers = entity.getResearchers().stream().map(item -> new Researcher().fromDataModel(item)).collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
this.associatedProfiles = new LinkedList<>();
|
// this.associatedProfiles = new LinkedList<>();
|
||||||
for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
|
// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
|
||||||
AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
|
// AssociatedProfile associatedProfile = new AssociatedProfile().fromData(dmpDescriptionProfile.getDatasetprofile());
|
||||||
try {
|
// try {
|
||||||
associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
|
// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
|
||||||
}
|
// }
|
||||||
catch (Exception e) {
|
// catch (Exception e) {
|
||||||
associatedProfile.setData(null);
|
// associatedProfile.setData(null);
|
||||||
}
|
// }
|
||||||
this.associatedProfiles.add(associatedProfile);
|
// this.associatedProfiles.add(associatedProfile);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
this.isPublic = entity.isPublic();
|
// this.isPublic = entity.isPublic();
|
||||||
this.publishedAt = entity.getPublishedAt();
|
// this.publishedAt = entity.getPublishedAt();
|
||||||
if (entity.getDois() != null) {
|
// if (entity.getDois() != null) {
|
||||||
this.dois = entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList());
|
// this.dois = entity.getDois().stream().map(item -> new Doi().fromDataModel(item)).collect(Collectors.toList());
|
||||||
} else {
|
// } else {
|
||||||
this.dois = new ArrayList<>();
|
// this.dois = new ArrayList<>();
|
||||||
}
|
// }
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() {
|
public DmpEntity toDataModel() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,12 @@
|
||||||
package eu.eudat.models.data.listingmodels;
|
package eu.eudat.models.data.listingmodels;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
public class DatasetListingModel implements DataModel<DescriptionEntity, DatasetListingModel> {
|
public class DatasetListingModel implements DataModel<DescriptionEntity, DatasetListingModel> {
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package eu.eudat.models.data.listingmodels;
|
package eu.eudat.models.data.listingmodels;
|
||||||
|
|
||||||
import eu.eudat.data.old.UserDMP;
|
import eu.eudat.commons.enums.DmpUserRole;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
import eu.eudat.model.DmpUser;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UserInfoListingModel implements DataModel<UserDMP, UserInfoListingModel> {
|
public class UserInfoListingModel implements DataModel<DmpUserEntity, UserInfoListingModel> {
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -42,23 +44,23 @@ public class UserInfoListingModel implements DataModel<UserDMP, UserInfoListingM
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserInfoListingModel fromDataModel(UserDMP entity) {
|
public UserInfoListingModel fromDataModel(DmpUserEntity entity) {
|
||||||
this.id = entity.getUser().getId();
|
// this.id = entity.getUser().getId(); //TODO
|
||||||
this.name = entity.getUser().getName();
|
// this.name = entity.getUser().getName();
|
||||||
this.role = entity.getRole();
|
// this.role = entity.getRole();
|
||||||
this.email = entity.getUser().getEmail();
|
// this.email = entity.getUser().getEmail();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDMP toDataModel() {
|
public DmpUserEntity toDataModel() {
|
||||||
UserDMP entity = new UserDMP();
|
DmpUserEntity entity = new DmpUserEntity();
|
||||||
entity.setId(this.getId());
|
entity.setId(this.getId());
|
||||||
entity.setRole(this.getRole());
|
entity.setRole(DmpUserRole.of((short) this.getRole()));
|
||||||
UserInfo userInfo = new UserInfo();
|
UserInfo userInfo = new UserInfo();
|
||||||
userInfo.setName(this.getName());
|
userInfo.setName(this.getName());
|
||||||
userInfo.setEmail(this.getEmail());
|
userInfo.setEmail(this.getEmail());
|
||||||
entity.setUser(userInfo);
|
// entity.setUser(userInfo);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package eu.eudat.models.data.listingmodels;
|
package eu.eudat.models.data.listingmodels;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
|
||||||
public class VersionListingModel implements DataModel<DMP, VersionListingModel> {
|
public class VersionListingModel implements DataModel<DmpEntity, VersionListingModel> {
|
||||||
private String id;
|
private String id;
|
||||||
private String groupId;
|
private String groupId;
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
@ -34,15 +34,15 @@ public class VersionListingModel implements DataModel<DMP, VersionListingModel>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VersionListingModel fromDataModel(DMP entity) {
|
public VersionListingModel fromDataModel(DmpEntity entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.groupId = entity.getGroupId().toString();
|
this.groupId = entity.getGroupId().toString();
|
||||||
this.version = entity.getVersion();
|
this.version = entity.getVersion().intValue();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() throws Exception {
|
public DmpEntity toDataModel() throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,9 @@ package eu.eudat.models.data.rda;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.UserDMP;
|
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
@ -128,46 +127,47 @@ public class DmpRDAExportModel {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DmpRDAExportModel fromDataModel(DMP entity, DatasetManager datasetManager) {
|
public DmpRDAExportModel fromDataModel(DmpEntity entity, DatasetManager datasetManager) {
|
||||||
DmpRDAExportModel dmpRda = new DmpRDAExportModel();
|
DmpRDAExportModel dmpRda = new DmpRDAExportModel();
|
||||||
dmpRda.contact = new ContactRDAExportModel().fromDataModel(entity.getUsers().stream().filter(x -> x.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
//TODO
|
||||||
if (entity.getUsers().stream().anyMatch(x -> x.getRole().equals(UserDMP.UserDMPRoles.USER.getValue()))) {
|
// dmpRda.contact = new ContactRDAExportModel().fromDataModel(entity.getUsers().stream().filter(x -> x.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).findFirst().get().getUser());
|
||||||
dmpRda.contributor = new LinkedList<>();
|
// if (entity.getUsers().stream().anyMatch(x -> x.getRole().equals(UserDMP.UserDMPRoles.USER.getValue()))) {
|
||||||
for (UserDMP userdmp : entity.getUsers().stream().filter(x -> x.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())).collect(Collectors.toList())) {
|
// dmpRda.contributor = new LinkedList<>();
|
||||||
dmpRda.contributor.add(new DmpContributorRDAExportModel().fromDataModel(userdmp.getUser(), UserDMP.UserDMPRoles.fromInteger(userdmp.getRole()).toString()));
|
// for (UserDMP userdmp : entity.getUsers().stream().filter(x -> x.getRole().equals(UserDMP.UserDMPRoles.USER.getValue())).collect(Collectors.toList())) {
|
||||||
}
|
// dmpRda.contributor.add(new DmpContributorRDAExportModel().fromDataModel(userdmp.getUser(), UserDMP.UserDMPRoles.fromInteger(userdmp.getRole()).toString()));
|
||||||
}
|
// }
|
||||||
dmpRda.cost = null;
|
// }
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
|
// dmpRda.cost = null;
|
||||||
dmpRda.created = formatter.format(entity.getCreated());
|
// SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
|
||||||
dmpRda.dataset = new LinkedList<>();
|
// dmpRda.created = formatter.format(entity.getCreated());
|
||||||
for (DescriptionEntity descriptionEntity : entity.getDataset()) {
|
// dmpRda.dataset = new LinkedList<>();
|
||||||
if (descriptionEntity.getIsActive() != IsActive.Inactive && descriptionEntity.getStatus() != DescriptionStatus.Canceled)
|
// for (DescriptionEntity descriptionEntity : entity.getDataset()) {
|
||||||
dmpRda.dataset.add(new DatasetRDAExportModel().fromDataModel(descriptionEntity, datasetManager));
|
// if (descriptionEntity.getIsActive() != IsActive.Inactive && descriptionEntity.getStatus() != DescriptionStatus.Canceled)
|
||||||
}
|
// dmpRda.dataset.add(new DatasetRDAExportModel().fromDataModel(descriptionEntity, datasetManager));
|
||||||
dmpRda.description = entity.getDescription().replace("\n", " ");
|
// }
|
||||||
if (entity.getDois() != null && !entity.getDois().isEmpty()) {
|
// dmpRda.description = entity.getDescription().replace("\n", " ");
|
||||||
boolean zenodoDoi = false;
|
// if (entity.getDois() != null && !entity.getDois().isEmpty()) {
|
||||||
for(EntityDoiEntity doi: entity.getDois()){
|
// boolean zenodoDoi = false;
|
||||||
if(doi.getRepositoryId().equals("Zenodo")){
|
// for(EntityDoiEntity doi: entity.getDois()){
|
||||||
dmpRda.dmp_id = new IdRDAExportModel(doi.getDoi(), "zenodo");
|
// if(doi.getRepositoryId().equals("Zenodo")){
|
||||||
zenodoDoi = true;
|
// dmpRda.dmp_id = new IdRDAExportModel(doi.getDoi(), "zenodo");
|
||||||
}
|
// zenodoDoi = true;
|
||||||
}
|
// }
|
||||||
if(!zenodoDoi){
|
// }
|
||||||
dmpRda.dmp_id = new IdRDAExportModel(entity.getId().toString(), "other");
|
// if(!zenodoDoi){
|
||||||
}
|
// dmpRda.dmp_id = new IdRDAExportModel(entity.getId().toString(), "other");
|
||||||
}
|
// }
|
||||||
else {
|
// }
|
||||||
dmpRda.dmp_id = new IdRDAExportModel(entity.getId().toString(), "other");
|
// else {
|
||||||
}
|
// dmpRda.dmp_id = new IdRDAExportModel(entity.getId().toString(), "other");
|
||||||
// Mock up data on "language" and "ethical_issues_*" for now.
|
// }
|
||||||
dmpRda.ethical_issues_exist = "unknown";
|
// // Mock up data on "language" and "ethical_issues_*" for now.
|
||||||
dmpRda.language = "en";
|
// dmpRda.ethical_issues_exist = "unknown";
|
||||||
dmpRda.modified = formatter.format(new Date());
|
// dmpRda.language = "en";
|
||||||
if (entity.getGrant() != null) {
|
// dmpRda.modified = formatter.format(new Date());
|
||||||
dmpRda.project = new ProjectRDAExportModel().fromDataModel(entity.getGrant());
|
// if (entity.getGrant() != null) {
|
||||||
}
|
// dmpRda.project = new ProjectRDAExportModel().fromDataModel(entity.getGrant());
|
||||||
|
// }
|
||||||
dmpRda.title = entity.getLabel();
|
dmpRda.title = entity.getLabel();
|
||||||
|
|
||||||
return dmpRda;
|
return dmpRda;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.models.data.rda;
|
package eu.eudat.models.data.rda;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
|
|
||||||
public class RDAExportModel {
|
public class RDAExportModel {
|
||||||
|
@ -13,7 +13,7 @@ public class RDAExportModel {
|
||||||
this.dmp = dmp;
|
this.dmp = dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RDAExportModel fromDataModel(DMP dmp, DatasetManager datasetManager) {
|
public RDAExportModel fromDataModel(DmpEntity dmp, DatasetManager datasetManager) {
|
||||||
this.dmp = new DmpRDAExportModel().fromDataModel(dmp, datasetManager);
|
this.dmp = new DmpRDAExportModel().fromDataModel(dmp, datasetManager);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
package eu.eudat.models.data.urls;
|
package eu.eudat.models.data.urls;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 3/19/2018.
|
* Created by ikalyvas on 3/19/2018.
|
||||||
*/
|
*/
|
||||||
public class DataManagementPlanUrlListing extends UrlListing<DMP, DataManagementPlanUrlListing> {
|
public class DataManagementPlanUrlListing extends UrlListing<DmpEntity, DataManagementPlanUrlListing> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlanUrlListing fromDataModel(DMP entity) {
|
public DataManagementPlanUrlListing fromDataModel(DmpEntity entity) {
|
||||||
this.setLabel(entity.getLabel());
|
this.setLabel(entity.getLabel());
|
||||||
this.setUrl(entity.getId().toString());
|
this.setUrl(entity.getId().toString());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() throws Exception {
|
public DmpEntity toDataModel() throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package eu.eudat.models.rda.mapper;
|
package eu.eudat.models.rda.mapper;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.old.Researcher;
|
import eu.eudat.data.old.Researcher;
|
||||||
import eu.eudat.data.old.UserDMP;
|
|
||||||
import eu.eudat.models.rda.Contributor;
|
import eu.eudat.models.rda.Contributor;
|
||||||
import eu.eudat.models.rda.ContributorId;
|
import eu.eudat.models.rda.ContributorId;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -14,15 +14,15 @@ import java.util.*;
|
||||||
public class ContributorRDAMapper {
|
public class ContributorRDAMapper {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ContributorRDAMapper.class);
|
private static final Logger logger = LoggerFactory.getLogger(ContributorRDAMapper.class);
|
||||||
|
|
||||||
public static Contributor toRDA(UserDMP userDMP) {
|
public static Contributor toRDA(DmpUserEntity userDMP) {
|
||||||
Contributor rda = new Contributor();
|
Contributor rda = new Contributor();
|
||||||
rda.setContributorId(ContributorIdRDAMapper.toRDA(userDMP.getUser().getId()));
|
rda.setContributorId(ContributorIdRDAMapper.toRDA(userDMP.getUser()));
|
||||||
if (userDMP.getUser().getName() == null) {
|
// if (userDMP.getUser().getName() == null) { //TODO
|
||||||
throw new IllegalArgumentException("Contributor Name is missing");
|
// throw new IllegalArgumentException("Contributor Name is missing");
|
||||||
}
|
// }
|
||||||
rda.setName(userDMP.getUser().getName());
|
// rda.setName(userDMP.getUser().getName());
|
||||||
rda.setMbox(userDMP.getUser().getEmail());
|
// rda.setMbox(userDMP.getUser().getEmail());
|
||||||
rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name())));
|
// rda.setRole(new HashSet<>(Arrays.asList(UserDMP.UserDMPRoles.fromInteger(userDMP.getRole()).name())));
|
||||||
return rda;
|
return rda;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,8 @@ package eu.eudat.models.rda.mapper;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
|
import eu.eudat.data.DmpDescriptionTemplateEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
@ -39,155 +41,155 @@ public class DmpRDAMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Dmp toRDA(DMP dmp) throws InvalidApplicationException {
|
public Dmp toRDA(DmpEntity dmp) throws InvalidApplicationException {
|
||||||
if (dmp.getDataset() == null || dmp.getDataset().isEmpty()) {
|
// if (dmp.getDataset() == null || dmp.getDataset().isEmpty()) { //TODO
|
||||||
throw new IllegalArgumentException("DMP has no Datasets");
|
// throw new IllegalArgumentException("DMP has no Datasets");
|
||||||
}
|
// }
|
||||||
Map<String, Object> extraProperties;
|
// Map<String, Object> extraProperties;
|
||||||
if (dmp.getExtraProperties() == null) {
|
// if (dmp.getExtraProperties() == null) {
|
||||||
throw new IllegalArgumentException("DMP is missing language and contact properties");
|
// throw new IllegalArgumentException("DMP is missing language and contact properties");
|
||||||
} else {
|
// } else {
|
||||||
extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap();
|
// extraProperties = new org.json.JSONObject(dmp.getExtraProperties()).toMap();
|
||||||
/*if (extraProperties.get("language") == null) {
|
// /*if (extraProperties.get("language") == null) {
|
||||||
throw new IllegalArgumentException("DMP must have it's language property defined");
|
// throw new IllegalArgumentException("DMP must have it's language property defined");
|
||||||
}*/
|
// }*/
|
||||||
if (extraProperties.get("contact") == null) {
|
// if (extraProperties.get("contact") == null) {
|
||||||
throw new IllegalArgumentException("DMP must have it's contact property defined");
|
// throw new IllegalArgumentException("DMP must have it's contact property defined");
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
Dmp rda = new Dmp();
|
Dmp rda = new Dmp();
|
||||||
if (dmp.getDois() != null && !dmp.getDois().isEmpty()) {
|
// if (dmp.getDois() != null && !dmp.getDois().isEmpty()) {
|
||||||
for(EntityDoiEntity doi: dmp.getDois()){
|
// for(EntityDoiEntity doi: dmp.getDois()){
|
||||||
if(doi.getRepositoryId().equals("Zenodo")){
|
// if(doi.getRepositoryId().equals("Zenodo")){
|
||||||
rda.setDmpId(DmpIdRDAMapper.toRDA(doi.getDoi()));
|
// rda.setDmpId(DmpIdRDAMapper.toRDA(doi.getDoi()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getId()));
|
// rda.setDmpId(DmpIdRDAMapper.toRDA(dmp.getId()));
|
||||||
}
|
// }
|
||||||
if (dmp.getCreated() == null) {
|
if (dmp.getCreatedAt() == null) {
|
||||||
throw new IllegalArgumentException("DMP Created is missing");
|
throw new IllegalArgumentException("DMP Created is missing");
|
||||||
}
|
}
|
||||||
if (dmp.getModified() == null) {
|
if (dmp.getUpdatedAt() == null) {
|
||||||
throw new IllegalArgumentException("DMP Modified is missing");
|
throw new IllegalArgumentException("DMP Modified is missing");
|
||||||
}
|
}
|
||||||
if (dmp.getLabel() == null) {
|
if (dmp.getLabel() == null) {
|
||||||
throw new IllegalArgumentException("DMP Label is missing");
|
throw new IllegalArgumentException("DMP Label is missing");
|
||||||
}
|
}
|
||||||
rda.setCreated(dmp.getCreated());
|
// rda.setCreated(dmp.getCreated()); //TODO
|
||||||
rda.setDescription(dmp.getDescription());
|
// rda.setDescription(dmp.getDescription());
|
||||||
rda.setModified(dmp.getModified());
|
// rda.setModified(dmp.getModified());
|
||||||
rda.setTitle(dmp.getLabel());
|
// rda.setTitle(dmp.getLabel());
|
||||||
|
//
|
||||||
if (!extraProperties.isEmpty()) {
|
// if (!extraProperties.isEmpty()) {
|
||||||
if (extraProperties.get("ethicalIssues") != null) {
|
// if (extraProperties.get("ethicalIssues") != null) {
|
||||||
rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.fromValue(extraProperties.get("ethicalIssues").toString()));
|
// rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.fromValue(extraProperties.get("ethicalIssues").toString()));
|
||||||
} else {
|
// } else {
|
||||||
rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.UNKNOWN);
|
// rda.setEthicalIssuesExist(Dmp.EthicalIssuesExist.UNKNOWN);
|
||||||
}
|
// }
|
||||||
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language") != null ? extraProperties.get("language").toString() : "en"));
|
// rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(extraProperties.get("language") != null ? extraProperties.get("language").toString() : "en"));
|
||||||
if (extraProperties.get("costs") != null) {
|
// if (extraProperties.get("costs") != null) {
|
||||||
rda.setCost(new ArrayList<>());
|
// rda.setCost(new ArrayList<>());
|
||||||
((List) extraProperties.get("costs")).forEach(costl -> {
|
// ((List) extraProperties.get("costs")).forEach(costl -> {
|
||||||
rda.getCost().add(CostRDAMapper.toRDA((Map)costl));
|
// rda.getCost().add(CostRDAMapper.toRDA((Map)costl));
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
try {
|
// try {
|
||||||
UserInfo contactDb = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString((String) extraProperties.get("contact")));
|
// UserInfo contactDb = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(UUID.fromString((String) extraProperties.get("contact")));
|
||||||
UserInfo contact = new UserInfo();
|
// UserInfo contact = new UserInfo();
|
||||||
contact.setId(contactDb.getId());
|
// contact.setId(contactDb.getId());
|
||||||
contact.setName(contactDb.getName());
|
// contact.setName(contactDb.getName());
|
||||||
contact.setEmail(contactDb.getEmail());
|
// contact.setEmail(contactDb.getEmail());
|
||||||
if (contact.getEmail() == null) {
|
// if (contact.getEmail() == null) {
|
||||||
for (UserDMP userDMP : dmp.getUsers()) {
|
// for (UserDMP userDMP : dmp.getUsers()) {
|
||||||
if (userDMP.getDmp().getId() == dmp.getId() && userDMP.getUser().getEmail() != null) {
|
// if (userDMP.getDmp().getId() == dmp.getId() && userDMP.getUser().getEmail() != null) {
|
||||||
contact.setEmail(userDMP.getUser().getEmail());
|
// contact.setEmail(userDMP.getUser().getEmail());
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
rda.setContact(ContactRDAMapper.toRDA(contact));
|
// rda.setContact(ContactRDAMapper.toRDA(contact));
|
||||||
} catch (NoResultException e) {
|
// } catch (NoResultException e) {
|
||||||
logger.error(e.getMessage(), e);
|
// logger.error(e.getMessage(), e);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
/*UserInfo creator;
|
// /*UserInfo creator;
|
||||||
if (dmp.getCreator() != null) {
|
// if (dmp.getCreator() != null) {
|
||||||
creator = dmp.getCreator();
|
// creator = dmp.getCreator();
|
||||||
} else {
|
// } else {
|
||||||
creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo());
|
// creator = dmp.getUsers().stream().filter(userDMP -> userDMP.getRole().equals(UserDMP.UserDMPRoles.OWNER.getValue())).map(UserDMP::getUser).findFirst().orElse(new UserInfo());
|
||||||
}
|
// }
|
||||||
rda.setContact(ContactRDAMapper.toRDA(creator));*/
|
// rda.setContact(ContactRDAMapper.toRDA(creator));*/
|
||||||
rda.setContributor(new ArrayList<>());
|
// rda.setContributor(new ArrayList<>());
|
||||||
if (dmp.getResearchers() != null && !dmp.getResearchers().isEmpty()) {
|
// if (dmp.getResearchers() != null && !dmp.getResearchers().isEmpty()) {
|
||||||
rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
// rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
||||||
}
|
// }
|
||||||
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
//// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
||||||
rda.setDataset(dmp.getDataset().stream().filter(dataset -> dataset.getIsActive() != IsActive.Inactive).map(dataset -> datasetRDAMapper.toRDA(dataset, rda)).collect(Collectors.toList()));
|
// rda.setDataset(dmp.getDataset().stream().filter(dataset -> dataset.getIsActive() != IsActive.Inactive).map(dataset -> datasetRDAMapper.toRDA(dataset, rda)).collect(Collectors.toList()));
|
||||||
if (dmp.getProject() != null) {
|
// if (dmp.getProject() != null) {
|
||||||
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
|
// rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
|
||||||
}
|
// }
|
||||||
rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray());
|
// rda.setAdditionalProperty("templates", dmp.getAssociatedDmps().stream().map(datasetProfile -> datasetProfile.getId().toString()).toArray());
|
||||||
return rda;
|
return rda;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DMP toEntity(Dmp rda, String[] profiles) throws InvalidApplicationException {
|
public DmpEntity toEntity(Dmp rda, String[] profiles) throws InvalidApplicationException {
|
||||||
DMP entity = new DMP();
|
DmpEntity entity = new DmpEntity();
|
||||||
entity.setLabel(rda.getTitle());
|
entity.setLabel(rda.getTitle());
|
||||||
if (rda.getDmpId().getType() == DmpId.Type.DOI) {
|
// if (rda.getDmpId().getType() == DmpId.Type.DOI) { //TODO
|
||||||
try {
|
// try {
|
||||||
//TODO: Find from doi = rda.getDmpId().getIdentifier()
|
// //TODO: Find from doi = rda.getDmpId().getIdentifier()
|
||||||
EntityDoiEntity doi = new EntityDoiEntity();
|
// EntityDoiEntity doi = new EntityDoiEntity();
|
||||||
Set<EntityDoiEntity> dois = new HashSet<>();
|
// Set<EntityDoiEntity> dois = new HashSet<>();
|
||||||
dois.add(doi);
|
// dois.add(doi);
|
||||||
entity.setDois(dois);
|
// entity.setDois(dois);
|
||||||
}
|
// }
|
||||||
catch (NoResultException e) {
|
// catch (NoResultException e) {
|
||||||
logger.warn("No entity doi: " + rda.getDmpId().getIdentifier() + " found in database. No dois are added to dmp.");
|
// logger.warn("No entity doi: " + rda.getDmpId().getIdentifier() + " found in database. No dois are added to dmp.");
|
||||||
entity.setDois(new HashSet<>());
|
// entity.setDois(new HashSet<>());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (((List<String>) rda.getAdditionalProperties().get("templates")) != null && !((List<String>) rda.getAdditionalProperties().get("templates")).isEmpty() && entity.getId() != null) {
|
// if (((List<String>) rda.getAdditionalProperties().get("templates")) != null && !((List<String>) rda.getAdditionalProperties().get("templates")).isEmpty() && entity.getId() != null) {
|
||||||
entity.setAssociatedDmps(((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(x -> {
|
// entity.setAssociatedDmps(((List<String>) rda.getAdditionalProperties().get("templates")).stream().map(x -> {
|
||||||
try {
|
// try {
|
||||||
return this.getProfile(x, entity.getId());
|
// return this.getProfile(x, entity.getId());
|
||||||
} catch (InvalidApplicationException e) {
|
// } catch (InvalidApplicationException e) {
|
||||||
throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
// }
|
||||||
}).filter(Objects::nonNull).collect(Collectors.toSet()));
|
// }).filter(Objects::nonNull).collect(Collectors.toSet()));
|
||||||
}
|
// }
|
||||||
if (entity.getAssociatedDmps() == null) {
|
// if (entity.getAssociatedDmps() == null) {
|
||||||
entity.setAssociatedDmps(new HashSet<>());
|
// entity.setAssociatedDmps(new HashSet<>());
|
||||||
}
|
// }
|
||||||
if (profiles != null && entity.getId() != null) {
|
// if (profiles != null && entity.getId() != null) {
|
||||||
for (String profile : profiles) {
|
// for (String profile : profiles) {
|
||||||
entity.getAssociatedDmps().add(this.getProfile(profile, entity.getId()));
|
// entity.getAssociatedDmps().add(this.getProfile(profile, entity.getId()));
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
if (rda.getContributor() != null && !rda.getContributor().isEmpty() && rda.getContributor().get(0).getContributorId() != null) {
|
// if (rda.getContributor() != null && !rda.getContributor().isEmpty() && rda.getContributor().get(0).getContributorId() != null) {
|
||||||
entity.setResearchers(rda.getContributor().stream().filter(r -> r.getContributorId() != null).map(ContributorRDAMapper::toEntity).filter(StreamDistinctBy.distinctByKey(Researcher::getReference)).collect(Collectors.toSet()));
|
// entity.setResearchers(rda.getContributor().stream().filter(r -> r.getContributorId() != null).map(ContributorRDAMapper::toEntity).filter(StreamDistinctBy.distinctByKey(Researcher::getReference)).collect(Collectors.toSet()));
|
||||||
}
|
// }
|
||||||
entity.setCreated(rda.getCreated());
|
// entity.setCreated(rda.getCreated());
|
||||||
entity.setModified(rda.getModified());
|
// entity.setModified(rda.getModified());
|
||||||
entity.setDescription(rda.getDescription());
|
// entity.setDescription(rda.getDescription());
|
||||||
DescriptionTemplateEntity defaultProfile = ((DescriptionTemplateEntity)entity.getAssociatedDmps().toArray()[0]);
|
// DescriptionTemplateEntity defaultProfile = ((DescriptionTemplateEntity)entity.getAssociatedDmps().toArray()[0]);
|
||||||
entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1, defaultProfile)).collect(Collectors.toSet()));
|
// entity.setDataset(rda.getDataset().stream().map(rda1 -> datasetRDAMapper.toEntity(rda1, defaultProfile)).collect(Collectors.toSet()));
|
||||||
if (rda.getProject().size() > 0) {
|
// if (rda.getProject().size() > 0) {
|
||||||
Map<String, Object> result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext);
|
// Map<String, Object> result = ProjectRDAMapper.toEntity(rda.getProject().get(0), apiContext);
|
||||||
entity.setProject((Project) result.get("project"));
|
// entity.setProject((Project) result.get("project"));
|
||||||
result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue()));
|
// result.entrySet().stream().filter(entry -> entry.getKey().startsWith("grant")).forEach(entry -> entity.setGrant((Grant) entry.getValue()));
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Map<String, Object> extraProperties = new HashMap<>();
|
// Map<String, Object> extraProperties = new HashMap<>();
|
||||||
extraProperties.put("language", LanguageRDAMapper.mapRDAIsoToLanguageIso(rda.getLanguage()));
|
// extraProperties.put("language", LanguageRDAMapper.mapRDAIsoToLanguageIso(rda.getLanguage()));
|
||||||
|
//
|
||||||
entity.setExtraProperties(JSONObject.toJSONString(extraProperties));
|
// entity.setExtraProperties(JSONObject.toJSONString(extraProperties));
|
||||||
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private DMPDatasetProfile getProfile(String descriptionTemplateId, UUID dmpId) throws InvalidApplicationException {
|
private DmpDescriptionTemplateEntity getProfile(String descriptionTemplateId, UUID dmpId) throws InvalidApplicationException {
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().asQueryable().where(((builder, root) -> builder.and(
|
return apiContext.getOperationsContext().getDatabaseRepository().getDmpDatasetProfileDao().asQueryable().where(((builder, root) -> builder.and(
|
||||||
builder.equal(root.get("datasetprofile"), UUID.fromString(descriptionTemplateId)),
|
builder.equal(root.get("datasetprofile"), UUID.fromString(descriptionTemplateId)),
|
||||||
builder.equal(root.get("dmp"), dmpId))
|
builder.equal(root.get("dmp"), dmpId))
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
package eu.eudat.publicapi.criteria.dmp;
|
package eu.eudat.publicapi.criteria.dmp;
|
||||||
|
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.dao.criteria.Criteria;
|
import eu.eudat.data.dao.criteria.Criteria;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DataManagementPlanPublicCriteria extends Criteria<DMP> {
|
public class DataManagementPlanPublicCriteria extends Criteria<DmpEntity> {
|
||||||
@ApiModelProperty(value = "periodStart", name = "periodStart", dataType = "Date", example = "2022-01-01T13:19:42.210Z")
|
@ApiModelProperty(value = "periodStart", name = "periodStart", dataType = "Date", example = "2022-01-01T13:19:42.210Z")
|
||||||
private Date periodStart;
|
private Date periodStart;
|
||||||
@ApiModelProperty(value = "periodEnd", name = "periodEnd", dataType = "Date", example = "2022-12-31T13:19:42.210Z")
|
@ApiModelProperty(value = "periodEnd", name = "periodEnd", dataType = "Date", example = "2022-12-31T13:19:42.210Z")
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package eu.eudat.publicapi.managers;
|
package eu.eudat.publicapi.managers;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.commons.enums.DmpAccessType;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.exceptions.security.ForbiddenException;
|
import eu.eudat.exceptions.security.ForbiddenException;
|
||||||
import eu.eudat.logic.managers.PaginationManager;
|
import eu.eudat.logic.managers.PaginationManager;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
|
@ -32,8 +34,8 @@ public class DataManagementPlanPublicManager {
|
||||||
|
|
||||||
public DataTableData<DataManagementPlanPublicListingModel> getPublicPaged(DataManagmentPlanPublicTableRequest dmpTableRequest, String fieldsGroup) throws Exception {
|
public DataTableData<DataManagementPlanPublicListingModel> getPublicPaged(DataManagmentPlanPublicTableRequest dmpTableRequest, String fieldsGroup) throws Exception {
|
||||||
dmpTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(HintedModelFactory.getHint(DataManagementPlanPublicListingModel.class)));
|
dmpTableRequest.setQuery(databaseRepository.getDmpDao().asQueryable().withHint(HintedModelFactory.getHint(DataManagementPlanPublicListingModel.class)));
|
||||||
QueryableList<DMP> items = dmpTableRequest.applyCriteria();
|
QueryableList<DmpEntity> items = dmpTableRequest.applyCriteria();
|
||||||
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(items, dmpTableRequest);
|
QueryableList<DmpEntity> pagedItems = PaginationManager.applyPaging(items, dmpTableRequest);
|
||||||
|
|
||||||
DataTableData<DataManagementPlanPublicListingModel> dataTable = new DataTableData<>();
|
DataTableData<DataManagementPlanPublicListingModel> dataTable = new DataTableData<>();
|
||||||
|
|
||||||
|
@ -62,11 +64,11 @@ public class DataManagementPlanPublicManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlanPublicModel getOverviewSinglePublic(String id) throws Exception {
|
public DataManagementPlanPublicModel getOverviewSinglePublic(String id) throws Exception {
|
||||||
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
DmpEntity dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||||
if (dataManagementPlanEntity.getStatus() == DMP.DMPStatus.DELETED.getValue()) {
|
if (dataManagementPlanEntity.getIsActive().equals(IsActive.Inactive)) {
|
||||||
throw new Exception("DMP is deleted.");
|
throw new Exception("DMP is deleted.");
|
||||||
}
|
}
|
||||||
if (!dataManagementPlanEntity.isPublic()) {
|
if (!dataManagementPlanEntity.getAccessType().equals(DmpAccessType.Public)) {
|
||||||
throw new ForbiddenException("Selected DMP is not public");
|
throw new ForbiddenException("Selected DMP is not public");
|
||||||
}
|
}
|
||||||
DataManagementPlanPublicModel datamanagementPlan = new DataManagementPlanPublicModel();
|
DataManagementPlanPublicModel datamanagementPlan = new DataManagementPlanPublicModel();
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.publicapi.models.listingmodels;
|
package eu.eudat.publicapi.models.listingmodels;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.publicapi.models.researcher.ResearcherPublicModel;
|
import eu.eudat.publicapi.models.researcher.ResearcherPublicModel;
|
||||||
|
@ -9,7 +9,7 @@ import eu.eudat.publicapi.models.user.UserInfoPublicModel;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DataManagementPlanPublicListingModel implements DataModel<DMP, DataManagementPlanPublicListingModel> {
|
public class DataManagementPlanPublicListingModel implements DataModel<DmpEntity, DataManagementPlanPublicListingModel> {
|
||||||
private String id;
|
private String id;
|
||||||
private String label;
|
private String label;
|
||||||
private String grant;
|
private String grant;
|
||||||
|
@ -100,70 +100,70 @@ public class DataManagementPlanPublicListingModel implements DataModel<DMP, Data
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlanPublicListingModel fromDataModel(DMP entity) {
|
public DataManagementPlanPublicListingModel fromDataModel(DmpEntity entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlanPublicListingModel fromDataModelAssociatedProfiles(DMP entity) {
|
public DataManagementPlanPublicListingModel fromDataModelAssociatedProfiles(DmpEntity entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
this.createdAt = entity.getCreated();
|
this.createdAt = Date.from(entity.getCreatedAt());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlanPublicListingModel fromDataModelAutoComplete(DMP entity) {
|
public DataManagementPlanPublicListingModel fromDataModelAutoComplete(DmpEntity entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
this.createdAt = entity.getCreated();
|
this.createdAt = Date.from(entity.getCreatedAt());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlanPublicListingModel fromDataModelNoDatasets(DMP entity) {
|
public DataManagementPlanPublicListingModel fromDataModelNoDatasets(DmpEntity entity) {
|
||||||
this.fromDataModel(entity);
|
this.fromDataModel(entity);
|
||||||
this.version = entity.getVersion();
|
// this.version = entity.getVersion(); //TODO
|
||||||
if (entity.getGrant() != null) {
|
// if (entity.getGrant() != null) {
|
||||||
this.grant = entity.getGrant().getLabel();
|
// this.grant = entity.getGrant().getLabel();
|
||||||
}
|
// }
|
||||||
this.createdAt = entity.getCreated();
|
// this.createdAt = entity.getCreated();
|
||||||
this.modifiedAt = entity.getModified();
|
// this.modifiedAt = entity.getModified();
|
||||||
try {
|
// try {
|
||||||
this.users = entity.getUsers() != null ? entity.getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.users = entity.getUsers() != null ? entity.getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(x -> new ResearcherPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.researchers = entity.getResearchers() != null ? entity.getResearchers().stream().map(x -> new ResearcherPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
}
|
// }
|
||||||
catch(Exception ex){
|
// catch(Exception ex){
|
||||||
this.users = new ArrayList<>();
|
// this.users = new ArrayList<>();
|
||||||
this.researchers = new ArrayList<>();
|
// this.researchers = new ArrayList<>();
|
||||||
}
|
// }
|
||||||
this.finalizedAt = entity.getFinalizedAt();
|
// this.finalizedAt = entity.getFinalizedAt();
|
||||||
this.publishedAt = entity.getPublishedAt();
|
// this.publishedAt = entity.getPublishedAt();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() {
|
public DmpEntity toDataModel() {
|
||||||
DMP entity = new DMP();
|
DmpEntity entity = new DmpEntity();
|
||||||
entity.setId(UUID.fromString(this.getId()));
|
entity.setId(UUID.fromString(this.getId()));
|
||||||
entity.setLabel(this.getLabel());
|
entity.setLabel(this.getLabel());
|
||||||
entity.setGroupId(this.getGroupId());
|
entity.setGroupId(this.getGroupId());
|
||||||
entity.setCreated(this.getCreatedAt());
|
// entity.setCreated(this.getCreatedAt()); //TODO
|
||||||
entity.setFinalizedAt(this.getFinalizedAt());
|
// entity.setFinalizedAt(this.getFinalizedAt());
|
||||||
entity.setModified(this.getModifiedAt());
|
// entity.setModified(this.getModifiedAt());
|
||||||
entity.setPublishedAt(this.getPublishedAt());
|
// entity.setPublishedAt(this.getPublishedAt());
|
||||||
entity.setVersion(this.getVersion());
|
// entity.setVersion(this.getVersion());
|
||||||
|
//
|
||||||
if (this.getGrant() != null) {
|
// if (this.getGrant() != null) {
|
||||||
Grant grant = new Grant();
|
// Grant grant = new Grant();
|
||||||
grant.setLabel(this.getGrant());
|
// grant.setLabel(this.getGrant());
|
||||||
entity.setGrant(grant);
|
// entity.setGrant(grant);
|
||||||
}
|
// }
|
||||||
entity.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
|
// entity.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
|
||||||
entity.setResearchers(this.getResearchers().stream().map(ResearcherPublicModel::toDataModel).collect(Collectors.toSet()));
|
// entity.setResearchers(this.getResearchers().stream().map(ResearcherPublicModel::toDataModel).collect(Collectors.toSet()));
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
package eu.eudat.publicapi.models.listingmodels;
|
package eu.eudat.publicapi.models.listingmodels;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.publicapi.models.datasetprofile.DatasetProfilePublicModel;
|
import eu.eudat.publicapi.models.datasetprofile.DatasetProfilePublicModel;
|
||||||
import eu.eudat.publicapi.models.user.UserInfoPublicModel;
|
import eu.eudat.publicapi.models.user.UserInfoPublicModel;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class DatasetPublicListingModel implements DataModel<DescriptionEntity, DatasetPublicListingModel> {
|
public class DatasetPublicListingModel implements DataModel<DescriptionEntity, DatasetPublicListingModel> {
|
||||||
private String id;
|
private String id;
|
||||||
|
|
|
@ -5,11 +5,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
import eu.eudat.data.old.DMP;
|
|
||||||
import eu.eudat.data.old.DMPDatasetProfile;
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import eu.eudat.publicapi.models.associatedprofile.AssociatedProfilePublicModel;
|
import eu.eudat.publicapi.models.associatedprofile.AssociatedProfilePublicModel;
|
||||||
|
@ -18,14 +17,13 @@ import eu.eudat.publicapi.models.grant.GrantPublicOverviewModel;
|
||||||
import eu.eudat.publicapi.models.organisation.OrganizationPublicModel;
|
import eu.eudat.publicapi.models.organisation.OrganizationPublicModel;
|
||||||
import eu.eudat.publicapi.models.researcher.ResearcherPublicModel;
|
import eu.eudat.publicapi.models.researcher.ResearcherPublicModel;
|
||||||
import eu.eudat.publicapi.models.user.UserInfoPublicModel;
|
import eu.eudat.publicapi.models.user.UserInfoPublicModel;
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DataManagementPlanPublicModel implements DataModel<DMP, DataManagementPlanPublicModel> {
|
public class DataManagementPlanPublicModel implements DataModel<DmpEntity, DataManagementPlanPublicModel> {
|
||||||
private String id;
|
private String id;
|
||||||
private String label;
|
private String label;
|
||||||
private String profile;
|
private String profile;
|
||||||
|
@ -165,56 +163,56 @@ public class DataManagementPlanPublicModel implements DataModel<DMP, DataManagem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataManagementPlanPublicModel fromDataModel(DMP entity) {
|
public DataManagementPlanPublicModel fromDataModel(DmpEntity entity) {
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.label = entity.getLabel();
|
this.label = entity.getLabel();
|
||||||
this.groupId = entity.getGroupId();
|
this.groupId = entity.getGroupId();
|
||||||
if (entity.getResearchers() != null) {
|
// if (entity.getResearchers() != null) { //TODO
|
||||||
this.researchers = entity.getResearchers().stream().map(item -> new ResearcherPublicModel().fromDataModel(item)).collect(Collectors.toList());
|
// this.researchers = entity.getResearchers().stream().map(item -> new ResearcherPublicModel().fromDataModel(item)).collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataManagementPlanPublicModel fromDataModelDatasets(DMP entity) {
|
public DataManagementPlanPublicModel fromDataModelDatasets(DmpEntity entity) {
|
||||||
this.fromDataModel(entity);
|
this.fromDataModel(entity);
|
||||||
this.version = entity.getVersion();
|
this.version = entity.getVersion();//TODO
|
||||||
if (entity.getGrant() != null) {
|
// if (entity.getGrant() != null) {
|
||||||
this.grant = new GrantPublicOverviewModel().fromDataModel(entity.getGrant());
|
// this.grant = new GrantPublicOverviewModel().fromDataModel(entity.getGrant());
|
||||||
}
|
// }
|
||||||
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
// if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
|
||||||
this.createdAt = entity.getCreated();
|
// this.createdAt = entity.getCreated();
|
||||||
this.modifiedAt = entity.getModified();
|
// this.modifiedAt = entity.getModified();
|
||||||
this.finalizedAt = entity.getFinalizedAt();
|
// this.finalizedAt = entity.getFinalizedAt();
|
||||||
this.organisations = entity.getOrganisations().stream().map(item -> new OrganizationPublicModel().fromDataModel(item)).collect(Collectors.toList());
|
// this.organisations = entity.getOrganisations().stream().map(item -> new OrganizationPublicModel().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled))
|
// this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled))
|
||||||
.map(datasetEntity-> {
|
// .map(datasetEntity-> {
|
||||||
DatasetPublicModel dataset = new DatasetPublicModel();
|
// DatasetPublicModel dataset = new DatasetPublicModel();
|
||||||
dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus().getValue(), datasetEntity));
|
// dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus().getValue(), datasetEntity));
|
||||||
dataset.fromDataModel(datasetEntity);
|
// dataset.fromDataModel(datasetEntity);
|
||||||
return dataset;
|
// return dataset;
|
||||||
}).collect(Collectors.toList());
|
// }).collect(Collectors.toList());
|
||||||
this.users = entity.getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList());
|
// this.users = entity.getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList());
|
||||||
this.description = entity.getDescription();
|
// this.description = entity.getDescription();
|
||||||
if (entity.getResearchers() != null) {
|
// if (entity.getResearchers() != null) {
|
||||||
this.researchers = entity.getResearchers().stream().map(item -> new ResearcherPublicModel().fromDataModel(item)).collect(Collectors.toList());
|
// this.researchers = entity.getResearchers().stream().map(item -> new ResearcherPublicModel().fromDataModel(item)).collect(Collectors.toList());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
// if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
|
||||||
this.associatedProfiles = new LinkedList<>();
|
// this.associatedProfiles = new LinkedList<>();
|
||||||
for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
|
// for (DMPDatasetProfile dmpDescriptionProfile : entity.getAssociatedDmps()) {
|
||||||
AssociatedProfilePublicModel associatedProfile = new AssociatedProfilePublicModel().fromData(dmpDescriptionProfile.getDatasetprofile());
|
// AssociatedProfilePublicModel associatedProfile = new AssociatedProfilePublicModel().fromData(dmpDescriptionProfile.getDatasetprofile());
|
||||||
associatedProfile.setId(dmpDescriptionProfile.getId());
|
// associatedProfile.setId(dmpDescriptionProfile.getId());
|
||||||
try {
|
// try {
|
||||||
associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
|
// associatedProfile.setData(new ObjectMapper().readValue(dmpDescriptionProfile.getData(), new TypeReference<Map<String, Object>>() {}));
|
||||||
}
|
// }
|
||||||
catch (Exception e) {
|
// catch (Exception e) {
|
||||||
associatedProfile.setData(null);
|
// associatedProfile.setData(null);
|
||||||
}
|
// }
|
||||||
this.associatedProfiles.add(associatedProfile);
|
// this.associatedProfiles.add(associatedProfile);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
this.publishedAt = entity.getPublishedAt();
|
// this.publishedAt = entity.getPublishedAt();
|
||||||
this.dois = entity.getDois().stream().map(item -> new DoiPublicModel().fromDataModel(item)).collect(Collectors.toList());
|
// this.dois = entity.getDois().stream().map(item -> new DoiPublicModel().fromDataModel(item)).collect(Collectors.toList());
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +243,7 @@ public class DataManagementPlanPublicModel implements DataModel<DMP, DataManagem
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DMP toDataModel() {
|
public DmpEntity toDataModel() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package eu.eudat.publicapi.models.user;
|
package eu.eudat.publicapi.models.user;
|
||||||
|
|
||||||
import eu.eudat.data.old.UserDMP;
|
import eu.eudat.commons.enums.DmpUserRole;
|
||||||
|
import eu.eudat.data.DmpUserEntity;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
import eu.eudat.model.DmpUser;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class UserInfoPublicModel implements DataModel<UserDMP, UserInfoPublicModel> {
|
public class UserInfoPublicModel implements DataModel<DmpUserEntity, UserInfoPublicModel> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String name;
|
private String name;
|
||||||
private int role;
|
private int role;
|
||||||
|
@ -41,23 +43,23 @@ public class UserInfoPublicModel implements DataModel<UserDMP, UserInfoPublicMod
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserInfoPublicModel fromDataModel(UserDMP entity) {
|
public UserInfoPublicModel fromDataModel(DmpUserEntity entity) {
|
||||||
this.id = entity.getUser().getId();
|
// this.id = entity.getUser().getId(); //TODO
|
||||||
this.name = entity.getUser().getName();
|
// this.name = entity.getUser().getName();
|
||||||
this.role = entity.getRole();
|
// this.role = entity.getRole().getValue();
|
||||||
this.email = entity.getUser().getEmail();
|
// this.email = entity.getUser().getEmail();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserDMP toDataModel() {
|
public DmpUserEntity toDataModel() {
|
||||||
UserDMP entity = new UserDMP();
|
DmpUserEntity entity = new DmpUserEntity();
|
||||||
entity.setId(this.getId());
|
entity.setId(this.getId());
|
||||||
entity.setRole(this.getRole());
|
entity.setRole(DmpUserRole.of((short)this.getRole()));
|
||||||
UserInfo userInfo = new UserInfo();
|
UserInfo userInfo = new UserInfo();
|
||||||
userInfo.setName(this.getName());
|
userInfo.setName(this.getName());
|
||||||
userInfo.setEmail(this.getEmail());
|
userInfo.setEmail(this.getEmail());
|
||||||
entity.setUser(userInfo);
|
// entity.setUser(userInfo);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.publicapi.request.dmp;
|
package eu.eudat.publicapi.request.dmp;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
import eu.eudat.data.query.PaginationService;
|
import eu.eudat.data.query.PaginationService;
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
import eu.eudat.data.query.definition.TableQuery;
|
||||||
import eu.eudat.publicapi.criteria.dmp.DataManagementPlanPublicCriteria;
|
import eu.eudat.publicapi.criteria.dmp.DataManagementPlanPublicCriteria;
|
||||||
|
@ -11,10 +12,10 @@ import eu.eudat.queryable.types.SelectionField;
|
||||||
import jakarta.persistence.criteria.Predicate;
|
import jakarta.persistence.criteria.Predicate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManagementPlanPublicCriteria, DMP, UUID> {
|
public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManagementPlanPublicCriteria, DmpEntity, UUID> {
|
||||||
|
|
||||||
public QueryableList<DMP> applyCriteria() {
|
public QueryableList<DmpEntity> applyCriteria() {
|
||||||
QueryableList<DMP> query = this.getQuery();
|
QueryableList<DmpEntity> query = this.getQuery();
|
||||||
query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
|
query.where((builder, root) -> builder.equal(root.get("isPublic"), true));
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.or(
|
query.where((builder, root) -> builder.or(
|
||||||
|
@ -89,12 +90,12 @@ public class DataManagmentPlanPublicTableRequest extends TableQuery<DataManageme
|
||||||
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty()) {
|
if (this.getCriteria().getGroupIds() != null && !this.getCriteria().getGroupIds().isEmpty()) {
|
||||||
query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
|
query.where((builder, root) -> root.get("groupId").in(this.getCriteria().getGroupIds()));
|
||||||
}
|
}
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), DMP.DMPStatus.DELETED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DMP> applyPaging(QueryableList<DMP> items) {
|
public QueryableList<DmpEntity> applyPaging(QueryableList<DmpEntity> items) {
|
||||||
return PaginationService.applyPaging(items, this);
|
return PaginationService.applyPaging(items, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue