use of com.odysseusinc.arachne.commons.api.v1.dto.CommonProfessionalTypeDTO 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;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonProfessionalTypeDTO 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;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonProfessionalTypeDTO 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;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonProfessionalTypeDTO in project ArachneCentralAPI by OHDSI.
the class ProfessionalTypeControllerTests method testCreateProfessionalType.
@Test
@DatabaseSetup(value = "/data/professionaltype/empty-professional-type.xml")
@ExpectedDatabase(table = "users_data", value = "/data/users-without-external-dependency.xml", assertionMode = NON_STRICT)
public void testCreateProfessionalType() throws Exception {
CommonProfessionalTypeDTO professionalTypeDTO = new CommonProfessionalTypeDTO();
professionalTypeDTO.setName(PROFESSIONAL_TYPE_NAME);
MvcResult mvcResult = mvc.perform(post("/api/v1/admin/professional-types/").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(professionalTypeDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(PROFESSIONAL_TYPE_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.CommonProfessionalTypeDTO in project ArachneCentralAPI by OHDSI.
the class ProfessionalTypeController method list.
@ApiOperation("List professional types.")
@RequestMapping(value = "/api/v1/user-management/professional-types", method = RequestMethod.GET)
public JsonResult<List<CommonProfessionalTypeDTO>> list() {
JsonResult result = null;
Iterable<ProfessionalType> professionalTypes = professionalTypeService.list();
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(professionalTypes);
return result;
}
Aggregations