Search in sources :

Example 36 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class LDAPSyncConfiguration method checkIfOlatPropertiesExists.

/**
 * Checks if defined OLAT Properties in olatextconfig.xml exist in OLAT.
 *
 * 	 Configuration: LDAP Attributes Map = olatextconfig.xml (property=reqAttrs, property=userAttributeMapper)
 *
 * @param attrs Map of OLAT Properties from of the LDAP configuration
 * @return true All exist OK, false Error
 */
protected boolean checkIfOlatPropertiesExists(Map<String, String> attrs) {
    List<UserPropertyHandler> upHandler = userManager.getAllUserPropertyHandlers();
    for (String ldapAttribute : attrs.keySet()) {
        boolean propertyExists = false;
        String olatProperty = attrs.get(ldapAttribute);
        if (olatProperty.equals(LDAPConstants.LDAP_USER_IDENTIFYER)) {
            // LDAP user identifyer is not a user propery, it's the username
            continue;
        }
        for (UserPropertyHandler userPropItr : upHandler) {
            if (olatProperty.equals(userPropItr.getName())) {
                // ok, this property exist, continue with next one
                propertyExists = true;
                break;
            }
        }
        if (!propertyExists) {
            log.error("Error in checkIfOlatPropertiesExists(): configured LDAP attribute::" + ldapAttribute + " configured to map to OLAT user property::" + olatProperty + " but no such user property configured in olat_userconfig.xml");
            return false;
        }
    }
    return true;
}
Also used : UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 37 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class LecturesSearchFormController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
    login.setVisible(adminProps);
    userPropertyHandlers = userManager.getUserPropertyHandlersFor(PROPS_IDENTIFIER, adminProps);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler != null) {
            FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, PROPS_IDENTIFIER, false, formLayout);
            fi.setMandatory(false);
            // DO NOT validate email field => see OLAT-3324, OO-155, OO-222
            if (userPropertyHandler instanceof EmailProperty && fi instanceof TextElement) {
                TextElement textElement = (TextElement) fi;
                textElement.setItemValidatorProvider(null);
            }
            propFormItems.put(userPropertyHandler.getName(), fi);
        }
    }
    bulkEl = uifactory.addTextAreaElement("bulk", 4, 72, "", formLayout);
    bulkEl.setHelpText(translate("bulk.hint"));
    bulkEl.setExampleKey("bulk.example", null);
    List<RepositoryEntryLifecycle> cycles = lifecycleDao.loadPublicLifecycle();
    String[] dateKeys;
    String[] dateValues;
    if (cycles.isEmpty()) {
        dateKeys = new String[] { "none", "private" };
        dateValues = new String[] { translate("dates.none"), translate("dates.private") };
    } else {
        dateKeys = new String[] { "none", "private", "public" };
        dateValues = new String[] { translate("dates.none"), translate("dates.private"), translate("dates.public") };
    }
    dateTypesEl = uifactory.addRadiosVertical("dates", formLayout, dateKeys, dateValues);
    dateTypesEl.select(dateKeys[0], true);
    dateTypesEl.addActionListener(FormEvent.ONCHANGE);
    List<RepositoryEntryLifecycle> filteredCycles = new ArrayList<>();
    for (RepositoryEntryLifecycle cycle : cycles) {
        if (cycle.getValidTo() == null) {
            filteredCycles.add(cycle);
        }
    }
    String[] publicKeys = new String[filteredCycles.size()];
    String[] publicValues = new String[filteredCycles.size()];
    int count = 0;
    for (RepositoryEntryLifecycle cycle : filteredCycles) {
        publicKeys[count] = cycle.getKey().toString();
        StringBuilder sb = new StringBuilder(32);
        boolean labelAvailable = StringHelper.containsNonWhitespace(cycle.getLabel());
        if (labelAvailable) {
            sb.append(cycle.getLabel());
        }
        if (StringHelper.containsNonWhitespace(cycle.getSoftKey())) {
            if (labelAvailable)
                sb.append(" - ");
            sb.append(cycle.getSoftKey());
        }
        publicValues[count++] = sb.toString();
    }
    publicDatesEl = uifactory.addDropdownSingleselect("public.dates", formLayout, publicKeys, publicValues, null);
    String privateDatePage = velocity_root + "/cycle_dates.html";
    privateDatesCont = FormLayoutContainer.createCustomFormLayout("private.date", getTranslator(), privateDatePage);
    privateDatesCont.setRootForm(mainForm);
    privateDatesCont.setLabel("private.dates", null);
    formLayout.add("private.date", privateDatesCont);
    startDateEl = uifactory.addDateChooser("date.start", "date.start", null, privateDatesCont);
    startDateEl.setElementCssClass("o_sel_repo_lifecycle_validfrom");
    endDateEl = uifactory.addDateChooser("date.end", "date.end", null, privateDatesCont);
    endDateEl.setElementCssClass("o_sel_repo_lifecycle_validto");
    FormLayoutContainer buttonCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add(buttonCont);
    uifactory.addFormSubmitButton("search", buttonCont);
}
Also used : FormItem(org.olat.core.gui.components.form.flexible.FormItem) ArrayList(java.util.ArrayList) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) EmailProperty(org.olat.user.propertyhandlers.EmailProperty) TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) RepositoryEntryLifecycle(org.olat.repository.model.RepositoryEntryLifecycle) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 38 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class ImportAuthorOverviewIdentitiesController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    // add the table
    FlexiTableColumnModel tableColumnModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    int colIndex = 0;
    if (isAdministrativeUser) {
        tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel("table.user.login", colIndex++));
    }
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(usageIdentifyer, isAdministrativeUser);
    List<UserPropertyHandler> resultingPropertyHandlers = new ArrayList<UserPropertyHandler>();
    // followed by the users fields
    for (int i = 0; i < userPropertyHandlers.size(); i++) {
        UserPropertyHandler userPropertyHandler = userPropertyHandlers.get(i);
        boolean visible = UserManager.getInstance().isMandatoryUserProperty(usageIdentifyer, userPropertyHandler);
        if (visible) {
            resultingPropertyHandlers.add(userPropertyHandler);
            tableColumnModel.addFlexiColumnModel(new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colIndex++));
        }
    }
    Translator myTrans = userManager.getPropertyHandlerTranslator(getTranslator());
    ImportAuthorOverviewDataModel userTableModel = new ImportAuthorOverviewDataModel(oks, resultingPropertyHandlers, isAdministrativeUser, getLocale(), tableColumnModel);
    uifactory.addTableElement(getWindowControl(), "users", userTableModel, myTrans, formLayout);
}
Also used : Translator(org.olat.core.gui.translator.Translator) ArrayList(java.util.ArrayList) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 39 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class ImportAuthorOverviewDataModel method getValueAt.

