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));
}
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));
}
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);
}
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;
}
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;
}
Aggregations