Search in sources :

Example 21 with BusinessGroupShort

use of org.olat.group.BusinessGroupShort in project OpenOLAT by OpenOLAT.

the class MembersSelectorFormFragment method getGroupNames.

private String getGroupNames(List<Long> keys) {
    StringBuilder sb = new StringBuilder();
    List<BusinessGroupShort> groups = businessGroupService.loadShortBusinessGroups(keys);
    for (BusinessGroupShort group : groups) {
        if (sb.length() > 0)
            sb.append("&nbsp;&nbsp;");
        sb.append("<i class='o_icon o_icon-fw o_icon_group'>&nbsp;</i> ");
        sb.append(StringHelper.escapeHtml(group.getName()));
    }
    return sb.toString();
}
Also used : BusinessGroupShort(org.olat.group.BusinessGroupShort)

Example 22 with BusinessGroupShort

use of org.olat.group.BusinessGroupShort in project OpenOLAT by OpenOLAT.

the class GTAWorkflowEditController method getGroupNames.

private String getGroupNames(List<Long> groupKeyList) {
    StringBuilder sb = new StringBuilder(64);
    List<BusinessGroupShort> groups = businessGroupService.loadShortBusinessGroups(groupKeyList);
    for (BusinessGroupShort group : groups) {
        if (sb.length() > 0)
            sb.append("&nbsp;&nbsp;");
        sb.append("<i class='o_icon o_icon-fw o_icon_group'>&nbsp;</i> ").append(StringHelper.escapeHtml(group.getName()));
    }
    return sb.toString();
}
Also used : BusinessGroupShort(org.olat.group.BusinessGroupShort)

Example 23 with BusinessGroupShort

use of org.olat.group.BusinessGroupShort in project OpenOLAT by OpenOLAT.

the class AbstractBusinessGroupListController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (createButton == source) {
        doCreate(ureq, getWindowControl(), null);
    } else if (deleteButton == source) {
        confirmDelete(ureq, getSelectedItems());
    } else if (duplicateButton == source) {
        doCopy(ureq, getSelectedItems());
    } else if (configButton == source) {
        doConfiguration(ureq, getSelectedItems());
    } else if (emailButton == source) {
        doEmails(ureq, getSelectedItems());
    } else if (usersButton == source) {
        doUserManagement(ureq, getSelectedItems());
    } else if (mergeButton == source) {
        doMerge(ureq, getSelectedItems());
    } else if (selectButton == source) {
        doSelect(ureq, getSelectedItems());
    } else if (source instanceof FormLink) {
        FormLink link = (FormLink) source;
        String cmd = link.getCmd();
        if ("mark".equals(cmd)) {
            BusinessGroupRow row = (BusinessGroupRow) link.getUserObject();
            boolean marked = toogleMark(row);
            link.setIconLeftCSS(marked ? "o_icon o_icon_bookmark o_icon-lg" : "o_icon o_icon_bookmark_add o_icon-lg");
            link.getComponent().setDirty(true);
        } else if ("allresources".equals(cmd)) {
            BusinessGroupShort bg = (BusinessGroupShort) link.getUserObject();
            NewControllerFactory.getInstance().launch("[BusinessGroup:" + bg.getKey() + "][toolresources:0]", ureq, getWindowControl());
        } else if ("resource".equals(cmd)) {
            RepositoryEntryShort re = (RepositoryEntryShort) link.getUserObject();
            NewControllerFactory.getInstance().launch("[RepositoryEntry:" + re.getKey() + "]", ureq, getWindowControl());
        } else if (link.getUserObject() instanceof BusinessGroupRef) {
            BusinessGroupRef item = (BusinessGroupRef) link.getUserObject();
            Long businessGroupKey = item.getKey();
            BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
            if (businessGroup == null) {
                groupTableModel.removeBusinessGroup(businessGroupKey);
                tableEl.reset();
            } else if (TABLE_ACTION_ACCESS.equals(cmd)) {
                doAccess(ureq, businessGroup);
            } else if (TABLE_ACTION_LEAVE.equals(cmd)) {
                doConfirmLeaving(ureq, businessGroup);
            }
        }
    } else if (source == tableEl) {
        String cmd = event.getCommand();
        if (event instanceof SelectionEvent) {
            SelectionEvent se = (SelectionEvent) event;
            if (se.getIndex() >= 0 && se.getIndex() < groupTableModel.getRowCount()) {
                BusinessGroupRef item = groupTableModel.getObject(se.getIndex());
                Long businessGroupKey = item.getKey();
                BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
                // prevent rs after a group is deleted by someone else
                if (businessGroup == null) {
                    groupTableModel.removeBusinessGroup(businessGroupKey);
                    tableEl.reset();
                } else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
                    doLaunch(ureq, businessGroup);
                } else if (TABLE_ACTION_DELETE.equals(cmd)) {
                    confirmDelete(ureq, Collections.singletonList(item));
                } else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
                    doLaunch(ureq, businessGroup);
                } else if (TABLE_ACTION_EDIT.equals(cmd)) {
                    doEdit(ureq, businessGroup);
                } else if (TABLE_ACTION_LEAVE.equals(cmd)) {
                    doConfirmLeaving(ureq, businessGroup);
                } else if (TABLE_ACTION_ACCESS.equals(cmd)) {
                    doAccess(ureq, businessGroup);
                } else if (TABLE_ACTION_SELECT.equals(cmd)) {
                    doSelect(ureq, businessGroup);
                }
            }
        } else if (event instanceof FlexiTableSearchEvent) {
            doSearch((FlexiTableSearchEvent) event);
        }
    }
    super.formInnerEvent(ureq, source, event);
}
Also used : BusinessGroupRef(org.olat.group.BusinessGroupRef) RepositoryEntryShort(org.olat.repository.RepositoryEntryShort) BGCopyBusinessGroup(org.olat.group.ui.wizard.BGCopyBusinessGroup) BGConfigBusinessGroup(org.olat.group.ui.wizard.BGConfigBusinessGroup) BusinessGroup(org.olat.group.BusinessGroup) SelectionEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.SelectionEvent) BusinessGroupSelectionEvent(org.olat.group.model.BusinessGroupSelectionEvent) FlexiTableSearchEvent(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) BusinessGroupShort(org.olat.group.BusinessGroupShort) BusinessGroupRow(org.olat.group.model.BusinessGroupRow)

