Search in sources :

Example 1 with BuddyGroup

use of org.olat.instantMessaging.model.BuddyGroup in project OpenOLAT by OpenOLAT.

the class IMBuddyListController method loadRoster.

private void loadRoster(ViewMode mode) {
    this.viewMode = mode;
    buddyList.clear();
    buddyList.getGroups().clear();
    boolean offlineUsers = (viewMode == ViewMode.offlineUsers);
    buddyList.getGroups().addAll(imService.getBuddyGroups(getIdentity(), offlineUsers));
    for (BuddyGroup group : buddyList.getGroups()) {
        for (Buddy buddy : group.getBuddy()) {
            forgeBuddyLink(group, buddy);
        }
    }
    buddiesListContent.setDirty(true);
}
Also used : BuddyGroup(org.olat.instantMessaging.model.BuddyGroup) Buddy(org.olat.instantMessaging.model.Buddy)

Example 2 with BuddyGroup

use of org.olat.instantMessaging.model.BuddyGroup in project OpenOLAT by OpenOLAT.

the class InstantMessagingServiceImpl method getBuddyGroups.

@Override
public List<BuddyGroup> getBuddyGroups(Identity me, boolean offlineUsers) {
    List<BuddyGroup> groups = new ArrayList<BuddyGroup>(25);
    Map<Long, BuddyGroup> groupMap = new HashMap<Long, BuddyGroup>();
    Map<Long, String> identityKeyToStatus = new HashMap<Long, String>();
    List<ContactViewExtended> contactList = contactDao.getContactWithExtendedInfos(me);
    collectMembersStatus(contactList, identityKeyToStatus);
    for (ContactViewExtended contact : contactList) {
        addBuddyToGroupList(contact, me, groupMap, groups, identityKeyToStatus, offlineUsers);
    }
    return groups;
}
Also used : HashMap(java.util.HashMap) ContactViewExtended(org.olat.group.model.ContactViewExtended) ArrayList(java.util.ArrayList) BuddyGroup(org.olat.instantMessaging.model.BuddyGroup)

Example 3 with BuddyGroup

use of org.olat.instantMessaging.model.BuddyGroup in project OpenOLAT by OpenOLAT.

the class Roster method getBuddies.

public synchronized List<Buddy> getBuddies() {
    Set<Buddy> buddies = new HashSet<Buddy>();
    Set<Buddy> vips = new HashSet<Buddy>();
    for (Buddy entry : entries) {
        if (entry.isVip()) {
            vips.add(entry);
        }
        buddies.add(entry);
    }
    for (BuddyGroup group : groups) {
        for (Buddy entry : group.getBuddy()) {
            if (entry.isVip()) {
                vips.add(entry);
            }
            buddies.add(entry);
        }
    }
    // if vip once, vip always
    List<Buddy> orderedBuddies = new ArrayList<Buddy>(buddies.size());
    for (Buddy buddy : buddies) {
        Buddy clone = buddy.clone();
        clone.setVip(vips.contains(buddy));
        orderedBuddies.add(clone);
    }
    Collections.sort(orderedBuddies);
    return orderedBuddies;
}
Also used : ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) BuddyGroup(org.olat.instantMessaging.model.BuddyGroup) Buddy(org.olat.instantMessaging.model.Buddy) HashSet(java.util.HashSet)

Example 4 with BuddyGroup

use of org.olat.instantMessaging.model.BuddyGroup in project openolat by klemens.

the class IMBuddyListController method loadRoster.

private void loadRoster(ViewMode mode) {
    this.viewMode = mode;
    buddyList.clear();
    buddyList.getGroups().clear();
    boolean offlineUsers = (viewMode == ViewMode.offlineUsers);
    buddyList.getGroups().addAll(imService.getBuddyGroups(getIdentity(), offlineUsers));
    for (BuddyGroup group : buddyList.getGroups()) {
        for (Buddy buddy : group.getBuddy()) {
            forgeBuddyLink(group, buddy);
        }
    }
    buddiesListContent.setDirty(true);
}
Also used : BuddyGroup(org.olat.instantMessaging.model.BuddyGroup) Buddy(org.olat.instantMessaging.model.Buddy)

Example 5 with BuddyGroup

use of org.olat.instantMessaging.model.BuddyGroup in project openolat by klemens.

the class InstantMessagingServiceImpl method addBuddyToGroupList.

private void addBuddyToGroupList(ContactViewExtended member, Identity me, Map<Long, BuddyGroup> groupMap, List<BuddyGroup> groups, Map<Long, String> identityKeyToStatus, boolean offlineUsers) {
    if (me != null && me.getKey().equals(member.getIdentityKey())) {
        return;
    }
    String status = identityKeyToStatus.get(member.getIdentityKey());
    if (status == null) {
        boolean online = isOnline(member.getIdentityKey());
        if (online) {
            status = prefsDao.getStatus(member.getIdentityKey());
            if (status == null) {
                status = Presence.available.name();
            }
        } else {
            status = Presence.unavailable.name();
        }
        identityKeyToStatus.put(member.getIdentityKey(), status);
    }
    if (offlineUsers || Presence.available.name().equals(status)) {
        BuddyGroup group = groupMap.get(member.getGroupKey());
        if (group == null) {
            group = new BuddyGroup(member.getGroupKey(), member.getGroupName());
            groupMap.put(member.getGroupKey(), group);
            groups.add(group);
        }
        boolean vip = GroupRoles.coach.name().equals(member.getRole());
        String name = userManager.getUserDisplayName(member);
        group.addBuddy(new Buddy(member.getIdentityKey(), member.getUsername(), name, false, vip, status));
    }
}
Also used : BuddyGroup(org.olat.instantMessaging.model.BuddyGroup) Buddy(org.olat.instantMessaging.model.Buddy)

Aggregations

BuddyGroup (org.olat.instantMessaging.model.BuddyGroup)8 Buddy (org.olat.instantMessaging.model.Buddy)6 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 ContactViewExtended (org.olat.group.model.ContactViewExtended)2