Search in sources :

Example 1 with UserDto

use of org.camunda.bpm.engine.rest.dto.task.UserDto in project camunda-bpm-platform by camunda.

the class IdentityRestServiceImpl method getGroupInfo.

@Override
public GroupInfoDto getGroupInfo(String userId) {
    if (userId == null) {
        throw new InvalidRequestException(Status.BAD_REQUEST, "No user id was supplied");
    }
    IdentityService identityService = getProcessEngine().getIdentityService();
    GroupQuery query = identityService.createGroupQuery();
    List<Group> userGroups = query.groupMember(userId).orderByGroupName().asc().list();
    Set<UserDto> allGroupUsers = new HashSet<UserDto>();
    List<GroupDto> allGroups = new ArrayList<GroupDto>();
    for (Group group : userGroups) {
        List<User> groupUsers = identityService.createUserQuery().memberOfGroup(group.getId()).list();
        for (User user : groupUsers) {
            if (!user.getId().equals(userId)) {
                allGroupUsers.add(new UserDto(user.getId(), user.getFirstName(), user.getLastName()));
            }
        }
        allGroups.add(new GroupDto(group.getId(), group.getName()));
    }
    return new GroupInfoDto(allGroups, allGroupUsers);
}
Also used : Group(org.camunda.bpm.engine.identity.Group) User(org.camunda.bpm.engine.identity.User) UserDto(org.camunda.bpm.engine.rest.dto.task.UserDto) GroupDto(org.camunda.bpm.engine.rest.dto.task.GroupDto) ArrayList(java.util.ArrayList) IdentityService(org.camunda.bpm.engine.IdentityService) GroupQuery(org.camunda.bpm.engine.identity.GroupQuery) GroupInfoDto(org.camunda.bpm.engine.rest.dto.task.GroupInfoDto) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IdentityService (org.camunda.bpm.engine.IdentityService)1 Group (org.camunda.bpm.engine.identity.Group)1 GroupQuery (org.camunda.bpm.engine.identity.GroupQuery)1 User (org.camunda.bpm.engine.identity.User)1 GroupDto (org.camunda.bpm.engine.rest.dto.task.GroupDto)1 GroupInfoDto (org.camunda.bpm.engine.rest.dto.task.GroupInfoDto)1 UserDto (org.camunda.bpm.engine.rest.dto.task.UserDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1