Search in sources :

Example 31 with NotExistException

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;
}
Also used : Characterization(com.odysseusinc.arachne.portal.model.achilles.Characterization) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) CharacterizationDTO(com.odysseusinc.arachne.portal.api.v1.dto.CharacterizationDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 32 with NotExistException

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;
}
Also used : RequestParam(org.springframework.web.bind.annotation.RequestParam) Arrays(java.util.Arrays) UploadFilesDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFilesDTO) Valid(javax.validation.Valid) CommentUtils.getRecentCommentables(com.odysseusinc.arachne.portal.util.CommentUtils.getRecentCommentables) AnalysisLockDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisLockDTO) Analysis(com.odysseusinc.arachne.portal.model.Analysis) Commentable(com.odysseusinc.arachne.portal.api.v1.dto.Commentable) Sort(org.springframework.data.domain.Sort) ImportedFile(com.odysseusinc.arachne.portal.util.ImportedFile) Resource(org.springframework.core.io.Resource) MessagingUtils(com.odysseusinc.arachne.portal.service.messaging.MessagingUtils) FieldError(org.springframework.validation.FieldError) Set(java.util.Set) AnalysisFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO) Page(org.springframework.data.domain.Page) MockMultipartFile(org.springframework.mock.web.MockMultipartFile) IUser(com.odysseusinc.arachne.portal.model.IUser) IOUtils(org.apache.commons.io.IOUtils) SimpMessagingTemplate(org.springframework.messaging.simp.SimpMessagingTemplate) Stream(java.util.stream.Stream) AnalysisFilesSavingService(com.odysseusinc.arachne.portal.service.analysis.AnalysisFilesSavingService) VALIDATION_ERROR(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.VALIDATION_ERROR) DataReference(com.odysseusinc.arachne.portal.model.DataReference) BindingResult(org.springframework.validation.BindingResult) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) RequestBody(org.springframework.web.bind.annotation.RequestBody) SubmissionInsightDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO) NO_ERROR(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR) StreamSupport(java.util.stream.StreamSupport) CommonEntityRequestDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonEntityRequestDTO) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) IOException(java.io.IOException) HttpUtils.putFileContentToResponse(com.odysseusinc.arachne.portal.util.HttpUtils.putFileContentToResponse) SubmissionInsightUpdateDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightUpdateDTO) DataReferenceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataReferenceDTO) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) UpdateNotificationDTO(com.odysseusinc.arachne.portal.api.v1.dto.UpdateNotificationDTO) AnalysisUpdateDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisUpdateDTO) PathVariable(org.springframework.web.bind.annotation.PathVariable) AnalysisUnlockRequestDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisUnlockRequestDTO) Date(java.util.Date) URISyntaxException(java.net.URISyntaxException) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) LoggerFactory(org.slf4j.LoggerFactory) ValidationRuntimeException(com.odysseusinc.arachne.portal.exception.ValidationRuntimeException) ApiOperation(io.swagger.annotations.ApiOperation) PutMapping(org.springframework.web.bind.annotation.PutMapping) AnalysisUnlockRequest(com.odysseusinc.arachne.portal.model.AnalysisUnlockRequest) PERMISSION_DENIED(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.PERMISSION_DENIED) ToPdfConverter(com.odysseusinc.arachne.portal.service.ToPdfConverter) BaseSubmissionService(com.odysseusinc.arachne.portal.service.submission.BaseSubmissionService) BaseAnalysisService(com.odysseusinc.arachne.portal.service.analysis.BaseAnalysisService) AnalysisDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisDTO) AlreadyExistException(com.odysseusinc.arachne.portal.exception.AlreadyExistException) CommonAnalysisType(com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisType) UUID(java.util.UUID) ShortBaseAnalysisDTO(com.odysseusinc.arachne.portal.api.v1.dto.ShortBaseAnalysisDTO) JMSException(javax.jms.JMSException) Collectors(java.util.stream.Collectors) FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) List(java.util.List) Principal(java.security.Principal) DataReferenceService(com.odysseusinc.arachne.portal.service.DataReferenceService) AnalysisCreateDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisCreateDTO) AnalysisUnlockRequestStatus(com.odysseusinc.arachne.portal.model.AnalysisUnlockRequestStatus) SubmissionGroupDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionGroupDTO) NotUniqueException(com.odysseusinc.arachne.portal.exception.NotUniqueException) FileDtoContentHandler(com.odysseusinc.arachne.portal.api.v1.dto.converters.FileDtoContentHandler) ClassPathResource(org.springframework.core.io.ClassPathResource) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ObjectMessage(javax.jms.ObjectMessage) GET(org.springframework.web.bind.annotation.RequestMethod.GET) Submission(com.odysseusinc.arachne.portal.model.Submission) SubmissionGroupSearch(com.odysseusinc.arachne.portal.model.search.SubmissionGroupSearch) ValidationException(com.odysseusinc.arachne.portal.exception.ValidationException) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) HeraclesAnalysisService(com.odysseusinc.arachne.portal.service.analysis.heracles.HeraclesAnalysisService) JmsTemplate(org.springframework.jms.core.JmsTemplate) ProducerConsumerTemplate(com.odysseusinc.arachne.commons.service.messaging.ProducerConsumerTemplate) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) POST(org.springframework.web.bind.annotation.RequestMethod.POST) UploadFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO) DestinationResolver(org.springframework.jms.support.destination.DestinationResolver) ServiceNotAvailableException(com.odysseusinc.arachne.portal.exception.ServiceNotAvailableException) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) Logger(org.slf4j.Logger) DELETE(org.springframework.web.bind.annotation.RequestMethod.DELETE) CommonFilenameUtils(com.odysseusinc.arachne.commons.utils.CommonFilenameUtils) HttpServletResponse(javax.servlet.http.HttpServletResponse) BaseDataNodeService(com.odysseusinc.arachne.portal.service.BaseDataNodeService) PermissionDeniedException(com.odysseusinc.arachne.portal.exception.PermissionDeniedException) OptionDTO(com.odysseusinc.arachne.commons.api.v1.dto.OptionDTO) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) HeraclesAnalysisKind(com.odysseusinc.arachne.portal.service.analysis.heracles.HeraclesAnalysisKind) ConcurrentSkipListSet(java.util.concurrent.ConcurrentSkipListSet) DataNode(com.odysseusinc.arachne.portal.model.DataNode) MultipartFile(org.springframework.web.multipart.MultipartFile) ImportService(com.odysseusinc.arachne.portal.service.ImportService) NotEmptyException(com.odysseusinc.arachne.portal.exception.NotEmptyException) SubmissionInsightService(com.odysseusinc.arachne.portal.service.submission.SubmissionInsightService) Collections(java.util.Collections) StringUtils(org.springframework.util.StringUtils) InputStream(java.io.InputStream) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) GET(org.springframework.web.bind.annotation.RequestMethod.GET) POST(org.springframework.web.bind.annotation.RequestMethod.POST) PERMISSION_DENIED(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.PERMISSION_DENIED) UUID(java.util.UUID) IUser(com.odysseusinc.arachne.portal.model.IUser) ArrayList(java.util.ArrayList) List(java.util.List) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 33 with NotExistException

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);
}
Also used : DataNode(com.odysseusinc.arachne.portal.model.DataNode) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) PostMapping(org.springframework.web.bind.annotation.PostMapping) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)33 ApiOperation (io.swagger.annotations.ApiOperation)13 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)12 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)11 IUser (com.odysseusinc.arachne.portal.model.IUser)9 Date (java.util.Date)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 Study (com.odysseusinc.arachne.portal.model.Study)7 UserStudy (com.odysseusinc.arachne.portal.model.UserStudy)7 AlreadyExistException (com.odysseusinc.arachne.portal.exception.AlreadyExistException)6 NotUniqueException (com.odysseusinc.arachne.portal.exception.NotUniqueException)6 ValidationException (com.odysseusinc.arachne.portal.exception.ValidationException)5 FavouriteStudy (com.odysseusinc.arachne.portal.model.FavouriteStudy)5 DataNodeUser (com.odysseusinc.arachne.portal.model.DataNodeUser)4 ResultFile (com.odysseusinc.arachne.portal.model.ResultFile)4 User (com.odysseusinc.arachne.portal.model.User)4 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)3 CommonAnalysisType (com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisType)2 Analysis (com.odysseusinc.arachne.portal.model.Analysis)2 AnalysisUnlockRequest (com.odysseusinc.arachne.portal.model.AnalysisUnlockRequest)2