use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findBusinessGroupsByNameFuzzy.
@Test
public void findBusinessGroupsByNameFuzzy() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-3");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, marker.toUpperCase(), "fingbg-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, marker + "xxx", "fingbg-2-desc", 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "yyy" + marker.toUpperCase(), "fingbg-3-desc", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setName("*" + marker + "*");
List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(3, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
Assert.assertTrue(groups.contains(group3));
// check the same with the views
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setName("*" + marker + "*");
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
Assert.assertNotNull(groupViews);
Assert.assertEquals(3, groupViews.size());
Assert.assertTrue(contains(groupViews, group1));
Assert.assertTrue(contains(groupViews, group2));
Assert.assertTrue(contains(groupViews, group3));
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findBusinessGroupsByName.
@Test
public void findBusinessGroupsByName() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-2");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, marker.toUpperCase(), "fingbg-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, marker + "xxx", "fingbg-2-desc", 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "yyy" + marker.toUpperCase(), "fingbg-3-desc", 0, 5, true, false, true, false, false);
BusinessGroup group4 = businessGroupDao.createAndPersist(null, "yyyyZZZxxx", "fingbg-3-desc", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setName(marker);
List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(3, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
Assert.assertTrue(groups.contains(group3));
Assert.assertFalse(groups.contains(group4));
// check the same with the views
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setName(marker);
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
Assert.assertNotNull(groupViews);
Assert.assertEquals(3, groupViews.size());
Assert.assertTrue(contains(groupViews, group1));
Assert.assertTrue(contains(groupViews, group2));
Assert.assertTrue(contains(groupViews, group3));
Assert.assertFalse(contains(groupViews, group4));
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class OLATUpgrade_11_0_0 method getAllAssessableIdentities.
/**
* Return the same amount of user as in the assessment tool.
* @param entry
* @return
*/
private List<Identity> getAllAssessableIdentities(ICourse course, RepositoryEntry entry) {
Set<Identity> duplicateKiller = new HashSet<>();
List<Identity> assessableIdentities = new ArrayList<>();
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
List<BusinessGroup> coachedGroups = businessGroupService.findBusinessGroups(params, entry, 0, -1);
List<Identity> participants = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
for (Identity participant : participants) {
if (!duplicateKiller.contains(participant)) {
assessableIdentities.add(participant);
duplicateKiller.add(participant);
}
}
List<Identity> courseParticipants = repositoryService.getMembers(entry, GroupRoles.participant.name());
for (Identity participant : courseParticipants) {
if (!duplicateKiller.contains(participant)) {
assessableIdentities.add(participant);
duplicateKiller.add(participant);
}
}
List<Identity> assessedUsers = getAllIdentitiesWithCourseAssessmentData(course.getResourceableId());
for (Identity assessedUser : assessedUsers) {
if (!duplicateKiller.contains(assessedUser)) {
assessableIdentities.add(assessedUser);
duplicateKiller.add(assessedUser);
}
}
return assessableIdentities;
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class BusinessGroupServiceImpl method removeResource.
@Override
public void removeResource(RepositoryEntryRef re) {
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
List<BusinessGroup> groups = findBusinessGroups(params, re, 0, -1);
removeResourceFrom(groups, re);
}
Aggregations