use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
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 klemens.
the class OpenBusinessGroupListController method getSearchParams.
@Override
protected BusinessGroupQueryParams getSearchParams(SearchEvent event) {
BusinessGroupQueryParams params = event.convertToBusinessGroupQueriesParams();
params.setPublicGroups(Boolean.TRUE);
return params;
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class FavoritBusinessGroupListController method getDefaultSearchParams.
@Override
protected BusinessGroupQueryParams getDefaultSearchParams() {
BusinessGroupQueryParams params = new BusinessGroupQueryParams();
params.setMarked(true);
params.setAttendee(true);
params.setOwner(true);
params.setWaiting(true);
return params;
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class FavoritBusinessGroupListController 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);
}
params.setMarked(true);
return params;
}
use of org.olat.group.model.BusinessGroupQueryParams in project openolat by klemens.
the class BusinessGroupListController method getDefaultSearchParams.
@Override
protected BusinessGroupQueryParams getDefaultSearchParams() {
BusinessGroupQueryParams params = new BusinessGroupQueryParams();
params.setAttendee(true);
params.setOwner(true);
params.setWaiting(true);
return params;
}
Aggregations