Search in sources :

Example 66 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.

the class GroupController method reloadData.

public void reloadData() {
    // refresh view
    List<Object[]> combo = securityManager.getIdentitiesAndDateOfSecurityGroup(securityGroup);
    List<GroupMemberView> views = new ArrayList<GroupMemberView>(combo.size());
    Map<Long, GroupMemberView> idToViews = new HashMap<Long, GroupMemberView>();
    Set<Long> loadStatus = new HashSet<Long>();
    for (Object[] co : combo) {
        Identity identity = (Identity) co[0];
        Date addedAt = (Date) co[1];
        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) Date(java.util.Date) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) HashSet(java.util.HashSet)

Example 67 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.

the class GroupController method initGroupTable.

/**
 * Init GroupList-table-controller for non-waitinglist (participant-list,
 * owner-list).
 */
protected void initGroupTable(TableController tableController, UserRequest ureq, boolean enableTablePreferences, boolean enableUserSelection) {
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
    if (isAdministrativeUser) {
        // first the login name, but only if administrative user
        DefaultColumnDescriptor cd0 = new DefaultColumnDescriptor("table.user.login", 0, COMMAND_VCARD, ureq.getLocale());
        cd0.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        tableController.addColumnDescriptor(cd0);
    }
    if (chatEnabled) {
        tableController.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.online", 1, COMMAND_IM, getLocale(), ColumnDescriptor.ALIGNMENT_LEFT, new OnlineIconRenderer()));
    }
    int visibleColId = 0;
    // followed by the users fields
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        boolean visible = userManager.isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
        ColumnDescriptor cd = userPropertyHandler.getColumnDescriptor(i + 3, COMMAND_VCARD, ureq.getLocale());
        // make all user attributes clickable to open visiting card
        if (cd instanceof DefaultColumnDescriptor) {
            DefaultColumnDescriptor dcd = (DefaultColumnDescriptor) cd;
            dcd.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        }
        tableController.addColumnDescriptor(visible, cd);
        if (visible) {
            visibleColId++;
        }
    }
    // in the end
    if (enableTablePreferences) {
        DefaultColumnDescriptor dcd = new DefaultColumnDescriptor("table.subject.addeddate", 2, COMMAND_VCARD, ureq.getLocale());
        dcd.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        tableController.addColumnDescriptor(true, dcd);
        tableController.setSortColumn(++visibleColId, true);
    }
    if (enableUserSelection) {
        tableController.addColumnDescriptor(new StaticColumnDescriptor(COMMAND_SELECTUSER, "table.subject.action", myTrans.translate("action.general")));
    }
    if (mayModifyMembers) {
        tableController.addMultiSelectAction("action.remove", COMMAND_REMOVEUSER);
        tableController.setMultiSelect(true);
    }
}
Also used : CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) OnlineIconRenderer(org.olat.group.ui.main.OnlineIconRenderer) CustomRenderColumnDescriptor(org.olat.core.gui.components.table.CustomRenderColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) ColumnDescriptor(org.olat.core.gui.components.table.ColumnDescriptor) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor)

Example 68 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.

the class ExtendedIdentitiesTableDataModel method getValueAt.

/**
 * @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int)
 */
@Override
public final Object getValueAt(int row, int col) {
    Identity identity = getObject(row);
    User user = identity.getUser();
    int offSet = isAdministrativeUser ? 1 : 0;
    if (col == 0 && isAdministrativeUser) {
        return identity.getName();
    }
    if (col >= offSet && col < userPropertyHandlers.size() + offSet) {
        // get user property for this column
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(col - offSet);
        String value = userPropertyHandler.getUserProperty(user, getLocale());
        return (value == null ? "n/a" : value);
    }
    if (col == userPropertyHandlers.size() + offSet) {
        return identity.getLastLogin();
    }
    if (col == userPropertyHandlers.size() + offSet + 1) {
        return user.getCreationDate();
    }
    return "error";
}
Also used : User(org.olat.core.id.User) Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 69 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.

the class ExtendedIdentitiesTableDataModel method addColumnDescriptors.

