Return the id of the cloned dmp when calling the dmp/clone endpoint
This commit is contained in:
parent
3bcafc0dd4
commit
8951b61b3b
|
@ -235,9 +235,9 @@ public class DMPs extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<DMP>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
ResponseEntity<ResponseItem<UUID>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||||
this.dataManagementPlanManager.clone(dataManagementPlan, principal);
|
UUID cloneId = this.dataManagementPlanManager.clone(dataManagementPlan, principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(cloneId));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
|
@ -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();
|
DMP newDmp = dataManagementPlan.toDataModel();
|
||||||
|
|
||||||
UserInfo user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
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()));
|
newDmp.setDataset(new HashSet<>(databaseRepository.getDatasetDao().getWithCriteria(criteria1).toList()));
|
||||||
|
|
||||||
this.updateIndex(newDmp);
|
this.updateIndex(newDmp);
|
||||||
|
|
||||||
|
return newDmp.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(UUID uuid) throws DMPWithDatasetsDeleteException, IOException {
|
public void delete(UUID uuid) throws DMPWithDatasetsDeleteException, IOException {
|
||||||
|
|
Loading…
Reference in New Issue