Search in sources :

Example 26 with BusinessGroupQueryParams

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));
}
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)

Example 27 with BusinessGroupQueryParams

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;
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams)

Example 28 with BusinessGroupQueryParams

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;
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams)

Example 29 with BusinessGroupQueryParams

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;
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams)

Example 30 with BusinessGroupQueryParams

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;
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams)

Aggregations

BusinessGroupQueryParams (org.olat.group.model.BusinessGroupQueryParams)82 Test (org.junit.Test)38 Identity (org.olat.core.id.Identity)38 BusinessGroup (org.olat.group.BusinessGroup)38 StatisticsBusinessGroupRow (org.olat.group.model.StatisticsBusinessGroupRow)38 OpenBusinessGroupRow (org.olat.group.model.OpenBusinessGroupRow)36 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)34 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)16 RepositoryEntry (org.olat.repository.RepositoryEntry)8 Offer (org.olat.resource.accesscontrol.Offer)4 OfferAccess (org.olat.resource.accesscontrol.OfferAccess)4 AccessMethod (org.olat.resource.accesscontrol.model.AccessMethod)4 TokenAccessMethod (org.olat.resource.accesscontrol.model.TokenAccessMethod)4 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 HashSet (java.util.HashSet)2 BGPermission (org.olat.course.member.PermissionHelper.BGPermission)2 BusinessGroupMembership (org.olat.group.BusinessGroupMembership)2 BusinessGroupRowComparator (org.olat.group.model.comparator.BusinessGroupRowComparator)2