use of org.olat.group.model.BusinessGroupRow in project OpenOLAT by OpenOLAT.
the class FavoritBusinessGroupListController method searchTableItems.
@Override
protected List<BGTableItem> searchTableItems(BusinessGroupQueryParams params) {
List<BusinessGroupRow> rows = businessGroupService.findBusinessGroupsWithMemberships(params, getIdentity());
List<BGTableItem> items = new ArrayList<>(rows.size());
for (BusinessGroupRow row : rows) {
BusinessGroupMembership membership = row.getMember();
Boolean allowLeave = membership != null;
Boolean allowDelete = isAdmin() ? Boolean.TRUE : (membership == null ? null : new Boolean(membership.isOwner()));
FormLink markLink = uifactory.addFormLink("mark_" + row.getKey(), "mark", "", null, null, Link.NONTRANSLATED);
markLink.setIconLeftCSS(row.isMarked() ? Mark.MARK_CSS_LARGE : Mark.MARK_ADD_CSS_LARGE);
BGTableItem item = new BGTableItem(row, markLink, allowLeave, allowDelete);
items.add(item);
}
return items;
}
use of org.olat.group.model.BusinessGroupRow 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.BusinessGroupRow 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.BusinessGroupRow in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findBusinessGroups.
@Test
public void findBusinessGroups() {
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "gduo", "gduo-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "gdvo", "gdvo-desc", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
Assert.assertNotNull(groups);
Assert.assertTrue(groups.size() >= 2);
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
Assert.assertNotNull(groupViews);
Assert.assertTrue(groupViews.size() >= 2);
Assert.assertTrue(contains(groupViews, group1));
Assert.assertTrue(contains(groupViews, group2));
List<StatisticsBusinessGroupRow> groupToSelect = businessGroupDao.searchBusinessGroupsForSelection(searchParams, identity);
Assert.assertNotNull(groupToSelect);
Assert.assertTrue(groupToSelect.size() >= 2);
List<OpenBusinessGroupRow> openGroups = businessGroupDao.searchPublishedBusinessGroups(searchParams, identity);
Assert.assertNotNull(openGroups);
}
use of org.olat.group.model.BusinessGroupRow in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findBusinessGroupsByCourseTitle.
@Test
public void findBusinessGroupsByCourseTitle() {
// 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.setCourseTitle(re.getDisplayname());
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(params, id);
Assert.assertNotNull(groupViews);
Assert.assertEquals(1, groupViews.size());
Assert.assertEquals(group.getKey(), groupViews.get(0).getKey());
}
Aggregations