Search in sources :

Example 31 with SearchBusinessGroupParams

use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.

the class BusinessGroupServiceTest method testCreateAndPersistBuddyGroup.

/**
 * Test existence of BuddyGroups inserted in the setUp phase................
 * this test rather tests the findXXX methods...............................
 * so if the setup was ok, and this test also fulfilled, then it means that
 * createAndPersistBuddyGroup works, and also the findXXX methods.
 *
 * @throws Exception
 */
@Test
public void testCreateAndPersistBuddyGroup() throws Exception {
    // id1
    List<BusinessGroup> groupOwnedId1 = businessGroupService.findBusinessGroupsOwnedBy(id1);
    Assert.assertEquals("2 BuddyGroups owned by id1", 3, groupOwnedId1.size());
    Assert.assertTrue(groupOwnedId1.contains(one));
    Assert.assertTrue(groupOwnedId1.contains(three));
    Assert.assertTrue(groupOwnedId1.contains(bgWithWaitingList));
    List<BusinessGroup> groupAttendeeId1 = businessGroupService.findBusinessGroupsAttendedBy(id1);
    Assert.assertEquals("0 BuddyGroup where id1 is partipicating", 0, groupAttendeeId1.size());
    // id2
    List<BusinessGroup> groupOwnedId2 = businessGroupService.findBusinessGroupsOwnedBy(id2);
    Assert.assertEquals("1 BuddyGroup owned by id2", 1, groupOwnedId2.size());
    Assert.assertTrue(groupOwnedId2.contains(two));
    List<BusinessGroup> groupAttendeeId2 = businessGroupService.findBusinessGroupsAttendedBy(id2);
    Assert.assertEquals("1 BuddyGroup where id2 is partipicating", 1, groupAttendeeId2.size());
    assertTrue("It's the correct BuddyGroup", groupAttendeeId2.contains(three));
    // id3
    List<BusinessGroup> groupOwnedId3 = businessGroupService.findBusinessGroupsOwnedBy(id3);
    Assert.assertEquals("1 BuddyGroup owned by id3", 1, groupOwnedId3.size());
    assertTrue("It's the correct BuddyGroup", groupOwnedId3.contains(three));
    List<BusinessGroup> groupAttendeeId3 = businessGroupService.findBusinessGroupsAttendedBy(id3);
    Assert.assertEquals("1 BuddyGroup where id3 is partipicating", 1, groupAttendeeId3.size());
    assertTrue("It's the correct BuddyGroup", groupAttendeeId3.contains(two));
    // id4
    List<BusinessGroup> groupOwnedId4 = businessGroupService.findBusinessGroupsOwnedBy(id4);
    Assert.assertEquals("0 BuddyGroup owned by id4", 0, groupOwnedId4.size());
    SearchBusinessGroupParams params4 = new SearchBusinessGroupParams(id4, false, true);
    List<BusinessGroup> groupAttendeeId4 = businessGroupService.findBusinessGroups(params4, null, 0, -1);
    Assert.assertEquals("1 BuddyGroup where id4 is partipicating", 1, groupAttendeeId4.size());
    assertTrue("It's the correct BuddyGroup", groupAttendeeId4.contains(two));
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) Test(org.junit.Test)

Example 32 with SearchBusinessGroupParams

use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.

the class BusinessGroupDAOTest method findBusinessGroupsByDescription.

@Test
public void findBusinessGroupsByDescription() {
    String marker = UUID.randomUUID().toString();
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-4");
    BusinessGroup group1 = businessGroupDao.createAndPersist(null, "fingbg-1", marker.toUpperCase() + "-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group2 = businessGroupDao.createAndPersist(null, "fingbg-2", "desc-" + marker, 0, 5, true, false, true, false, false);
    BusinessGroup group3 = businessGroupDao.createAndPersist(null, "fingbg-3", "desc-other-one", 0, 5, true, false, true, false, false);
    dbInstance.commitAndCloseSession();
    // check find business group
    SearchBusinessGroupParams params = new SearchBusinessGroupParams();
    params.setDescription(marker);
    List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
    Assert.assertNotNull(groups);
    Assert.assertEquals(2, groups.size());
    Assert.assertTrue(groups.contains(group1));
    Assert.assertTrue(groups.contains(group2));
    Assert.assertFalse(groups.contains(group3));
    // check find business group
    BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
    searchParams.setDescription(marker);
    List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
    Assert.assertNotNull(groupViews);
    Assert.assertEquals(2, groupViews.size());
    Assert.assertTrue(contains(groupViews, group1));
    Assert.assertTrue(contains(groupViews, group2));
    Assert.assertFalse(contains(groupViews, group3));
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams) BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) StatisticsBusinessGroupRow(org.olat.group.model.StatisticsBusinessGroupRow) BusinessGroupRow(org.olat.group.model.BusinessGroupRow) OpenBusinessGroupRow(org.olat.group.model.OpenBusinessGroupRow) Test(org.junit.Test)

