Search in sources :

Example 1 with CreateVirtualDataSourceDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO 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 2 with CreateVirtualDataSourceDTO

use of com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO 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 3 with CreateVirtualDataSourceDTO

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

the class StudyDataSourceControllerTests method testAddVirtualDataSource.

@Test
@WithUserDetails(STUDY_LEAD)
@ExpectedDatabase(value = "/data/study/datasource/study-data-source1-virtual.xml", assertionMode = NON_STRICT)
public void testAddVirtualDataSource() throws Exception {
    final CreateVirtualDataSourceDTO createVirtualDataSourceDTO = new CreateVirtualDataSourceDTO();
    createVirtualDataSourceDTO.setName("virtual");
    createVirtualDataSourceDTO.setDataOwnersIds(Arrays.asList(UserIdUtils.idToUuid(1l)));
    mvc.perform(post("/api/v1/study-management/studies/{studyId}/data-sources", STUDY_ID).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(createVirtualDataSourceDTO))).andExpect(NO_ERROR_CODE);
}
Also used : CreateVirtualDataSourceDTO(com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO) ExpectedDatabase(com.github.springtestdbunit.annotation.ExpectedDatabase) Test(org.junit.Test) WithUserDetails(org.springframework.security.test.context.support.WithUserDetails)

Aggregations

CreateVirtualDataSourceDTO (com.odysseusinc.arachne.portal.api.v1.dto.CreateVirtualDataSourceDTO)3 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)2 DataSourceDTO (com.odysseusinc.arachne.portal.api.v1.dto.DataSourceDTO)2 IDataSource (com.odysseusinc.arachne.portal.model.IDataSource)2 IUser (com.odysseusinc.arachne.portal.model.IUser)2 ApiOperation (io.swagger.annotations.ApiOperation)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ExpectedDatabase (com.github.springtestdbunit.annotation.ExpectedDatabase)1 Test (org.junit.Test)1 WithUserDetails (org.springframework.security.test.context.support.WithUserDetails)1