use of org.olat.group.model.BusinessGroupQueryParams 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));
}
use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.
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));
}
use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findBusinessGroupWithAuthorConnection.
@Test
public void findBusinessGroupWithAuthorConnection() {
Identity author = JunitTestHelper.createAndPersistIdentityAsUser("bdao-5-" + UUID.randomUUID().toString());
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
repositoryEntryRelationDao.addRole(author, re, GroupRoles.owner.name());
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "gdlo", "gdlo-desc", 0, 5, true, false, false, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(author, "gdmo", "gdmo-desc", 0, 5, true, false, false, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(author, "gdmo", "gdmo-desc", 0, 5, true, false, false, false, false);
businessGroupRelationDao.addRelationToResource(group1, re);
businessGroupRelationDao.addRelationToResource(group3, re);
dbInstance.commitAndCloseSession();
// check
BusinessGroupQueryParams params = new BusinessGroupQueryParams();
params.setAuthorConnection(true);
List<StatisticsBusinessGroupRow> groups = businessGroupDao.searchBusinessGroupsForSelection(params, author);
Assert.assertNotNull(groups);
Assert.assertEquals(2, groups.size());
Set<Long> retrievedGroupkey = new HashSet<Long>();
for (StatisticsBusinessGroupRow group : groups) {
retrievedGroupkey.add(group.getKey());
}
Assert.assertTrue(retrievedGroupkey.contains(group1.getKey()));
Assert.assertTrue(retrievedGroupkey.contains(group3.getKey()));
Assert.assertFalse(retrievedGroupkey.contains(group2.getKey()));
}
use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findMarkedBusinessGroup.
@Test
public void findMarkedBusinessGroup() {
Identity marker = JunitTestHelper.createAndPersistIdentityAsUser("marker-" + UUID.randomUUID().toString());
// create a group with a mark and an other without as control
BusinessGroup group1 = businessGroupDao.createAndPersist(marker, "marked-grp-1", "marked-grp-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(marker, "marked-grp-2", "marked-grp-2-desc", 0, 5, true, false, true, false, false);
markManager.setMark(group1.getResource(), marker, null, "[BusinessGroup:" + group1.getKey() + "]");
dbInstance.commitAndCloseSession();
// check the search with the views
// check marked
BusinessGroupQueryParams queryMarkedParams = new BusinessGroupQueryParams();
queryMarkedParams.setOwner(true);
queryMarkedParams.setMarked(true);
List<BusinessGroupRow> markedGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryMarkedParams, marker);
Assert.assertNotNull(markedGroupViews);
Assert.assertEquals(1, markedGroupViews.size());
Assert.assertTrue(contains(markedGroupViews, group1));
Assert.assertFalse(contains(markedGroupViews, group2));
}
use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.
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));
}
Aggregations