use of org.olat.instantMessaging.model.BuddyGroup in project OpenOLAT by OpenOLAT.
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));
}
}
use of org.olat.instantMessaging.model.BuddyGroup in project openolat by klemens.
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;
}
use of org.olat.instantMessaging.model.BuddyGroup in project openolat by klemens.
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;
}
Aggregations