use of com.odysseusinc.arachne.portal.model.StudyDataSourceLink in project ArachneCentralAPI by OHDSI.
the class BaseStudyServiceImpl method addDataSource.
@Override
// ordering annotations is important to check current participants before method invoke
@PreAuthorize("hasPermission(#studyId, 'Study', " + "T(com.odysseusinc.arachne.portal.security.ArachnePermission).INVITE_DATANODE)")
public StudyDataSourceLink addDataSource(IUser createdBy, Long studyId, Long dataSourceId) throws NotExistException, AlreadyExistException {
T study = studyRepository.findOne(studyId);
if (study == null) {
throw new NotExistException("study not exist", Study.class);
}
DS dataSource = dataSourceService.getNotDeletedById(dataSourceId);
if (dataSource == null) {
throw new NotExistException("dataSource not exist", DataSource.class);
}
StudyDataSourceLink studyDataSourceLink = studyDataSourceLinkRepository.findByDataSourceIdAndStudyId(dataSource.getId(), study.getId());
if (studyDataSourceLink == null) {
studyDataSourceLink = new StudyDataSourceLink();
} else if (studyDataSourceLink.getStatus().isPendingOrApproved()) {
throw new AlreadyExistException();
}
studyDataSourceLink.setStudy(study);
studyDataSourceLink.setDataSource(dataSource);
studyDataSourceLink.setCreated(new Date());
studyDataSourceLink.setToken(UUID.randomUUID().toString());
studyDataSourceLink.setCreatedBy(createdBy);
studyDataSourceLink.setDeletedAt(null);
AddDataSourceStrategy<DS> strategy = addDataSourceStrategyFactory.getStrategy(dataSource);
strategy.addDataSourceToStudy(createdBy, dataSource, studyDataSourceLink);
return studyDataSourceLink;
}
use of com.odysseusinc.arachne.portal.model.StudyDataSourceLink in project ArachneCentralAPI by OHDSI.
the class BaseStudyController method listDataSources.
@ApiOperation("List study data sources.")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/data-sources/", method = GET)
public JsonResult<List<DataSourceDTO>> listDataSources(@PathVariable("studyId") Long studyId) throws PermissionDeniedException {
long start = System.currentTimeMillis();
JsonResult<List<DataSourceDTO>> result;
List<StudyDataSourceLink> dataSources = studyService.listApprovedDataSources(studyId);
List<DataSourceDTO> dataSourceDTOs = new ArrayList<>();
for (StudyDataSourceLink dataSource : dataSources) {
DataSourceDTO dataSourceDTO = conversionService.convert(dataSource, DataSourceDTO.class);
dataSourceDTOs.add(dataSourceDTO);
}
result = new JsonResult<>(NO_ERROR);
result.setResult(dataSourceDTOs);
return result;
}
use of com.odysseusinc.arachne.portal.model.StudyDataSourceLink 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;
}
Aggregations