Return the id of the cloned dmp when calling the dmp/clone endpoint

This commit is contained in:
George Kalampokis 2020-09-02 18:32:12 +03:00
parent 3bcafc0dd4
commit 8951b61b3b
2 changed files with 6 additions and 4 deletions

View File

@ -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<ResponseItem<DMP>> 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<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE));
ResponseEntity<ResponseItem<UUID>> 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<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(cloneId));
}
@Transactional

View File

@ -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 {