Example 24 with BusinessGroupShort

use of org.olat.group.BusinessGroupShort in project OpenOLAT by OpenOLAT.

the class AbstractMemberListController method updateTableModel.

protected List<MemberView> updateTableModel(SearchMembersParams params) {
    // course membership
    boolean managedMembersRepo = RepositoryEntryManagedFlag.isManaged(repoEntry, RepositoryEntryManagedFlag.membersmanagement);
    List<RepositoryEntryMembership> repoMemberships = repoEntry == null ? Collections.<RepositoryEntryMembership>emptyList() : repositoryManager.getRepositoryEntryMembership(repoEntry);
    // groups membership
    List<BusinessGroup> groups = repoEntry == null ? Collections.singletonList(businessGroup) : businessGroupService.findBusinessGroups(null, repoEntry, 0, -1);
    List<Long> groupKeys = new ArrayList<Long>();
    Map<Long, BusinessGroupShort> keyToGroupMap = new HashMap<>();
    for (BusinessGroup group : groups) {
        groupKeys.add(group.getKey());
        keyToGroupMap.put(group.getKey(), group);
    }
    List<BusinessGroupMembership> memberships = groups.isEmpty() ? Collections.<BusinessGroupMembership>emptyList() : businessGroupService.getBusinessGroupsMembership(groups);
    // get identities
    Set<Long> identityKeys = new HashSet<>();
    for (RepositoryEntryMembership membership : repoMemberships) {
        identityKeys.add(membership.getIdentityKey());
    }
    for (BusinessGroupMembership membership : memberships) {
        identityKeys.add(membership.getIdentityKey());
    }
    List<Identity> identities;
    if (identityKeys.isEmpty()) {
        identities = new ArrayList<>(0);
    } else {
        identities = filterIdentities(params, identityKeys);
    }
    Map<Long, MemberView> keyToMemberMap = new HashMap<>();
    List<MemberView> memberList = new ArrayList<>();
    Locale locale = getLocale();
    // reservations
    if (params.isPending()) {
        List<OLATResource> resourcesForReservations = new ArrayList<>();
        if (repoEntry != null) {
            resourcesForReservations.add(repoEntry.getOlatResource());
        }
        for (BusinessGroup group : groups) {
            resourcesForReservations.add(group.getResource());
        }
        List<ResourceReservation> reservations = acService.getReservations(resourcesForReservations);
        List<Long> pendingIdentityKeys = new ArrayList<>(reservations.size());
        for (ResourceReservation reservation : reservations) {
            pendingIdentityKeys.add(reservation.getIdentity().getKey());
        }
        if (StringHelper.containsNonWhitespace(params.getSearchString()) || StringHelper.containsNonWhitespace(params.getLogin()) || (params.getUserPropertiesSearch() != null && !params.getUserPropertiesSearch().isEmpty())) {
            List<Identity> pendingIdentities = filterIdentities(params, pendingIdentityKeys);
            pendingIdentityKeys.retainAll(PersistenceHelper.toKeys(pendingIdentities));
        }
        for (ResourceReservation reservation : reservations) {
            Identity identity = reservation.getIdentity();
            if (pendingIdentityKeys.contains(identity.getKey())) {
                MemberView member = new MemberView(identity, userPropertyHandlers, locale);
                member.getMembership().setPending(true);
                memberList.add(member);
                forgeLinks(member);
                keyToMemberMap.put(identity.getKey(), member);
            }
        }
    }
    Long me = getIdentity().getKey();
    Set<Long> loadStatus = new HashSet<>();
    for (Identity identity : identities) {
        MemberView member = new MemberView(identity, userPropertyHandlers, locale);
        if (chatEnabled) {
            if (identity.getKey().equals(me)) {
                member.setOnlineStatus("me");
            } else if (sessionManager.isOnline(identity.getKey())) {
                loadStatus.add(identity.getKey());
            } else {
                member.setOnlineStatus(Presence.unavailable.name());
            }
        }
        memberList.add(member);
        forgeLinks(member);
        keyToMemberMap.put(identity.getKey(), member);
    }
    if (loadStatus.size() > 0) {
        List<Long> statusToLoadList = new ArrayList<>(loadStatus);
        Map<Long, String> statusMap = imService.getBuddyStatus(statusToLoadList);
        for (Long toLoad : statusToLoadList) {
            String status = statusMap.get(toLoad);
            MemberView member = keyToMemberMap.get(toLoad);
            if (status == null) {
                member.setOnlineStatus(Presence.available.name());
            } else {
                member.setOnlineStatus(status);
            }
        }
    }
    for (BusinessGroupMembership membership : memberships) {
        Long identityKey = membership.getIdentityKey();
        MemberView memberView = keyToMemberMap.get(identityKey);
        if (memberView != null) {
            memberView.setFirstTime(membership.getCreationDate());
            memberView.setLastTime(membership.getLastModified());
            if (membership.isOwner()) {
                memberView.getMembership().setGroupTutor(true);
            }
            if (membership.isParticipant()) {
                memberView.getMembership().setGroupParticipant(true);
            }
            if (membership.isWaiting()) {
                memberView.getMembership().setGroupWaiting(true);
            }
            Long groupKey = membership.getGroupKey();
            BusinessGroupShort group = keyToGroupMap.get(groupKey);
            memberView.addGroup(group);
        }
    }
    for (RepositoryEntryMembership membership : repoMemberships) {
        Long identityKey = membership.getIdentityKey();
        MemberView memberView = keyToMemberMap.get(identityKey);
        if (memberView != null) {
            memberView.setFirstTime(membership.getCreationDate());
            memberView.setLastTime(membership.getLastModified());
            memberView.getMembership().setManagedMembersRepo(managedMembersRepo);
            if (membership.isOwner()) {
                memberView.getMembership().setRepoOwner(true);
            }
            if (membership.isCoach()) {
                memberView.getMembership().setRepoTutor(true);
            }
            if (membership.isParticipant()) {
                memberView.getMembership().setRepoParticipant(true);
            }
        }
    }
    if (repoEntry != null) {
        Map<Long, Date> lastLaunchDates = userInfosMgr.getRecentLaunchDates(repoEntry.getOlatResource());
        for (MemberView memberView : keyToMemberMap.values()) {
            Long identityKey = memberView.getIdentityKey();
            Date date = lastLaunchDates.get(identityKey);
            memberView.setLastTime(date);
        }
    }
    // the order of the filter is important
    filterByRoles(memberList, params);
    filterByOrigin(memberList, params);
    memberListModel.setObjects(memberList);
    membersTable.reset(true, true, true);
    return memberList;
}
Also used : Locale(java.util.Locale) BusinessGroupMembership(org.olat.group.BusinessGroupMembership) RepositoryEntryMembership(org.olat.repository.model.RepositoryEntryMembership) HashMap(java.util.HashMap) ResourceReservation(org.olat.resource.accesscontrol.ResourceReservation) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) BusinessGroupShort(org.olat.group.BusinessGroupShort) HashSet(java.util.HashSet) BusinessGroup(org.olat.group.BusinessGroup) OLATResource(org.olat.resource.OLATResource) Date(java.util.Date)

