Search in sources :

Example 6 with StudyDataSourceLink

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;
}
Also used : StudyDataSourceLink(com.odysseusinc.arachne.portal.model.StudyDataSourceLink) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) AlreadyExistException(com.odysseusinc.arachne.portal.exception.AlreadyExistException) Date(java.util.Date) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 7 with 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;
}
Also used : DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) CreateVirtualDataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO) StudyDataSourceLink(com.odysseusinc.arachne.portal.model.StudyDataSourceLink) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with StudyDataSourceLink

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;
}
Also used : StudyFile(com.odysseusinc.arachne.portal.model.StudyFile) StudyDataSourceLink(com.odysseusinc.arachne.portal.model.StudyDataSourceLink) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) ParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO) StudyTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO) StudyFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyFileDTO) DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) BaseAnalysisDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseAnalysisDTO) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) Analysis(com.odysseusinc.arachne.portal.model.Analysis) StudyStatusDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO) BaseAnalysisDTO(com.odysseusinc.arachne.portal.api.v1.dto.BaseAnalysisDTO) ParticipantDTO(com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO) DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) StudyTypeDTO(com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO) StudyDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO) StudyFileDTO(com.odysseusinc.arachne.portal.api.v1.dto.StudyFileDTO)

Aggregations

StudyDataSourceLink (com.odysseusinc.arachne.portal.model.StudyDataSourceLink)8 DataSourceDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO)3 ParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO)2 StudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)2 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)2 DataSourceStatus (com.odysseusinc.arachne.portal.model.DataSourceStatus)2 Study (com.odysseusinc.arachne.portal.model.Study)2 ApiOperation (io.swagger.annotations.ApiOperation)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 BaseAnalysisDTO (com.odysseusinc.arachne.portal.api.v1.dto.BaseAnalysisDTO)1 CreateVirtualDataSourceDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO)1 ParticipantExtendedDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantExtendedDTO)1 PermissionsDTO (com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO)1 StudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO)1 StudyFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyFileDTO)1 StudyMediumDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyMediumDTO)1 BaseConversionServiceAwareConverter (com.odysseusinc.arachne.portal.api.v1.dto.converters.BaseConversionServiceAwareConverter)1 StudyTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO)1