use of com.odysseusinc.arachne.portal.api.v1.dto.UserLinkDTO in project ArachneCentralAPI by OHDSI.
the class UserLinkToLinkDTOConverter method convert.
@Override
public UserLinkDTO convert(UserLink userLink) {
UserLinkDTO dto = new UserLinkDTO();
dto.setDescription(userLink.getDescription());
dto.setTitle(userLink.getTitle());
dto.setId(userLink.getId());
dto.setUrl(userLink.getUrl());
return dto;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.UserLinkDTO 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.UserLinkDTO in project ArachneCentralAPI by OHDSI.
the class UserControllerTests method testLinkToUser.
@Test
@WithUserDetails(value = ADMIN_EMAIL)
@DatabaseSetup("/data/user/admin-user.xml")
@ExpectedDatabase(value = "/data/user/admin-user-with-link.xml", assertionMode = NON_STRICT)
public void testLinkToUser() throws Exception {
UserLinkDTO link = getUserLinkDTO();
MvcResult mvcResult = mvc.perform(post("/api/v1/user-management/users/links").contentType(APPLICATION_JSON).content(objectMapper.writeValueAsString(link))).andExpect(NO_ERROR_CODE).andExpect(OK_STATUS).andExpect(jsonPath("$.result.links").isNotEmpty()).andExpect(jsonPath("$.result.links").isArray()).andExpect(jsonPath("$.result.links", hasSize(1))).andReturn();
JSONAssert.assertEquals(ADMIN_JSON_OBJECT, getGeneral(mvcResult), FALSE);
JSONArray links = (JSONArray) getResultJSONObject(mvcResult).get("links");
JSONAssert.assertEquals(USER_LINK, (JSONObject) links.get(0), FALSE);
}
use of com.odysseusinc.arachne.portal.api.v1.dto.UserLinkDTO in project ArachneCentralAPI by OHDSI.
the class BaseUserController method addLink.
@ApiOperation("Add link to user profile.")
@RequestMapping(value = "/api/v1/user-management/users/links", method = POST)
public JsonResult<UserProfileDTO> addLink(Principal principal, @Valid @RequestBody UserLinkDTO userLinkDTO, BindingResult binding) throws NotExistException, PermissionDeniedException, NotUniqueException {
JsonResult<UserProfileDTO> result;
if (binding.hasErrors()) {
result = new JsonResult<>(VALIDATION_ERROR);
for (FieldError fieldError : binding.getFieldErrors()) {
result.getValidatorErrors().put(fieldError.getField(), fieldError.getDefaultMessage());
}
} else {
U user = userService.getByEmail(principal.getName());
user = userService.addLinkToUser(user.getId(), conversionService.convert(userLinkDTO, UserLink.class));
UserProfileDTO userProfileDTO = conversionService.convert(user, UserProfileDTO.class);
result = new JsonResult<>(JsonResult.ErrorCode.NO_ERROR);
result.setResult(userProfileDTO);
}
return result;
}
use of com.odysseusinc.arachne.portal.api.v1.dto.UserLinkDTO in project ArachneCentralAPI by OHDSI.
the class UserControllerTests method getUserLinkDTO.
private UserLinkDTO getUserLinkDTO() {
UserLinkDTO link = new UserLinkDTO();
link.setDescription(USER_LINK_DESCRIPTION);
link.setTitle(USER_LINK_TITLE);
link.setUrl(USER_LINK_URL);
return link;
}
Aggregations