Search in sources :

Example 51 with SearchBusinessGroupParams

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));
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams) BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) StatisticsBusinessGroupRow(org.olat.group.model.StatisticsBusinessGroupRow) BusinessGroupRow(org.olat.group.model.BusinessGroupRow) OpenBusinessGroupRow(org.olat.group.model.OpenBusinessGroupRow) Test(org.junit.Test)

Example 52 with SearchBusinessGroupParams

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));
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams) BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) StatisticsBusinessGroupRow(org.olat.group.model.StatisticsBusinessGroupRow) BusinessGroupRow(org.olat.group.model.BusinessGroupRow) OpenBusinessGroupRow(org.olat.group.model.OpenBusinessGroupRow) Test(org.junit.Test)

Example 53 with SearchBusinessGroupParams

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));
}
Also used : BusinessGroupQueryParams(org.olat.group.model.BusinessGroupQueryParams) BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) StatisticsBusinessGroupRow(org.olat.group.model.StatisticsBusinessGroupRow) BusinessGroupRow(org.olat.group.model.BusinessGroupRow) OpenBusinessGroupRow(org.olat.group.model.OpenBusinessGroupRow) Test(org.junit.Test)

Example 54 with SearchBusinessGroupParams

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;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams)

Example 55 with SearchBusinessGroupParams

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);
        }
    }
}
Also used : Task(org.olat.course.nodes.gta.Task) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Aggregations

SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)92 BusinessGroup (org.olat.group.BusinessGroup)84 Identity (org.olat.core.id.Identity)36 Test (org.junit.Test)34 ArrayList (java.util.ArrayList)26 BusinessGroupService (org.olat.group.BusinessGroupService)18 BusinessGroupQueryParams (org.olat.group.model.BusinessGroupQueryParams)16 BusinessGroupRow (org.olat.group.model.BusinessGroupRow)16 OpenBusinessGroupRow (org.olat.group.model.OpenBusinessGroupRow)16 StatisticsBusinessGroupRow (org.olat.group.model.StatisticsBusinessGroupRow)16 RepositoryEntry (org.olat.repository.RepositoryEntry)16 HashSet (java.util.HashSet)12 GET (javax.ws.rs.GET)10 Produces (javax.ws.rs.Produces)10 Roles (org.olat.core.id.Roles)10 HashMap (java.util.HashMap)8 Map (java.util.Map)8 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)6 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)6 ICourse (org.olat.course.ICourse)6