use of com.odysseusinc.arachne.portal.model.StudyFile in project ArachneCentralAPI by OHDSI.
the class BaseStudyServiceImpl method getAllStudyFilesExceptLinks.
@Override
@PreAuthorize("hasPermission(#studyId, 'Study', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).ACCESS_STUDY)")
public void getAllStudyFilesExceptLinks(Long studyId, String archiveName, OutputStream os) throws IOException {
T study = studyRepository.findOne(studyId);
Path storeFilesPath = fileService.getPath(study);
List<StudyFile> files = study.getFiles().stream().filter(file -> StringUtils.isEmpty(file.getLink())).collect(Collectors.toList());
fileService.archiveFiles(os, storeFilesPath, files);
}
use of com.odysseusinc.arachne.portal.model.StudyFile 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;
}
use of com.odysseusinc.arachne.portal.model.StudyFile in project ArachneCentralAPI by OHDSI.
the class StudyFileServiceImpl method getFileInputStream.
@Override
public InputStream getFileInputStream(AbstractStudyFile studyFile) throws FileNotFoundException {
Objects.requireNonNull(studyFile, "File must not be null");
final File file = getPathToFile(studyFile).toFile();
if (!file.exists()) {
if (!StringUtils.isEmpty(studyFile.getLink())) {
InputStream response = getInputStream(studyFile);
if (response != null) {
return response;
}
}
throw new FileNotFoundException();
}
return new FileInputStream(file);
}
use of com.odysseusinc.arachne.portal.model.StudyFile in project ArachneCentralAPI by OHDSI.
the class BaseStudyToStudyDTOConverter method convert.
@Override
public DTO convert(final S source) {
final DTO studyDTO = createResultObject();
studyDTO.setStatus(conversionService.convert(source.getStatus(), StudyStatusDTO.class));
studyDTO.setTitle(source.getTitle());
studyDTO.setType(conversionService.convert(source.getType(), StudyTypeDTO.class));
studyDTO.setEndDate(source.getEndDate());
studyDTO.setStartDate(source.getStartDate());
studyDTO.setDescription(source.getDescription());
if (!CollectionUtils.isEmpty(source.getParticipants())) {
studyDTO.setParticipants(source.getParticipants().stream().map(link -> conversionService.convert(link, ParticipantDTO.class)).collect(Collectors.toList()));
}
final List<StudyDataSourceLink> foundLinks = studyService.getLinksByStudyId(source.getId(), EntityUtils.fromAttributePaths("dataSource.dataNode.dataNodeUsers.user"));
for (final StudyDataSourceLink studyDataSourceLink : foundLinks) {
final DataSourceDTO dataSourceDTO = conversionService.convert(studyDataSourceLink, DataSourceDTO.class);
studyDTO.getDataSources().add(dataSourceDTO);
}
List<Analysis> analyses = getAnalyses(source);
for (final Analysis analysis : analyses) {
studyDTO.getAnalyses().add(conversionService.convert(analysis, BaseAnalysisDTO.class));
}
List<StudyFile> files = studyService.getFilesByStudyId(source.getId(), EntityUtils.fromAttributePaths("author"));
for (final StudyFile studyFile : files) {
studyDTO.getFiles().add(conversionService.convert(studyFile, StudyFileDTO.class));
}
studyDTO.setCreated(source.getCreated());
studyDTO.setUpdated(source.getUpdated());
studyDTO.setId(source.getId());
studyDTO.setPermissions(conversionService.convert(source, PermissionsDTO.class));
studyDTO.setPaperId(source.getPaper() == null ? null : source.getPaper().getId());
studyDTO.setPrivacy(source.getPrivacy());
proceedAdditionalFields(studyDTO, source);
return studyDTO;
}
Aggregations