Search in sources :

Example 16 with SearchBusinessGroupParams

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));
}
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 17 with SearchBusinessGroupParams

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));
}
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 18 with SearchBusinessGroupParams

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

Example 19 with SearchBusinessGroupParams

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;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) TransientIdentity(org.olat.admin.user.imp.TransientIdentity) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) HashSet(java.util.HashSet)

Example 20 with SearchBusinessGroupParams

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