Search in sources :

Example 31 with SingleIdentityChosenEvent

use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.

the class UserSearchFlexiController method doFireSelection.

@Override
protected void doFireSelection(UserRequest ureq, List<String> res) {
    String mySel = res.isEmpty() ? null : res.get(0);
    if (StringHelper.containsNonWhitespace(mySel) && StringHelper.isLong(mySel)) {
        try {
            Long key = Long.valueOf(mySel);
            if (key > 0) {
                Identity chosenIdent = securityManager.loadIdentityByKey(key);
                if (chosenIdent != null) {
                    fireEvent(ureq, new SingleIdentityChosenEvent(chosenIdent));
                    List<Identity> selectedIdentities = Collections.singletonList(chosenIdent);
                    userTableModel.setObjects(selectedIdentities);
                    Set<Integer> selectedIndex = new HashSet<>();
                    selectedIndex.add(new Integer(0));
                    tableEl.setMultiSelectedIndex(selectedIndex);
                }
            }
        } catch (NumberFormatException e) {
            getWindowControl().setWarning(translate("error.no.user.found"));
        }
    } else {
        getWindowControl().setWarning(translate("error.search.form.notempty"));
    }
}
Also used : SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Example 32 with SingleIdentityChosenEvent

use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.

the class UsermanagerUserSearchForm method activate.

@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
    if (state instanceof StateMapped) {
        StateMapped searchState = (StateMapped) state;
        searchform.setStateEntry(searchState);
        if (entries != null && entries.size() > 0) {
            String table = entries.get(0).getOLATResourceable().getResourceableTypeName();
            if ("table".equals(table)) {
                entries.remove(0);
                event(ureq, searchform, Event.DONE_EVENT);
            }
        }
    }
    if (entries == null || entries.isEmpty())
        return;
    for (int i = 0; i < entries.size(); i++) {
        String resourceType = entries.get(i).getOLATResourceable().getResourceableTypeName();
        if ("Identity".equalsIgnoreCase(resourceType)) {
            Long identityKey = entries.get(i).getOLATResourceable().getResourceableId();
            Identity found = null;
            if (tdm != null) {
                for (Identity identity : tdm.getObjects()) {
                    if (identityKey.equals(identity.getKey())) {
                        found = identity;
                    }
                }
            }
            if (found == null) {
                found = securityManager.loadIdentityByKey(identityKey);
                if (found == null)
                    return;
                List<Identity> foundIdentites = new ArrayList<>();
                foundIdentites.add(found);
                initUserListCtr(ureq, foundIdentites, 0);
            }
            fireEvent(ureq, new SingleIdentityChosenEvent(found));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Identity(org.olat.core.id.Identity) StateMapped(org.olat.core.id.context.StateMapped)

Example 33 with SingleIdentityChosenEvent

use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.

the class DirectDeleteController method event.

/**
 * This dispatches controller events...
 *
 * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
 *      org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
 */
public void event(UserRequest ureq, Controller sourceController, Event event) {
    if (sourceController == usc) {
        if (event == Event.CANCELLED_EVENT) {
            removeAsListenerAndDispose(usc);
        } else if (event instanceof MultiIdentityChosenEvent) {
            MultiIdentityChosenEvent multiEvent = (MultiIdentityChosenEvent) event;
            toDelete = multiEvent.getChosenIdentities();
            if (toDelete.size() == 0) {
                showError("msg.selectionempty");
                return;
            }
            String names = buildUserNameList(toDelete);
            deleteConfirmController = activateOkCancelDialog(ureq, null, translate("readyToDelete.delete.confirm", names), deleteConfirmController);
            return;
        } else if (event instanceof SingleIdentityChosenEvent) {
            // single choose event may come from autocompleter user search
            SingleIdentityChosenEvent uce = (SingleIdentityChosenEvent) event;
            toDelete = new ArrayList<Identity>();
            toDelete.add(uce.getChosenIdentity());
            String fullname = userManager.getUserDisplayName(uce.getChosenIdentity());
            deleteConfirmController = activateOkCancelDialog(ureq, null, translate("readyToDelete.delete.confirm", fullname), deleteConfirmController);
            return;
        } else {
            throw new AssertException("unknown event ::" + event.getCommand());
        }
    } else if (sourceController == deleteConfirmController) {
        if (DialogBoxUIFactory.isOkEvent(event)) {
            deleteIdentities(toDelete);
            if (bdc != null) {
                bdc.sendMail();
            }
            initializeUserSearchController(ureq);
            initializeUserListForm(ureq);
            showInfo("deleted.users.msg");
        }
    } else if (sourceController == bdc) {
        toDelete = bdc.getToDelete();
        cmc.deactivate();
        String names = buildUserNameList(toDelete);
        deleteConfirmController = activateOkCancelDialog(ureq, null, translate("readyToDelete.delete.confirm", names), deleteConfirmController);
    } else if (sourceController == cmc) {
        if (event == Event.CANCELLED_EVENT) {
            cmc.deactivate();
        }
    } else if (sourceController == userListForm) {
        removeAsListenerAndDispose(bdc);
        bdc = new BulkDeleteController(ureq, getWindowControl(), userListForm.getLogins(), userListForm.getReason());
        listenTo(bdc);
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), bdc.getInitialComponent());
        listenTo(cmc);
        cmc.activate();
    }
}
Also used : AssertException(org.olat.core.logging.AssertException) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent) Identity(org.olat.core.id.Identity)

