Search in sources :

Example 1 with FileDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.FileDTO in project ArachneCentralAPI by OHDSI.

the class BasePaperController method getFile.

@ApiOperation("Get file of the Paper")
@RequestMapping(value = "/{id}/files/{fileUuid}", method = GET)
public FileDTO getFile(@PathVariable("id") Long id, @PathVariable("fileUuid") String uuid, @RequestParam("type") PaperFileType type, @RequestParam(defaultValue = "true") Boolean withContent) throws PermissionDeniedException, IOException {
    final AbstractPaperFile paperFile = paperService.getFile(id, uuid, type);
    FileDTO fileDto = conversionService.convert(paperFile, PaperFileDTO.class);
    if (withContent) {
        fileDto = FileDtoContentHandler.getInstance(fileDto, fileService.getPathToFile(paperFile).toFile()).withPdfConverter(toPdfConverter::convert).handle();
    }
    return fileDto;
}
Also used : PaperFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.PaperFileDTO) FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) UploadFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO) AbstractPaperFile(com.odysseusinc.arachne.portal.model.AbstractPaperFile) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with FileDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.FileDTO in project ArachneCentralAPI by OHDSI.

the class ArachneFileMetaToFileDTOConverter method convert.

@Override
public FileDTO convert(ArachneFileMeta source) {
    FileDTO fileDTO = new FileDTO();
    fileDTO.setUuid(source.getUuid());
    fileDTO.setPath(source.getPath());
    fileDTO.setName(source.getName());
    fileDTO.setCreated(source.getCreated());
    fileDTO.setUpdated(source.getUpdated());
    fileDTO.setDocType(source.getContentType());
    fileDTO.setAuthor(new UserInfoDTO(UserIdUtils.idToUuid(source.getCreatedBy())));
    return fileDTO;
}
Also used : FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) UserInfoDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserInfoDTO)

Example 3 with FileDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.FileDTO in project ArachneCentralAPI by OHDSI.

the class SubmissionFileToSubmissionFileDTOConverter method convert.

@Override
public SubmissionFileDTO convert(SubmissionFile source) {
    FileDTO fileDTO = conversionService.convert(source, FileDTO.class);
    fileDTO.setFileId(source.getId());
    SubmissionFileDTO submissionFileDTO = new SubmissionFileDTO();
    BeanUtils.copyProperties(fileDTO, submissionFileDTO);
    submissionFileDTO.setLabel(source.getLabel());
    submissionFileDTO.setVersion(source.getVersion());
    submissionFileDTO.setChecksum(source.getChecksum());
    return submissionFileDTO;
}
Also used : FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) SubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO) SubmissionFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO)

Example 4 with FileDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.FileDTO in project ArachneCentralAPI by OHDSI.

the class BaseAnalysisController method sendUnlockRequest.

@ApiOperation("Send analysis unlock request")
@RequestMapping(value = "/api/v1/analysis-management/analyses/{analysisId}/unlock-request", method = POST)
public JsonResult<FileDTO> sendUnlockRequest(Principal principal, @PathVariable("analysisId") Long analysisId, @RequestBody AnalysisUnlockRequestDTO analysisUnlockRequestDTO) throws NotExistException, PermissionDeniedException, AlreadyExistException {
    JsonResult result;
    final IUser user = getUser(principal);
    final AnalysisUnlockRequest unlockRequest = new AnalysisUnlockRequest();
    unlockRequest.setUser(user);
    unlockRequest.setStatus(AnalysisUnlockRequestStatus.PENDING);
    unlockRequest.setCreated(new Date());
    unlockRequest.setToken(UUID.randomUUID().toString().replace("-", ""));
    unlockRequest.setDescription(analysisUnlockRequestDTO.getDescription());
    try {
        final AnalysisUnlockRequest analysisUnlockRequest = analysisService.sendAnalysisUnlockRequest(analysisId, unlockRequest);
        analysisService.findLeads((T) analysisUnlockRequest.getAnalysis()).forEach(lead -> wsTemplate.convertAndSendToUser(lead.getUsername(), "/topic/invitations", new UpdateNotificationDTO()));
        result = new JsonResult<>(NO_ERROR);
    } catch (AlreadyExistException ex) {
        result = new JsonResult<>(VALIDATION_ERROR);
        result.setErrorMessage("Unlock request for the analysis was already created");
    }
    return result;
}
Also used : UpdateNotificationDTO(com.odysseusinc.arachne.portal.api.v1.dto.UpdateNotificationDTO) 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) AlreadyExistException(com.odysseusinc.arachne.portal.exception.AlreadyExistException) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) AnalysisUnlockRequest(com.odysseusinc.arachne.portal.model.AnalysisUnlockRequest) Date(java.util.Date) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with FileDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.FileDTO in project ArachneCentralAPI by OHDSI.

the class BaseStudyController method getFile.

@ApiOperation("Get file of the study.")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/files/{fileUuid}", method = GET)
public FileDTO getFile(@PathVariable("studyId") Long studyId, @PathVariable("fileUuid") String uuid, @RequestParam(defaultValue = "true") Boolean withContent) throws PermissionDeniedException, NotExistException, IOException {
    StudyFile studyFile = studyService.getStudyFile(studyId, uuid);
    FileDTO fileDto = conversionService.convert(studyFile, StudyFileContentDTO.class);
    if (withContent) {
        fileDto = FileDtoContentHandler.getInstance(fileDto, fileService.getPathToFile(studyFile).toFile()).withPdfConverter(toPdfConverter::convert).handle();
    }
    return fileDto;
}
Also used : FileDTO(com.odysseusinc.arachne.portal.api.v1.dto.FileDTO) UploadFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO) StudyFile(com.odysseusinc.arachne.portal.model.StudyFile) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

FileDTO (com.odysseusinc.arachne.portal.api.v1.dto.FileDTO)5 ApiOperation (io.swagger.annotations.ApiOperation)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)2 SubmissionFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO)2 UploadFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO)2 PaperFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.PaperFileDTO)1 ResultFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO)1 UpdateNotificationDTO (com.odysseusinc.arachne.portal.api.v1.dto.UpdateNotificationDTO)1 UserInfoDTO (com.odysseusinc.arachne.portal.api.v1.dto.UserInfoDTO)1 AlreadyExistException (com.odysseusinc.arachne.portal.exception.AlreadyExistException)1 AbstractPaperFile (com.odysseusinc.arachne.portal.model.AbstractPaperFile)1 AnalysisUnlockRequest (com.odysseusinc.arachne.portal.model.AnalysisUnlockRequest)1 IUser (com.odysseusinc.arachne.portal.model.IUser)1 StudyFile (com.odysseusinc.arachne.portal.model.StudyFile)1 SubmissionFile (com.odysseusinc.arachne.portal.model.SubmissionFile)1 Date (java.util.Date)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