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");
}
}
}
}
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;
}
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;
}
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;
}
}
}
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();
}
Aggregations