use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.
the class BusinessGroupListController method getSearchParams.
@Override
protected BusinessGroupQueryParams getSearchParams(SearchEvent event) {
BusinessGroupQueryParams params = event.convertToBusinessGroupQueriesParams();
// security
if (!params.isAttendee() && !params.isOwner() && !params.isWaiting()) {
params.setOwner(true);
params.setAttendee(true);
params.setWaiting(true);
}
return params;
}
use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.
the class BusinessGroupListController method getDefaultSearchParams.
@Override
protected BusinessGroupQueryParams getDefaultSearchParams() {
BusinessGroupQueryParams params = new BusinessGroupQueryParams();
params.setAttendee(true);
params.setOwner(true);
params.setWaiting(true);
return params;
}
use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findMarkedBusinessGroupCrossContamination.
@Test
public void findMarkedBusinessGroupCrossContamination() {
Identity marker1 = JunitTestHelper.createAndPersistIdentityAsUser("marker-1-" + UUID.randomUUID().toString());
Identity marker2 = JunitTestHelper.createAndPersistIdentityAsUser("marker-2-" + UUID.randomUUID().toString());
// create a group with a mark and an other without as control
BusinessGroup group1 = businessGroupDao.createAndPersist(marker1, "marked-grp-3", "marked-grp-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(marker1, "marked-grp-4", "marked-grp-2-desc", 0, 5, true, false, true, false, false);
markManager.setMark(group1.getResource(), marker1, null, "[BusinessGroup:" + group1.getKey() + "]");
markManager.setMark(group2.getResource(), marker2, null, "[BusinessGroup:" + group2.getKey() + "]");
dbInstance.commitAndCloseSession();
// check the search with views
// check marked
BusinessGroupQueryParams queryParamsMarker1 = new BusinessGroupQueryParams();
queryParamsMarker1.setMarked(true);
List<BusinessGroupRow> markedGroupViews = businessGroupDao.searchBusinessGroupsWithMemberships(queryParamsMarker1, marker1);
Assert.assertNotNull(markedGroupViews);
Assert.assertEquals(1, markedGroupViews.size());
Assert.assertTrue(contains(markedGroupViews, group1));
}
use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.
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));
}
use of org.olat.group.model.BusinessGroupQueryParams in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findPublicGroups.
@Test
public void findPublicGroups() {
// create a group with an access control
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-11");
BusinessGroup group = businessGroupDao.createAndPersist(null, "access-grp-1", "access-grp-1-desc", 0, 5, true, false, true, false, false);
// create and save an offer
Offer offer = acService.createOffer(group.getResource(), "TestBGWorkflow");
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);
dbInstance.commitAndCloseSession();
// retrieve the offer
// check the search with the views
BusinessGroupQueryParams queryAllParams = new BusinessGroupQueryParams();
queryAllParams.setPublicGroups(Boolean.TRUE);
List<OpenBusinessGroupRow> accessGroupViews = businessGroupDao.searchPublishedBusinessGroups(queryAllParams, identity);
Assert.assertNotNull(accessGroupViews);
Assert.assertTrue(accessGroupViews.size() >= 1);
Assert.assertTrue(contains(accessGroupViews, group));
for (OpenBusinessGroupRow accessGroup : accessGroupViews) {
OLATResource resource = resourceManager.findResourceById(accessGroup.getResourceKey());
List<Offer> offers = acService.findOfferByResource(resource, true, new Date());
Assert.assertNotNull(offers);
Assert.assertFalse(offers.isEmpty());
}
}
Aggregations