Search in sources :

Example 56 with SearchBusinessGroupParams

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);
}
Also used : PortletEntry(org.olat.core.gui.control.generic.portal.PortletEntry) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) Map(java.util.Map) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams)

Example 57 with SearchBusinessGroupParams

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;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams)

Example 58 with SearchBusinessGroupParams

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);
            }
        }
    }
}
Also used : SearchRepositoryEntryParameters(org.olat.repository.model.SearchRepositoryEntryParameters) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) BusinessGroup(org.olat.group.BusinessGroup) VisibleTreeFilter(org.olat.course.run.userview.VisibleTreeFilter) CourseTreeVisitor(org.olat.course.run.userview.CourseTreeVisitor) Roles(org.olat.core.id.Roles) ICourse(org.olat.course.ICourse) RepositoryEntry(org.olat.repository.RepositoryEntry) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) WebApplicationException(javax.ws.rs.WebApplicationException) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) CourseConfig(org.olat.course.config.CourseConfig) UserCourseEnvironmentImpl(org.olat.course.run.userview.UserCourseEnvironmentImpl) BusinessGroupService(org.olat.group.BusinessGroupService) ACService(org.olat.resource.accesscontrol.ACService) AccessResult(org.olat.resource.accesscontrol.AccessResult) CalendarModule(org.olat.commons.calendar.CalendarModule) RepositoryManager(org.olat.repository.RepositoryManager) Identity(org.olat.core.id.Identity) IdentityEnvironment(org.olat.core.id.IdentityEnvironment) CollaborationManager(org.olat.collaboration.CollaborationManager)

Example 59 with SearchBusinessGroupParams

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;
}
Also used : I18nModule(org.olat.core.util.i18n.I18nModule) HashMap(java.util.HashMap) Calendar(java.util.Calendar) SecurityGroup(org.olat.basesecurity.SecurityGroup) InstantMessagingModule(org.olat.instantMessaging.InstantMessagingModule) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) PermissionOnResourceable(org.olat.basesecurity.PermissionOnResourceable)

Example 60 with SearchBusinessGroupParams

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();
}
Also used : BusinessGroupMembership(org.olat.group.BusinessGroupMembership) BusinessGroup(org.olat.group.BusinessGroup) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams)

Aggregations

SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)92 BusinessGroup (org.olat.group.BusinessGroup)84 Identity (org.olat.core.id.Identity)36 Test (org.junit.Test)34 ArrayList (java.util.ArrayList)26 BusinessGroupService (org.olat.group.BusinessGroupService)18 BusinessGroupQueryParams (org.olat.group.model.BusinessGroupQueryParams)16 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)16 OpenBusinessGroupRow (org.olat.group.model.OpenBusinessGroupRow)16 StatisticsBusinessGroupRow (org.olat.group.model.StatisticsBusinessGroupRow)16 RepositoryEntry (org.olat.repository.RepositoryEntry)16 HashSet (java.util.HashSet)12 GET (javax.ws.rs.GET)10 Produces (javax.ws.rs.Produces)10 Roles (org.olat.core.id.Roles)10 HashMap (java.util.HashMap)8 Map (java.util.Map)8 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)6 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)6 ICourse (org.olat.course.ICourse)6