Search in sources :

Example 26 with BusinessGroupRow

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

the class BusinessGroupDAOTest method findBusinessGroupsHeadless.

@Test
public void findBusinessGroupsHeadless() {
    Identity owner = JunitTestHelper.createAndPersistIdentityAsUser("head-1-" + UUID.randomUUID().toString());
    BusinessGroup headlessGroup = businessGroupDao.createAndPersist(null, "headless-grp", "headless-grp-desc", 0, 5, true, false, true, false, false);
    BusinessGroup headedGroup = businessGroupDao.createAndPersist(owner, "headed-grp", "headed-grp-desc", 0, 5, true, false, true, false, false);
    dbInstance.commitAndCloseSession();
    // check marked
    BusinessGroupQueryParams headlessParams = new BusinessGroupQueryParams();
    headlessParams.setHeadless(true);
    List<BusinessGroupRow> groups = businessGroupDao.searchBusinessGroupsWithMemberships(headlessParams, owner);
    Assert.assertNotNull(groups);
    Assert.assertFalse(groups.isEmpty());
    Assert.assertTrue(contains(groups, headlessGroup));
    Assert.assertFalse(contains(groups, headedGroup));
}
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 27 with BusinessGroupRow

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

the class BusinessGroupDAOTest method findBusinessGroupsByNameOrDescFuzzy.

@Test
public void findBusinessGroupsByNameOrDescFuzzy() {
    String marker = UUID.randomUUID().toString();
    Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-7");
    BusinessGroup group1 = businessGroupDao.createAndPersist(null, "fingbg-1", marker + "-desc", 0, 5, true, false, true, false, false);
    BusinessGroup group2 = businessGroupDao.createAndPersist(null, "fingbg-2", "desc-" + marker.toUpperCase(), 0, 5, true, false, true, false, false);
    BusinessGroup group3 = businessGroupDao.createAndPersist(null, "fingbg-3", "desc-" + marker + "-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(3, groups.size());
    Assert.assertTrue(groups.contains(group1));
    Assert.assertTrue(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(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 28 with BusinessGroupRow

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

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));
}
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 29 with BusinessGroupRow

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

the class BusinessGroupDAOTest method findBusinessGroupsByRepositoryEntry.

@Test
public void findBusinessGroupsByRepositoryEntry() {
    // 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.setRepositoryEntry(re);
    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 30 with BusinessGroupRow

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

the class BusinessGroupDAOTest method findPublicGroupsLimitedDate.

@Test
public void findPublicGroupsLimitedDate() {
    // create a group with an access control limited by a valid date
    Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-11");
    BusinessGroup groupVisible = businessGroupDao.createAndPersist(null, "access-grp-2", "access-grp-2-desc", 0, 5, true, false, true, false, false);
    // create and save an offer
    Offer offer = acService.createOffer(groupVisible.getResource(), "TestBGWorkflow");
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.HOUR_OF_DAY, -1);
    offer.setValidFrom(cal.getTime());
    cal.add(Calendar.HOUR_OF_DAY, 2);
    offer.setValidTo(cal.getTime());
    assertNotNull(offer);
    offer = acService.save(offer);
    acMethodManager.enableMethod(TokenAccessMethod.class, true);
    List<AccessMethod> methods = acMethodManager.getAvailableMethodsByType(TokenAccessMethod.class);
    AccessMethod method = methods.get(0);
    OfferAccess access = acMethodManager.createOfferAccess(offer, method);
    acMethodManager.save(access);
    // create a group with an access control limited by dates in the past
    BusinessGroup oldGroup = businessGroupDao.createAndPersist(null, "access-grp-3", "access-grp-3-desc", 0, 5, true, false, true, false, false);
    // create and save an offer
    Offer oldOffer = acService.createOffer(oldGroup.getResource(), "TestBGWorkflow");
    cal.add(Calendar.HOUR_OF_DAY, -5);
    oldOffer.setValidFrom(cal.getTime());
    cal.add(Calendar.HOUR_OF_DAY, -5);
    oldOffer.setValidTo(cal.getTime());
    assertNotNull(oldOffer);
    oldOffer = acService.save(oldOffer);
    OfferAccess oldAccess = acMethodManager.createOfferAccess(oldOffer, method);
    acMethodManager.save(oldAccess);
    dbInstance.commitAndCloseSession();
    // retrieve the offer
    BusinessGroupQueryParams paramsAll = new BusinessGroupQueryParams();
    paramsAll.setPublicGroups(Boolean.TRUE);
    List<BusinessGroupRow> accessGroups = businessGroupDao.searchBusinessGroupsWithMemberships(paramsAll, id);
    Assert.assertNotNull(accessGroups);
    Assert.assertTrue(accessGroups.size() >= 1);
    Assert.assertTrue(contains(accessGroups, groupVisible));
    Assert.assertFalse(contains(accessGroups, oldGroup));
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams) AccessMethod(org.olat.resource.accesscontrol.model.AccessMethod) TokenAccessMethod(org.olat.resource.accesscontrol.model.TokenAccessMethod) OfferAccess(org.olat.resource.accesscontrol.OfferAccess) BusinessGroup(org.olat.group.BusinessGroup) Offer(org.olat.resource.accesscontrol.Offer) Calendar(java.util.Calendar) 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