public Collection<UserGroupDTO> getMembersForGroup(String groupId) { Map<String, String> membersMap = groupMembersRepository.findMembers(groupId); Collection<UserGroupDTO> userGroupDTOs = new TreeSet<UserGroupDTO>(); for (Map.Entry<String, String> member : membersMap.entrySet()) { UserGroupDTO dto = new UserGroupDTO(); User user = userRepository.findUserByLogin(member.getKey()); dto.setLogin(user.getLogin()); dto.setUsername(user.getUsername()); dto.setGravatar(user.getGravatar()); dto.setFirstName(user.getFirstName()); dto.setLastName(user.getLastName()); dto.setRole(member.getValue()); userGroupDTOs.add(dto); } return userGroupDTOs; }
@Override public int compareTo(UserGroupDTO o) { return this.username.compareTo(o.getUsername()); }