Fixed issue when finalizing datasets from the DMP Overview.

This commit is contained in:
George Kalampokis 2020-07-31 14:04:49 +03:00
parent feee5b49e9
commit 5d44d8bf45
1 changed files with 11 additions and 1 deletions

View File

@ -419,6 +419,9 @@ public class DataManagementPlanManager {
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao() apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasetsToBeFinalized())) .asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasetsToBeFinalized()))
.update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue()); .update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue());
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasetsToBeFinalized()))
.update(root -> root.<Date>get("finalizedat"), new Date());
List<UUID> datasetsToBeCanceled = new LinkedList<>(); List<UUID> datasetsToBeCanceled = new LinkedList<>();
for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) { for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) {
@ -894,8 +897,15 @@ public class DataManagementPlanManager {
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao() apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeFinalized.getUuids())) .asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeFinalized.getUuids()))
.update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue()); .update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue());
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeFinalized.getUuids()))
.update(root -> root.<Date>get("finalizedAt"), new Date());
List<Dataset> finalizedDatasets = dmp.getDataset().stream().filter(dataset -> datasetsToBeFinalized.getUuids().contains(dataset.getId())).collect(Collectors.toList()); List<Dataset> finalizedDatasets = dmp.getDataset().stream().filter(dataset -> datasetsToBeFinalized.getUuids().contains(dataset.getId())).collect(Collectors.toList());
finalizedDatasets.forEach(dataset -> dataset.setStatus(Dataset.Status.FINALISED.getValue())); finalizedDatasets.forEach(dataset ->{
dataset.setStatus(Dataset.Status.FINALISED.getValue());
dataset.setFinalizedAt(new Date());
dataset.setModified(new Date());
} );
indexDatasets.addAll(finalizedDatasets); indexDatasets.addAll(finalizedDatasets);
List<UUID> datasetsToBeCanceled = new LinkedList<>(); List<UUID> datasetsToBeCanceled = new LinkedList<>();
for (Dataset dataset : dmp.getDataset()) { for (Dataset dataset : dmp.getDataset()) {