use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findBusinessGroupsByNameOrDescFuzzy.
@Test
public void findBusinessGroupsByNameOrDescFuzzy() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-7");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "fingbg-1", marker + "-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "fingbg-2", "desc-" + marker.toUpperCase(), 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "fingbg-3", "desc-" + marker + "-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(3, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(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(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 OpenOLAT.
the class BusinessGroupDAOTest method findBusinessGroupsByDescription.
@Test
public void findBusinessGroupsByDescription() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-4");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "fingbg-1", marker.toUpperCase() + "-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "fingbg-2", "desc-" + marker, 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "fingbg-3", "desc-other-one", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
// check find business group
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setDescription(marker);
List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(2, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
Assert.assertFalse(groups.contains(group3));
// check find business group
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setDescription(marker);
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
Assert.assertNotNull(groupViews);
Assert.assertEquals(2, groupViews.size());
Assert.assertTrue(contains(groupViews, group1));
Assert.assertTrue(contains(groupViews, group2));
Assert.assertFalse(contains(groupViews, group3));
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class EnrollmentManager method getBusinessGroupsWhereEnrolled.
// Helper Methods
// ////////////////
/**
* @param identity
* @param List<Long> groupKeys which are in the list
* @param List<Long> areaKeys which are in the list
* @return List<BusinessGroup> in which the identity is enrolled
*/
protected List<BusinessGroup> getBusinessGroupsWhereEnrolled(Identity identity, List<Long> groupKeys, List<Long> areaKeys, RepositoryEntry courseResource) {
List<BusinessGroup> groups = new ArrayList<BusinessGroup>();
// search in the enrollable bg keys for the groups where identity is attendee
if (groupKeys != null && !groupKeys.isEmpty()) {
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setAttendee(true);
params.setIdentity(identity);
params.setGroupKeys(groupKeys);
groups.addAll(businessGroupService.findBusinessGroups(params, courseResource, 0, 0));
}
// search in the enrollable area keys for the groups where identity is attendee
if (areaKeys != null && !areaKeys.isEmpty()) {
groups.addAll(areaManager.findBusinessGroupsOfAreaAttendedBy(identity, areaKeys, courseResource.getOlatResource()));
}
return groups;
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class GTANotifications method createIndividualSubscriptionInfo.
private void createIndividualSubscriptionInfo(Identity subscriberIdentity) {
RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
List<String> roles = repositoryService.getRoles(subscriberIdentity, entry);
boolean owner = roles.contains(GroupRoles.owner.name());
boolean coach = roles.contains(GroupRoles.coach.name());
if (owner || coach) {
Set<Identity> duplicateKiller = new HashSet<>();
List<Identity> assessableIdentities = new ArrayList<>();
List<Identity> participants;
List<BusinessGroup> coachedGroups = null;
if (owner) {
participants = businessGroupService.getMembersOf(entry, false, true);
} else {
SearchBusinessGroupParams params = new SearchBusinessGroupParams(subscriberIdentity, true, false);
coachedGroups = businessGroupService.findBusinessGroups(params, entry, 0, -1);
participants = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
}
for (Identity participant : participants) {
if (!duplicateKiller.contains(participant)) {
assessableIdentities.add(participant);
duplicateKiller.add(participant);
}
}
boolean repoTutor = owner || (coachedGroups.isEmpty() && repositoryService.hasRole(subscriberIdentity, entry, GroupRoles.coach.name()));
if (repoTutor) {
List<Identity> courseParticipants = repositoryService.getMembers(entry, GroupRoles.participant.name());
for (Identity participant : courseParticipants) {
if (!duplicateKiller.contains(participant)) {
assessableIdentities.add(participant);
duplicateKiller.add(participant);
}
}
}
for (Identity assessedIdentity : assessableIdentities) {
createIndividualSubscriptionInfo(assessedIdentity, true);
}
createCoachSolutionItems();
} else {
Task task = gtaManager.getTask(subscriberIdentity, taskList);
if (task != null) {
header = translator.translate("notifications.individual.header.task", new String[] { getTaskName(task), displayName });
}
}
if (roles.contains(GroupRoles.participant.name())) {
createIndividualSubscriptionInfo(subscriberIdentity, false);
Task task = gtaManager.getTask(subscriberIdentity, taskList);
if (isSolutionVisible(subscriberIdentity, null, task)) {
createParticipantSolutionItems(task, subscriberIdentity, null);
}
if (task != null && task.getTaskStatus() == TaskProcess.graded) {
createAssessmentItem(task, subscriberIdentity, false);
}
}
}
Aggregations