Search in sources :

Example 1 with BusinessGroupMembership

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

the class BusinessGroupMainRunController method event.

/**
 * @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)
 */
@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == bgEditCntrllr) {
        // changes from the admin controller
        if (event == Event.CHANGED_EVENT) {
            businessGroup = bgEditCntrllr.getBusinessGroup();
            chatAvailable = isChatAvailable();
            TreeModel trMdl = buildTreeModel();
            bgTree.setTreeModel(trMdl);
            bgTree.setSelectedNode(nodeAdmin);
        } else if (event == Event.CANCELLED_EVENT) {
            // could not get lock on business group, back to inital screen
            bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
            mainPanel.setContent(main);
        }
    } else if (source == resourcesCtr) {
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent te = (TableEvent) event;
            String actionid = te.getActionId();
            int rowid = te.getRowId();
            RepositoryTableModel repoTableModel = (RepositoryTableModel) resourcesCtr.getTableDataModel();
            if (RepositoryTableModel.TABLE_ACTION_SELECT_LINK.equals(actionid)) {
                RepositoryEntry currentRepoEntry = repoTableModel.getObject(rowid);
                OLATResource ores = currentRepoEntry.getOlatResource();
                if (ores == null)
                    throw new AssertException("repoEntry had no olatresource, repoKey = " + currentRepoEntry.getKey());
                addLoggingResourceable(LoggingResourceable.wrap(ores, OlatResourceableType.genRepoEntry));
                String businessPath = "[RepositoryEntry:" + currentRepoEntry.getKey() + "]";
                NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
            }
        }
    } else if (source == sendToChooserForm) {
        if (event == Event.DONE_EVENT) {
            removeAsListenerAndDispose(collabToolCtr);
            collabToolCtr = createContactFormController(ureq);
            listenTo(collabToolCtr);
            mainPanel.setContent(collabToolCtr.getInitialComponent());
        } else if (event == Event.CANCELLED_EVENT) {
            // back to group overview
            bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
            mainPanel.setContent(main);
        }
    } else if (source == collabToolCtr) {
        if (event == Event.CANCELLED_EVENT || event == Event.DONE_EVENT || event == Event.BACK_EVENT || event == Event.FAILED_EVENT) {
            // In all cases (success or failure) we
            // go back to the group overview page.
            bgTree.setSelectedNodeId(bgTree.getTreeModel().getRootNode().getIdent());
            mainPanel.setContent(main);
        }
    } else if (source == accessController) {
        if (event.equals(AccessEvent.ACCESS_OK_EVENT)) {
            removeAsListenerAndDispose(accessController);
            accessController = null;
            // check if on waiting list
            List<BusinessGroupMembership> memberships = businessGroupService.getBusinessGroupMembership(Collections.singletonList(businessGroup.getKey()), getIdentity());
            if (isOnWaitinglist(memberships)) {
                Component cmp = getOnWaitingListMessage(ureq, businessGroup);
                mainPanel.setContent(cmp);
            } else {
                mainPanel.setContent(main);
                bgTree.setTreeModel(buildTreeModel());
                needActivation = false;
            }
        } else if (event.equals(AccessEvent.ACCESS_FAILED_EVENT)) {
            String msg = ((AccessEvent) event).getMessage();
            if (StringHelper.containsNonWhitespace(msg)) {
                getWindowControl().setError(msg);
            } else {
                showError("error.accesscontrol");
            }
        }
    }
}
Also used : TreeModel(org.olat.core.gui.components.tree.TreeModel) GenericTreeModel(org.olat.core.gui.components.tree.GenericTreeModel) BusinessGroupMembership(org.olat.group.BusinessGroupMembership) RepositoryTableModel(org.olat.repository.ui.RepositoryTableModel) AssertException(org.olat.core.logging.AssertException) TableEvent(org.olat.core.gui.components.table.TableEvent) OLATResource(org.olat.resource.OLATResource) RepositoryEntry(org.olat.repository.RepositoryEntry) Component(org.olat.core.gui.components.Component)

Example 2 with BusinessGroupMembership

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

the class OpenBusinessGroupListController method searchTableItems.

@Override
protected List<BGTableItem> searchTableItems(BusinessGroupQueryParams params) {
    List<OpenBusinessGroupRow> rows = businessGroupService.findPublishedBusinessGroups(params, getIdentity());
    List<BGTableItem> items = new ArrayList<>(rows.size());
    for (OpenBusinessGroupRow row : rows) {
        BusinessGroupMembership membership = row.getMember();
        Boolean allowLeave = membership != null;
        BGTableItem item = new BGTableItem(row, null, allowLeave, Boolean.FALSE);
        addAccessLink(item);
        items.add(item);
    }
    return items;
}
Also used : BusinessGroupMembership(org.olat.group.BusinessGroupMembership) OpenBusinessGroupRow(org.olat.group.model.OpenBusinessGroupRow) ArrayList(java.util.ArrayList)