Example 25 with BusinessGroupShort

use of org.olat.group.BusinessGroupShort in project OpenOLAT by OpenOLAT.

the class COCourseNode method isConfigValid.

/**
 * @see org.olat.course.nodes.CourseNode#isConfigValid(org.olat.course.run.userview.UserCourseEnvironment)
 */
public StatusDescription[] isConfigValid(CourseEditorEnv cev) {
    oneClickStatusCache = null;
    // only here we know which translator to take for translating condition
    // error messages
    String translatorStr = Util.getPackageName(ConditionEditController.class);
    List<StatusDescription> condErrs = isConfigValidWithTranslator(cev, translatorStr, getConditionExpressions());
    List<StatusDescription> missingNames = new ArrayList<StatusDescription>();
    /*
         * check group and area names for existence
         */
    String nodeId = getIdent();
    ModuleConfiguration mc = getModuleConfiguration();
    @SuppressWarnings("unchecked") List<Long> areaKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA_IDS);
    if (areaKeys != null) {
        BGAreaManager areaManager = CoreSpringFactory.getImpl(BGAreaManager.class);
        List<BGArea> areas = areaManager.loadAreas(areaKeys);
        a_a: for (Long areaKey : areaKeys) {
            for (BGArea area : areas) {
                if (area.getKey().equals(areaKey)) {
                    continue a_a;
                }
            }
            StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", areaKey.toString() }, translatorStr);
            sd.setDescriptionForUnit(nodeId);
            missingNames.add(sd);
        }
    } else {
        String areaStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_AREA);
        if (areaStr != null) {
            String[] areas = areaStr.split(",");
            for (int i = 0; i < areas.length; i++) {
                String trimmed = areas[i] != null ? areas[i].trim() : areas[i];
                if (!trimmed.equals("") && !cev.existsArea(trimmed)) {
                    StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", trimmed }, translatorStr);
                    sd.setDescriptionForUnit(nodeId);
                    missingNames.add(sd);
                }
            }
        }
    }
    @SuppressWarnings("unchecked") List<Long> groupKeys = (List<Long>) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP_ID);
    if (groupKeys != null) {
        BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
        List<BusinessGroupShort> groups = bgs.loadShortBusinessGroups(groupKeys);
        a_a: for (Long activeGroupKey : groupKeys) {
            for (BusinessGroupShort group : groups) {
                if (group.getKey().equals(activeGroupKey)) {
                    continue a_a;
                }
            }
            StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", activeGroupKey.toString() }, translatorStr);
            sd.setDescriptionForUnit(nodeId);
            missingNames.add(sd);
        }
    } else {
        String groupStr = (String) mc.get(COEditController.CONFIG_KEY_EMAILTOCOACHES_GROUP);
        if (groupStr != null) {
            String[] groups = groupStr.split(",");
            for (int i = 0; i < groups.length; i++) {
                String trimmed = groups[i] != null ? groups[i].trim() : groups[i];
                if (!trimmed.equals("") && !cev.existsGroup(trimmed)) {
                    StatusDescription sd = new StatusDescription(StatusDescription.WARNING, "error.notfound.name", "solution.checkgroupmanagement", new String[] { "NONE", trimmed }, translatorStr);
                    sd.setDescriptionForUnit(nodeId);
                    missingNames.add(sd);
                }
            }
        }
    }
    missingNames.addAll(condErrs);
    oneClickStatusCache = StatusDescriptionHelper.sort(missingNames);
    return oneClickStatusCache;
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) ArrayList(java.util.ArrayList) BGArea(org.olat.group.area.BGArea) BusinessGroupService(org.olat.group.BusinessGroupService) StatusDescription(org.olat.course.editor.StatusDescription) ArrayList(java.util.ArrayList) List(java.util.List) BusinessGroupShort(org.olat.group.BusinessGroupShort) BGAreaManager(org.olat.group.area.BGAreaManager)

Aggregations

BusinessGroupShort (org.olat.group.BusinessGroupShort)34 ArrayList (java.util.ArrayList)18 BusinessGroup (org.olat.group.BusinessGroup)10 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6 List (java.util.List)6 BGArea (org.olat.group.area.BGArea)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)4 Identity (org.olat.core.id.Identity)4 BusinessGroupMembership (org.olat.group.BusinessGroupMembership)4 RepositoryEntryShort (org.olat.repository.RepositoryEntryShort)4 RepositoryEntryMembership (org.olat.repository.model.RepositoryEntryMembership)4 Date (java.util.Date)2 Locale (java.util.Locale)2 Map (java.util.Map)2 Test (org.junit.Test)2 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)2 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)2