use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.SkillDTO in project ArachneCentralAPI by OHDSI.
the class BaseSkillController method update.
@ApiOperation(value = "Update skill description.", hidden = true)
@RequestMapping(value = "/api/v1/admin/skills/{skillId}", method = RequestMethod.PUT)
public JsonResult<SkillDTO> update(@PathVariable("skillId") Long id, @RequestBody @Valid SkillDTO skillDTO, BindingResult binding) throws NotExistException, NotUniqueException, ValidationException {
JsonResult<SkillDTO> result;
if (binding.hasErrors()) {
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
for (FieldError fieldError : binding.getFieldErrors()) {
result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
}
} else {
skillDTO.setId(id);
S skill = convertDtoToSkill(skillDTO);
skill = skillService.update(skill);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(conversionService.convert(skill, SkillDTO.class));
}
return result;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.SkillDTO in project ArachneCentralAPI by OHDSI.
the class SkillToSkillDTOConverter method convert.
@Override
public SkillDTO convert(Skill source) {
SkillDTO skillDTO = new SkillDTO();
skillDTO.setId(source.getId());
skillDTO.setName(source.getName());
return skillDTO;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.SkillDTO in project ArachneCentralAPI by OHDSI.
the class UserToUserProfileDTOConverter method convert.
@Override
public UserProfileDTO convert(IUser user) {
UserProfileDTO dto = new UserProfileDTO();
dto.setId(user.getUuid());
dto.setEnabled(user.getEnabled());
dto.setCreated(user.getCreated());
dto.setUpdated(user.getUpdated());
HashSet<SkillDTO> skills = new HashSet<>();
for (Skill skill : user.getSkills()) {
skills.add(conversionService.convert(skill, SkillDTO.class));
}
dto.setSkills(skills);
LinkedList<UserPublicationDTO> publications = new LinkedList<>();
for (UserPublication userPublication : user.getPublications()) {
publications.add(conversionService.convert(userPublication, UserPublicationDTO.class));
}
dto.setPublications(publications);
LinkedList<UserLinkDTO> links = new LinkedList<>();
for (UserLink userLink : user.getLinks()) {
links.add(conversionService.convert(userLink, UserLinkDTO.class));
}
dto.setLinks(links);
dto.setGeneral(conversionService.convert(user, UserProfileGeneralDTO.class));
return dto;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.SkillDTO in project ArachneCentralAPI by OHDSI.
the class SkillControllerTests method testCreateSkill.
@Test
@DatabaseSetup("/data/skill/empty-skill.xml")
@ExpectedDatabase(value = "/data/skill/added-skill.xml", assertionMode = NON_STRICT)
public void testCreateSkill() throws Exception {
SkillDTO skillDTO = new SkillDTO();
skillDTO.setName(SKILL_NAME);
MvcResult mvcResult = mvc.perform(post("/api/v1/user-management/skills/").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(skillDTO))).andExpect(jsonPath("$.result.id").isNotEmpty()).andExpect(OK_STATUS).andExpect(NO_ERROR_CODE).andReturn();
JSONAssert.assertEquals(SKILL_JSON_OBJECT, getResultJSONObject(mvcResult), false);
}
use of com.odysseusinc.arachne.portal.api.v1.dto.dictionary.SkillDTO in project ArachneCentralAPI by OHDSI.
the class BaseSkillController method create.
@ApiOperation("Register new skill.")
@RequestMapping(value = "/api/v1/user-management/skills", method = RequestMethod.POST)
public JsonResult<SkillDTO> create(@RequestBody @Valid SkillDTO skillDTO, BindingResult binding) throws NotExistException, NotUniqueException, PermissionDeniedException {
JsonResult<SkillDTO> result;
if (binding.hasErrors()) {
result = new JsonResult<>(JsonResult.ErrorCode.VALIDATION_ERROR);
for (FieldError fieldError : binding.getFieldErrors()) {
result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
}
} else {
S skill = convertDtoToSkill(skillDTO);
skill = skillService.create(skill);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(conversionService.convert(skill, SkillDTO.class));
}
return result;
}
Aggregations