use of com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method getFileContent.
@ApiOperation("Get analysis code file.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/code-files/{fileUuid}", method = GET)
public JsonResult<AnalysisFileDTO> getFileContent(@PathVariable("analysisId") Long analysisId, @RequestParam(defaultValue = "true") Boolean withContent, @PathVariable("fileUuid") String uuid) throws PermissionDeniedException, NotExistException, IOException {
AnalysisFile analysisFile = analysisService.getAnalysisFile(analysisId, uuid);
AnalysisFileDTO analysisFileDTO = conversionService.convert(analysisFile, AnalysisFileDTO.class);
if (withContent) {
analysisFileDTO = (AnalysisFileDTO) FileDtoContentHandler.getInstance(analysisFileDTO, analysisService.getPath(analysisFile).toFile()).withPdfConverter(toPdfConverter::convert).handle();
}
return new JsonResult<>(NO_ERROR, analysisFileDTO);
}
use of com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO in project ArachneCentralAPI by OHDSI.
the class BaseAnalysisController method uploadFile.
@ApiOperation("Upload file to attach to analysis.")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/upload", method = POST)
public JsonResult<List<AnalysisFileDTO>> uploadFile(Principal principal, @Valid UploadFileDTO uploadFileDTO, @PathVariable("analysisId") Long id) throws PermissionDeniedException, NotExistException, IOException {
IUser user = getUser(principal);
T analysis = analysisService.getById(id);
JsonResult<List<AnalysisFileDTO>> result = new JsonResult<>(NO_ERROR);
List<AnalysisFileDTO> createdFiles = new ArrayList<>();
if (uploadFileDTO.getFile() != null) {
AnalysisFile createdFile = analysisService.saveFile(uploadFileDTO.getFile(), user, analysis, uploadFileDTO.getLabel(), uploadFileDTO.getExecutable(), null);
createdFiles.add(conversionService.convert(createdFile, AnalysisFileDTO.class));
} else {
if (StringUtils.hasText(uploadFileDTO.getLink())) {
AnalysisFile createdFile = analysisService.saveFile(uploadFileDTO.getLink(), user, analysis, uploadFileDTO.getLabel(), uploadFileDTO.getExecutable());
createdFiles.add(conversionService.convert(createdFile, AnalysisFileDTO.class));
} else {
result.setErrorCode(VALIDATION_ERROR.getCode());
}
}
result.setResult(createdFiles);
return result;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO in project ArachneCentralAPI by OHDSI.
the class AnalysisFileToAnalysisFileDTOConverter method convert.
@Override
public AnalysisFileDTO convert(AnalysisFile source) {
AnalysisFileDTO analysisFileDTO = new AnalysisFileDTO();
analysisFileDTO.setImported(source.getDataReference() != null);
analysisFileDTO.setUuid(source.getUuid());
analysisFileDTO.setFileId(source.getId());
analysisFileDTO.setName(source.getRealName());
analysisFileDTO.setCreated(source.getCreated());
analysisFileDTO.setUpdated(source.getUpdated());
analysisFileDTO.setIsExecutable(source.getExecutable());
analysisFileDTO.setLabel(source.getLabel());
analysisFileDTO.setEntryPoint(source.getEntryPoint());
analysisFileDTO.setAuthor(conversionService.convert(source.getAuthor(), UserInfoDTO.class));
analysisFileDTO.setUpdatedBy(conversionService.convert(source.getUpdatedBy(), UserInfoDTO.class));
analysisFileDTO.setAnalysisId(source.getAnalysis().getId());
analysisFileDTO.setDocType(source.getContentType());
analysisFileDTO.setVersion(source.getVersion());
analysisFileDTO.setPermissions(conversionService.convert(source, PermissionsDTO.class));
analysisFileDTO.setAntivirusStatus(source.getAntivirusStatus());
analysisFileDTO.setAntivirusDescription(source.getAntivirusDescription());
return analysisFileDTO;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO in project ArachneCentralAPI by OHDSI.
the class ArachneFileToFileContentDTOConverter method convert.
@Override
public AnalysisFileDTO convert(ArachneFile source) {
AnalysisFileDTO fileContentDTO = new AnalysisFileDTO();
fileContentDTO.setUuid(source.getUuid());
fileContentDTO.setName(source.getRealName());
fileContentDTO.setCreated(source.getCreated());
fileContentDTO.setLabel(source.getLabel());
if (source instanceof AnalysisFile && ((AnalysisFile) source).getAnalysis() != null) {
fileContentDTO.setAnalysisId(((AnalysisFile) source).getAnalysis().getId());
}
if (source instanceof SubmissionFile) {
fileContentDTO.setDocType(source.getContentType());
}
return fileContentDTO;
}
Aggregations