use of com.odysseusinc.arachne.portal.model.Submission in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionServiceImpl method getSubmissionArchiveChunk.
@Override
public Path getSubmissionArchiveChunk(Long id, String updatePassword, String fileName) throws FileNotFoundException {
Path file;
Submission submission = submissionRepository.findByIdAndUpdatePassword(id, updatePassword);
if (submission != null) {
file = analysisHelper.getSplittedFolder(submission.getSubmissionGroup()).resolve(fileName);
if (Files.notExists(file)) {
throw new FileNotFoundException();
}
} else {
throw new FileNotFoundException();
}
return file;
}
use of com.odysseusinc.arachne.portal.model.Submission 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.portal.model.Submission in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionServiceImpl method getSubmissionResultAllFiles.
@Override
public void getSubmissionResultAllFiles(IUser user, Long analysisId, Long submissionId, String archiveName, OutputStream os) throws IOException, PermissionDeniedException {
Submission submission = submissionRepository.findOne(submissionId);
checkSubmissionPermission(user, submission);
Path resultFilesPath = Paths.get(contentStorageHelper.getResultFilesDir(submission));
try (ZipOutputStream zos = new ZipOutputStream(os)) {
for (ResultFile resultFile : submission.getResultFiles()) {
Path relativePath = resultFilesPath.relativize(Paths.get(resultFile.getPath()));
ZipUtil.addZipEntry(zos, relativePath.toString(), contentStorageService.getContentByFilepath(resultFile.getPath()));
}
}
}
use of com.odysseusinc.arachne.portal.model.Submission in project ArachneCentralAPI by OHDSI.
the class AnalysisSubmissionControllerTests method getResultFilePath.
/*private void prepareResultFile(Long studyId, Long analysisId, Long submissionGroupId, Long submissionId) throws IOException {
Path dir = Paths.get(analysisHelper.getStoreFilesPath(), studyId.toString(), analysisId.toString(), "sg_" + submissionGroupId, submissionId.toString(), AnalysisPaths.RESULT_DIR);
Files.createDirectories(dir);
Path path = dir.resolve("9934135d-07f0-4c6a-afd2-b705a1c8d948");
Files.write(path, "SELECT * FROM death LIMIT 10".getBytes());
}*/
private String getResultFilePath(Long submissionId) {
Submission submission = new Submission();
submission.setId(submissionId);
return contentStorageHelper.getResultFilesDir(submission, "test.sql");
}
use of com.odysseusinc.arachne.portal.model.Submission 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