argos/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanListingMo...

204 lines
6.2 KiB
Java
Raw Normal View History

2018-06-27 12:29:21 +02:00
package eu.eudat.models.data.listingmodels;
2017-12-19 15:09:49 +01:00
2018-03-21 11:57:56 +01:00
import eu.eudat.data.entities.DMP;
import eu.eudat.logic.utilities.builders.XmlBuilder;
2017-12-19 15:09:49 +01:00
import eu.eudat.models.DataModel;
import eu.eudat.models.data.dmp.AssociatedProfile;
2018-06-27 12:29:21 +02:00
import eu.eudat.models.data.dmp.Organisation;
import eu.eudat.logic.utilities.helpers.LabelBuilder;
2018-07-23 15:09:19 +02:00
import eu.eudat.models.data.urls.DatasetUrlListing;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
2017-12-19 15:09:49 +01:00
2018-10-02 16:33:58 +02:00
import java.util.Date;
import java.util.LinkedList;
2018-07-23 15:09:19 +02:00
import java.util.List;
2018-02-08 09:42:02 +01:00
import java.util.UUID;
2017-12-19 15:09:49 +01:00
import java.util.stream.Collectors;
2018-02-01 10:08:06 +01:00
2018-02-16 11:34:02 +01:00
public class DataManagementPlanListingModel implements DataModel<DMP, DataManagementPlanListingModel> {
2017-12-19 15:09:49 +01:00
private String id;
private String label;
private String project;
private String profile;
2018-10-02 16:33:58 +02:00
private Date creationTime;
private Date modifiedTime;
2017-12-19 15:09:49 +01:00
private String organisations;
2018-10-02 16:33:58 +02:00
private int version;
private int status;
2018-02-08 09:42:02 +01:00
private UUID groupId;
2018-07-23 15:09:19 +02:00
private List<DatasetUrlListing> datasets;
private List<AssociatedProfile> associatedProfiles;
2019-05-06 11:41:13 +02:00
private List<UserInfoListingModel> users;
private String description;
private String projectAbbreviation;
private String projectId;
2017-12-19 15:09:49 +01:00
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getProject() {
return project;
}
public void setProject(String project) {
this.project = project;
}
public String getProfile() {
return profile;
}
public void setProfile(String profile) {
this.profile = profile;
}
2018-10-02 16:33:58 +02:00
public Date getCreationTime() {
2018-02-02 12:09:38 +01:00
return creationTime;
2017-12-19 15:09:49 +01:00
}
2018-10-02 16:33:58 +02:00
public void setCreationTime(Date creationTime) {
2018-02-02 12:09:38 +01:00
this.creationTime = creationTime;
2017-12-19 15:09:49 +01:00
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
2017-12-19 15:09:49 +01:00
public String getOrganisations() {
return organisations;
}
public void setOrganisations(String organisations) {
this.organisations = organisations;
}
2018-10-02 16:33:58 +02:00
public int getVersion() {
2017-12-19 15:09:49 +01:00
return version;
}
2018-10-02 16:33:58 +02:00
public void setVersion(int version) {
2017-12-19 15:09:49 +01:00
this.version = version;
}
2018-02-08 09:42:02 +01:00
public UUID getGroupId() {
return groupId;
}
public void setGroupId(UUID groupId) {
this.groupId = groupId;
}
2018-07-23 15:09:19 +02:00
public List<DatasetUrlListing> getDatasets() {
return datasets;
2018-01-23 16:21:38 +01:00
}
2018-07-23 15:09:19 +02:00
public void setDatasets(List<DatasetUrlListing> datasets) {
this.datasets = datasets;
2018-01-23 16:21:38 +01:00
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public List<AssociatedProfile> getAssociatedProfiles() {
return associatedProfiles;
}
public void setAssociatedProfiles(List<AssociatedProfile> associatedProfiles) {
this.associatedProfiles = associatedProfiles;
}
2019-05-06 11:41:13 +02:00
public List<UserInfoListingModel> getUsers() {
return users;
}
public void setUsers(List<UserInfoListingModel> users) {
this.users = users;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getProjectAbbreviation() {
return projectAbbreviation;
}
public void setProjectAbbreviation(String projectAbbreviation) {
this.projectAbbreviation = projectAbbreviation;
}
public String getProjectId() {
return projectId;
}
public void setProjectId(String projectId) {
this.projectId = projectId;
}
2017-12-19 15:09:49 +01:00
@Override
2018-02-16 08:45:18 +01:00
public DataManagementPlanListingModel fromDataModel(DMP entity) {
2017-12-19 15:09:49 +01:00
this.id = entity.getId().toString();
this.label = entity.getLabel();
this.groupId = entity.getGroupId();
return this;
}
public DataManagementPlanListingModel fromDataModelDatasets(DMP entity) {
this.fromDataModel(entity);
this.status = entity.getStatus();
this.version = entity.getVersion();
this.project = entity.getProject().getLabel();
2018-02-16 11:34:02 +01:00
if (entity.getProfile() != null) this.profile = entity.getProfile().getLabel();
2018-10-02 16:33:58 +02:00
this.creationTime = entity.getCreated();
this.modifiedTime = entity.getModified();
this.organisations = LabelBuilder.getLabel(entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList()));
2018-07-23 15:09:19 +02:00
this.datasets = entity.getDataset().stream().map(x-> new DatasetUrlListing().fromDataModel(x)).collect(Collectors.toList());
2019-05-06 11:41:13 +02:00
this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
this.description = entity.getDescription();
this.projectAbbreviation = entity.getProject().getAbbreviation();
this.projectId = entity.getProject().getId().toString();
if (entity.getAssociatedDmps() != null && !entity.getAssociatedDmps().isEmpty()) {
Document viewStyleDoc = XmlBuilder.fromXml(entity.getAssociatedDmps());
Element item = (Element) viewStyleDoc.getElementsByTagName("profiles").item(0);
this.associatedProfiles = new LinkedList<>();
if (item != null) {
NodeList associatedProfilesElement = item.getChildNodes();
for (int temp = 0; temp < associatedProfilesElement.getLength(); temp++) {
Node associatedProfileElement = associatedProfilesElement.item(temp);
if (associatedProfileElement.getNodeType() == Node.ELEMENT_NODE) {
this.associatedProfiles.add(new AssociatedProfile().fromXml((Element) associatedProfileElement));
}
}
}
}
2018-02-16 08:45:18 +01:00
return this;
2017-12-19 15:09:49 +01:00
}
@Override
public DMP toDataModel() {
return null;
}
2018-01-19 10:31:05 +01:00
@Override
public String getHint() {
return "dataManagementPlanListingModel";
}
2017-12-19 15:09:49 +01:00
}