From 8951b61b3b208d5a100fc82be48a38ff85db6b41 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Wed, 2 Sep 2020 18:32:12 +0300 Subject: [PATCH] Return the id of the cloned dmp when calling the dmp/clone endpoint --- .../web/src/main/java/eu/eudat/controllers/DMPs.java | 6 +++--- .../eu/eudat/logic/managers/DataManagementPlanManager.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java index 0460b92d4..29961db46 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPs.java @@ -235,9 +235,9 @@ public class DMPs extends BaseController { @RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json") public @ResponseBody - ResponseEntity> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception { - this.dataManagementPlanManager.clone(dataManagementPlan, principal); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE)); + ResponseEntity> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception { + UUID cloneId = this.dataManagementPlanManager.clone(dataManagementPlan, principal); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).payload(cloneId)); } @Transactional diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index d0fefe13f..412343668 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -559,7 +559,7 @@ public class DataManagementPlanManager { } } - public void clone(DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception { + public UUID clone(DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception { DMP newDmp = dataManagementPlan.toDataModel(); UserInfo user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build(); @@ -595,6 +595,8 @@ public class DataManagementPlanManager { newDmp.setDataset(new HashSet<>(databaseRepository.getDatasetDao().getWithCriteria(criteria1).toList())); this.updateIndex(newDmp); + + return newDmp.getId(); } public void delete(UUID uuid) throws DMPWithDatasetsDeleteException, IOException {