@Override
public Object getValueAt(int row, int col) {
    Identity identity = getObject(row);
    if (col == 0 && isAdministrativeUser) {
        return identity.getName();
    }
    int pos = isAdministrativeUser ? col - 1 : col;
    if (pos >= 0 && pos < userPropertyHandlers.size()) {
        UserPropertyHandler handler = userPropertyHandlers.get(pos);
        return handler.getUserProperty(identity.getUser(), locale);
    }
    return "";
}
Also used : Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 40 with UserPropertyHandler

use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.

the class CoachingDAOTest method testExtern.

/**
 * To test performance against an external database ( of a customer ).
 */
@Test
@Ignore
public void testExtern() {
    Identity coach = securityManager.loadIdentityByKey(46268418l);
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(UserListController.usageIdentifyer, false);
    if (coach != null) {
        long start = System.nanoTime();
        coachingDAO.getCoursesStatisticsNative(coach);
        CodeHelper.printNanoTime(start, "Courses");
        start = System.nanoTime();
        coachingDAO.getGroupsStatisticsNative(coach);
        CodeHelper.printNanoTime(start, "Groups");
        start = System.nanoTime();
        coachingDAO.getStudentsStatisticsNative(coach, userPropertyHandlers);
        CodeHelper.printNanoTime(start, "Students");
    }
}
Also used : Identity(org.olat.core.id.Identity) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler) Ignore(org.junit.Ignore) CoachingLargeTest(org.olat.modules.coach.CoachingLargeTest) Test(org.junit.Test)

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