argos/dmp-backend/src/main/java/eu/eudat/models/project/Project.java

212 lines
4.2 KiB
Java
Raw Normal View History

2017-12-15 00:01:26 +01:00
package eu.eudat.models.project;
2017-12-14 18:07:09 +01:00
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.UUID;
2017-12-15 00:01:26 +01:00
import eu.eudat.entities.UserInfo;
import eu.eudat.models.DataModel;
import eu.eudat.models.dmp.DataManagementPlan;
2017-12-14 18:07:09 +01:00
2017-12-18 16:55:12 +01:00
2017-12-15 00:01:26 +01:00
public class Project implements DataModel<eu.eudat.entities.Project>{
2017-12-18 16:55:12 +01:00
public enum Status {
2017-12-19 09:38:47 +01:00
ACTIVE((short) 1), INACTIVE((short) 0),DELETED((short)99);
2017-12-18 16:55:12 +01:00
private short value;
private Status(short value) { this.value = value; }
public short getValue(){return value;}
public static Status fromInteger(int value) {
switch (value) {
case 0:
return ACTIVE;
case 1:
return INACTIVE;
2017-12-19 09:38:47 +01:00
case 99:
return INACTIVE;
2017-12-18 16:55:12 +01:00
default:
throw new RuntimeException("Unsupported Project Status");
}
}
}
2017-12-14 18:07:09 +01:00
private UUID id;
private List<DataManagementPlan> dmps;
private String label;
private String abbreviation;
private String reference;
private String uri;
private String definition;
2017-12-18 16:55:12 +01:00
private Date startDate;
2017-12-14 18:07:09 +01:00
2017-12-18 16:55:12 +01:00
private Date endDate;
2017-12-14 18:07:09 +01:00
2017-12-18 16:55:12 +01:00
private Status status;
2017-12-14 18:07:09 +01:00
private UserInfo creationUser;
private Date created;
private Date modified;
private String description;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public List<DataManagementPlan> getDmps() {
return dmps;
}
public void setDmps(List<DataManagementPlan> 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;
}
2017-12-18 16:55:12 +01:00
public Date getStartDate() {
return startDate;
2017-12-14 18:07:09 +01:00
}
2017-12-18 16:55:12 +01:00
public void setStartDate(Date startDate) {
this.startDate = startDate;
2017-12-14 18:07:09 +01:00
}
2017-12-18 16:55:12 +01:00
public Date getEndDate() {
return endDate;
2017-12-14 18:07:09 +01:00
}
2017-12-18 16:55:12 +01:00
public void setEndDate(Date endDate) {
this.endDate = endDate;
2017-12-14 18:07:09 +01:00
}
2017-12-18 16:55:12 +01:00
public short getStatus() {
return status.getValue();
2017-12-14 18:07:09 +01:00
}
public void setStatus(Short status) {
2017-12-18 16:55:12 +01:00
this.status = Status.fromInteger(status);
2017-12-14 18:07:09 +01:00
}
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;
}
@Override
2017-12-15 00:01:26 +01:00
public void fromDataModel(eu.eudat.entities.Project entity) throws InstantiationException, IllegalAccessException {
2017-12-14 18:07:09 +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();
2017-12-18 16:55:12 +01:00
this.startDate = entity.getStartdate();
this.endDate = entity.getEnddate();
this.setStatus(entity.getStatus());
2017-12-14 18:07:09 +01:00
this.created = entity.getCreated();
this.modified = entity.getModified();
this.description = entity.getDescription();
}
@Override
2017-12-15 00:01:26 +01:00
public eu.eudat.entities.Project toDataModel() {
eu.eudat.entities.Project entity = new eu.eudat.entities.Project();
2017-12-14 18:07:09 +01:00
entity.setId(this.id);
entity.setAbbreviation(this.abbreviation);
entity.setLabel(this.label);
entity.setReference(this.reference);
entity.setUri(this.uri);
entity.setDefinition(this.definition);
2017-12-18 16:55:12 +01:00
entity.setStartdate(this.startDate);
2017-12-14 18:07:09 +01:00
entity.setCreated(this.created == null? new Date():this.created);
2017-12-18 16:55:12 +01:00
entity.setEnddate(this.endDate);
2017-12-19 09:38:47 +01:00
entity.setStatus(this.status!=null?this.getStatus():Status.ACTIVE.getValue());
2017-12-14 18:07:09 +01:00
entity.setModified(new Date());
entity.setDescription(this.description);
return entity;
}
}