use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionServiceImpl method getSubmissionGroups.
@Override
@PreAuthorize("hasPermission(#submissoinGroupSearch.analysisId, 'Analysis', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).ACCESS_STUDY)")
@PostAuthorize("@ArachnePermissionEvaluator.addPermissionsToSubmissions(principal, returnObject )")
public Page<SubmissionGroup> getSubmissionGroups(SubmissionGroupSearch submissoinGroupSearch) {
final SubmissionGroupSpecification submissionGroupSpecification = new SubmissionGroupSpecification(submissoinGroupSearch);
final Integer page = submissoinGroupSearch.getPage();
final PageRequest pageRequest = new PageRequest(page == null ? 0 : page - 1, submissoinGroupSearch.getPageSize(), new Sort(Sort.Direction.DESC, "created"));
final Page<SubmissionGroup> submissionGroups = submissionGroupRepository.findAll(submissionGroupSpecification, pageRequest);
final List<SubmissionGroup> content = submissionGroups.getContent();
final Map<Long, SubmissionGroup> submissionGroupMap = content.stream().collect(Collectors.toMap(SubmissionGroup::getId, sg -> {
sg.setSubmissions(new ArrayList<>());
return sg;
}));
final Set<Long> submissionGroupIds = submissionGroupMap.keySet();
if (!CollectionUtils.isEmpty(submissionGroupIds)) {
final SubmissionSpecification<T> submissionSpecification = SubmissionSpecification.<T>builder(submissionGroupIds).withStatuses(submissoinGroupSearch.getSubmissionStatuses()).withDataSourceIds(submissoinGroupSearch.getDataSourceIds()).hasInsight(submissoinGroupSearch.getHasInsight()).showHidden(submissoinGroupSearch.getShowHidden()).build();
submissionRepository.findAll(submissionSpecification).forEach(s -> submissionGroupMap.get(s.getSubmissionGroup().getId()).getSubmissions().add(s));
}
return submissionGroups;
}
use of com.odysseusinc.arachne.portal.model.Analysis 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());
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class InvitationableToInvitationDTOConverter method convert.
@Override
public InvitationDTO convert(Invitationable source) {
final InvitationDTO invitationDTO = new InvitationDTO();
final List<ActionDTO> actionList = Arrays.asList(new ActionDTO("Accept", "accept", "success"), new ActionDTO("Decline", "decline", "cancel"));
invitationDTO.setActionList(actionList);
invitationDTO.setType(source.getInvitationType());
invitationDTO.setId(source.getId());
invitationDTO.setActionType(source.getActionType());
invitationDTO.setDate(source.getCreated());
invitationDTO.setUser(conversionService.convert(source.getAuthor(), ShortUserDTO.class));
final Object entity = source.getEntity();
String title = "";
Long id = null;
if (entity instanceof Study) {
final Study study = (Study) entity;
title = study.getTitle();
id = study.getId();
} else if (entity instanceof Paper) {
final Paper paper = (Paper) entity;
title = paper.getStudy().getDescription();
id = paper.getId();
} else if (entity instanceof Analysis) {
final Analysis analysis = (Analysis) entity;
title = analysis.getTitle();
id = analysis.getId();
}
final InvitationEntityDTO studyShortDTO = getInvitationEntityDTO(title, id);
invitationDTO.setEntity(studyShortDTO);
return invitationDTO;
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class BaseStudyToStudyDTOConverter method convert.
@Override
public DTO convert(final S source) {
final DTO studyDTO = createResultObject();
studyDTO.setStatus(conversionService.convert(source.getStatus(), StudyStatusDTO.class));
studyDTO.setTitle(source.getTitle());
studyDTO.setType(conversionService.convert(source.getType(), StudyTypeDTO.class));
studyDTO.setEndDate(source.getEndDate());
studyDTO.setStartDate(source.getStartDate());
studyDTO.setDescription(source.getDescription());
if (!CollectionUtils.isEmpty(source.getParticipants())) {
studyDTO.setParticipants(source.getParticipants().stream().map(link -> conversionService.convert(link, ParticipantDTO.class)).collect(Collectors.toList()));
}
final List<StudyDataSourceLink> foundLinks = studyService.getLinksByStudyId(source.getId(), EntityUtils.fromAttributePaths("dataSource.dataNode.dataNodeUsers.user"));
for (final StudyDataSourceLink studyDataSourceLink : foundLinks) {
final DataSourceDTO dataSourceDTO = conversionService.convert(studyDataSourceLink, DataSourceDTO.class);
studyDTO.getDataSources().add(dataSourceDTO);
}
List<Analysis> analyses = getAnalyses(source);
for (final Analysis analysis : analyses) {
studyDTO.getAnalyses().add(conversionService.convert(analysis, BaseAnalysisDTO.class));
}
List<StudyFile> files = studyService.getFilesByStudyId(source.getId(), EntityUtils.fromAttributePaths("author"));
for (final StudyFile studyFile : files) {
studyDTO.getFiles().add(conversionService.convert(studyFile, StudyFileDTO.class));
}
studyDTO.setCreated(source.getCreated());
studyDTO.setUpdated(source.getUpdated());
studyDTO.setId(source.getId());
studyDTO.setPermissions(conversionService.convert(source, PermissionsDTO.class));
studyDTO.setPaperId(source.getPaper() == null ? null : source.getPaper().getId());
studyDTO.setPrivacy(source.getPrivacy());
proceedAdditionalFields(studyDTO, source);
return studyDTO;
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class AnalysisHelperTest method createSubmission.
@Test
@WithUserDetails("admin@odysseusinc.com")
public void createSubmission() throws Exception {
DataSource dataSource = prepareDataSource();
when(dataSourceService.getByIdUnsecured(1L)).thenReturn(dataSource);
IUser user = prepareUser();
Study study = prepareStudy(user);
Analysis analysis = prepareAnalysis(user, study);
List<Submission> submissions = AnalysisHelper.createSubmission(submissionService, Collections.<Long>singletonList(1L), user, analysis);
try {
assertThat(submissions, is(not(empty())));
assertThat(submissions, contains(hasProperty("status", notNullValue())));
assertThat(submissions, contains(hasProperty("submissionGroup", notNullValue())));
} finally {
cleanup(submissions, analysis, study);
}
}
Aggregations