use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class UsermanagerUserSearchForm method findIdentitiesFromSearchForm.
/**
* @return List of identities that match the criterias from the search form
*/
private List<Identity> findIdentitiesFromSearchForm() {
// get user attributes from form
String login = searchform.getStringValue("login");
// when searching for deleted users, add wildcard to match with backup prefix
if (searchform.getStatus().equals(Identity.STATUS_DELETED)) {
login = "*" + login;
}
Integer status = null;
// get user fields from form
// build user fields search map
Map<String, String> userPropertiesSearch = new HashMap<String, String>();
for (UserPropertyHandler userPropertyHandler : searchform.getPropertyHandlers()) {
if (userPropertyHandler == null)
continue;
FormItem ui = searchform.getItem(userPropertyHandler.getName());
String uiValue = userPropertyHandler.getStringValue(ui);
if (userPropertyHandler.getName().startsWith("genericCheckboxProperty") && ui instanceof MultipleSelectionElement) {
if (!"false".equals(uiValue)) {
// ignore false for the search
userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
}
} else if (StringHelper.containsNonWhitespace(uiValue)) {
// when searching for deleted users, add wildcard to match with backup prefix
if (userPropertyHandler instanceof EmailProperty && searchform.getStatus().equals(Identity.STATUS_DELETED)) {
uiValue = "*" + uiValue;
}
userPropertiesSearch.put(userPropertyHandler.getName(), uiValue);
}
}
if (userPropertiesSearch.isEmpty())
userPropertiesSearch = null;
// get group memberships from form
List<SecurityGroup> groupsList = new ArrayList<SecurityGroup>();
if (searchform.getRole("admin")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_ADMIN);
groupsList.add(group);
}
if (searchform.getRole("author")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_AUTHORS);
groupsList.add(group);
}
if (searchform.getRole("groupmanager")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_GROUPMANAGERS);
groupsList.add(group);
}
if (searchform.getRole("usermanager")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_USERMANAGERS);
groupsList.add(group);
}
if (searchform.getRole("oresmanager")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_INST_ORES_MANAGER);
groupsList.add(group);
}
if (searchform.getRole("poolmanager")) {
SecurityGroup group = securityManager.findSecurityGroupByName(Constants.GROUP_POOL_MANAGER);
groupsList.add(group);
}
status = searchform.getStatus();
SecurityGroup[] groups = groupsList.toArray(new SecurityGroup[groupsList.size()]);
// no permissions in this form so far
PermissionOnResourceable[] permissionOnResources = null;
String[] authProviders = searchform.getAuthProviders();
// get date constraints from form
Date createdBefore = searchform.getBeforeDate();
Date createdAfter = searchform.getAfterDate();
Date userLoginBefore = searchform.getUserLoginBefore();
Date userLoginAfter = searchform.getUserLoginAfter();
// now perform power search
List<Identity> myIdentities = securityManager.getIdentitiesByPowerSearch((login.equals("") ? null : login), userPropertiesSearch, true, groups, permissionOnResources, authProviders, createdAfter, createdBefore, userLoginAfter, userLoginBefore, status);
return myIdentities;
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class UsermanagerUserSearchForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_user_search_form");
login = uifactory.addTextElement("login", "search.form.login", 128, "", formLayout);
login.setVisible(isAdministrativeUser);
login.setElementCssClass("o_sel_user_search_username");
items.put("login", login);
String currentGroup = null;
// Add all available user fields to this form
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null)
continue;
String group = userPropertyHandler.getGroup();
if (!group.equals(currentGroup)) {
if (currentGroup != null) {
uifactory.addSpacerElement("spacer_" + group, formLayout, false);
}
currentGroup = group;
}
FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, getClass().getCanonicalName(), false, formLayout);
// Do not validate items, this is a search form!
if (fi instanceof TextElement) {
TextElement textElement = (TextElement) fi;
textElement.setItemValidatorProvider(null);
}
fi.setElementCssClass("o_sel_user_search_".concat(userPropertyHandler.getName().toLowerCase()));
fi.setTranslator(getTranslator());
items.put(fi.getName(), fi);
}
uifactory.addSpacerElement("space1", formLayout, false);
roles = uifactory.addCheckboxesVertical("roles", "search.form.title.roles", formLayout, roleKeys, roleValues, 1);
uifactory.addSpacerElement("space2", formLayout, false);
auth = uifactory.addCheckboxesVertical("auth", "search.form.title.authentications", formLayout, authKeys, authValues, 1);
uifactory.addSpacerElement("space3", formLayout, false);
status = uifactory.addRadiosVertical("status", "search.form.title.status", formLayout, statusKeys, statusValues);
status.select(statusKeys[0], true);
uifactory.addSpacerElement("space4", formLayout, false);
afterDate = uifactory.addDateChooser("search.form.afterDate", null, formLayout);
afterDate.setValidDateCheck("error.search.form.no.valid.datechooser");
beforeDate = uifactory.addDateChooser("search.form.beforeDate", null, formLayout);
beforeDate.setValidDateCheck("error.search.form.no.valid.datechooser");
uifactory.addSpacerElement("space5", formLayout, false);
userLoginAfter = uifactory.addDateChooser("search.form.userLoginAfterDate", null, formLayout);
userLoginAfter.setValidDateCheck("error.search.form.no.valid.datechooser");
userLoginBefore = uifactory.addDateChooser("search.form.userLoginBeforeDate", null, formLayout);
userLoginBefore.setValidDateCheck("error.search.form.no.valid.datechooser");
uifactory.addSpacerElement("spaceBottom", formLayout, false);
// Don't use submit button, form should not be marked as dirty since this is
// not a configuration form but only a search form (OLAT-5626)
searchButton = uifactory.addFormLink("search", formLayout, Link.BUTTON);
searchButton.addActionListener(FormEvent.ONCLICK);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class GlossaryTermAndSynonymController method createOrUpdateSynonymLayout.
private void createOrUpdateSynonymLayout(FormItemContainer formLayout, ArrayList<String> glossItemSynonymsToUse) {
FormUIFactory formUIf = FormUIFactory.getInstance();
FormItem synLay = formLayout.getFormComponent("synonymLayout");
if (synLay != null) {
formLayout.remove("synonymLayout");
}
FormLayoutContainer tmpLayout = FormLayoutContainer.createCustomFormLayout("synonymLayout", getTranslator(), velocity_root + "/editSynonym.html");
formLayout.add(tmpLayout);
tmpLayout.setLabel("glossary.term.synonym", null);
Collections.sort(glossItemSynonymsToUse);
tmpLayout.contextPut("glossItemSynonyms", glossItemSynonymsToUse);
// add input fields with existing synonyms
synonymTextElementList = new ArrayList<TextElement>(glossItemSynonymsToUse.size());
for (int synNum = 1; synNum < glossItemSynonymsToUse.size() + 1; synNum++) {
TextElement tmpSynonymTE = formUIf.addTextElement(SYNONYM_TEXT_ELEMENT + synNum, null, 100, glossItemSynonymsToUse.get(synNum - 1), tmpLayout);
synonymTextElementList.add(tmpSynonymTE);
}
// add delete-links for existing synonyms
for (int linkNum = 1; linkNum < glossItemSynonymsToUse.size() + 1; linkNum++) {
FormLink tmpRemoveButton = formUIf.addFormLink(CMD_DELETE_SYNONYM + linkNum, tmpLayout, Link.BUTTON_XSMALL);
tmpRemoveButton.setUserObject(glossItemSynonymsToUse.get(linkNum - 1));
tmpRemoveButton.setI18nKey("synonym.link.delete");
}
// add input field for new synonym
newSynonymField = formUIf.addTextElement("synonym.inputfield", "glossary.term.synonym", 100, "", tmpLayout);
newSynonymField.setVisible(true);
newSynonymField.setLabel("synonym.inputfield", null);
formUIf.addFormSubmitButton("form.submit", tmpLayout);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class CourseLayoutGeneratorController method compileCustomConfigFromGuiWrapper.
private Map<String, Map<String, Object>> compileCustomConfigFromGuiWrapper() {
// get config from wrapper-object
elWithErrorExists = false;
Map<String, Map<String, Object>> customConfig = new HashMap<String, Map<String, Object>>();
for (Iterator<Entry<String, Map<String, FormItem>>> iterator = guiWrapper.entrySet().iterator(); iterator.hasNext(); ) {
Entry<String, Map<String, FormItem>> type = iterator.next();
String cIdent = type.getKey();
Map<String, Object> elementConfig = new HashMap<String, Object>();
Map<String, FormItem> element = type.getValue();
for (Entry<String, FormItem> entry : element.entrySet()) {
String attribName = entry.getKey();
if (!attribName.equals(PreviewLA.IDENTIFIER)) {
// exclude preview
FormItem foItem = entry.getValue();
String value = "";
if (foItem instanceof SingleSelection) {
value = ((SingleSelection) foItem).isOneSelected() ? ((SingleSelection) foItem).getSelectedKey() : "";
} else if (foItem.getUserObject() != null && foItem.getUserObject() instanceof SpecialAttributeFormItemHandler) {
// enclosed item
SpecialAttributeFormItemHandler specHandler = (SpecialAttributeFormItemHandler) foItem.getUserObject();
value = specHandler.getValue();
if (specHandler.hasError()) {
elWithErrorExists = true;
}
} else {
throw new AssertException("implement a getValue for this FormItem to get back a processable value.");
}
elementConfig.put(attribName, value);
}
}
customConfig.put(cIdent, elementConfig);
}
return customConfig;
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class GTAAvailableTaskController method loadModel.
private void loadModel() {
File taskFolder = gtaManager.getTasksDirectory(courseEnv, gtaNode);
List<AvailableTask> availableTasks = new ArrayList<>(taskDefs.size());
List<String> usedSlotes;
if (GTACourseNode.GTASK_SAMPLING_UNIQUE.equals(gtaNode.getModuleConfiguration().getStringValue(GTACourseNode.GTASK_SAMPLING))) {
usedSlotes = gtaManager.getAssignedTasks(taskList);
} else {
usedSlotes = Collections.emptyList();
}
for (TaskDefinition taskDef : taskDefs) {
String filename = taskDef.getFilename();
if (usedSlotes.contains(filename)) {
continue;
}
FormLink descriptionLink = null;
if (StringHelper.containsNonWhitespace(taskDef.getDescription())) {
descriptionLink = uifactory.addFormLink("preview-" + CodeHelper.getRAMUniqueID(), "description", "task.description", null, flc, Link.LINK);
descriptionLink.setIconLeftCSS("o_icon o_icon_description");
}
FormItem download = null;
boolean preview = gtaNode.getModuleConfiguration().getBooleanSafe(GTACourseNode.GTASK_PREVIEW);
if (preview) {
if (taskDef.getFilename().endsWith(".html")) {
download = uifactory.addFormLink("prev-html-" + CodeHelper.getRAMUniqueID(), "preview-html", filename, null, flc, Link.LINK | Link.NONTRANSLATED);
download.setUserObject(filename);
} else {
File taskFile = new File(taskFolder, filename);
download = uifactory.addDownloadLink("prev-" + CodeHelper.getRAMUniqueID(), filename, null, taskFile, tableEl);
}
}
AvailableTask wrapper = new AvailableTask(taskDef, descriptionLink, download);
availableTasks.add(wrapper);
if (descriptionLink != null) {
descriptionLink.setUserObject(wrapper);
}
}
taskModel.setObjects(availableTasks);
tableEl.reset();
if (availableTasks.isEmpty()) {
flc.contextPut("noMoreTasks", Boolean.TRUE);
} else {
flc.contextPut("noMoreTasks", Boolean.FALSE);
}
}
Aggregations