use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class GroupsPortletRunController method getPersistentManuallySortedItems.
/**
* Retrieves the persistent manually sorted items for the current portlet.
* @param ureq
* @return
*/
private List<PortletEntry<BusinessGroupEntry>> getPersistentManuallySortedItems() {
@SuppressWarnings("unchecked") Map<Long, Integer> storedPrefs = (Map<Long, Integer>) guiPreferences.get(Map.class, getPreferenceKey(SORTED_ITEMS_PREF));
List<PortletEntry<BusinessGroupEntry>> portletEntryList;
if (storedPrefs != null) {
SearchBusinessGroupParams params = new SearchBusinessGroupParams(getIdentity(), true, true);
params.setGroupKeys(storedPrefs.keySet());
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(params, null, 0, -1);
portletEntryList = convertBusinessGroupToPortletEntryList(groups, false);
} else {
List<BusinessGroup> groups = new ArrayList<BusinessGroup>();
portletEntryList = convertShortBusinessGroupToPortletEntryList(groups, false);
}
return getPersistentManuallySortedItems(portletEntryList);
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class LDAPLoginManagerImpl method getManagerBusinessGroup.
private BusinessGroup getManagerBusinessGroup(String externalId) {
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setExternalId(externalId);
List<BusinessGroup> businessGroups = businessGroupService.findBusinessGroups(params, null, 0, -1);
BusinessGroup managedBusinessGroup;
if (businessGroups.size() == 0) {
String managedFlags = BusinessGroupManagedFlag.membersmanagement.name() + "," + BusinessGroupManagedFlag.delete.name();
managedBusinessGroup = businessGroupService.createBusinessGroup(null, externalId, externalId, externalId, managedFlags, null, null, false, false, null);
} else if (businessGroups.size() == 1) {
managedBusinessGroup = businessGroups.get(0);
} else {
log.error(businessGroups.size() + " managed groups found with the following external id: " + externalId);
managedBusinessGroup = null;
}
return managedBusinessGroup;
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class UserCalendarWebService method getCalendars.
private void getCalendars(CalendarVisitor calVisitor, UserRequest ureq) {
Roles roles = ureq.getUserSession().getRoles();
Identity retrievedUser = ureq.getIdentity();
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (calendarModule.isEnabled()) {
if (calendarModule.isEnablePersonalCalendar()) {
KalendarRenderWrapper personalWrapper = getPersonalCalendar(ureq.getIdentity());
calVisitor.visit(personalWrapper);
}
if (calendarModule.isEnableCourseToolCalendar() || calendarModule.isEnableCourseElementCalendar()) {
RepositoryManager rm = RepositoryManager.getInstance();
ACService acManager = CoreSpringFactory.getImpl(ACService.class);
SearchRepositoryEntryParameters repoParams = new SearchRepositoryEntryParameters(retrievedUser, roles, "CourseModule");
repoParams.setOnlyExplicitMember(true);
repoParams.setIdentity(retrievedUser);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(retrievedUser);
ienv.setRoles(roles);
List<RepositoryEntry> entries = rm.genericANDQueryWithRolesRestriction(repoParams, 0, -1, true);
for (RepositoryEntry entry : entries) {
AccessResult result = acManager.isAccessible(entry, retrievedUser, false);
if (result.isAccessible()) {
try {
final ICourse course = CourseFactory.loadCourse(entry);
CourseConfig config = course.getCourseEnvironment().getCourseConfig();
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
if (config.isCalendarEnabled()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
} else {
CalCourseNodeVisitor visitor = new CalCourseNodeVisitor();
new CourseTreeVisitor(course, ienv).visit(visitor, new VisibleTreeFilter());
if (visitor.isFound()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
}
}
} catch (Exception e) {
log.error("", e);
}
}
}
}
if (calendarModule.isEnableGroupCalendar()) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
// start found forums in groups
BusinessGroupService bgm = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, true, true);
params.addTools(CollaborationTools.TOOL_CALENDAR);
List<BusinessGroup> groups = bgm.findBusinessGroups(params, null, 0, -1);
for (BusinessGroup group : groups) {
KalendarRenderWrapper wrapper = collaborationManager.getCalendar(group, ureq, false);
calVisitor.visit(wrapper);
}
}
}
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class SystemRegistrationManager method getRegistrationPropertiesMessage.
public Map<String, String> getRegistrationPropertiesMessage() {
Map<String, String> msgProperties = new HashMap<String, String>();
boolean website = registrationModule.isPublishWebsite();
boolean notify = registrationModule.isNotifyReleases();
// OLAT version
msgProperties.put("appName", Settings.getApplicationName());
msgProperties.put("version", Settings.getFullVersionInfo());
// Location
msgProperties.put("location", registrationModule.getLocation());
msgProperties.put("locationCSV", registrationModule.getLocationCoordinates());
// System config
msgProperties.put("instantMessagingEnabled", String.valueOf(CoreSpringFactory.getImpl(InstantMessagingModule.class).isEnabled()));
msgProperties.put("enabledLanguages", CoreSpringFactory.getImpl(I18nModule.class).getEnabledLanguageKeys().toString());
msgProperties.put("clusterEnabled", clusterMode);
msgProperties.put("debuggingEnabled", String.valueOf(Settings.isDebuging()));
// Course counts
int allCourses = repositoryManager.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_OWNERS);
int publishedCourses = repositoryManager.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_USERS);
msgProperties.put("courses", String.valueOf(allCourses));
msgProperties.put("coursesPublished", String.valueOf(publishedCourses));
// User counts
SecurityGroup olatuserGroup = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
int users = securityManager.countIdentitiesOfSecurityGroup(olatuserGroup);
long disabled = securityManager.countIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, null, null, Identity.STATUS_LOGIN_DENIED);
msgProperties.put("usersEnabled", String.valueOf(users - disabled));
PermissionOnResourceable[] permissions = { new PermissionOnResourceable(Constants.PERMISSION_HASROLE, Constants.ORESOURCE_AUTHOR) };
long authors = securityManager.countIdentitiesByPowerSearch(null, null, true, null, permissions, null, null, null, null, null, null);
msgProperties.put("authors", String.valueOf(authors));
// Activity
Calendar lastLoginLimit = Calendar.getInstance();
// -1 - 6 = -7 for last week
lastLoginLimit.add(Calendar.DAY_OF_YEAR, -6);
Long activeUsersLastWeek = securityManager.countUniqueUserLoginsSince(lastLoginLimit.getTime());
msgProperties.put("activeUsersLastWeek", String.valueOf(activeUsersLastWeek));
lastLoginLimit = Calendar.getInstance();
lastLoginLimit.add(Calendar.MONTH, -1);
Long activeUsersLastMonth = securityManager.countUniqueUserLoginsSince(lastLoginLimit.getTime());
msgProperties.put("activeUsersLastMonth", String.valueOf(activeUsersLastMonth));
// Groups
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
int groups = businessGroupService.countBusinessGroups(params, null);
msgProperties.put("buddyGroups", String.valueOf(groups));
msgProperties.put("learningGroups", String.valueOf(groups));
msgProperties.put("rightGroups", String.valueOf(groups));
msgProperties.put("groups", String.valueOf(groups));
// URL
msgProperties.put("url", Settings.getServerContextPathURI());
msgProperties.put("publishWebsite", String.valueOf(website));
// Description
String desc = registrationModule.getWebsiteDescription();
msgProperties.put("description", desc);
if (notify) {
// Email
String email = registrationModule.getEmail();
msgProperties.put("email", email);
}
return msgProperties;
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class GroupOverviewController method updateModel.
/**
* @param ureq
* @param control
* @param identity
* @return
*/
private void updateModel() {
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setIdentity(identity);
params.setOwner(true);
params.setAttendee(true);
params.setWaiting(true);
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(params, null, 0, -1);
List<Long> groupKeysWithMembers;
if (groups.size() > 50) {
groupKeysWithMembers = null;
} else {
groupKeysWithMembers = new ArrayList<Long>(groups.size());
for (BusinessGroup view : groups) {
groupKeysWithMembers.add(view.getKey());
}
}
// retrieve all user's membership if there are more than 50 groups
List<BusinessGroupMembership> groupsAsOwner = businessGroupService.getBusinessGroupMembership(groupKeysWithMembers, identity);
Map<Long, BusinessGroupMembership> memberships = new HashMap<Long, BusinessGroupMembership>();
for (BusinessGroupMembership membership : groupsAsOwner) {
memberships.put(membership.getGroupKey(), membership);
}
List<GroupOverviewRow> items = new ArrayList<GroupOverviewRow>();
for (BusinessGroup group : groups) {
BusinessGroupMembership membership = memberships.get(group.getKey());
GroupOverviewRow tableItem = new GroupOverviewRow(group, membership, Boolean.TRUE);
items.add(tableItem);
}
tableDataModel.setEntries(items);
groupListCtr.modelChanged();
}
Aggregations