use of com.odysseusinc.arachne.portal.exception.NotExistException in project ArachneCentralAPI by OHDSI.
the class BaseAchillesController method getLatestCharacterization.
@ApiOperation("List latest characterization for given datasource")
@RequestMapping(value = "datasource/{id}", method = RequestMethod.GET)
public JsonResult<CharacterizationDTO> getLatestCharacterization(@PathVariable("id") Long datasourceId) throws NotExistException {
DS dataSource = checkDataSource(datasourceId);
Characterization characterization = achillesService.getLatestCharacterization(dataSource).orElseThrow(() -> new NotExistException(String.format("Characterization doesn't exist for dataSource: %s", datasourceId), Characterization.class));
JsonResult<CharacterizationDTO> result = new JsonResult<>();
result.setErrorCode(NO_ERROR.getCode());
CharacterizationDTO dto = conversionService.convert(characterization, CharacterizationDTO.class);
result.setResult(dto);
return result;
}
use of com.odysseusinc.arachne.portal.exception.NotExistException in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method list.
@ApiOperation("List analyses.")
@RequestMapping(value = "/api/v1/analysis-management/analyses", method = GET)
public JsonResult<List<D>> list(Principal principal, @RequestParam("study-id") Long studyId) throws PermissionDeniedException, NotExistException {
JsonResult<List<D>> result;
IUser user = userService.getByUsername(principal.getName());
if (user == null) {
result = new JsonResult<>(PERMISSION_DENIED);
return result;
}
Iterable<T> analyses = analysisService.list(user, studyId);
result = new JsonResult<>(NO_ERROR);
List<D> analysisDTOs = StreamSupport.stream(analyses.spliterator(), false).map(analysis -> conversionService.convert(analysis, getAnalysisDTOClass())).collect(Collectors.toList());
result.setResult(analysisDTOs);
return result;
}
use of com.odysseusinc.arachne.portal.exception.NotExistException in project ArachneCentralAPI by OHDSI.
the class BaseUserController method linkUserToDataNode.
@ApiOperation("Link U to DataNode")
@PostMapping(value = "/api/v1/user-management/datanodes/{datanodeSid}/users")
public JsonResult linkUserToDataNode(@PathVariable("datanodeSid") Long datanodeId, @RequestBody CommonLinkUserToDataNodeDTO linkUserToDataNode) throws NotExistException, AlreadyExistException {
final DN dataNode = Optional.ofNullable(baseDataNodeService.getById(datanodeId)).orElseThrow(() -> new NotExistException(String.format(DATA_NODE_NOT_FOUND_EXCEPTION, datanodeId), DataNode.class));
final U user = userService.getByUsernameInAnyTenant(linkUserToDataNode.getUserName());
if (Objects.isNull(user)) {
throw new NotExistException(String.format("User %s not found", linkUserToDataNode.getUserName()), IUser.class);
}
baseDataNodeService.linkUserToDataNode(dataNode, user);
return new JsonResult<>(NO_ERROR);
}
Aggregations