Search in sources :

Example 1 with ResultFile

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;
}
Also used : ValidationException(com.odysseusinc.arachne.portal.exception.ValidationException) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with ResultFile

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());
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) EntityGraphUtils(com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) EXECUTED_PUBLISHED(com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED_PUBLISHED) Submission(com.odysseusinc.arachne.portal.model.Submission) FAILED_PUBLISHED(com.odysseusinc.arachne.portal.model.SubmissionStatus.FAILED_PUBLISHED) Map(java.util.Map) BigInteger(java.math.BigInteger) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) LinkedList(java.util.LinkedList) CommentService(com.odysseusinc.arachne.portal.service.CommentService) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) Logger(org.slf4j.Logger) AlreadyExistException(com.odysseusinc.arachne.portal.exception.AlreadyExistException) SubmissionResultFileRepository(com.odysseusinc.arachne.portal.repository.SubmissionResultFileRepository) Set(java.util.Set) PostAuthorize(org.springframework.security.access.prepost.PostAuthorize) SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) SubmissionInsightRepository(com.odysseusinc.arachne.portal.repository.SubmissionInsightRepository) SubmissionService(com.odysseusinc.arachne.portal.service.submission.SubmissionService) List(java.util.List) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) EntityUtils(com.odysseusinc.arachne.portal.util.EntityUtils) Stream(java.util.stream.Stream) SubmissionInsightService(com.odysseusinc.arachne.portal.service.submission.SubmissionInsightService) SubmissionInsightSubmissionFileRepository(com.odysseusinc.arachne.portal.repository.SubmissionInsightSubmissionFileRepository) SubmissionStatus(com.odysseusinc.arachne.portal.model.SubmissionStatus) Submission(com.odysseusinc.arachne.portal.model.Submission) SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) LinkedList(java.util.LinkedList)

Example 3 with ResultFile

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);
}
Also used : Submission(com.odysseusinc.arachne.portal.model.Submission) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 4 with ResultFile

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;
}
Also used : UserDetails(org.springframework.security.core.userdetails.UserDetails) IUser(com.odysseusinc.arachne.portal.model.IUser) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile) File(java.io.File) AnalysisFile(com.odysseusinc.arachne.portal.model.AnalysisFile) SubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionFile) MultipartFile(org.springframework.web.multipart.MultipartFile) Date(java.util.Date)

Example 5 with 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);
}
Also used : SubmissionInsightSubmissionFile(com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile) SubmissionInsight(com.odysseusinc.arachne.portal.model.SubmissionInsight) ResultFile(com.odysseusinc.arachne.portal.model.ResultFile)

Aggregations

ResultFile (com.odysseusinc.arachne.portal.model.ResultFile)10 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)5 Submission (com.odysseusinc.arachne.portal.model.Submission)5 Date (java.util.Date)5 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)4 EntityGraphUtils (com.cosium.spring.data.jpa.entity.graph.domain.EntityGraphUtils)3 ValidationException (com.odysseusinc.arachne.portal.exception.ValidationException)3 SubmissionInsight (com.odysseusinc.arachne.portal.model.SubmissionInsight)3 SubmissionInsightSubmissionFile (com.odysseusinc.arachne.portal.model.SubmissionInsightSubmissionFile)3 SubmissionStatus (com.odysseusinc.arachne.portal.model.SubmissionStatus)3 EXECUTED_PUBLISHED (com.odysseusinc.arachne.portal.model.SubmissionStatus.EXECUTED_PUBLISHED)3 FAILED_PUBLISHED (com.odysseusinc.arachne.portal.model.SubmissionStatus.FAILED_PUBLISHED)3 SubmissionInsightRepository (com.odysseusinc.arachne.portal.repository.SubmissionInsightRepository)3 SubmissionResultFileRepository (com.odysseusinc.arachne.portal.repository.SubmissionResultFileRepository)3 EntityUtils (com.odysseusinc.arachne.portal.util.EntityUtils)3 ArachneFileMeta (com.odysseusinc.arachne.storage.model.ArachneFileMeta)3 Arrays (java.util.Arrays)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 Map (java.util.Map)3