Example 3 with BusinessGroupMembership

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

the class FavoritBusinessGroupListController method searchTableItems.

@Override
protected List<BGTableItem> searchTableItems(BusinessGroupQueryParams params) {
    List<BusinessGroupRow> rows = businessGroupService.findBusinessGroupsWithMemberships(params, getIdentity());
    List<BGTableItem> items = new ArrayList<>(rows.size());
    for (BusinessGroupRow row : rows) {
        BusinessGroupMembership membership = row.getMember();
        Boolean allowLeave = membership != null;
        Boolean allowDelete = isAdmin() ? Boolean.TRUE : (membership == null ? null : new Boolean(membership.isOwner()));
        FormLink markLink = uifactory.addFormLink("mark_" + row.getKey(), "mark", "", null, null, Link.NONTRANSLATED);
        markLink.setIconLeftCSS(row.isMarked() ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
        BGTableItem item = new BGTableItem(row, markLink, allowLeave, allowDelete);
        items.add(item);
    }
    return items;
}
Also used : BusinessGroupMembership(org.olat.group.BusinessGroupMembership) ArrayList(java.util.ArrayList) FormLink(org.olat.core.gui.components.form.flexible.elements.FormLink) BusinessGroupRow(org.olat.group.model.BusinessGroupRow)

Example 4 with BusinessGroupMembership

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

the class BGRoleCellRenderer method render.

private void render(StringOutput sb, Object val) {
    if (val instanceof BusinessGroupMembership) {
        BusinessGroupMembership membership = (BusinessGroupMembership) val;
        boolean and = false;
        if (membership.isOwner()) {
            and = and(sb, and);
            sb.append(trans.translate("owned.groups"));
        }
        if (membership.isParticipant()) {
            and = and(sb, and);
            sb.append(trans.translate("search.attendee"));
        }
        if (membership.isWaiting()) {
            and = and(sb, and);
            sb.append(trans.translate("search.waiting"));
        }
    } else if (val instanceof BGMembership) {
        BGMembership membership = (BGMembership) val;
        switch(membership) {
            case owner:
                sb.append(trans.translate("owned.groups"));
                break;
            case participant:
                sb.append(trans.translate("search.attendee"));
                break;
            case waiting:
                sb.append(trans.translate("search.waiting"));
                break;
        }
    }
}
Also used : BusinessGroupMembership(org.olat.group.BusinessGroupMembership) BGMembership(org.olat.group.model.BGMembership)

Example 5 with BusinessGroupMembership

use of org.olat.group.BusinessGroupMembership in project openolat by klemens.

the class CourseOverviewController method updateModel.

private void updateModel() {
    // course membership
    List<RepositoryEntryMembership> memberships = repositoryManager.getRepositoryEntryMembership(null, editedIdentity);
    // group membership
    List<BusinessGroupMembership> groupMemberships = businessGroupService.getBusinessGroupMembership(Collections.<Long>emptyList(), editedIdentity);
    Collection<Long> groupKeys = new ArrayList<Long>(groupMemberships.size());
    for (BusinessGroupMembership membership : groupMemberships) {
        groupKeys.add(membership.getGroupKey());
    }
    // relation to course
    List<BGRepositoryEntryRelation> relations = businessGroupService.findRelationToRepositoryEntries(groupKeys, 0, -1);
    Map<Long, List<Long>> groupKeyToRepoKeyMap = new HashMap<>();
    for (BGRepositoryEntryRelation relation : relations) {
        if (groupKeyToRepoKeyMap.containsKey(relation.getGroupKey())) {
            groupKeyToRepoKeyMap.get(relation.getGroupKey()).add(relation.getRepositoryEntryKey());
        } else {
            List<Long> repoEntryKeys = new ArrayList<>(2);
            repoEntryKeys.add(relation.getRepositoryEntryKey());
            groupKeyToRepoKeyMap.put(relation.getGroupKey(), repoEntryKeys);
        }
    }
    Map<Long, CourseMemberView> repoKeyToViewMap = new HashMap<Long, CourseMemberView>();
    for (RepositoryEntryMembership membership : memberships) {
        Long repoKey = membership.getRepoKey();
        CourseMemberView memberView;
        if (repoKeyToViewMap.containsKey(repoKey)) {
            memberView = repoKeyToViewMap.get(repoKey);
        } else {
            memberView = new CourseMemberView(repoKey);
            repoKeyToViewMap.put(repoKey, memberView);
        }
        memberView.setFirstTime(membership.getCreationDate());
        if (memberView.getLastTime() == null || (memberView.getLastTime() != null && membership.getLastModified() != null && membership.getLastModified().after(memberView.getLastTime()))) {
            memberView.setLastTime(membership.getLastModified());
        }
        // add the roles
        if (!memberView.getMembership().isRepoOwner()) {
            memberView.getMembership().setRepoOwner(membership.isOwner());
        }
        if (!memberView.getMembership().isRepoTutor()) {
            memberView.getMembership().setRepoTutor(membership.isCoach());
        }
        if (!memberView.getMembership().isRepoParticipant()) {
            memberView.getMembership().setRepoParticipant(membership.isParticipant());
        }
    }
    List<BusinessGroupShort> groups = businessGroupService.loadShortBusinessGroups(groupKeys);
    Map<Long, BusinessGroupShort> groupKeyToGroupMap = new HashMap<Long, BusinessGroupShort>();
    for (BusinessGroupShort group : groups) {
        groupKeyToGroupMap.put(group.getKey(), group);
    }
    for (BusinessGroupMembership membership : groupMemberships) {
        List<Long> repoKeys;
        if (groupKeyToRepoKeyMap.containsKey(membership.getGroupKey())) {
            repoKeys = groupKeyToRepoKeyMap.get(membership.getGroupKey());
        } else {
            continue;
        }
        BusinessGroupShort group = groupKeyToGroupMap.get(membership.getGroupKey());
        if (group == null) {
            continue;
        }
        for (Long repoKey : repoKeys) {
            CourseMemberView memberView;
            if (repoKeyToViewMap.containsKey(repoKey)) {
                memberView = repoKeyToViewMap.get(repoKey);
            } else {
                memberView = new CourseMemberView(repoKey);
                repoKeyToViewMap.put(repoKey, memberView);
            }
            memberView.addGroup(group);
            memberView.setFirstTime(membership.getCreationDate());
            if (memberView.getLastTime() == null || (memberView.getLastTime() != null && membership.getLastModified() != null && membership.getLastModified().after(memberView.getLastTime()))) {
                memberView.setLastTime(membership.getLastModified());
            }
            switch(membership.getMembership()) {
                case owner:
                    memberView.getMembership().setGroupTutor(true);
                    break;
                case participant:
                    memberView.getMembership().setGroupParticipant(true);
                    break;
                case waiting:
                    memberView.getMembership().setGroupWaiting(true);
                    break;
            }
        }
    }
    List<RepositoryEntry> entries = repositoryManager.lookupRepositoryEntries(repoKeyToViewMap.keySet());
    Map<Long, RepositoryEntry> entryKeyToRepoEntryMap = new HashMap<Long, RepositoryEntry>();
    for (RepositoryEntry entry : entries) {
        entryKeyToRepoEntryMap.put(entry.getKey(), entry);
    }
    for (CourseMemberView memberView : repoKeyToViewMap.values()) {
        RepositoryEntry entry = entryKeyToRepoEntryMap.get(memberView.getRepoKey());
        if (entry != null) {
            memberView.setEntry(entry);
            boolean managedMembersRepo = RepositoryEntryManagedFlag.isManaged(entry, RepositoryEntryManagedFlag.membersmanagement);
            memberView.getMembership().setManagedMembersRepo(managedMembersRepo);
        }
    }
    List<CourseMemberView> views = new ArrayList<CourseMemberView>(repoKeyToViewMap.values());
    tableDataModel.setObjects(views);
    courseListCtr.modelChanged();
}
Also used : BusinessGroupMembership(org.olat.group.BusinessGroupMembership) RepositoryEntryMembership(org.olat.repository.model.RepositoryEntryMembership) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) List(java.util.List) ArrayList(java.util.ArrayList) BGRepositoryEntryRelation(org.olat.group.model.BGRepositoryEntryRelation) BusinessGroupShort(org.olat.group.BusinessGroupShort)

Aggregations

BusinessGroupMembership (org.olat.group.BusinessGroupMembership)34 ArrayList (java.util.ArrayList)26 HashMap (java.util.HashMap)12 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)10 Identity (org.olat.core.id.Identity)10 BusinessGroup (org.olat.group.BusinessGroup)10 RepositoryEntryMembership (org.olat.repository.model.RepositoryEntryMembership)8 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 HashSet (java.util.HashSet)4 List (java.util.List)4 BusinessGroupShort (org.olat.group.BusinessGroupShort)4 StatisticsBusinessGroupRow (org.olat.group.model.StatisticsBusinessGroupRow)4 OLATResource (org.olat.resource.OLATResource)4 Date (java.util.Date)2 Locale (java.util.Locale)2 Test (org.junit.Test)2 Component (org.olat.core.gui.components.Component)2 TableEvent (org.olat.core.gui.components.table.TableEvent)2 GenericTreeModel (org.olat.core.gui.components.tree.GenericTreeModel)2