Fixes bug on not populating the Project entity with Grant when Project is not selected, on DMP creation.

This commit is contained in:
gkolokythas 2019-08-22 14:29:33 +03:00
parent 218595c358
commit f5866107ad
3 changed files with 23 additions and 1 deletions

View File

@ -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.funder;
if (entity.getContent() != null) this.content = entity.getContent();
}

View File

@ -254,6 +254,25 @@ public class Project implements DataEntity<Project, UUID> {
if (entity.getContent() != null) this.content = entity.getContent();
}
public Project projectFromGrant(Grant grant) {
Project project = new Project();
project.setDescription(grant.getDescription());
project.setLabel(grant.getLabel());
project.setAbbreviation(grant.getAbbreviation());
project.setCreated(new Date());
project.setDefinition(grant.getDefinition());
project.setDmps(grant.getDmps());
project.setStartdate(grant.getStartdate());
project.setEnddate(grant.getEnddate());
project.setModified(new Date());
project.setUri(grant.getUri());
project.setContent(grant.getContent());
project.setReference(grant.getReference());
project.setStatus(grant.getStatus());
return project;
}
@Override
public UUID getKeys() {
return this.id;

View File

@ -428,6 +428,9 @@ public class DataManagementPlanManager {
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao());
createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao(), user);
if (newDmp.getProject().getLabel() == null) {
newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant()));
}
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao());
DMP dmp;