Search in sources :

Example 16 with BusinessGroupQueryParams

use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.

the class BusinessGroupDAOTest method findBusinessGroups.

@Test
public void findBusinessGroups() {
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search");
    BusinessGroup group1 = businessGroupDao.createAndPersist(null, "gduo", "gduo-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group2 = businessGroupDao.createAndPersist(null, "gdvo", "gdvo-desc", 0, 5, true, false, true, false, false);
    dbInstance.commitAndCloseSession();
    SearchBusinessGroupParams params = new SearchBusinessGroupParams();
    List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
    Assert.assertNotNull(groups);
    Assert.assertTrue(groups.size() >= 2);
    Assert.assertTrue(groups.contains(group1));
    Assert.assertTrue(groups.contains(group2));
    BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
    List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
    Assert.assertNotNull(groupViews);
    Assert.assertTrue(groupViews.size() >= 2);
    Assert.assertTrue(contains(groupViews, group1));
    Assert.assertTrue(contains(groupViews, group2));
    List<StatisticsBusinessGroupRow> groupToSelect = businessGroupDao.searchBusinessGroupsForSelection(searchParams, identity);
    Assert.assertNotNull(groupToSelect);
    Assert.assertTrue(groupToSelect.size() >= 2);
    List<OpenBusinessGroupRow> openGroups = businessGroupDao.searchPublishedBusinessGroups(searchParams, identity);
    Assert.assertNotNull(openGroups);
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams) StatisticsBusinessGroupRow(org.olat.group.model.StatisticsBusinessGroupRow) BusinessGroup(org.olat.group.BusinessGroup) OpenBusinessGroupRow(org.olat.group.model.OpenBusinessGroupRow) 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 BusinessGroupQueryParams

use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.

the class BusinessGroupDAOTest method findBusinessGroupsByCourseTitle.

@Test
public void findBusinessGroupsByCourseTitle() {
    // create a repository entry with a relation to a group
    Identity id = JunitTestHelper.createAndPersistIdentityAsUser("re-grp-1-" + UUID.randomUUID().toString());
    RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
    BusinessGroup group = businessGroupDao.createAndPersist(id, "grp-course-1", "grp-course-1-desc", 0, 5, true, false, true, false, false);
    businessGroupRelationDao.addRole(id, group, GroupRoles.participant.name());
    businessGroupRelationDao.addRelationToResource(group, re);
    dbInstance.commitAndCloseSession();
    // retrieve the group through its relation
    BusinessGroupQueryParams params = new BusinessGroupQueryParams();
    params.setOwner(true);
    params.setAttendee(true);
    params.setWaiting(true);
    params.setCourseTitle(re.getDisplayname());
    List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(params, id);
    Assert.assertNotNull(groupViews);
    Assert.assertEquals(1, groupViews.size());
    Assert.assertEquals(group.getKey(), groupViews.get(0).getKey());
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams) BusinessGroup(org.olat.group.BusinessGroup) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) 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 BusinessGroupQueryParams

use of org.olat.group.model.BusinessGroupQueryParams 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 19 with BusinessGroupQueryParams

use of org.olat.group.model.BusinessGroupQueryParams 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 20 with BusinessGroupQueryParams

use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.

the class BusinessGroupDAOTest method findBusinessGroupsByOwnerFuzzy.

@Test
public void findBusinessGroupsByOwnerFuzzy() {
    String marker = UUID.randomUUID().toString();
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser(marker);
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("ddao-2-" + marker.toUpperCase());
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser(marker + "-ddao-3-");
    BusinessGroup group1 = businessGroupDao.createAndPersist(id1, "fingbg-own-1-1", "fingbg-own-1-1-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group2 = businessGroupDao.createAndPersist(id2, "fingbg-own-1-2", "fingbg-own-1-2-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group3 = businessGroupDao.createAndPersist(id3, "fingbg-own-1-3", "fingbg-own-1-3-desc", 0, 5, true, false, true, false, false);
    dbInstance.commitAndCloseSession();
    // check the same with the views
    BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
    searchParams.setOwnerName("*" + marker + "*");
    List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, id1);
    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) StatisticsBusinessGroupRow(org.olat.group.model.StatisticsBusinessGroupRow) BusinessGroupRow(org.olat.group.model.BusinessGroupRow) OpenBusinessGroupRow(org.olat.group.model.OpenBusinessGroupRow) Test(org.junit.Test)

Aggregations

BusinessGroupQueryParams (org.olat.group.model.BusinessGroupQueryParams)82 Test (org.junit.Test)38 Identity (org.olat.core.id.Identity)38 BusinessGroup (org.olat.group.BusinessGroup)38 StatisticsBusinessGroupRow (org.olat.group.model.StatisticsBusinessGroupRow)38 OpenBusinessGroupRow (org.olat.group.model.OpenBusinessGroupRow)36 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)34 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)16 RepositoryEntry (org.olat.repository.RepositoryEntry)8 Offer (org.olat.resource.accesscontrol.Offer)4 OfferAccess (org.olat.resource.accesscontrol.OfferAccess)4 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)4 TokenAccessMethod (org.olat.resource.accesscontrol.model.TokenAccessMethod)4 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 BGPermission (org.olat.course.member.PermissionHelper.BGPermission)2 BusinessGroupMembership (org.olat.group.BusinessGroupMembership)2 BusinessGroupRowComparator (org.olat.group.model.comparator.BusinessGroupRowComparator)2