use of org.olat.group.BusinessGroupMembership in project OpenOLAT by OpenOLAT.
the class EditMembershipController method loadModel.
private void loadModel(Identity memberToLoad) {
BusinessGroupQueryParams params = new BusinessGroupQueryParams();
if (repoEntry == null) {
params.setBusinessGroupKey(businessGroup.getKey());
} else {
params.setRepositoryEntry(repoEntry);
}
List<StatisticsBusinessGroupRow> groups = businessGroupService.findBusinessGroupsStatistics(params);
if (groups.size() > 1) {
Collections.sort(groups, new BusinessGroupRowComparator(getLocale()));
}
boolean defaultMembership = false;
if (memberToLoad == null) {
if (repoEntry != null && groups.isEmpty()) {
boolean managed = RepositoryEntryManagedFlag.isManaged(repoEntry, RepositoryEntryManagedFlag.membersmanagement) && !overrideManaged;
if (!managed) {
repoRightsEl.select("participant", true);
}
} else if (repoEntry == null && groups.size() == 1) {
boolean managed = BusinessGroupManagedFlag.isManaged(groups.get(0).getManagedFlags(), BusinessGroupManagedFlag.membersmanagement) && !overrideManaged;
if (!managed) {
defaultMembership = true;
}
}
}
List<Long> businessGroupKeys = new ArrayList<>(groups.size());
groups.forEach(group -> businessGroupKeys.add(group.getKey()));
groupMemberships = memberToLoad == null ? Collections.<BusinessGroupMembership>emptyList() : businessGroupService.getBusinessGroupMembership(businessGroupKeys, memberToLoad);
List<MemberOption> options = new ArrayList<MemberOption>();
for (StatisticsBusinessGroupRow group : groups) {
boolean managed = BusinessGroupManagedFlag.isManaged(group.getManagedFlags(), BusinessGroupManagedFlag.membersmanagement) && !overrideManaged;
MemberOption option = new MemberOption(group);
BGPermission bgPermission = PermissionHelper.getPermission(group.getKey(), memberToLoad, groupMemberships);
option.setTutor(createSelection(bgPermission.isTutor(), !managed, GroupRoles.coach.name()));
option.setParticipant(createSelection(bgPermission.isParticipant() || defaultMembership, !managed, GroupRoles.participant.name()));
boolean waitingListEnable = !managed && group.isWaitingListEnabled();
option.setWaiting(createSelection(bgPermission.isWaitingList(), waitingListEnable, GroupRoles.waiting.name()));
options.add(option);
}
tableDataModel.setObjects(options);
}
use of org.olat.group.BusinessGroupMembership in project OpenOLAT by OpenOLAT.
the class CourseBusinessGroupListController method searchTableItems.
@Override
protected List<BGTableItem> searchTableItems(BusinessGroupQueryParams params) {
List<StatisticsBusinessGroupRow> rows = businessGroupService.findBusinessGroupsFromRepositoryEntry(params, getIdentity(), getResource());
List<BGTableItem> items = new ArrayList<>(rows.size());
for (StatisticsBusinessGroupRow 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);
item.setNumOfOwners(row.getNumOfCoaches());
item.setNumOfParticipants(row.getNumOfParticipants());
item.setNumWaiting(row.getNumWaiting());
item.setNumOfPendings(row.getNumPending());
items.add(item);
}
return items;
}
use of org.olat.group.BusinessGroupMembership in project openolat by klemens.
the class MembersTableController method getMembersFromIdentity.
private List<MemberView> getMembersFromIdentity(UserRequest ureq, List<Identity> identities, Map<Long, BusinessGroupMembership> groupmemberships, Map<Long, Date> recentLaunches, Map<Long, Date> initialLaunches) {
if (!deduplicateList) {
duplicateCatcher = new HashSet<>();
}
List<MemberView> memberList = new ArrayList<>();
for (Identity identity : identities) {
MemberView member = new MemberView(identity, userPropertyHandlers, getLocale());
if (userLastTimeVisible) {
if (repoEntry == null) {
BusinessGroupMembership groupmembership = groupmemberships.get(identity.getKey());
if (groupmembership != null) {
member.setFirstTime(groupmembership.getCreationDate());
member.setLastTime(groupmembership.getLastModified());
}
} else {
member.setFirstTime(initialLaunches.get(identity.getKey()));
member.setLastTime(recentLaunches.get(identity.getKey()));
}
}
if (!duplicateCatcher.contains(member)) {
memberList.add(member);
if (!identity.equals(ureq.getIdentity())) {
forgeChatLink(member);
}
}
duplicateCatcher.add(member);
}
return memberList;
}
use of org.olat.group.BusinessGroupMembership in project openolat by klemens.
the class MembersExportManager method getGroupMembershipMap.
public Map<Long, BusinessGroupMembership> getGroupMembershipMap(List<BusinessGroup> groups) {
List<BusinessGroupMembership> groupMemberships = businessGroupService.getBusinessGroupsMembership(groups);
Map<Long, BusinessGroupMembership> map = new HashMap<>();
for (BusinessGroupMembership membership : groupMemberships) {
map.put(membership.getIdentityKey(), membership);
}
return map;
}
use of org.olat.group.BusinessGroupMembership in project openolat by klemens.
the class MembersExportManager method getXlsMediaResource.
public MediaResource getXlsMediaResource(boolean showOwners, boolean showCoaches, boolean showParticipants, boolean showWaiting, List<Identity> owners, List<Identity> coaches, List<Identity> participants, List<Identity> waiting, Translator translator, List<UserPropertyHandler> userPropertyHandlers, RepositoryEntry repoEntry, BusinessGroup businessGroup) {
// TODO
Map<Long, BusinessGroupMembership> groupmemberships;
Map<Long, RepositoryEntryMembership> repomemberships;
if (repoEntry == null) {
List<BusinessGroup> groups = new ArrayList<>();
groups.add(businessGroup);
groupmemberships = getGroupMembershipMap(groups);
repomemberships = new HashMap<>();
} else {
repomemberships = getRepoMembershipMap(repoEntry);
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(null, repoEntry, 0, -1);
groupmemberships = getGroupMembershipMap(groups);
}
List<List<Identity>> roleMembers = new ArrayList<>();
if (showOwners) {
roleMembers.add(owners);
}
if (showCoaches) {
roleMembers.add(coaches);
}
if (showParticipants) {
roleMembers.add(participants);
}
if (showWaiting) {
roleMembers.add(waiting);
}
Translator repoTranslator = Util.createPackageTranslator(Member.class, translator.getLocale());
Translator groupTranslator = Util.createPackageTranslator(GroupMembersRunController.class, translator.getLocale());
Map<Identity, StringBuilder> membersMap = new HashMap<>();
List<Identity> rows = new ArrayList<>();
for (List<Identity> membersList : roleMembers) {
for (Identity member : membersList) {
Long memberKey = member.getKey();
if (repomemberships != null && !repomemberships.isEmpty() && repomemberships.containsKey(memberKey)) {
RepositoryEntryMembership repomembership = repomemberships.get(memberKey);
if (repomembership.isOwner()) {
putRoleToMember(rows, membersMap, member, "owners", repoTranslator);
}
if (repomembership.isCoach()) {
putRoleToMember(rows, membersMap, member, "coaches", repoTranslator);
}
if (repomembership.isParticipant()) {
putRoleToMember(rows, membersMap, member, "participants", repoTranslator);
}
}
if (groupmemberships != null && !groupmemberships.isEmpty() && groupmemberships.containsKey(memberKey)) {
BusinessGroupMembership groupmembership = groupmemberships.get(memberKey);
if (groupmembership.isOwner()) {
putRoleToMember(rows, membersMap, member, "coaches", groupTranslator);
}
if (groupmembership.isParticipant()) {
putRoleToMember(rows, membersMap, member, "participants", groupTranslator);
}
if (groupmembership.isWaiting()) {
putRoleToMember(rows, membersMap, member, "waiting", groupTranslator);
}
}
}
}
Translator handlerTranslator = userManager.getPropertyHandlerTranslator(translator);
XlsMembersExport exporter = new XlsMembersExport();
MediaResource resource = exporter.export(rows, membersMap, handlerTranslator, userPropertyHandlers);
return resource;
}
Aggregations