Adds new endpoint to get overview single public DMP.
This commit is contained in:
parent
d80a0837af
commit
d4832731af
|
@ -119,6 +119,17 @@ public class DMPs extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity getOverviewSinglePublic(@PathVariable String id) {
|
||||||
|
try {
|
||||||
|
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSinglePublic(id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
|
|
|
@ -351,6 +351,19 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DataManagementPlanOverviewModel getOverviewSinglePublic(String id) throws Exception{
|
||||||
|
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||||
|
if (dataManagementPlanEntity != null && dataManagementPlanEntity.getStatus() == 1) {
|
||||||
|
DataManagementPlanOverviewModel datamanagementPlan = new DataManagementPlanOverviewModel();
|
||||||
|
datamanagementPlan.fromDataModelDatasets(dataManagementPlanEntity);
|
||||||
|
datamanagementPlan.setDatasets(datamanagementPlan.getDatasets().stream().filter(dataset -> dataset.getStatus() == Dataset.Status.FINALISED.getValue()).collect(Collectors.toList()));
|
||||||
|
return datamanagementPlan;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Exception("Selected DMP is not public");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<DataManagementPlan> getWithCriteria(DMPDao dmpsRepository, DataManagementPlanCriteriaRequest dataManagementPlanCriteria, Principal principal) throws IllegalAccessException, InstantiationException {
|
public List<DataManagementPlan> getWithCriteria(DMPDao dmpsRepository, DataManagementPlanCriteriaRequest dataManagementPlanCriteria, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||||
UUID principalID = principal.getId();
|
UUID principalID = principal.getId();
|
||||||
QueryableList<DMP> items = dmpsRepository.getWithCriteria(dataManagementPlanCriteria.getCriteria()).withHint(HintedModelFactory.getHint(DataManagementPlan.class));
|
QueryableList<DMP> items = dmpsRepository.getWithCriteria(dataManagementPlanCriteria.getCriteria()).withHint(HintedModelFactory.getHint(DataManagementPlan.class));
|
||||||
|
|
Loading…
Reference in New Issue