Search in sources :

Example 1 with CommonUserDTO

use of com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO in project ArachneCentralAPI by OHDSI.

the class BaseExpertFinderController method get.

@ApiOperation("Get user by id")
@RequestMapping(value = "/api/v1/user-management/users/{id}", method = GET)
public JsonResult<CommonUserDTO> get(@PathVariable("id") Long id) {
    JsonResult<CommonUserDTO> result;
    U user = userService.getByIdInAnyTenant(id);
    CommonUserDTO userDTO = conversionService.convert(user, CommonUserDTO.class);
    result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
    result.setResult(userDTO);
    return result;
}
Also used : CommonUserDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with CommonUserDTO

use of com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO in project ArachneCentralAPI by OHDSI.

the class BaseUserController method create.

@ApiOperation("Create new user")
@RequestMapping(value = "/api/v1/admin/users", method = POST)
public CommonUserDTO create(@RequestBody @Valid CommonUserRegistrationDTO dto) throws PasswordValidationException {
    CommonUserDTO result;
    U user = convertRegistrationDTO(dto);
    user.setEmailConfirmed(false);
    user = userService.create(user);
    result = conversionService.convert(user, CommonUserDTO.class);
    return result;
}
Also used : CommonUserDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with CommonUserDTO

use of com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO in project ArachneCentralAPI by OHDSI.

the class BaseExpertFinderController method buildResponse.

private JsonResult<CommonUserDTO> buildResponse(U user) {
    CommonUserDTO userDTO = conversionService.convert(user, CommonUserDTO.class);
    JsonResult<CommonUserDTO> result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
    result.setResult(userDTO);
    return result;
}
Also used : CommonUserDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)

Example 4 with CommonUserDTO

use of com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO in project ArachneCentralAPI by OHDSI.

the class UserToCommonUserDTOConverter method convert.

@Override
public CommonUserDTO convert(IUser user) {
    CommonUserDTO dto = new CommonUserDTO();
    dto.setId(UserIdUtils.idToUuid(user.getId()));
    dto.setPassword("");
    dto.setEmail(user.getEmail());
    dto.setFirstname(user.getFirstname());
    dto.setMiddlename(user.getMiddlename());
    dto.setLastname(user.getLastname());
    dto.setUsername(user.getUsername());
    dto.setEmailConfirmed(user.getEmailConfirmed());
    dto.setEnabled(user.getEnabled());
    dto.setCreated(user.getCreated());
    dto.setUpdated(user.getUpdated());
    if (user.getProfessionalType() != null) {
        if (conversionService.canConvert(ProfessionalType.class, CommonProfessionalTypeDTO.class)) {
            dto.setProfessionalType(conversionService.convert(user.getProfessionalType(), CommonProfessionalTypeDTO.class));
        } else {
            throw new NoDTOConverterException("cannot convert ProfessionalType to ProfessionaltypeDTO");
        }
    }
    return dto;
}
Also used : CommonProfessionalTypeDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonProfessionalTypeDTO) NoDTOConverterException(com.odysseusinc.arachne.portal.exception.NoDTOConverterException) CommonUserDTO(com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO)

Aggregations

CommonUserDTO (com.odysseusinc.arachne.commons.api.v1.dto.CommonUserDTO)4 ApiOperation (io.swagger.annotations.ApiOperation)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 CommonProfessionalTypeDTO (com.odysseusinc.arachne.commons.api.v1.dto.CommonProfessionalTypeDTO)1 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)1 NoDTOConverterException (com.odysseusinc.arachne.portal.exception.NoDTOConverterException)1