Fix issue with project creation
This commit is contained in:
parent
8899e1ba65
commit
58ecadd79b
|
@ -859,21 +859,24 @@ public class DataManagementPlanManager {
|
||||||
eu.eudat.data.entities.Project projectEntity = projectDao.getWithCritetia(criteria).toList().stream().max(Comparator.comparing(project1 -> project1.getModified().getTime())).orElse(null);
|
eu.eudat.data.entities.Project projectEntity = projectDao.getWithCritetia(criteria).toList().stream().max(Comparator.comparing(project1 -> project1.getModified().getTime())).orElse(null);
|
||||||
if (projectEntity != null) project.setId(projectEntity.getId());
|
if (projectEntity != null) project.setId(projectEntity.getId());
|
||||||
else {
|
else {
|
||||||
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
createExternalProject(project, projectDao);
|
||||||
if (project.getId() == null) project.setId(UUID.randomUUID());
|
|
||||||
projectDao.createOrUpdate(project);
|
|
||||||
metricsManager.increaseValue(MetricNames.PROJECT, 1, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
createExternalProject(project, projectDao);
|
||||||
if (project.getId() == null) project.setId(UUID.randomUUID());
|
|
||||||
projectDao.createOrUpdate(project);
|
|
||||||
metricsManager.increaseValue(MetricNames.PROJECT, 1, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createExternalProject(Project project, ProjectDao projectDao) {
|
||||||
|
if (project.getStartdate() == null) project.setStartdate(new Date());
|
||||||
|
if (project.getEnddate() == null) project.setEnddate(new Date());
|
||||||
|
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
||||||
|
if (project.getId() == null) project.setId(UUID.randomUUID());
|
||||||
|
projectDao.createOrUpdate(project);
|
||||||
|
metricsManager.increaseValue(MetricNames.PROJECT, 1, null);
|
||||||
|
}
|
||||||
|
|
||||||
private void copyDatasets(DMP newDmp, DatasetDao datasetDao) {
|
private void copyDatasets(DMP newDmp, DatasetDao datasetDao) {
|
||||||
List<CompletableFuture<Dataset>> futures = new LinkedList<>();
|
List<CompletableFuture<Dataset>> futures = new LinkedList<>();
|
||||||
for (Dataset dataset : newDmp.getDataset()) {
|
for (Dataset dataset : newDmp.getDataset()) {
|
||||||
|
|
Loading…
Reference in New Issue