package eu.eudat.models.project; import eu.eudat.data.entities.UserInfo; import eu.eudat.models.DataModel; import eu.eudat.models.dmp.DataManagementPlan; import eu.eudat.models.files.ContentFile; import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.UUID; public class Project implements DataModel { private UUID id; private List dmps; private String label; private int type; private String abbreviation; private String reference; private String uri; private String definition; private Date startDate; private Date endDate; private eu.eudat.data.entities.Project.Status status; private UserInfo creationUser; private Date created; private Date modified; private String description; private List files; public UUID getId() { return id; } public void setId(UUID id) { this.id = id; } public int getType() { return type; } public void setType(int type) { this.type = type; } public List getDmps() { return dmps; } public void setDmps(List dmps) { 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 Date getStartDate() { return startDate; } public void setStartDate(Date startDate) { this.startDate = startDate; } public Date getEndDate() { return endDate; } public void setEndDate(Date endDate) { this.endDate = endDate; } public short getStatus() { return status.getValue(); } public void setStatus(Short status) { this.status = eu.eudat.data.entities.Project.Status.fromInteger(status); } public UserInfo getCreationUser() { return creationUser; } public void setCreationUser(UserInfo creationUser) { this.creationUser = creationUser; } 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 String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public List getFiles() { return files; } public void setFiles(List files) { this.files = files; } @Override public Project fromDataModel(eu.eudat.data.entities.Project entity) { this.id = entity.getId(); this.label = entity.getLabel(); this.abbreviation = entity.getAbbreviation(); this.reference = entity.getReference(); this.uri = entity.getUri(); this.type = entity.getType(); this.definition = entity.getDefinition(); this.startDate = entity.getStartdate(); this.endDate = entity.getEnddate(); this.setStatus(entity.getStatus()); this.created = entity.getCreated(); this.modified = entity.getModified(); 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)); return this; } @Override public eu.eudat.data.entities.Project toDataModel() { eu.eudat.data.entities.Project entity = new eu.eudat.data.entities.Project(); entity.setId(this.id); entity.setAbbreviation(this.abbreviation); entity.setLabel(this.label); entity.setType(this.type); entity.setReference(this.reference == null ? "dmp:" + this.label : this.reference); entity.setUri(this.uri); entity.setDefinition(this.definition); entity.setStartdate(this.startDate); entity.setCreated(this.created == null ? new Date() : this.created); entity.setEnddate(this.endDate); entity.setStatus(this.status != null ? this.getStatus() : eu.eudat.data.entities.Project.Status.ACTIVE.getValue()); entity.setModified(new Date()); entity.setDescription(this.description); return entity; } @Override public String getHint() { return null; } }