Example 33 with SearchBusinessGroupParams

use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.

the class BusinessGroupServiceTest method testLoadBusinessGroups.

@Test
public void testLoadBusinessGroups() {
    SearchBusinessGroupParams params = new SearchBusinessGroupParams(null, false, false);
    List<BusinessGroup> groups = businessGroupService.findBusinessGroups(params, null, 0, 5);
    Assert.assertNotNull(groups);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) Test(org.junit.Test)

Example 34 with SearchBusinessGroupParams

use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.

the class GoToMeetingCourseNode method isCoach.

private final boolean isCoach(RepositoryEntry re, Identity identity) {
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    SearchBusinessGroupParams params = new SearchBusinessGroupParams(identity, true, false);
    int count = bgs.countBusinessGroups(params, re);
    return count > 0;
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams)

Example 35 with SearchBusinessGroupParams

use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.

the class HomeCalendarManager method getListOfCalendarsFiles.

@Override
public List<CalendarFileInfos> getListOfCalendarsFiles(Identity identity) {
    List<CalendarFileInfos> aggregatedFiles = new ArrayList<>();
    Map<CalendarKey, CalendarUserConfiguration> configMap = calendarManager.getCalendarUserConfigurationsMap(identity);
    // personal calendar
    CalendarKey personalCalendarKey = new CalendarKey(identity.getName(), CalendarManager.TYPE_USER);
    CalendarUserConfiguration personalCalendarConfig = configMap.get(personalCalendarKey);
    if (calendarModule.isEnablePersonalCalendar() && (personalCalendarConfig == null || personalCalendarConfig.isInAggregatedFeed())) {
        File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_USER, identity.getName());
        if (iCalFile != null) {
            aggregatedFiles.add(new CalendarFileInfos(identity.getName(), CalendarManager.TYPE_USER, iCalFile));
        }
        // reload every hour
        List<CalendarFileInfos> importedCalendars = importCalendarManager.getImportedCalendarInfosForIdentity(identity, true);
        aggregatedFiles.addAll(importedCalendars);
    }
    // group calendars
    if (calendarModule.isEnableGroupCalendar()) {
        SearchBusinessGroupParams groupParams = new SearchBusinessGroupParams(identity, true, true);
        groupParams.addTools(CollaborationTools.TOOL_CALENDAR);
        List<BusinessGroup> groups = businessGroupService.findBusinessGroups(groupParams, null, 0, -1);
        Set<BusinessGroup> resourceSet = new HashSet<>();
        for (BusinessGroup group : groups) {
            if (resourceSet.contains(group)) {
                continue;
            } else {
                resourceSet.add(group);
            }
            String calendarId = group.getKey().toString();
            CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_GROUP);
            CalendarUserConfiguration calendarConfig = configMap.get(key);
            if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
                File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_GROUP, calendarId);
                if (iCalFile != null) {
                    aggregatedFiles.add(new CalendarFileInfos(calendarId, CalendarManager.TYPE_GROUP, iCalFile));
                }
            }
        }
    }
    if (calendarModule.isEnableCourseElementCalendar() || calendarModule.isEnableCourseToolCalendar()) {
        List<Object[]> resources = getCourses(identity);
        Set<RepositoryEntry> resourceSet = new HashSet<>();
        for (Object[] resource : resources) {
            RepositoryEntry courseEntry = (RepositoryEntry) resource[0];
            if (resourceSet.contains(courseEntry)) {
                continue;
            } else {
                resourceSet.add(courseEntry);
            }
            String calendarId = courseEntry.getOlatResource().getResourceableId().toString();
            CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_COURSE);
            CalendarUserConfiguration calendarConfig = configMap.get(key);
            if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
                File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_COURSE, calendarId);
                if (iCalFile != null) {
                    aggregatedFiles.add(new CalendarFileInfos(calendarId, CalendarManager.TYPE_COURSE, iCalFile));
                }
            }
        }
    }
    return aggregatedFiles;
}
Also used : CalendarKey(org.olat.commons.calendar.model.CalendarKey) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) CalendarFileInfos(org.olat.commons.calendar.model.CalendarFileInfos) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) File(java.io.File) HashSet(java.util.HashSet)

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