use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class ArachnePermissionEvaluator method addPermissions.
public boolean addPermissions(ArachneUser user, HasArachnePermissions hasPermissionsObj) {
Set<ArachnePermission> allPermissions = getAllPermissions(hasPermissionsObj, user);
hasPermissionsObj.setPermissions(allPermissions);
if (hasPermissionsObj instanceof Analysis) {
final Analysis analysis = (Analysis) hasPermissionsObj;
final List<SubmissionGroup> submissionGroups = analysis.getSubmissionGroups();
if (!CollectionUtils.isEmpty(submissionGroups)) {
submissionGroups.forEach(submissionGroup -> submissionGroup.getSubmissions().forEach(submission -> {
final Set<ArachnePermission> submissionPermissions = getAllPermissions(submission, user);
submission.setPermissions(submissionPermissions);
}));
}
final List<AnalysisFile> files = analysis.getFiles();
if (!CollectionUtils.isEmpty(files)) {
files.forEach(file -> {
final Set<ArachnePermission> filePermissions = getAllPermissions(file, user);
file.setPermissions(filePermissions);
});
}
}
return true;
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method createSubmission.
@ApiOperation("Create and send submission.")
@RequestMapping(value = "/api/v1/analysis-management/{analysisId}/submissions", method = POST)
public JsonResult<List<DTO>> createSubmission(Principal principal, @RequestBody @Validated CreateSubmissionsDTO createSubmissionsDTO, @PathVariable("analysisId") Long analysisId) throws PermissionDeniedException, NotExistException, IOException, NoExecutableFileException, ValidationException {
final JsonResult<List<DTO>> result;
if (principal == null) {
throw new PermissionDeniedException();
}
IUser user = userService.getByEmail(principal.getName());
if (user == null) {
throw new PermissionDeniedException();
}
Analysis analysis = analysisService.getById(analysisId);
final List<Submission> submissions = AnalysisHelper.createSubmission(submissionService, createSubmissionsDTO.getDataSources(), user, analysis);
final List<DTO> submissionDTOs = submissions.stream().map(s -> conversionService.convert(s, getSubmissionDTOClass())).collect(Collectors.toList());
result = new JsonResult<>(NO_ERROR);
result.setResult(submissionDTOs);
return result;
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionToCommonAnalysisDTOConverter method convert.
@Override
public CommonAnalysisDTO convert(T source) {
final CommonAnalysisDTO dto = createResultObject();
dto.setId(source.getId());
final Analysis analysis = source.getSubmissionGroup().getAnalysis();
if (analysis != null) {
dto.setName(analysis.getTitle());
dto.setType(analysis.getType());
Study study = analysis.getStudy();
if (study != null && conversionService.canConvert(study.getClass(), CommonStudyDTO.class)) {
dto.setStudy(conversionService.convert(study, CommonStudyDTO.class));
}
}
IUser author = source.getSubmissionGroup().getAuthor();
if (author != null && conversionService.canConvert(author.getClass(), CommonArachneUserDTO.class)) {
CommonArachneUserDTO userDTO = conversionService.convert(author, CommonArachneUserDTO.class);
dto.setOwner(userDTO);
}
dto.setUpdateSubmissionStatusPassword(source.getUpdatePassword());
dto.setCentralDataSourceId(source.getDataSource().getId());
for (SubmissionFile submissionFile : source.getSubmissionGroup().getFiles()) {
if (submissionFile.getExecutable() && StringUtils.isEmpty(dto.getExecutableFileName())) {
dto.setExecutableFileName(submissionFile.getRealName());
dto.setInnerExecutableFilename(submissionFile.getEntryPoint());
}
}
dto.setAnalysisFiles(source.getSubmissionGroup().getFiles().stream().map(file -> conversionService.convert(file, CommonAnalysisFileDTO.class)).collect(Collectors.toList()));
proceedAdditionalFields(dto, source);
return dto;
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class StudyStateMachineTest method testAnalysisListDiscriminatorChangingInfo.
@Test
public void testAnalysisListDiscriminatorChangingInfo() {
Study activeStudy = createStudy(ACTIVE);
activeStudy.getAnalyses().add(new Analysis());
// now study has one analysis and transitions from Active to Initiate should have Info status
List<StudyTransition> availableStates = stateMachine.getAvailableStates(activeStudy);
assertEquals(2, availableStates.size());
assertTrue(availableStates.get(0).isInfo());
assertFalse(availableStates.get(1).isInfo());
}
use of com.odysseusinc.arachne.portal.model.Analysis in project ArachneCentralAPI by OHDSI.
the class AnalysisHelperTest method prepareAnalysis.
private Analysis prepareAnalysis(IUser author, Study study) throws Exception {
List<Analysis> exists = analysisRepository.findByTitleAndStudyId("AnalysisHelperTest#test", study.getId());
if (!exists.isEmpty()) {
analysisRepository.delete(exists);
}
Analysis analysis = new Analysis();
analysis.setTitle("AnalysisHelperTest#test");
analysis.setFiles(new ArrayList<>());
analysis.setAuthor(author);
analysis.setStudy(study);
analysis.setType(CommonAnalysisType.COHORT_CHARACTERIZATION);
Set<ArachnePermission> permissions = new HashSet<>();
permissions.add(ArachnePermission.CREATE_SUBMISSION);
permissions.add(ArachnePermission.CREATE_ANALYSIS);
analysis.setPermissions(permissions);
analysis = analysisService.create(analysis);
AnalysisFile file = new AnalysisFile();
file.setUuid(UUID.randomUUID().toString());
file.setAnalysis(analysis);
file.setContentType("text/plain");
file.setLabel("");
file.setAuthor(author);
file.setUpdatedBy(author);
file.setExecutable(Boolean.TRUE);
file.setRealName("test.sql");
Date created = new Date();
file.setCreated(created);
file.setUpdated(created);
file.setVersion(1);
file = analysisFileRepository.save(file);
analysis.getFiles().add(file);
Path dir = Paths.get(analysisHelper.getStoreFilesPath(), study.getId().toString(), analysis.getId().toString());
Files.createDirectories(dir);
Path path = dir.resolve(file.getUuid());
Files.write(path, "test".getBytes());
return analysis;
}
Aggregations