Search in sources :

Example 1 with DataSourceDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO in project ArachneCentralAPI by OHDSI.

the class BaseStudyController method getDataSource.

@ApiOperation("Get data source linked to study")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/data-sources/{dataSourceId}", method = GET)
public DataSourceDTO getDataSource(Principal principal, @PathVariable("studyId") Long studyId, @PathVariable("dataSourceId") Long dataSourceId) throws PermissionDeniedException {
    final IUser createdBy = getUser(principal);
    final DS dataSource = studyService.getStudyDataSource(createdBy, studyId, dataSourceId);
    final DataSourceDTO dataSourceDTO = conversionService.convert(dataSource, DataSourceDTO.class);
    final List<ShortUserDTO> userDTOs = dataSource.getDataNode().getDataNodeUsers().stream().map(dnu -> {
        final IUser user = dnu.getUser();
        final ShortUserDTO userDTO = new ShortUserDTO();
        userDTO.setId(user.getUuid());
        userDTO.setFirstname(user.getFirstname());
        userDTO.setLastname(user.getLastname());
        return userDTO;
    }).distinct().collect(Collectors.toList());
    dataSourceDTO.getDataNode().setDataOwners(userDTOs);
    return dataSourceDTO;
}
Also used : DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) CreateVirtualDataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO) ShortUserDTO(com.odysseusinc.arachne.portal.api.v1.dto.ShortUserDTO) IUser(com.odysseusinc.arachne.portal.model.IUser) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with DataSourceDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO in project ArachneCentralAPI by OHDSI.

the class BaseStudyController method updateDataSource.

@ApiOperation("Update data source linked to study")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/data-sources/{dataSourceId}", method = PUT)
public JsonResult<DataSourceDTO> updateDataSource(Principal principal, @PathVariable("studyId") Long studyId, @PathVariable("dataSourceId") Long dataSourceId, @RequestBody @Valid CreateVirtualDataSourceDTO dataSourceDTO) throws PermissionDeniedException, ValidationException, IOException, NoSuchFieldException, SolrServerException, IllegalAccessException {
    final IUser user = getUser(principal);
    IDataSource dataSource = studyService.updateVirtualDataSource(user, studyId, dataSourceId, dataSourceDTO.getName(), dataSourceDTO.getDataOwnersIds());
    return new JsonResult<>(NO_ERROR, conversionService.convert(dataSource, DataSourceDTO.class));
}
Also used : DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) CreateVirtualDataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO) IUser(com.odysseusinc.arachne.portal.model.IUser) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) IDataSource(com.odysseusinc.arachne.portal.model.IDataSource) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with DataSourceDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO in project ArachneCentralAPI by OHDSI.

the class DataSourceToDataSourceDTOConverter method proceedAdditionalFields.

@Override
protected void proceedAdditionalFields(DataSourceDTO dataSourceDTO, IDataSource dataSource) {
    final CommonHealthStatus healthStatus = dataSource.getHealthStatus();
    dataSourceDTO.setHealthStatus(healthStatus);
    dataSourceDTO.setHealthStatusTitle(healthStatus.toString());
    dataSourceDTO.setDeleted(dataSource.getDeleted());
    DataNodeDTO dataNodeDTO = conversionService.convert(dataSource.getDataNode(), DataNodeDTO.class);
    dataSourceDTO.setDataNode(dataNodeDTO);
    dataSourceDTO.setPermissions(conversionService.convert(dataSource, PermissionsDTO.class));
}
Also used : CommonHealthStatus(com.odysseusinc.arachne.commons.api.v1.dto.CommonHealthStatus) DataNodeDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataNodeDTO) PermissionsDTO(com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO)

Example 4 with DataSourceDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO in project ArachneCentralAPI by OHDSI.

the class BaseStudyController method createVirtualDataSource.

@ApiOperation("Create virtual data source linked to study")
@RequestMapping(value = "/api/v1/study-management/studies/{studyId}/data-sources", method = POST)
public JsonResult<DataSourceDTO> createVirtualDataSource(Principal principal, @PathVariable("studyId") Long studyId, @RequestBody @Valid CreateVirtualDataSourceDTO dataSourceDTO) throws PermissionDeniedException, NotExistException, IllegalAccessException, SolrServerException, IOException, ValidationException, FieldException, AlreadyExistException, NoSuchFieldException {
    final IUser createdBy = getUser(principal);
    final IDataSource dataSource = studyService.addVirtualDataSource(createdBy, studyId, dataSourceDTO.getName(), dataSourceDTO.getDataOwnersIds());
    final DataSourceDTO registeredDataSourceDTO = conversionService.convert(dataSource, DataSourceDTO.class);
    return new JsonResult<>(NO_ERROR, registeredDataSourceDTO);
}
Also used : DataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO) CreateVirtualDataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO) IUser(com.odysseusinc.arachne.portal.model.IUser) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) IDataSource(com.odysseusinc.arachne.portal.model.IDataSource) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with DataSourceDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO 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)

Aggregations

DataSourceDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO)6 CreateVirtualDataSourceDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO)4 ApiOperation (io.swagger.annotations.ApiOperation)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 IUser (com.odysseusinc.arachne.portal.model.IUser)3 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)2 PermissionsDTO (com.odysseusinc.arachne.portal.api.v1.dto.PermissionsDTO)2 IDataSource (com.odysseusinc.arachne.portal.model.IDataSource)2 StudyDataSourceLink (com.odysseusinc.arachne.portal.model.StudyDataSourceLink)2 CommonHealthStatus (com.odysseusinc.arachne.commons.api.v1.dto.CommonHealthStatus)1 BaseAnalysisDTO (com.odysseusinc.arachne.portal.api.v1.dto.BaseAnalysisDTO)1 DataNodeDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataNodeDTO)1 ParticipantDTO (com.odysseusinc.arachne.portal.api.v1.dto.ParticipantDTO)1 ShortUserDTO (com.odysseusinc.arachne.portal.api.v1.dto.ShortUserDTO)1 StudyDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyDTO)1 StudyFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.StudyFileDTO)1 StudyStatusDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyStatusDTO)1 StudyTypeDTO (com.odysseusinc.arachne.portal.api.v1.dto.dictionary.StudyTypeDTO)1 Analysis (com.odysseusinc.arachne.portal.model.Analysis)1 StudyFile (com.odysseusinc.arachne.portal.model.StudyFile)1