use of com.odysseusinc.arachne.storage.model.ArachneFileMeta in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionServiceImpl method storeExtractedFiles.
private void storeExtractedFiles(Submission submission, Path unzipDir, long uploadedBy) {
List<ResultFile> resultFiles = new ArrayList<>();
for (File extractedFile : CommonFileUtils.getFiles(unzipDir.toFile())) {
String relativeFilepath = unzipDir.relativize(extractedFile.toPath()).toString().replace('\\', '/');
String destinationPath = contentStorageHelper.getResultFilesDir(submission, relativeFilepath);
ArachneFileMeta arachneFileMeta = contentStorageService.saveFile(extractedFile, destinationPath, uploadedBy);
ResultFile resultFile = new ResultFile();
resultFile.setSubmission(submission);
resultFile.setPath(arachneFileMeta.getPath());
resultFiles.add(resultFile);
}
submissionResultFileRepository.saveAll(resultFiles);
}
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;
}
Aggregations