Search in sources :

Example 41 with BusinessGroupRow

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

the class BusinessGroupDAOTest method findBusinessGroupsByOwner.

@Test
public void findBusinessGroupsByOwner() {
    // 5 identities
    String marker = UUID.randomUUID().toString();
    Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser(marker);
    Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("ddao-2-" + marker);
    Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser(marker + "-ddao-3");
    Identity id4 = JunitTestHelper.createAndPersistIdentityAsUser("something-else-ddao-4");
    BusinessGroup group1 = businessGroupDao.createAndPersist(id1, "fingbgown-1", "fingbgown-1-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group2 = businessGroupDao.createAndPersist(id2, "fingbgown-2", "fingbgown-2-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group3 = businessGroupDao.createAndPersist(id3, "fingbgown-3", "fingbgown-3-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group4 = businessGroupDao.createAndPersist(id4, "fingbgown-4", "fingbgown-4-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));
    Assert.assertFalse(contains(groupViews, group4));
}
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)

Example 42 with BusinessGroupRow

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

the class BusinessGroupDAOTest method findBusinessGroupsByIdentity.

@Test
public void findBusinessGroupsByIdentity() {
    Identity id = JunitTestHelper.createAndPersistIdentityAsUser("is-in-grp-" + UUID.randomUUID().toString());
    BusinessGroup group1 = businessGroupDao.createAndPersist(id, "is-in-grp-1", "is-in-grp-1-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group2 = businessGroupDao.createAndPersist(null, "is-in-grp-2", "is-in-grp-2-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group3 = businessGroupDao.createAndPersist(null, "is-in-grp-3", "is-in-grp-3-desc", 0, 5, true, false, true, false, false);
    dbInstance.commitAndCloseSession();
    businessGroupRelationDao.addRole(id, group2, GroupRoles.participant.name());
    businessGroupRelationDao.addRole(id, group3, GroupRoles.waiting.name());
    dbInstance.commitAndCloseSession();
    // check owner
    SearchBusinessGroupParams paramsOwner = new SearchBusinessGroupParams();
    paramsOwner.setIdentity(id);
    paramsOwner.setOwner(true);
    List<BusinessGroup> ownedGroups = businessGroupDao.findBusinessGroups(paramsOwner, null, 0, 0);
    Assert.assertNotNull(ownedGroups);
    Assert.assertEquals(1, ownedGroups.size());
    Assert.assertTrue(ownedGroups.contains(group1));
    // check attendee
    SearchBusinessGroupParams paramsAttendee = new SearchBusinessGroupParams();
    paramsAttendee.setIdentity(id);
    paramsAttendee.setAttendee(true);
    List<BusinessGroup> attendeeGroups = businessGroupDao.findBusinessGroups(paramsAttendee, null, 0, 0);
    Assert.assertNotNull(attendeeGroups);
    Assert.assertEquals(1, attendeeGroups.size());
    Assert.assertTrue(attendeeGroups.contains(group2));
    // check waiting
    SearchBusinessGroupParams paramsWaiting = new SearchBusinessGroupParams();
    paramsWaiting.setIdentity(id);
    paramsWaiting.setWaiting(true);
    List<BusinessGroup> waitingGroups = businessGroupDao.findBusinessGroups(paramsWaiting, null, 0, 0);
    Assert.assertNotNull(waitingGroups);
    Assert.assertEquals(1, waitingGroups.size());
    Assert.assertTrue(waitingGroups.contains(group3));
    // check all
    SearchBusinessGroupParams paramsAll = new SearchBusinessGroupParams();
    paramsAll.setIdentity(id);
    paramsAll.setOwner(true);
    paramsAll.setAttendee(true);
    paramsAll.setWaiting(true);
    List<BusinessGroup> allGroups = businessGroupDao.findBusinessGroups(paramsAll, null, 0, 0);
    Assert.assertNotNull(allGroups);
    Assert.assertEquals(3, allGroups.size());
    Assert.assertTrue(allGroups.contains(group1));
    Assert.assertTrue(allGroups.contains(group2));
    Assert.assertTrue(allGroups.contains(group3));
    // The same tests with the views
    // check owner on views
    BusinessGroupQueryParams queryParamsOwner = new BusinessGroupQueryParams();
    queryParamsOwner.setOwner(true);
    List<BusinessGroupRow> ownedGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryParamsOwner, id);
    Assert.assertNotNull(ownedGroupViews);
    Assert.assertEquals(1, ownedGroupViews.size());
    Assert.assertTrue(contains(ownedGroupViews, group1));
    // check attendee on views
    BusinessGroupQueryParams queryParamsAttendee = new BusinessGroupQueryParams();
    queryParamsAttendee.setAttendee(true);
    List<BusinessGroupRow> attendeeGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryParamsAttendee, id);
    Assert.assertNotNull(attendeeGroupViews);
    Assert.assertEquals(1, attendeeGroupViews.size());
    Assert.assertTrue(contains(attendeeGroupViews, group2));
    // check waiting on views
    BusinessGroupQueryParams queryParamsWaiting = new BusinessGroupQueryParams();
    queryParamsWaiting.setWaiting(true);
    List<BusinessGroupRow> waitingGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryParamsWaiting, id);
    Assert.assertNotNull(waitingGroupViews);
    Assert.assertEquals(1, waitingGroupViews.size());
    Assert.assertTrue(contains(waitingGroupViews, group3));
    // check all on views
    BusinessGroupQueryParams queryParamsAll = new BusinessGroupQueryParams();
    queryParamsAll.setOwner(true);
    queryParamsAll.setAttendee(true);
    queryParamsAll.setWaiting(true);
    List<BusinessGroupRow> allGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryParamsAll, id);
    Assert.assertNotNull(allGroupViews);
    Assert.assertEquals(3, allGroupViews.size());
    Assert.assertTrue(contains(allGroupViews, group1));
    Assert.assertTrue(contains(allGroupViews, group2));
    Assert.assertTrue(contains(allGroupViews, 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 43 with BusinessGroupRow

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

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 44 with BusinessGroupRow

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

the class BusinessGroupDAOTest method findBusinessGroupsByNameOrDesc.

@Test
public void findBusinessGroupsByNameOrDesc() {
    String marker = UUID.randomUUID().toString();
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-6");
    BusinessGroup group1 = businessGroupDao.createAndPersist(null, "fingbg-1", marker.toUpperCase() + "-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group2 = businessGroupDao.createAndPersist(null, "fingbg-2", "fingbg-2-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group3 = businessGroupDao.createAndPersist(null, marker.toUpperCase() + "-xxx", "desc-fingb-desc", 0, 5, true, false, true, false, false);
    dbInstance.commitAndCloseSession();
    SearchBusinessGroupParams params = new SearchBusinessGroupParams();
    params.setNameOrDesc(marker);
    List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
    Assert.assertNotNull(groups);
    Assert.assertEquals(2, groups.size());
    Assert.assertTrue(groups.contains(group1));
    Assert.assertFalse(groups.contains(group2));
    Assert.assertTrue(groups.contains(group3));
    // check the same search with the views
    BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
    searchParams.setNameOrDesc(marker);
    List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
    Assert.assertNotNull(groupViews);
    Assert.assertEquals(2, groupViews.size());
    Assert.assertTrue(contains(groupViews, group1));
    Assert.assertFalse(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 45 with BusinessGroupRow

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

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

BusinessGroupRow (org.olat.group.model.BusinessGroupRow)60 StatisticsBusinessGroupRow (org.olat.group.model.StatisticsBusinessGroupRow)50 OpenBusinessGroupRow (org.olat.group.model.OpenBusinessGroupRow)46 BusinessGroup (org.olat.group.BusinessGroup)38 Test (org.junit.Test)34 Identity (org.olat.core.id.Identity)34 BusinessGroupQueryParams (org.olat.group.model.BusinessGroupQueryParams)34 ArrayList (java.util.ArrayList)20 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)16 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)8 HashMap (java.util.HashMap)6 BusinessGroupMembership (org.olat.group.BusinessGroupMembership)6 BusinessGroupToSearch (org.olat.group.model.BusinessGroupToSearch)6 RepositoryEntry (org.olat.repository.RepositoryEntry)6 List (java.util.List)4 BusinessGroupSelectionEvent (org.olat.group.model.BusinessGroupSelectionEvent)4 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)4 Calendar (java.util.Calendar)2 MarkImpl (org.olat.core.commons.services.mark.impl.MarkImpl)2 FlexiTableSearchEvent (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableSearchEvent)2