use of org.olat.group.BusinessGroupShort in project openolat by klemens.
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 klemens.
the class ConditionConfigEasyController 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(StringHelper.escapeHtml(group.getName()));
}
return sb.toString();
}
use of org.olat.group.BusinessGroupShort in project openolat by klemens.
the class ConditionConfigEasyController method validateGroupFields.
/**
* @param retVal
* @return
*/
private boolean validateGroupFields() {
boolean retVal = true;
if (groupSwitch.getSelectedKeys().size() == 1) {
List<Long> activeGroupSelection = null;
List<Long> activeAreaSelection = null;
groupChooseSubContainer.clearError();
if (!isEmpty(easyGroupList)) {
// check whether groups exist
activeGroupSelection = getKeys(easyGroupList);
Set<Long> missingGroups = new HashSet<Long>();
List<BusinessGroupShort> existingGroups = businessGroupService.loadShortBusinessGroups(activeGroupSelection);
a_a: for (Long activeGroupKey : activeGroupSelection) {
for (BusinessGroupShort group : existingGroups) {
if (group.getKey().equals(activeGroupKey)) {
continue a_a;
}
}
missingGroups.add(activeGroupKey);
}
if (missingGroups.size() > 0) {
retVal = false;
String labelKey = missingGroups.size() == 1 ? "error.notfound.name" : "error.notfound.names";
String csvMissGrps = toString(missingGroups);
String[] params = new String[] { "-", csvMissGrps };
// create error with link to fix it
String vc_errorPage = velocity_root + "/erroritem.html";
FormLayoutContainer errorGroupItemLayout = FormLayoutContainer.createCustomFormLayout("errorgroupitem", getTranslator(), vc_errorPage);
groupChooseSubContainer.setErrorComponent(errorGroupItemLayout, this.flc);
// FIXING LINK ONLY IF A DEFAULTCONTEXT EXISTS
fixGroupError = new FormLinkImpl("error.fix", "create");
// link
fixGroupError.setCustomEnabledLinkCSS("btn btn-default");
errorGroupItemLayout.add(fixGroupError);
fixGroupError.setErrorKey(labelKey, params);
fixGroupError.showError(true);
fixGroupError.showLabel(false);
// String[].lenght > 1 -> show bulkmode creation group
if (missingGroups.size() > 1) {
fixGroupError.setUserObject(new String[] { csvMissGrps, "dummy" });
} else {
fixGroupError.setUserObject(new String[] { csvMissGrps });
}
groupChooseSubContainer.showError(true);
} else {
// no more errors
groupChooseSubContainer.clearError();
}
}
areaChooseSubContainer.clearError();
if (!isEmpty(easyAreaList)) {
// check whether areas exist
activeAreaSelection = getKeys(easyAreaList);
List<Long> missingAreas = new ArrayList<Long>();
List<BGArea> cnt = areaManager.loadAreas(activeAreaSelection);
a_a: for (Long activeAreaKey : activeAreaSelection) {
for (BGArea element : cnt) {
if (element.getKey().equals(activeAreaKey)) {
continue a_a;
}
}
missingAreas.add(activeAreaKey);
}
if (missingAreas.size() > 0) {
retVal = false;
String labelKey = missingAreas.size() == 1 ? "error.notfound.name" : "error.notfound.names";
String csvMissAreas = toString(missingAreas);
String[] params = new String[] { "-", csvMissAreas };
// create error with link to fix it
String vc_errorPage = velocity_root + "/erroritem.html";
FormLayoutContainer errorAreaItemLayout = FormLayoutContainer.createCustomFormLayout("errorareaitem", getTranslator(), vc_errorPage);
areaChooseSubContainer.setErrorComponent(errorAreaItemLayout, this.flc);
// FXINGIN LINK ONLY IF DEFAULT CONTEXT EXISTS
// erstellen
fixAreaError = new FormLinkImpl("error.fix", "create");
// link
fixAreaError.setCustomEnabledLinkCSS("btn btn-default");
errorAreaItemLayout.add(fixAreaError);
fixAreaError.setErrorKey(labelKey, params);
fixAreaError.showError(true);
fixAreaError.showLabel(false);
// String[].lenght > 1 -> show bulkmode creation group
if (missingAreas.size() > 1) {
fixAreaError.setUserObject(new String[] { csvMissAreas, "dummy" });
} else {
fixAreaError.setUserObject(new String[] { csvMissAreas });
}
areaChooseSubContainer.showError(true);
} else {
areaChooseSubContainer.clearError();
}
}
boolean easyGroupOK = (!isEmpty(easyGroupList) && activeGroupSelection != null && !activeGroupSelection.isEmpty());
boolean easyAreaOK = (!isEmpty(easyAreaList) && activeAreaSelection != null && !activeAreaSelection.isEmpty());
if (easyGroupOK || easyAreaOK) {
// clear general error
groupSubContainer.clearError();
} else {
// error concerns both fields -> set it as switch error
groupSubContainer.setErrorKey("form.easy.error.group", null);
retVal = false;
}
}
return retVal;
}
use of org.olat.group.BusinessGroupShort in project openolat by klemens.
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;
}
Aggregations