Enriches models with Funder entity.
This commit is contained in:
parent
0d74177d6b
commit
efde5fe5a3
|
@ -157,6 +157,7 @@ public class Funder implements DataEntity<Funder, UUID> {
|
|||
this.created = entity.getCreated();
|
||||
this.definition = entity.getDefinition();
|
||||
this.modified = new Date();
|
||||
this.status = entity.getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -279,7 +279,7 @@ public class Grant implements DataEntity<Grant, UUID> {
|
|||
this.enddate = entity.getEnddate();
|
||||
this.modified = new Date();
|
||||
this.uri = entity.getUri();
|
||||
//this.funder = entity.funder;
|
||||
this.funder = entity.getFunder();
|
||||
if (entity.getContent() != null) this.content = entity.getContent();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.logic.utilities.builders.XmlBuilder;
|
|||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
|
||||
import eu.eudat.models.data.funder.Funder;
|
||||
import eu.eudat.models.data.helpermodels.Tuple;
|
||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
|
@ -40,6 +41,7 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
private List<UserInfoListingModel> users;
|
||||
private String doi;
|
||||
private Project project;
|
||||
private Funder funder;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -202,6 +204,13 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
this.project = project;
|
||||
}
|
||||
|
||||
public Funder getFunder() {
|
||||
return funder;
|
||||
}
|
||||
public void setFunder(Funder funder) {
|
||||
this.funder = funder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataManagementPlan fromDataModel(DMP entity) {
|
||||
this.id = entity.getId();
|
||||
|
@ -242,11 +251,15 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
|||
this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
|
||||
this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.doi = entity.getDoi();
|
||||
if (entity.getProject() != null) {
|
||||
|
||||
this.project = new Project();
|
||||
if (entity.getProject() != null)
|
||||
this.project = new Project().fromDataModel(entity.getProject());
|
||||
} else {
|
||||
this.project = null;
|
||||
}
|
||||
|
||||
this.funder = new Funder();
|
||||
if (entity.getGrant().getFunder() != null)
|
||||
this.funder.fromDataModel(entity.getGrant().getFunder());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.logic.utilities.builders.XmlBuilder;
|
|||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
||||
import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanProfile;
|
||||
import eu.eudat.models.data.funder.FunderDMPEditorModel;
|
||||
import eu.eudat.models.data.helpermodels.Tuple;
|
||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||
|
@ -40,6 +41,7 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
|||
private List<UserInfoListingModel> users;
|
||||
private List<UUID> datasetsToBeFinalized;
|
||||
private ProjectDMPEditorModel project;
|
||||
private FunderDMPEditorModel funder;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -202,6 +204,13 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
|||
this.project = project;
|
||||
}
|
||||
|
||||
public FunderDMPEditorModel getFunder() {
|
||||
return funder;
|
||||
}
|
||||
public void setFunder(FunderDMPEditorModel funder) {
|
||||
this.funder = funder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataManagementPlanEditorModel fromDataModel(DMP entity) {
|
||||
this.id = entity.getId();
|
||||
|
@ -243,6 +252,9 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
|||
this.project.getExistProject().fromDataModel(entity.getProject());
|
||||
this.associatedUsers = entity.getUsers().stream().map(item -> new UserListingModel().fromDataModel(item.getUser())).collect(Collectors.toList());
|
||||
this.users = entity.getUsers().stream().map(item -> new UserInfoListingModel().fromDataModel(item)).collect(Collectors.toList());
|
||||
this.funder = new FunderDMPEditorModel();
|
||||
this.funder.getExistFunder().fromDataModel(entity.getGrant().getFunder());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -281,6 +293,23 @@ public class DataManagementPlanEditorModel implements DataModel<DMP, DataManagem
|
|||
}
|
||||
}
|
||||
|
||||
if (this.funder != null) {
|
||||
if (this.funder.getExistFunder() != null && this.funder.getLabel() == null)
|
||||
dataManagementPlanEntity.getGrant().setFunder(this.funder.getExistFunder().toDataModel());
|
||||
else {
|
||||
Funder funder = new Funder();
|
||||
funder.setLabel(this.funder.getLabel());
|
||||
funder.setType(Funder.FunderType.INTERNAL.getValue());
|
||||
funder.setReference("dmp:" + this.funder.getLabel());
|
||||
funder.setDefinition("");
|
||||
funder.setCreated(new Date());
|
||||
funder.setStatus(Funder.Status.ACTIVE.getValue());
|
||||
funder.setModified(new Date());
|
||||
|
||||
dataManagementPlanEntity.getGrant().setFunder(funder);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.project != null) {
|
||||
if (this.project.getExistProject() != null && this.project.getLabel() == null && this.project.getDescription() == null)
|
||||
dataManagementPlanEntity.setProject(this.project.getExistProject().toDataModel());
|
||||
|
|
|
@ -11,7 +11,7 @@ public class Funder implements DataModel<eu.eudat.data.entities.Funder, Funder>
|
|||
private String label;
|
||||
private String reference;
|
||||
private String definition;
|
||||
private eu.eudat.data.entities.Funder.Status status;
|
||||
private Short status;
|
||||
private Date created;
|
||||
private Date modified;
|
||||
private Integer type;
|
||||
|
@ -45,10 +45,10 @@ public class Funder implements DataModel<eu.eudat.data.entities.Funder, Funder>
|
|||
}
|
||||
|
||||
public Short getStatus() {
|
||||
return status.getValue();
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Short status) {
|
||||
this.status = eu.eudat.data.entities.Funder.Status.fromInteger(status);
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
|
@ -79,7 +79,7 @@ public class Funder implements DataModel<eu.eudat.data.entities.Funder, Funder>
|
|||
this.reference = entity.getReference();
|
||||
this.type = entity.getType();
|
||||
this.definition = entity.getDefinition();
|
||||
this.setStatus(entity.getStatus());
|
||||
this.status = entity.getStatus();
|
||||
this.created = entity.getCreated();
|
||||
this.modified = entity.getModified();
|
||||
return this;
|
||||
|
|
|
@ -5,7 +5,6 @@ import eu.eudat.data.entities.UserInfo;
|
|||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.data.files.ContentFile;
|
||||
import eu.eudat.models.data.funder.FunderDMPEditorModel;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
@ -31,8 +30,7 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
|||
private Date modified;
|
||||
private String description;
|
||||
private List<ContentFile> files;
|
||||
private FunderDMPEditorModel funder;
|
||||
|
||||
private UUID funderId;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
|
@ -146,11 +144,11 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
|||
this.files = files;
|
||||
}
|
||||
|
||||
public FunderDMPEditorModel getFunder() {
|
||||
return funder;
|
||||
public UUID getFunderId() {
|
||||
return funderId;
|
||||
}
|
||||
public void setFunder(FunderDMPEditorModel funder) {
|
||||
this.funder = funder;
|
||||
public void setFunderId(UUID funderId) {
|
||||
this.funderId = funderId;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -169,9 +167,8 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
|||
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));
|
||||
this.funder = new FunderDMPEditorModel();
|
||||
if (entity.getFunder() != null)
|
||||
this.funder.getExistFunder().fromDataModel(entity.getFunder());
|
||||
this.funderId = entity.getFunder().getId();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -192,22 +189,11 @@ public class Grant implements DataModel<eu.eudat.data.entities.Grant, Grant> {
|
|||
entity.setStatus(this.status != null ? this.getStatus() : eu.eudat.data.entities.Grant.Status.ACTIVE.getValue());
|
||||
entity.setModified(new Date());
|
||||
entity.setDescription(this.description);
|
||||
if (this.funder != null) {
|
||||
if (this.funder.getExistFunder() != null && this.funder.getLabel() == null)
|
||||
entity.setFunder(this.funder.getExistFunder().toDataModel());
|
||||
else {
|
||||
Funder funder = new Funder();
|
||||
funder.setLabel(this.funder.getLabel());
|
||||
funder.setType(Funder.FunderType.INTERNAL.getValue());
|
||||
funder.setReference("dmp:" + this.funder.getLabel());
|
||||
funder.setDefinition("");
|
||||
funder.setCreated(new Date());
|
||||
funder.setStatus(Funder.Status.ACTIVE.getValue());
|
||||
funder.setModified(new Date());
|
||||
|
||||
entity.setFunder(funder);
|
||||
}
|
||||
entity.setFunder(new Funder());
|
||||
if (this.funderId != null) {
|
||||
entity.getFunder().setId(this.funderId);
|
||||
}
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue