Search in sources :

Example 1 with ProfessionalType

use of com.odysseusinc.arachne.portal.model.ProfessionalType in project ArachneCentralAPI by OHDSI.

the class ProfessionalTypeController method update.

@ApiOperation(value = "Update professional type.", hidden = true)
@RequestMapping(value = "/api/v1/admin/professional-types/{professionalTypeId}", method = RequestMethod.PUT)
public JsonResult<CommonProfessionalTypeDTO> update(@PathVariable("professionalTypeId") Long id, @RequestBody @Valid CommonProfessionalTypeDTO professionalTypeDTO, BindingResult binding) throws NotExistException, NotUniqueException, ValidationException {
    JsonResult result = null;
    if (binding.hasErrors()) {
        result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
        for (FieldError fieldError : binding.getFieldErrors()) {
            result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
        }
    } else {
        ProfessionalType professionalType = conversionService.convert(professionalTypeDTO, ProfessionalType.class);
        professionalType.setId(id);
        professionalType = professionalTypeService.update(professionalType);
        result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
        result.setResult(professionalType);
    }
    return result;
}
Also used : FieldError(org.springframework.validation.FieldError) ProfessionalType(com.odysseusinc.arachne.portal.model.ProfessionalType) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with ProfessionalType

use of com.odysseusinc.arachne.portal.model.ProfessionalType in project ArachneCentralAPI by OHDSI.

the class ProfessionalTypeController method get.

@ApiOperation("Get professional type.")
@RequestMapping(value = "/api/v1/user-management/professional-types/{professionalTypeId}", method = RequestMethod.GET)
public JsonResult<CommonProfessionalTypeDTO> get(@PathVariable("professionalTypeId") Long id) throws NotExistException {
    JsonResult result;
    if (id == null) {
        result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
        result.getValidatorErrors().put("professionalTypeId", "cannot be null");
    } else {
        ProfessionalType skill = professionalTypeService.getById(id);
        result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
        result.setResult(skill);
    }
    return result;
}
Also used : ProfessionalType(com.odysseusinc.arachne.portal.model.ProfessionalType) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with ProfessionalType

use of com.odysseusinc.arachne.portal.model.ProfessionalType in project ArachneCentralAPI by OHDSI.

the class ProfessionalTypeController method create.

@ApiOperation(value = "Register new professional type.", hidden = true)
@RequestMapping(value = "/api/v1/admin/professional-types", method = RequestMethod.POST)
public JsonResult<CommonProfessionalTypeDTO> create(@RequestBody @Valid CommonProfessionalTypeDTO professionalTypeDTO, BindingResult binding) throws NotExistException, NotUniqueException, PermissionDeniedException {
    JsonResult result;
    if (binding.hasErrors()) {
        result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
        for (FieldError fieldError : binding.getFieldErrors()) {
            result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
        }
    } else {
        ProfessionalType professionalType = conversionService.convert(professionalTypeDTO, ProfessionalType.class);
        professionalType = professionalTypeService.create(professionalType);
        result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
        result.setResult(conversionService.convert(professionalType, professionalTypeDTO.getClass()));
    }
    return result;
}
Also used : FieldError(org.springframework.validation.FieldError) ProfessionalType(com.odysseusinc.arachne.portal.model.ProfessionalType) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with ProfessionalType

use of com.odysseusinc.arachne.portal.model.ProfessionalType in project ArachneCentralAPI by OHDSI.

the class ProfessionalTypeDTOToProfessionalTypeConverter method convert.

@Override
public ProfessionalType convert(CommonProfessionalTypeDTO source) {
    ProfessionalType professionalType = new ProfessionalType();
    professionalType.setId(source.getId());
    professionalType.setName(source.getName());
    return professionalType;
}
Also used : ProfessionalType(com.odysseusinc.arachne.portal.model.ProfessionalType)

Example 5 with ProfessionalType

use of com.odysseusinc.arachne.portal.model.ProfessionalType in project ArachneCentralAPI by OHDSI.

the class BaseUserServiceImpl method baseUpdate.

private U baseUpdate(U forUpdate, U user) {
    final Date date = new Date();
    forUpdate.setId(user.getId());
    if (user.getFirstname() != null) {
        forUpdate.setFirstname(user.getFirstname());
    }
    if (user.getMiddlename() != null) {
        forUpdate.setMiddlename(user.getMiddlename());
    }
    if (user.getLastname() != null) {
        forUpdate.setLastname(user.getLastname());
    }
    forUpdate.setEnabled(user.getEnabled() != null ? user.getEnabled() : forUpdate.getEnabled());
    forUpdate.setUpdated(date);
    if (user.getProfessionalType() != null) {
        ProfessionalType professionalType = professionalTypeService.getById(user.getProfessionalType().getId());
        if (professionalType != null) {
            forUpdate.setProfessionalType(professionalType);
        }
    }
    if (user.getPhone() != null) {
        forUpdate.setPhone(user.getPhone());
    }
    if (user.getMobile() != null) {
        forUpdate.setMobile(user.getMobile());
    }
    if (user.getAddress1() != null) {
        forUpdate.setAddress1(user.getAddress1());
    }
    if (user.getAddress2() != null) {
        forUpdate.setAddress2(user.getAddress2());
    }
    if (user.getCity() != null) {
        forUpdate.setCity(user.getCity());
    }
    if (user.getZipCode() != null) {
        forUpdate.setZipCode(user.getZipCode());
    }
    if (user.getCountry() != null) {
        Country country = countryRepository.findOne(user.getCountry().getId());
        if (country != null) {
            forUpdate.setCountry(country);
        }
    }
    if (user.getStateProvince() != null) {
        StateProvince stateProvince = stateProvinceRepository.findOne(user.getStateProvince().getId());
        if (stateProvince != null) {
            forUpdate.setStateProvince(stateProvince);
        }
    }
    if (user.getAffiliation() != null) {
        forUpdate.setAffiliation(user.getAffiliation());
    }
    if (user.getPersonalSummary() != null) {
        forUpdate.setPersonalSummary(user.getPersonalSummary());
    }
    if (user.getContactEmail() != null) {
        forUpdate.setContactEmail(user.getContactEmail());
    }
    if (user.getTenants() != null) {
        forUpdate.setTenants(user.getTenants());
    }
    return forUpdate;
}
Also used : StateProvince(com.odysseusinc.arachne.portal.model.StateProvince) Country(com.odysseusinc.arachne.portal.model.Country) ProfessionalType(com.odysseusinc.arachne.portal.model.ProfessionalType) Date(java.util.Date)

Aggregations

ProfessionalType (com.odysseusinc.arachne.portal.model.ProfessionalType)7 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)4 ApiOperation (io.swagger.annotations.ApiOperation)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 FieldError (org.springframework.validation.FieldError)2 Country (com.odysseusinc.arachne.portal.model.Country)1 StateProvince (com.odysseusinc.arachne.portal.model.StateProvince)1 User (com.odysseusinc.arachne.portal.model.User)1 Date (java.util.Date)1