Search in sources :

Example 1 with GroupMemberView

use of org.olat.admin.securitygroup.gui.GroupMemberView in project OpenOLAT by OpenOLAT.

the class GroupController method reloadData.

public void reloadData() {
    // refresh view
    List<GroupMembership> combo = groupDao.getMemberships(group, role);
    List<GroupMemberView> views = new ArrayList<GroupMemberView>(combo.size());
    Map<Long, GroupMemberView> idToViews = new HashMap<Long, GroupMemberView>();
    Set<Long> loadStatus = new HashSet<Long>();
    for (GroupMembership co : combo) {
        Identity identity = co.getIdentity();
        Date addedAt = co.getCreationDate();
        String onlineStatus = null;
        if (chatEnabled) {
            if (getIdentity().equals(identity)) {
                onlineStatus = "me";
            } else if (sessionManager.isOnline(identity.getKey())) {
                loadStatus.add(identity.getKey());
            } else {
                onlineStatus = Presence.unavailable.name();
            }
        }
        GroupMemberView member = new GroupMemberView(identity, addedAt, onlineStatus);
        views.add(member);
        idToViews.put(identity.getKey(), member);
    }
    if (loadStatus.size() > 0) {
        List<Long> statusToLoadList = new ArrayList<Long>(loadStatus);
        Map<Long, String> statusMap = imService.getBuddyStatus(statusToLoadList);
        for (Long toLoad : statusToLoadList) {
            String status = statusMap.get(toLoad);
            GroupMemberView member = idToViews.get(toLoad);
            if (status == null) {
                member.setOnlineStatus(Presence.available.name());
            } else {
                member.setOnlineStatus(status);
            }
        }
    }
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
    identitiesTableModel = new IdentitiesOfGroupTableDataModel(views, getLocale(), userPropertyHandlers, isAdministrativeUser);
    tableCtr.setTableDataModel(identitiesTableModel);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GroupMembership(org.olat.basesecurity.GroupMembership) IdentitiesOfGroupTableDataModel(org.olat.admin.securitygroup.gui.IdentitiesOfGroupTableDataModel) Date(java.util.Date) GroupMemberView(org.olat.admin.securitygroup.gui.GroupMemberView) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) HashSet(java.util.HashSet)

Example 2 with GroupMemberView

use of org.olat.admin.securitygroup.gui.GroupMemberView in project openolat by klemens.

the class GroupController method reloadData.

public void reloadData() {
    // refresh view
    List<GroupMembership> combo = groupDao.getMemberships(group, role);
    List<GroupMemberView> views = new ArrayList<GroupMemberView>(combo.size());
    Map<Long, GroupMemberView> idToViews = new HashMap<Long, GroupMemberView>();
    Set<Long> loadStatus = new HashSet<Long>();
    for (GroupMembership co : combo) {
        Identity identity = co.getIdentity();
        Date addedAt = co.getCreationDate();
        String onlineStatus = null;
        if (chatEnabled) {
            if (getIdentity().equals(identity)) {
                onlineStatus = "me";
            } else if (sessionManager.isOnline(identity.getKey())) {
                loadStatus.add(identity.getKey());
            } else {
                onlineStatus = Presence.unavailable.name();
            }
        }
        GroupMemberView member = new GroupMemberView(identity, addedAt, onlineStatus);
        views.add(member);
        idToViews.put(identity.getKey(), member);
    }
    if (loadStatus.size() > 0) {
        List<Long> statusToLoadList = new ArrayList<Long>(loadStatus);
        Map<Long, String> statusMap = imService.getBuddyStatus(statusToLoadList);
        for (Long toLoad : statusToLoadList) {
            String status = statusMap.get(toLoad);
            GroupMemberView member = idToViews.get(toLoad);
            if (status == null) {
                member.setOnlineStatus(Presence.available.name());
            } else {
                member.setOnlineStatus(status);
            }
        }
    }
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
    identitiesTableModel = new IdentitiesOfGroupTableDataModel(views, getLocale(), userPropertyHandlers, isAdministrativeUser);
    tableCtr.setTableDataModel(identitiesTableModel);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GroupMembership(org.olat.basesecurity.GroupMembership) IdentitiesOfGroupTableDataModel(org.olat.admin.securitygroup.gui.IdentitiesOfGroupTableDataModel) Date(java.util.Date) GroupMemberView(org.olat.admin.securitygroup.gui.GroupMemberView) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 GroupMemberView (org.olat.admin.securitygroup.gui.GroupMemberView)2 IdentitiesOfGroupTableDataModel (org.olat.admin.securitygroup.gui.IdentitiesOfGroupTableDataModel)2 GroupMembership (org.olat.basesecurity.GroupMembership)2 Identity (org.olat.core.id.Identity)2 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)2