use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
the class OLATUpgrade_11_0_0 method getAllAssessableIdentities.
/**
* Return the same amount of user as in the assessment tool.
* @param entry
* @return
*/
private List<Identity> getAllAssessableIdentities(ICourse course, RepositoryEntry entry) {
Set<Identity> duplicateKiller = new HashSet<>();
List<Identity> assessableIdentities = new ArrayList<>();
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
List<BusinessGroup> coachedGroups = businessGroupService.findBusinessGroups(params, entry, 0, -1);
List<Identity> participants = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
for (Identity participant : participants) {
if (!duplicateKiller.contains(participant)) {
assessableIdentities.add(participant);
duplicateKiller.add(participant);
}
}
List<Identity> courseParticipants = repositoryService.getMembers(entry, GroupRoles.participant.name());
for (Identity participant : courseParticipants) {
if (!duplicateKiller.contains(participant)) {
assessableIdentities.add(participant);
duplicateKiller.add(participant);
}
}
List<Identity> assessedUsers = getAllIdentitiesWithCourseAssessmentData(course.getResourceableId());
for (Identity assessedUser : assessedUsers) {
if (!duplicateKiller.contains(assessedUser)) {
assessableIdentities.add(assessedUser);
duplicateKiller.add(assessedUser);
}
}
return assessableIdentities;
}
use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
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.SearchBusinessGroupParams in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByNameFuzzy.
@Test
public void findBusinessGroupsByNameFuzzy() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-3");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, marker.toUpperCase(), "fingbg-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, marker + "xxx", "fingbg-2-desc", 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "yyy" + marker.toUpperCase(), "fingbg-3-desc", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setName("*" + marker + "*");
List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(3, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
Assert.assertTrue(groups.contains(group3));
// check the same with the views
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setName("*" + marker + "*");
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
Assert.assertNotNull(groupViews);
Assert.assertEquals(3, groupViews.size());
Assert.assertTrue(contains(groupViews, group1));
Assert.assertTrue(contains(groupViews, group2));
Assert.assertTrue(contains(groupViews, group3));
}
use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
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));
}
use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
the class BusinessGroupImportExportTest method importLearningGroupsWithResource.
@Test
public void importLearningGroupsWithResource() throws URISyntaxException {
RepositoryEntry resource = JunitTestHelper.createAndPersistRepositoryEntry();
URL input = BusinessGroupImportExportTest.class.getResource("learninggroupexport_2.xml");
File importXml = new File(input.toURI());
businessGroupService.importGroups(resource, importXml);
dbInstance.commitAndCloseSession();
// check if all three groups are imported
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(null, resource, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(3, groups.size());
// get first group (members true, true, false) (no collaboration tools)
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setExactName("Export group 1");
List<BusinessGroup> group1List = businessGroupService.findBusinessGroups(params, resource, 0, -1);
Assert.assertNotNull(group1List);
Assert.assertEquals(1, group1List.size());
// check settings of the first group
BusinessGroup group1 = group1List.get(0);
Assert.assertEquals("Export group 1", group1.getName());
Assert.assertEquals("<p>Export group 1</p>", group1.getDescription());
Assert.assertFalse(group1.getAutoCloseRanksEnabled().booleanValue());
Assert.assertFalse(group1.getWaitingListEnabled().booleanValue());
// check display members settings
Assert.assertTrue(group1.isOwnersVisibleIntern());
Assert.assertTrue(group1.isParticipantsVisibleIntern());
Assert.assertFalse(group1.isWaitingListVisibleIntern());
// check collaboration tools
CollaborationTools toolGroup1 = CollaborationToolsFactory.getInstance().getCollaborationToolsIfExists(group1);
Assert.assertNotNull(toolGroup1);
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_CALENDAR));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_CHAT));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_CONTACT));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_FOLDER));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_FORUM));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_NEWS));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_PORTFOLIO));
Assert.assertFalse(toolGroup1.isToolEnabled(CollaborationTools.TOOL_WIKI));
// get third group (members true, true, true) (all collaboration tools)
params.setExactName("Export group 3");
List<BusinessGroup> group3List = businessGroupService.findBusinessGroups(params, resource, 0, -1);
Assert.assertNotNull(group3List);
Assert.assertEquals(1, group3List.size());
// check settings of the first group
BusinessGroup group3 = group3List.get(0);
Assert.assertEquals("Export group 3", group3.getName());
Assert.assertEquals("<p>Export group 2</p>", group3.getDescription());
Assert.assertFalse(group3.getAutoCloseRanksEnabled().booleanValue());
Assert.assertTrue(group3.getWaitingListEnabled().booleanValue());
Assert.assertEquals(new Integer(25), group3.getMaxParticipants());
// check display members settings
Assert.assertTrue(group3.isOwnersVisibleIntern());
Assert.assertTrue(group3.isParticipantsVisibleIntern());
Assert.assertTrue(group3.isWaitingListVisibleIntern());
// check collaboration tools
CollaborationTools toolGroup3 = CollaborationToolsFactory.getInstance().getCollaborationToolsIfExists(group3);
Assert.assertNotNull(toolGroup3);
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_CALENDAR));
// Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_CHAT)); chat is not enabled during unit tests
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_CONTACT));
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_FOLDER));
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_FORUM));
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_NEWS));
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_PORTFOLIO));
Assert.assertTrue(toolGroup3.isToolEnabled(CollaborationTools.TOOL_WIKI));
Assert.assertEquals("<p>Hello Mitglied</p>", toolGroup3.lookupNews());
}
Aggregations