Example 34 with SingleIdentityChosenEvent

use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.

the class MemberSearchController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (event instanceof SingleIdentityChosenEvent) {
        SingleIdentityChosenEvent e = (SingleIdentityChosenEvent) event;
        String key = e.getChosenIdentity().getKey().toString();
        addToRunContext("keys", Collections.singletonList(key));
        fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
    } else if (event instanceof MultiIdentityChosenEvent) {
        MultiIdentityChosenEvent e = (MultiIdentityChosenEvent) event;
        Collection<String> keys = new ArrayList<String>();
        for (Identity identity : e.getChosenIdentities()) {
            keys.add(identity.getKey().toString());
        }
        addToRunContext("keys", keys);
        fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
    } else {
        super.event(ureq, source, event);
    }
}
Also used : SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) Collection(java.util.Collection) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent) Identity(org.olat.core.id.Identity)

Example 35 with SingleIdentityChosenEvent

use of org.olat.basesecurity.events.SingleIdentityChosenEvent in project OpenOLAT by OpenOLAT.

the class ImportMemberBySearchController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (event instanceof SingleIdentityChosenEvent) {
        SingleIdentityChosenEvent e = (SingleIdentityChosenEvent) event;
        addToRunContext("keyIdentities", Collections.singletonList(e.getChosenIdentity()));
        fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
    } else if (event instanceof MultiIdentityChosenEvent) {
        MultiIdentityChosenEvent e = (MultiIdentityChosenEvent) event;
        addToRunContext("keyIdentities", e.getChosenIdentities());
        fireEvent(ureq, StepsEvent.ACTIVATE_NEXT);
    } else {
        super.event(ureq, source, event);
    }
}
Also used : SingleIdentityChosenEvent(org.olat.basesecurity.events.SingleIdentityChosenEvent) MultiIdentityChosenEvent(org.olat.basesecurity.events.MultiIdentityChosenEvent)

Aggregations

SingleIdentityChosenEvent (org.olat.basesecurity.events.SingleIdentityChosenEvent)46 Identity (org.olat.core.id.Identity)40 MultiIdentityChosenEvent (org.olat.basesecurity.events.MultiIdentityChosenEvent)24 ArrayList (java.util.ArrayList)16 List (java.util.List)14 TableEvent (org.olat.core.gui.components.table.TableEvent)10 TableMultiSelectEvent (org.olat.core.gui.components.table.TableMultiSelectEvent)10 WindowControl (org.olat.core.gui.control.WindowControl)8 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)8 UserRequest (org.olat.core.gui.UserRequest)6 ControllerCreator (org.olat.core.gui.control.creator.ControllerCreator)6 PopupBrowserWindow (org.olat.core.gui.control.generic.popup.PopupBrowserWindow)6 AssertException (org.olat.core.logging.AssertException)6 UserInfoMainController (org.olat.user.UserInfoMainController)6 Collection (java.util.Collection)4 ContextEntry (org.olat.core.id.context.ContextEntry)4 ContactList (org.olat.core.util.mail.ContactList)4 MailNotificationEditController (org.olat.core.util.mail.MailNotificationEditController)4 MailTemplate (org.olat.core.util.mail.MailTemplate)4 DateFormat (java.text.DateFormat)2