2017-12-09 23:31:07 +01:00
|
|
|
package models.dmp;
|
|
|
|
|
|
|
|
import com.sun.org.apache.regexp.internal.RE;
|
|
|
|
import entities.*;
|
|
|
|
import entities.Project;
|
|
|
|
import models.DataModel;
|
|
|
|
import utilities.builders.DomainModelConverter;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.stream.Collector;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
public class DataManagementPlan implements DataModel<DMP>{
|
|
|
|
private UUID id;
|
|
|
|
private String label;
|
|
|
|
private UUID previous;
|
|
|
|
private int version;
|
|
|
|
private int status;
|
|
|
|
private models.dmp.Project project;
|
|
|
|
private List<Organisation> organizations;
|
|
|
|
private List<Researcher> researchers;
|
2017-12-13 13:01:43 +01:00
|
|
|
private UserInfo creator;
|
2017-12-09 23:31:07 +01:00
|
|
|
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 getPrevious() {
|
|
|
|
return previous;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPrevious(UUID previous) {
|
|
|
|
this.previous = previous;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getVersion() {
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setVersion(int version) {
|
|
|
|
this.version = version;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Organisation> getOrganizations() {
|
|
|
|
return organizations;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOrganizations(List<Organisation> organizations) {
|
|
|
|
this.organizations = organizations;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Researcher> getResearchers() {
|
|
|
|
return researchers;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setResearchers(List<Researcher> researchers) {
|
|
|
|
this.researchers = researchers;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getStatus() {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setStatus(int status) {
|
|
|
|
this.status = status;
|
|
|
|
}
|
|
|
|
|
|
|
|
public models.dmp.Project getProject() {
|
|
|
|
return project;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setProject(models.dmp.Project project) {
|
|
|
|
this.project = project;
|
|
|
|
}
|
|
|
|
|
2017-12-13 13:01:43 +01:00
|
|
|
public UserInfo getCreator() {
|
|
|
|
return creator;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCreator(UserInfo creator) {
|
|
|
|
this.creator = creator;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-12-09 23:31:07 +01:00
|
|
|
public void fromDataModel(DMP entity) throws InstantiationException, IllegalAccessException {
|
|
|
|
this.id = entity.getId();
|
|
|
|
this.organizations =new DomainModelConverter<entities.Organisation,Organisation>().fromDataModel(entity.getOrganisations().stream().collect(Collectors.toList()),Organisation.class);
|
|
|
|
this.researchers =new DomainModelConverter<entities.Researcher,Researcher>().fromDataModel(entity.getResearchers().stream().collect(Collectors.toList()),Researcher.class);
|
|
|
|
this.version = entity.getVersion();
|
|
|
|
this.previous = entity.getPrevious();
|
|
|
|
this.label = entity.getLabel();
|
|
|
|
this.project = new models.dmp.Project();
|
|
|
|
this.project.fromDataModel(entity.getProject());
|
2017-12-13 13:01:43 +01:00
|
|
|
this.creator = new models.dmp.UserInfo();
|
|
|
|
this.creator.fromDataModel(entity.getCreator());
|
2017-12-09 23:31:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public DMP toDataModel() {
|
|
|
|
DMP dataManagementPlanEntity = new DMP();
|
|
|
|
dataManagementPlanEntity.setId(this.id);
|
|
|
|
dataManagementPlanEntity.setOrganisations(new HashSet<entities.Organisation>(new DomainModelConverter<entities.Organisation,Organisation>().toDataModel(this.organizations)));
|
|
|
|
dataManagementPlanEntity.setResearchers(new HashSet<entities.Researcher>(new DomainModelConverter<entities.Researcher,Researcher>().toDataModel(this.researchers)));
|
|
|
|
dataManagementPlanEntity.setVersion(this.version);
|
|
|
|
dataManagementPlanEntity.setPrevious(this.previous);
|
|
|
|
dataManagementPlanEntity.setLabel(this.label);
|
2017-12-11 10:48:18 +01:00
|
|
|
dataManagementPlanEntity.setProject(this.project.toDataModel());
|
2017-12-09 23:31:07 +01:00
|
|
|
return dataManagementPlanEntity;
|
|
|
|
}
|
|
|
|
}
|