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