argos/dmp-backend/web/src/main/java/eu/eudat/models/data/project/ProjectListingModel.java

202 lines
4.6 KiB
Java
Raw Normal View History

2018-06-27 12:29:21 +02:00
package eu.eudat.models.data.project;
2018-01-17 13:03:51 +01:00
2018-03-21 11:57:56 +01:00
import eu.eudat.data.entities.Project;
import eu.eudat.data.entities.UserInfo;
2018-01-17 13:03:51 +01:00
import eu.eudat.models.DataModel;
2018-06-27 12:29:21 +02:00
import eu.eudat.models.data.files.ContentFile;
import eu.eudat.models.data.urls.DataManagementPlanUrlListing;
2018-01-17 13:03:51 +01:00
2018-03-19 13:40:04 +01:00
import java.util.Arrays;
2018-10-02 16:33:58 +02:00
import java.util.Date;
2018-02-16 11:34:02 +01:00
import java.util.List;
import java.util.UUID;
2018-03-19 17:58:34 +01:00
import java.util.stream.Collectors;
2018-02-16 11:34:02 +01:00
2018-01-17 13:03:51 +01:00
2018-03-21 11:57:56 +01:00
public class ProjectListingModel implements DataModel<eu.eudat.data.entities.Project, ProjectListingModel> {
2018-01-17 13:03:51 +01:00
private UUID id;
private String label;
private String abbreviation;
private String reference;
private String uri;
private String definition;
2018-10-02 16:33:58 +02:00
private Date startDate;
2018-01-17 13:03:51 +01:00
2018-10-02 16:33:58 +02:00
private Date endDate;
2018-01-17 13:03:51 +01:00
2018-01-19 12:11:22 +01:00
private Project.Status status;
2018-01-17 13:03:51 +01:00
private UserInfo creationUser;
2018-10-02 16:33:58 +02:00
private Date created;
2018-01-17 13:03:51 +01:00
2018-10-02 16:33:58 +02:00
private Date modified;
2018-01-17 13:03:51 +01:00
private String description;
2018-03-19 13:40:04 +01:00
private List<ContentFile> files;
2018-03-19 17:58:34 +01:00
private List<DataManagementPlanUrlListing> dmps;
2018-01-17 13:03:51 +01:00
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
2018-03-19 17:58:34 +01:00
public List<DataManagementPlanUrlListing> getDmps() {
2018-01-17 13:03:51 +01:00
return dmps;
}
2018-03-19 17:58:34 +01:00
public void setDmps(List<DataManagementPlanUrlListing> dmps) {
2018-01-17 13:03:51 +01:00
this.dmps = dmps;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getDefinition() {
return definition;
}
public void setDefinition(String definition) {
this.definition = definition;
}
public short getStatus() {
return status.getValue();
}
public void setStatus(Short status) {
2018-01-19 12:11:22 +01:00
this.status = Project.Status.fromInteger(status);
2018-01-17 13:03:51 +01:00
}
public UserInfo getCreationUser() {
return creationUser;
}
public void setCreationUser(UserInfo creationUser) {
this.creationUser = creationUser;
}
2018-10-02 16:33:58 +02:00
public Date getStartDate() {
2018-01-17 13:03:51 +01:00
return startDate;
}
2018-10-02 16:33:58 +02:00
public void setStartDate(Date startDate) {
2018-01-17 13:03:51 +01:00
this.startDate = startDate;
}
2018-10-02 16:33:58 +02:00
public Date getEndDate() {
2018-01-17 13:03:51 +01:00
return endDate;
}
2018-10-02 16:33:58 +02:00
public void setEndDate(Date endDate) {
2018-01-17 13:03:51 +01:00
this.endDate = endDate;
}
2018-10-02 16:33:58 +02:00
public void setStatus(Project.Status status) {
this.status = status;
}
public Date getCreated() {
2018-01-17 13:03:51 +01:00
return created;
}
2018-10-02 16:33:58 +02:00
public void setCreated(Date created) {
2018-01-17 13:03:51 +01:00
this.created = created;
}
2018-10-02 16:33:58 +02:00
public Date getModified() {
2018-01-17 13:03:51 +01:00
return modified;
}
2018-10-02 16:33:58 +02:00
public void setModified(Date modified) {
2018-01-17 13:03:51 +01:00
this.modified = modified;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
2018-03-19 13:40:04 +01:00
public List<ContentFile> getFiles() {
return files;
}
public void setFiles(List<ContentFile> files) {
this.files = files;
}
2018-01-17 13:03:51 +01:00
@Override
2018-03-21 11:57:56 +01:00
public ProjectListingModel fromDataModel(eu.eudat.data.entities.Project entity) {
2018-01-17 13:03:51 +01:00
this.id = entity.getId();
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.reference = entity.getReference();
this.uri = entity.getUri();
this.definition = entity.getDefinition();
2018-10-02 16:33:58 +02:00
this.startDate = entity.getStartdate();
this.endDate = entity.getEnddate();
2018-01-17 13:03:51 +01:00
this.setStatus(entity.getStatus());
2018-10-02 16:33:58 +02:00
this.created = entity.getCreated();
this.modified = entity.getModified();
2018-01-17 13:03:51 +01:00
this.description = entity.getDescription();
2018-03-19 17:58:34 +01:00
this.dmps = entity.getDmps().stream().map(item -> new DataManagementPlanUrlListing().fromDataModel(item)).collect(Collectors.toList());
2018-03-19 13:40:04 +01:00
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));
2018-02-16 08:45:18 +01:00
return this;
2018-01-17 13:03:51 +01:00
}
@Override
2018-03-21 11:57:56 +01:00
public eu.eudat.data.entities.Project toDataModel() throws Exception {
2018-01-23 16:21:38 +01:00
throw new Exception("Not Implemented");
2018-01-17 13:03:51 +01:00
}
2018-01-19 10:31:05 +01:00
@Override
public String getHint() {
2018-03-19 17:58:34 +01:00
return "projectListingItem";
2018-01-19 10:31:05 +01:00
}
2018-01-17 13:03:51 +01:00
}