use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class BusinessGroupArchiver method appendIdentity.
private void appendIdentity(StringBuffer buf, Identity owner, Date addedTo, Translator translator) {
Locale loc = translator.getLocale();
// add the identities user name
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(owner);
String uname = BusinessControlFactory.getInstance().getAsURIString(Collections.singletonList(ce), false);
buf.append(uname);
buf.append(DELIMITER);
// add all user properties
for (UserPropertyHandler propertyHandler : getUserPropertyHandlers()) {
String value = propertyHandler.getUserProperty(owner.getUser(), loc);
if (StringHelper.containsNonWhitespace(value)) {
buf.append(value);
}
buf.append(DELIMITER);
}
// add the added-to date
buf.append(addedTo.toString());
buf.append(EOL);
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class BusinessGroupArchiver method appendIdentityTableHeader.
private void appendIdentityTableHeader(StringBuffer buf, Translator translator) {
// first the identites name
buf.append(translator.translate("table.user.url"));
buf.append(DELIMITER);
// second the users properties
for (UserPropertyHandler propertyHandler : getUserPropertyHandlers()) {
String label = translator.translate(propertyHandler.i18nColumnDescriptorLabelKey());
buf.append(label);
buf.append(DELIMITER);
}
// third the users added-to date
buf.append(translator.translate("table.subject.addeddate"));
buf.append(EOL);
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class AbstractMemberListController method initColumns.
private SortKey initColumns(FlexiTableColumnModel columnsModel) {
SortKey defaultSortKey = null;
String editAction = readOnly ? null : TABLE_ACTION_EDIT;
if (chatEnabled) {
DefaultFlexiColumnModel chatCol = new DefaultFlexiColumnModel(Cols.online.i18n(), Cols.online.ordinal());
chatCol.setExportable(false);
columnsModel.addFlexiColumnModel(chatCol);
}
if (isAdministrativeUser) {
FlexiCellRenderer renderer = new StaticFlexiCellRenderer(editAction, new TextFlexiCellRenderer());
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.username.i18n(), Cols.username.ordinal(), editAction, true, Cols.username.name(), renderer));
defaultSortKey = new SortKey(Cols.username.name(), true);
}
int colPos = USER_PROPS_OFFSET;
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null)
continue;
String propName = userPropertyHandler.getName();
boolean visible = userManager.isMandatoryUserProperty(USER_PROPS_ID, userPropertyHandler);
FlexiColumnModel col;
if (UserConstants.FIRSTNAME.equals(propName) || UserConstants.LASTNAME.equals(propName)) {
col = new DefaultFlexiColumnModel(userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, editAction, true, propName, new StaticFlexiCellRenderer(editAction, new TextFlexiCellRenderer()));
} else {
col = new DefaultFlexiColumnModel(visible, userPropertyHandler.i18nColumnDescriptorLabelKey(), colPos, true, propName);
}
columnsModel.addFlexiColumnModel(col);
colPos++;
if (defaultSortKey == null) {
defaultSortKey = new SortKey(propName, true);
}
}
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.firstTime.i18n(), Cols.firstTime.ordinal(), true, Cols.firstTime.name()));
if (isLastVisitVisible) {
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.lastTime.i18n(), Cols.lastTime.ordinal(), true, Cols.lastTime.name()));
}
CourseRoleCellRenderer roleRenderer = new CourseRoleCellRenderer(getLocale());
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.role.i18n(), Cols.role.ordinal(), true, Cols.role.name(), roleRenderer));
if (repoEntry != null) {
GroupCellRenderer groupRenderer = new GroupCellRenderer();
columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.groups.i18n(), Cols.groups.ordinal(), true, Cols.groups.name(), groupRenderer));
}
DefaultFlexiColumnModel toolsCol = new DefaultFlexiColumnModel(Cols.tools.i18n(), Cols.tools.ordinal());
toolsCol.setExportable(false);
toolsCol.setAlwaysVisible(true);
columnsModel.addFlexiColumnModel(toolsCol);
return defaultSortKey;
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class AbstractMemberListController method filterIdentities.
private List<Identity> filterIdentities(SearchMembersParams params, Collection<Long> identityKeys) {
SearchIdentityParams idParams = new SearchIdentityParams();
if (StringHelper.containsNonWhitespace(params.getSearchString())) {
String searchString = params.getSearchString();
Map<String, String> propertiesSearch = new HashMap<>();
for (UserPropertyHandler handler : userPropertyHandlers) {
propertiesSearch.put(handler.getName(), searchString);
}
idParams.setLogin(searchString);
idParams.setUserProperties(propertiesSearch);
} else {
if (params.getUserPropertiesSearch() != null && !params.getUserPropertiesSearch().isEmpty()) {
idParams.setUserProperties(params.getUserPropertiesSearch());
}
if (StringHelper.containsNonWhitespace(params.getLogin())) {
idParams.setLogin(params.getLogin());
}
}
List<Long> identityKeyList = new ArrayList<>(identityKeys);
List<Identity> identities = new ArrayList<>(identityKeyList.size());
int count = 0;
int batch = 500;
do {
int toIndex = Math.min(count + batch, identityKeyList.size());
List<Long> toLoad = identityKeyList.subList(count, toIndex);
idParams.setIdentityKeys(toLoad);
List<Identity> batchOfIdentities = securityManager.getIdentitiesByPowerSearch(idParams, 0, -1);
identities.addAll(batchOfIdentities);
count += batch;
} while (count < identityKeyList.size());
return identities;
}
use of org.olat.user.propertyhandlers.UserPropertyHandler in project OpenOLAT by OpenOLAT.
the class RegistrationController method createNewUserAfterRegistration.
/**
* OO-92
* this will finally create the user, set all it's userproperties
*
* @return User the newly created, persisted User Object
*/
private Identity createNewUserAfterRegistration() {
// create user with mandatory fields from registration-form
UserManager um = UserManager.getInstance();
User volatileUser = um.createUser(registrationForm.getFirstName(), registrationForm.getLastName(), tempKey.getEmailAddress());
// set user configured language
Preferences preferences = volatileUser.getPreferences();
preferences.setLanguage(registrationForm.getLangKey());
volatileUser.setPreferences(preferences);
// create an identity with the given username / pwd and the user object
String login = registrationForm.getLogin();
String pwd = registrationForm.getPassword();
Identity persistedIdentity = registrationManager.createNewUserAndIdentityFromTemporaryKey(login, pwd, volatileUser, tempKey);
if (persistedIdentity == null) {
showError("user.notregistered");
return null;
} else {
// update other user properties from form
List<UserPropertyHandler> userPropertyHandlers = um.getUserPropertyHandlersFor(RegistrationForm2.USERPROPERTIES_FORM_IDENTIFIER, false);
User persistedUser = persistedIdentity.getUser();
// add eventually static value
UserPropertiesConfig userPropertiesConfig = CoreSpringFactory.getImpl(UserPropertiesConfig.class);
if (registrationModule.isStaticPropertyMappingEnabled()) {
String propertyName = registrationModule.getStaticPropertyMappingName();
String propertyValue = registrationModule.getStaticPropertyMappingValue();
if (StringHelper.containsNonWhitespace(propertyName) && StringHelper.containsNonWhitespace(propertyValue) && userPropertiesConfig.getPropertyHandler(propertyName) != null) {
try {
persistedUser.setProperty(propertyName, propertyValue);
} catch (Exception e) {
logError("Cannot set the static property value", e);
}
}
}
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
FormItem fi = registrationForm.getPropFormItem(userPropertyHandler.getName());
userPropertyHandler.updateUserFromFormItem(persistedUser, fi);
}
// persist changes in db
um.updateUserFromIdentity(persistedIdentity);
// send notification mail to sys admin
String notiEmail = CoreSpringFactory.getImpl(RegistrationModule.class).getRegistrationNotificationEmail();
if (notiEmail != null) {
registrationManager.sendNewUserNotificationMessage(notiEmail, persistedIdentity);
}
// tell system that this user did accept the disclaimer
registrationManager.setHasConfirmedDislaimer(persistedIdentity);
return persistedIdentity;
}
}
Aggregations