191 lines
5.4 KiB
Java
191 lines
5.4 KiB
Java
package eu.eudat.models.data.dmp;
|
|
|
|
import eu.eudat.data.entities.DMP;
|
|
import eu.eudat.data.entities.UserDMP;
|
|
import eu.eudat.models.DataModel;
|
|
import eu.eudat.models.data.dataset.Dataset;
|
|
import eu.eudat.models.data.grant.Grant;
|
|
import eu.eudat.models.data.userinfo.UserInfo;
|
|
|
|
import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* Created by ikalyvas on 2/5/2018.
|
|
*/
|
|
public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataManagementPlanNewVersionModel> {
|
|
private UUID id;
|
|
private String label;
|
|
private UUID groupId;
|
|
private int version;
|
|
private int status;
|
|
private String description;
|
|
private List<AssociatedProfile> profiles;
|
|
private eu.eudat.models.data.grant.Grant grant;
|
|
private List<Organisation> organisations;
|
|
private List<Researcher> researchers;
|
|
private List<UserDMP> associatedUsers;
|
|
private eu.eudat.models.data.userinfo.UserInfo creator;
|
|
private Date created;
|
|
private List<Dataset> datasets;
|
|
|
|
public UUID getId() {
|
|
return id;
|
|
}
|
|
|
|
public void setId(UUID id) {
|
|
this.id = id;
|
|
}
|
|
|
|
public String getLabel() {
|
|
return label;
|
|
}
|
|
|
|
public void setLabel(String label) {
|
|
this.label = label;
|
|
}
|
|
|
|
public UUID getGroupId() {
|
|
return groupId;
|
|
}
|
|
|
|
public void setGroupId(UUID groupId) {
|
|
this.groupId = groupId;
|
|
}
|
|
|
|
public int getVersion() {
|
|
return version;
|
|
}
|
|
|
|
public void setVersion(int version) {
|
|
this.version = version;
|
|
}
|
|
|
|
public int getStatus() {
|
|
return status;
|
|
}
|
|
|
|
public void setStatus(int status) {
|
|
this.status = status;
|
|
}
|
|
|
|
public String getDescription() {
|
|
return description;
|
|
}
|
|
|
|
public void setDescription(String description) {
|
|
this.description = description;
|
|
}
|
|
|
|
public List<AssociatedProfile> getProfiles() {
|
|
return profiles;
|
|
}
|
|
|
|
public void setProfiles(List<AssociatedProfile> profiles) {
|
|
this.profiles = profiles;
|
|
}
|
|
|
|
public Grant getGrant() {
|
|
return grant;
|
|
}
|
|
|
|
public void setGrant(Grant grant) {
|
|
this.grant = grant;
|
|
}
|
|
|
|
public List<Organisation> getOrganisations() {
|
|
return organisations;
|
|
}
|
|
|
|
public void setOrganisations(List<Organisation> organisations) {
|
|
this.organisations = organisations;
|
|
}
|
|
|
|
public List<Researcher> getResearchers() {
|
|
return researchers;
|
|
}
|
|
|
|
public void setResearchers(List<Researcher> researchers) {
|
|
this.researchers = researchers;
|
|
}
|
|
|
|
public List<UserDMP> getAssociatedUsers() {
|
|
return associatedUsers;
|
|
}
|
|
|
|
public void setAssociatedUsers(List<UserDMP> associatedUsers) {
|
|
this.associatedUsers = associatedUsers;
|
|
}
|
|
|
|
public UserInfo getCreator() {
|
|
return creator;
|
|
}
|
|
|
|
public void setCreator(UserInfo creator) {
|
|
this.creator = creator;
|
|
}
|
|
|
|
public Date getCreated() {
|
|
return created;
|
|
}
|
|
|
|
public void setCreated(Date created) {
|
|
this.created = created;
|
|
}
|
|
|
|
public List<Dataset> getDatasets() {
|
|
return datasets;
|
|
}
|
|
|
|
public void setDatasets(List<Dataset> datasets) {
|
|
this.datasets = datasets;
|
|
}
|
|
|
|
@Override
|
|
public DataManagementPlanNewVersionModel fromDataModel(DMP entity) {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public DMP toDataModel() throws Exception {
|
|
DMP entity = new DMP();
|
|
entity.setId(this.id);
|
|
entity.setUsers(new HashSet<>(new ArrayList<>(this.associatedUsers)));
|
|
entity.setDescription(this.description);
|
|
entity.setStatus((short) this.status);
|
|
entity.setGroupId(this.groupId == null ? UUID.randomUUID() : this.groupId);
|
|
entity.setCreated(new Date());
|
|
entity.setLabel(this.label);
|
|
entity.setModified(new Date());
|
|
List<eu.eudat.data.entities.Dataset> datasets = new LinkedList<>();
|
|
if (this.datasets != null) {
|
|
for (Dataset dataset : this.datasets) {
|
|
eu.eudat.data.entities.Dataset entityDataset = new eu.eudat.data.entities.Dataset();
|
|
entityDataset.setId(dataset.getId());
|
|
datasets.add(entityDataset);
|
|
}
|
|
entity.setDataset(new HashSet<>(datasets));
|
|
}
|
|
if (this.organisations != null && !this.organisations.isEmpty())
|
|
entity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
|
if (this.researchers != null && !this.researchers.isEmpty())
|
|
entity.setResearchers(new HashSet<>(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
|
if (this.grant != null) entity.setGrant(this.grant.toDataModel());
|
|
if (this.profiles != null)
|
|
entity.setAssociatedDmps(this.profiles.stream().map(x -> x.toData()).collect(Collectors.toSet()));
|
|
/*Document associatedProfileDoc = XmlBuilder.getDocument();
|
|
Element associatedProfilesElement = associatedProfileDoc.createElement("profiles");
|
|
for (AssociatedProfile associatedProfile : this.profiles) {
|
|
associatedProfilesElement.appendChild(associatedProfile.toXml(associatedProfileDoc));
|
|
}
|
|
associatedProfileDoc.appendChild(associatedProfilesElement);
|
|
entity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));*/
|
|
return entity;
|
|
}
|
|
|
|
@Override
|
|
public String getHint() {
|
|
return null;
|
|
}
|
|
}
|