Search in sources :

Example 76 with JsonResult

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.

the class BaseSubmissionController method approveSubmission.

@ApiOperation("Approve submission for execute")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/approve", method = POST)
public JsonResult<DTO> approveSubmission(Principal principal, @PathVariable("submissionId") Long id, @RequestBody @Valid ApproveDTO approveDTO) throws PermissionDeniedException, NotExistException, IOException {
    Boolean isApproved = approveDTO.getIsApproved();
    IUser user = getUser(principal);
    T updatedSubmission = submissionService.approveSubmission(id, isApproved, approveDTO.getComment(), user);
    DTO updatedSubmissionDTO = conversionService.convert(updatedSubmission, getSubmissionDTOClass());
    return new JsonResult<>(NO_ERROR, updatedSubmissionDTO);
}
Also used : PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) GET(org.springframework.web.bind.annotation.RequestMethod.GET) POST(org.springframework.web.bind.annotation.RequestMethod.POST) IUser(com.odysseusinc.arachne.portal.model.IUser) ResultFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO) FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) BaseSubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionDTO) ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) SubmissionStatusHistoryElementDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO) UploadFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO) CommonAnalysisExecutionStatusDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonAnalysisExecutionStatusDTO) CreateSubmissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateSubmissionsDTO) SubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO) SubmissionDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionDTO) BaseSubmissionAndAnalysisTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseSubmissionAndAnalysisTypeDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 77 with JsonResult

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult in project ArachneCentralAPI by OHDSI.

the class BaseAchillesController method getFile.

@ApiOperation("Get file contents")
@RequestMapping(value = { "datasource/{id}/files/{filename:.*}", "datasource/{id}/files/{filepath:.*}/{filename:.*}" }, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public JsonResult<JsonNode> getFile(@PathVariable("id") Long datasourceId, @RequestParam(name = "char", required = false) Long characterizationId, @PathVariable(value = "filepath", required = false) String path, @PathVariable("filename") String filename) throws NotExistException, IOException {
    final String filepath = StringUtils.isBlank(path) ? filename : path + File.separator + filename;
    DS dataSource = checkDataSource(datasourceId);
    if (characterizationId == null) {
        characterizationId = achillesService.getLatestCharacterizationId(dataSource);
    }
    AchillesFile file = achillesService.getAchillesFile(characterizationId, filepath).orElseThrow(() -> new NotExistException(String.format("File %s not found", filepath), AchillesFile.class));
    JsonObject jsonObject = file.getData();
    JsonNode node = objectMapper.readTree(new Gson().toJson(jsonObject));
    return new JsonResult<>(NO_ERROR, node);
}
Also used : JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) JsonNode(com.fasterxml.jackson.databind.JsonNode) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) AchillesFile(com.odysseusinc.arachne.portal.model.achilles.AchillesFile) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 78 with JsonResult

use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult 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)

Aggregations

JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)71 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)58 ApiOperation (io.swagger.annotations.ApiOperation)55 IUser (com.odysseusinc.arachne.portal.model.IUser)22 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)17 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)17 ResponseEntity (org.springframework.http.ResponseEntity)16 GET (org.springframework.web.bind.annotation.RequestMethod.GET)10 POST (org.springframework.web.bind.annotation.RequestMethod.POST)10 PUT (org.springframework.web.bind.annotation.RequestMethod.PUT)10 NotUniqueException (com.odysseusinc.arachne.portal.exception.NotUniqueException)6 FieldError (org.springframework.validation.FieldError)6 PermissionDeniedException (com.odysseusinc.arachne.portal.exception.PermissionDeniedException)5 ValidationException (com.odysseusinc.arachne.portal.exception.ValidationException)5 AnalysisFile (com.odysseusinc.arachne.portal.model.AnalysisFile)5 DataNode (com.odysseusinc.arachne.portal.model.DataNode)5 IOException (java.io.IOException)5 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)4 FileDTO (com.odysseusinc.arachne.portal.api.v1.dto.FileDTO)4 SubmissionFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO)4