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);
}
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);
}
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;
}
Aggregations