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(" ");
sb.append("<i class='o_icon o_icon-fw o_icon_group'> </i> ");
sb.append(StringHelper.escapeHtml(group.getName()));
}
return sb.toString();
}
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(" ");
sb.append("<i class='o_icon o_icon-fw o_icon_group'> </i> ").append(StringHelper.escapeHtml(group.getName()));
}
return sb.toString();
}
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);
}
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;
}
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;
}
Aggregations