/**
 * Add all column descriptors to this table that are available in the table
 * model
 *
 * @param tableCtr
 */
public void addColumnDescriptors(TableController tableCtr, Translator trans) {
    setLocale(trans.getLocale());
    if (isAdministrativeUser) {
        String action = actionEnabled ? COMMAND_SELECTUSER : null;
        tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.identity.name", colCount++, action, getLocale()));
    }
    UserManager um = UserManager.getInstance();
    // followed by the users fields
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        boolean visible = um.isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
        String action = null;
        if (actionEnabled && i < 2) {
            action = COMMAND_SELECTUSER;
        }
        tableCtr.addColumnDescriptor(visible, userPropertyHandler.getColumnDescriptor(colCount++, action, getLocale()));
    }
    // in the end the last login and creation date
    tableCtr.addColumnDescriptor(false, new DefaultColumnDescriptor("table.identity.lastlogin", colCount++, null, getLocale()));
    // creation date at the end, enabled by default
    tableCtr.addColumnDescriptor(new DefaultColumnDescriptor("table.identity.creationdate", colCount++, null, getLocale()));
    if (actionEnabled) {
        StaticColumnDescriptor vcd = new StaticColumnDescriptor(COMMAND_VCARD, "table.header.vcard", trans.translate("table.identity.vcard"));
        vcd.setIsPopUpWindowAction(true, "height=700, width=900, location=no, menubar=no, resizable=yes, status=no, scrollbars=yes, toolbar=no");
        tableCtr.addColumnDescriptor(vcd);
    }
}
Also used : UserManager(org.olat.user.UserManager) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 70 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project openolat by klemens.

the class MembersTableController method initColumns.

private SortKey initColumns(FlexiTableColumnModel columnsModel) {
    int colPos = AbstractMemberListController.USER_PROPS_OFFSET;
    SortKey defaultSortKey = null;
    String rowAction = "vcard";
    if (chatEnabled && editable) {
        DefaultFlexiColumnModel chatCol = new DefaultFlexiColumnModel(Cols.online.i18n(), Cols.online.ordinal());
        chatCol.setExportable(false);
        columnsModel.addFlexiColumnModel(chatCol);
    }
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        boolean visible = userManager.isMandatoryUserProperty(MembersDisplayRunController.USER_PROPS_LIST_ID, userPropertyHandler);
        String emailRowAction = rowAction;
        FlexiColumnModel col;
        if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName) || UserConstants.EMAIL.equals(propName)) {
            // when email is enabled, the action will trigger email workflow
            if (UserConstants.EMAIL.equals(propName) && canEmail) {
                emailRowAction = "email";
            }
            col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, emailRowAction, true, propName, new StaticFlexiCellRenderer(emailRowAction, new TextFlexiCellRenderer()));
        } else {
            col = new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName);
        }
        columnsModel.addFlexiColumnModel(col);
        colPos++;
        if (defaultSortKey == null) {
            defaultSortKey = new SortKey(propName, true);
        }
    }
    if (userLastTimeVisible) {
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.firstTime.i18n(), Cols.firstTime.ordinal(), true, Cols.firstTime.name()));
        columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.lastTime.i18n(), Cols.lastTime.ordinal(), true, Cols.lastTime.name()));
    }
    return defaultSortKey;
}
Also used : StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) FlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel) SortKey(org.olat.core.commons.persistence.SortKey) TextFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Aggregations

UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)319 Identity (org.olat.core.id.Identity)84 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)74 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)70 ArrayList (java.util.ArrayList)62 FormItem (org.olat.core.gui.components.form.flexible.FormItem)62 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)56 User (org.olat.core.id.User)52 HashMap (java.util.HashMap)40 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)36 FlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiColumnModel)34 Translator (org.olat.core.gui.translator.Translator)32 Date (java.util.Date)30 UserManager (org.olat.user.UserManager)28 TextFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.TextFlexiCellRenderer)24 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)24 File (java.io.File)22 BusinessGroup (org.olat.group.BusinessGroup)22 SortKey (org.olat.core.commons.persistence.SortKey)18 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)18