Search in sources :

Example 1 with AnalysisFileDTO

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

Example 2 with 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;
}
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) ArrayList(java.util.ArrayList) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) IUser(com.odysseusinc.arachne.portal.model.IUser) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) AnalysisFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with AnalysisFileDTO

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;
}
Also used : PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) UserInfoDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserInfoDTO) AnalysisFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO)

Example 4 with 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;
}
Also used : AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) AnalysisFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO) SubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionFile)

Aggregations

AnalysisFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.AnalysisFileDTO)4 AnalysisFile (com.odysseusinc.arachne.portal.model.AnalysisFile)3 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)2 ApiOperation (io.swagger.annotations.ApiOperation)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 PermissionsDTO (com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO)1 UserInfoDTO (com.odysseusinc.arachne.portal.api.v1.dto.UserInfoDTO)1 IUser (com.odysseusinc.arachne.portal.model.IUser)1 SubmissionFile (com.odysseusinc.arachne.portal.model.SubmissionFile)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 GET (org.springframework.web.bind.annotation.RequestMethod.GET)1 POST (org.springframework.web.bind.annotation.RequestMethod.POST)1 PUT (org.springframework.web.bind.annotation.RequestMethod.PUT)1