Fix issue with project creation

This commit is contained in:
George Kalampokis 2021-11-09 10:19:20 +02:00
parent 8899e1ba65
commit 58ecadd79b
1 changed files with 11 additions and 8 deletions

View File

@ -859,20 +859,23 @@ public class DataManagementPlanManager {
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());
else {
project.setType(Project.ProjectType.EXTERNAL.getValue());
if (project.getId() == null) project.setId(UUID.randomUUID());
projectDao.createOrUpdate(project);
metricsManager.increaseValue(MetricNames.PROJECT, 1, null);
createExternalProject(project, projectDao);
}
}
else {
createExternalProject(project, projectDao);
}
}
}
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) {
List<CompletableFuture<Dataset>> futures = new LinkedList<>();