use of com.odysseusinc.arachne.storage.model.ArachneFileMeta in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionServiceImpl method createResultFilesBatch.
@Override
@Transactional
public List<ResultFile> createResultFilesBatch(List<FileSaveRequest> fileSaveRequests, Submission submission, Long createById) throws IOException {
fileSaveRequests.forEach(entry -> entry.setDestinationFilepath(contentStorageHelper.getResultFilesDir(submission, entry.getDestinationFilepath())));
List<ArachneFileMeta> metaList = contentStorageService.saveBatch(fileSaveRequests, createById);
return metaList.stream().map(fm -> {
ResultFile resultFile = new ResultFile();
resultFile.setSubmission(submission);
resultFile.setPath(fm.getPath());
return resultFile;
}).collect(Collectors.toList());
}
use of com.odysseusinc.arachne.storage.model.ArachneFileMeta in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionServiceImpl method getResultFileAndCheckPermission.
@Override
public ArachneFileMeta getResultFileAndCheckPermission(IUser user, Submission submission, Long analysisId, String fileUuid) throws PermissionDeniedException {
ArachneFileMeta byFileUuid = contentStorageService.getFileByIdentifier(fileUuid);
checkSubmissionPermission(user, submission);
return byFileUuid;
}
use of com.odysseusinc.arachne.storage.model.ArachneFileMeta in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionServiceImpl method deleteSubmissionResultFile.
@Override
public boolean deleteSubmissionResultFile(Long submissionId, ResultFile resultFile) throws NotExistException, ValidationException {
final T submission = submissionRepository.findByIdAndStatusIn(submissionId, Collections.singletonList(IN_PROGRESS.name()));
throwNotExistExceptionIfNull(submission, submissionId);
Optional.ofNullable(resultFile).orElseThrow(() -> new NotExistException(String.format(RESULT_FILE_NOT_EXISTS_EXCEPTION, resultFile.getId(), submission.getId()), ResultFile.class));
ArachneFileMeta fileMeta = contentStorageService.getFileByPath(resultFile.getPath());
if (fileMeta.getCreatedBy() == null) {
// not manually uploaded
throw new ValidationException(String.format(FILE_NOT_UPLOADED_MANUALLY_EXCEPTION, resultFile.getId()));
}
deleteSubmissionResultFile(resultFile);
submission.getResultFiles().remove(resultFile);
submission.setUpdated(new Date());
saveSubmission(submission);
return true;
}
use of com.odysseusinc.arachne.storage.model.ArachneFileMeta in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionServiceImpl method createResultFile.
@Override
@Transactional
public ResultFile createResultFile(Path filePath, String name, Submission submission, Long createById) throws IOException {
ResultFile resultFile = new ResultFile();
resultFile.setSubmission(submission);
ArachneFileMeta fileMeta = contentStorageService.saveFile(filePath.toFile(), contentStorageHelper.getResultFilesDir(submission, name), createById);
resultFile.setPath(fileMeta.getPath());
return resultFile;
}
use of com.odysseusinc.arachne.storage.model.ArachneFileMeta in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method getResultFiles.
@ApiOperation("Get result files of the submission.")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/results", method = GET)
public List<ResultFileDTO> getResultFiles(Principal principal, @PathVariable("submissionId") Long submissionId, @RequestParam(value = "path", required = false, defaultValue = "") String path, @RequestParam(value = "real-name", required = false) String realName) throws PermissionDeniedException, IOException {
IUser user = userService.getByEmail(principal.getName());
ResultFileSearch resultFileSearch = new ResultFileSearch();
resultFileSearch.setPath(path);
resultFileSearch.setRealName(realName);
List<? extends ArachneFileMeta> resultFileList = submissionService.getResultFiles(user, submissionId, resultFileSearch);
String resultFilesPath = contentStorageHelper.getResultFilesDir(Submission.class, submissionId, null);
return resultFileList.stream().map(rf -> {
ResultFileDTO rfDto = conversionService.convert(rf, ResultFileDTO.class);
rfDto.setSubmissionId(submissionId);
rfDto.setRelativePath(contentStorageHelper.getRelativePath(resultFilesPath, rfDto.getPath()));
return rfDto;
}).collect(Collectors.toList());
}
Aggregations