Пример #1
0
 /**
  * Counts the total number of user entries from the memberslist.<br>
  * NOTE: This does not count distinct users - so with multiple selected groups, the count may be
  * off
  */
 public int getAssignedUsersCount() {
   int assignedUsersCount = 0;
   Iterator groupOptions = getMembersList().iterator();
   while (groupOptions.hasNext()) {
     GroupOption groupOption = (GroupOption) groupOptions.next();
     assignedUsersCount += groupOption.getChildOptions().size();
   }
   return assignedUsersCount;
 }
Пример #2
0
 /** used to determine what the option value (format) for a UserOption should be */
 public String getOptionValue(UserOption userOption) {
   if (userOption != null) {
     GroupOption parentOption = userOption.getParentOption();
     if (parentOption != null && parentOption.getGroup() != null) {
       return userOption.getName() + OPTION_VALUE_SEPERATOR + parentOption.getRawName();
     } else {
       return userOption.getName();
     }
   }
   return "";
 }
Пример #3
0
  /**
   * Used to populate the assigned users of the selected groups.<br>
   * Always has the 'All' group which represents all the members of the selected groups.<br>
   * Rest of the users are added under individual group names.
   */
  public Collection getMembersList() {
    if (membersList != null || getSelectedGroupsUserHasPermToSee() == null) return membersList;

    membersList = new ArrayList();
    overloadedGroups = new ArrayList();
    boolean singleGroupSelected = getSelectedGroupsUserHasPermToSee().size() == 1;

    // for each selected group
    GroupOption allGroupOption =
        new GroupOption(getText("admin.bulkeditgroups.all.selected.groups"));
    membersList.add(allGroupOption);
    Iterator<Group> groups = getSelectedGroupsUserHasPermToSee().iterator();
    while (groups.hasNext()) {
      Group group = groups.next();
      // and for each users in that group
      if (group != null) {
        GroupOption groupOption = new GroupOption(group);
        Collection<User> users = groupManager.getDirectUsersInGroup(group);
        Iterator<User> usersOfGroup = users.iterator();
        int count = 0;
        while (usersOfGroup.hasNext()) {
          User user = usersOfGroup.next();
          if (user != null) {
            // increment count
            count++;

            if (count > getMaxUsersDisplayedPerGroup()) {
              overloadedGroups.add(group.getName());
              break;
            }

            if (singleGroupSelected || !isUserInAllGroupsSelected(user)) {
              groupOption.addChildOption(new UserOption(user));
            } else // if more than one group is selected and the user is in all groups add to the
            // main list
            {
              allGroupOption.addChildOption(new UserOption(user));
            }
          }
        }

        if (!groupOption.getChildOptions().isEmpty()) membersList.add(groupOption);
      }
    }
    if (allGroupOption.getChildOptions().isEmpty()) {
      // remove only if empty (must be inserted at top to keep order)
      membersList.remove(allGroupOption);
    }
    return membersList;
  }