Fix issue when creating new DMPs

This commit is contained in:
George Kalampokis 2020-03-10 18:15:42 +02:00
parent 4a7a947b66
commit 2329ad8bed
1 changed files with 13 additions and 0 deletions

View File

@ -760,6 +760,11 @@ public class DataManagementPlanManager {
criteria.setReference(grant.getReference()); criteria.setReference(grant.getReference());
eu.eudat.data.entities.Grant grantEntity = grantDao.getWithCriteria(criteria).getSingleOrDefault(); eu.eudat.data.entities.Grant grantEntity = grantDao.getWithCriteria(criteria).getSingleOrDefault();
if (grantEntity != null) grant.setId(grantEntity.getId()); if (grantEntity != null) grant.setId(grantEntity.getId());
else {
grant.setType(Grant.GrantType.EXTERNAL.getValue());
grant.setCreationUser(null);
grantDao.createOrUpdate(grant);
}
} }
else { else {
grant.setType(Grant.GrantType.EXTERNAL.getValue()); grant.setType(Grant.GrantType.EXTERNAL.getValue());
@ -777,6 +782,9 @@ public class DataManagementPlanManager {
criteria.setReference(funder.getReference()); criteria.setReference(funder.getReference());
eu.eudat.data.entities.Funder funderEntity = funderDao.getWithCritetia(criteria).getSingleOrDefault(); eu.eudat.data.entities.Funder funderEntity = funderDao.getWithCritetia(criteria).getSingleOrDefault();
if (funderEntity != null) funder.setId(funderEntity.getId()); if (funderEntity != null) funder.setId(funderEntity.getId());
else {
funderDao.createOrUpdate(funder);
}
} }
else { else {
funderDao.createOrUpdate(funder); funderDao.createOrUpdate(funder);
@ -792,6 +800,11 @@ public class DataManagementPlanManager {
criteria.setReference(project.getReference()); criteria.setReference(project.getReference());
eu.eudat.data.entities.Project projectEntity = projectDao.getWithCritetia(criteria).getSingleOrDefault(); eu.eudat.data.entities.Project projectEntity = projectDao.getWithCritetia(criteria).getSingleOrDefault();
if (projectEntity != null) project.setId(projectEntity.getId()); if (projectEntity != null) project.setId(projectEntity.getId());
else {
project.setType(Project.ProjectType.EXTERNAL.getValue());
if (project.getId() == null) project.setId(UUID.randomUUID());
projectDao.createOrUpdate(project);
}
} }
else { else {
project.setType(Project.ProjectType.EXTERNAL.getValue()); project.setType(Project.ProjectType.EXTERNAL.getValue());