use of com.odysseusinc.arachne.portal.model.ResultFile in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method deleteSubmissionResultsByUuid.
@ApiOperation("Delete manually uploaded submission result file")
@RequestMapping(value = "/api/v1/analysis-management/submissions/{submissionId}/result/{fileUuid}", method = DELETE)
public JsonResult<Boolean> deleteSubmissionResultsByUuid(@PathVariable("submissionId") Long id, @PathVariable("fileUuid") String fileUuid) {
LOGGER.info("deleting result file for submission with id={} having uuid={}", id, fileUuid);
JsonResult.ErrorCode errorCode;
Boolean hasResult;
try {
ResultFile resultFile = submissionService.getResultFileByPath(contentStorageService.getFileByIdentifier(fileUuid).getPath());
hasResult = submissionService.deleteSubmissionResultFile(id, resultFile);
errorCode = JsonResult.ErrorCode.NO_ERROR;
} catch (NotExistException e) {
LOGGER.warn("Submission was not found, id: {}", id);
errorCode = JsonResult.ErrorCode.VALIDATION_ERROR;
hasResult = false;
} catch (ValidationException e) {
LOGGER.warn("Result file was not deleted", e);
errorCode = JsonResult.ErrorCode.VALIDATION_ERROR;
hasResult = false;
}
JsonResult<Boolean> result = new JsonResult<>(errorCode);
result.setResult(hasResult);
return result;
}
use of com.odysseusinc.arachne.portal.model.ResultFile in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionInsightServiceImpl method extractCommentTopics.
private Set<CommentTopic> extractCommentTopics(SubmissionInsight insight) {
final Stream<CommentTopic> submissionFilesTopics = insight.getSubmissionInsightSubmissionFiles().stream().map(SubmissionInsightSubmissionFile::getCommentTopic);
final Submission submission = insight.getSubmission();
final Stream<CommentTopic> resultFileTopics = submission.getResultFiles().stream().map(ResultFile::getCommentTopic);
return Stream.concat(submissionFilesTopics, resultFileTopics).map(commentTopic -> {
commentTopic.setComments(new LinkedList<>());
return commentTopic;
}).collect(Collectors.toSet());
}
use of com.odysseusinc.arachne.portal.model.ResultFile in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionInsightServiceImpl method deleteSubmissionInsight.
@Override
@PreAuthorize("hasPermission(#submissionId, 'Submission', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).EDIT_ANALYSIS)")
public void deleteSubmissionInsight(Long submissionId) throws NotExistException {
LOGGER.info(DELETING_INSIGHT_LOG, submissionId);
final Submission submission = submissionService.getSubmissionById(submissionId, EntityUtils.fromAttributePaths("submissionInsight", "resultFiles"));
throwNotExistExceptionIfNull(submission, submissionId);
throwNotExistExceptionIfNull(submission.getSubmissionInsight(), submissionId);
final List<ResultFile> resultFiles = submission.getResultFiles();
resultFiles.forEach(resultFile -> resultFile.setCommentTopic(null));
submissionResultFileRepository.save(resultFiles);
submissionInsightRepository.deleteBySubmissionId(submissionId);
}
use of com.odysseusinc.arachne.portal.model.ResultFile in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionServiceImpl method uploadResultsByDataOwner.
@Override
public ResultFile uploadResultsByDataOwner(Long submissionId, String name, MultipartFile file) throws NotExistException, IOException {
UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
IUser user = userService.getByUsername(userDetails.getUsername());
T submission = submissionRepository.findByIdAndStatusIn(submissionId, Collections.singletonList(IN_PROGRESS.name()));
throwNotExistExceptionIfNull(submission, submissionId);
File tempFile = File.createTempFile("manual-upload", name);
file.transferTo(tempFile);
ResultFile resultFile = createResultFile(tempFile.toPath(), ObjectUtils.firstNonNull(name, file.getOriginalFilename()), submission, user.getId());
Date updated = new Date();
List<ResultFile> resultFiles = submission.getResultFiles();
resultFiles.add(resultFile);
submission.setUpdated(updated);
submissionResultFileRepository.save(resultFiles);
saveSubmission(submission);
return resultFile;
}
use of com.odysseusinc.arachne.portal.model.ResultFile in project ArachneCentralAPI by OHDSI.
the class BaseArachneSecureServiceImpl method getRolesByCommentTopic.
@Override
public List<ParticipantRole> getRolesByCommentTopic(ArachneUser user, CommentTopic topic) {
SubmissionInsightSubmissionFile submissionInsightLink = submissionInsightSubmissionFileRepository.findByCommentTopic(topic);
SubmissionInsight insight;
if (submissionInsightLink == null) {
ResultFile resultFile = resultFileRepository.findByCommentTopic(topic);
insight = resultFile.getSubmission().getSubmissionInsight();
} else {
insight = submissionInsightLink.getSubmissionInsight();
}
return getRolesByInsight(user, insight);
}
Aggregations