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;
}
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));
}
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));
}
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);
}
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;
}
Aggregations