示例#1
0
  @Override
  public List<Long> fetchUserIdsFromGroupId(final Long groupId) {
    final CMQueryResult result =
        view.select(anyAttribute(userClass())) //
            .from(userClass()) //
            .join(roleClass(), over(userGroupDomain())) //
            .where(
                condition(
                    attribute(roleClass(), roleClass().getKeyAttributeName()), eq(groupId))) //
            .run();

    final List<Long> userIdsForSpecifiedGroup = Lists.newArrayList();
    for (final CMQueryRow row : result) {
      final CMCard userCard = row.getCard(userClass());
      userIdsForSpecifiedGroup.add(userCard.getId());
    }
    return userIdsForSpecifiedGroup;
  }
示例#2
0
  private CMUser buildUserFromCard(final CMCard _userCard) {
    final CMCard userCard = NullOnErrorOfGetCard.of(_userCard);
    final Long userId = userCard.getId();
    final String username = userCard.get(userNameAttribute(), String.class);
    final String email = userCard.get(userEmailAttribute(), String.class);
    final String userDescription = userCard.get(userDescriptionAttribute(), String.class);
    final String defaultGroupName = fetchDefaultGroupNameForUser(username);
    final UserImplBuilder userBuilder =
        UserImpl.newInstanceBuilder() //
            .withId(userId) //
            .withUsername(defaultString(username)) //
            .withEmail(defaultString(email)) //
            .withDescription(defaultString(userDescription)) //
            .withDefaultGroupName(defaultGroupName); //

    final List<String> userGroups = fetchGroupNamesForUser(userId);
    for (final String groupName : userGroups) {
      userBuilder.withGroupName(groupName);
      addGroupDescription(userBuilder, groupName);
    }
    userBuilder.withActiveStatus(isActive(userCard));
    return userBuilder.build();
  }