Search in sources :

Example 61 with SearchBusinessGroupParams

use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.

the class GroupSearchController method doSearchGroups.

/**
 * Perform a search for the given search value in the search result providers
 * and clear any GUI errors that might be on the page
 *
 * @param searchValue
 * @param ureq
 */
private void doSearchGroups(String searchValue) {
    if (StringHelper.containsNonWhitespace(searchValue)) {
        SearchBusinessGroupParams param1s = new SearchBusinessGroupParams();
        param1s.setNameOrDesc(searchValue);
        Set<BusinessGroup> dedupGroups = new HashSet<>();
        List<BusinessGroup> group1s = businessGroupService.findBusinessGroups(param1s, null, 0, -1);
        filterGroups(group1s, dedupGroups);
        SearchBusinessGroupParams param2s = new SearchBusinessGroupParams();
        param2s.setCourseTitle(searchValue);
        List<BusinessGroup> group2s = businessGroupService.findBusinessGroups(param2s, null, 0, -1);
        filterGroups(group2s, dedupGroups);
        List<BusinessGroup> groups = new ArrayList<BusinessGroup>(group1s.size() + group2s.size());
        groups.addAll(group1s);
        groups.addAll(group2s);
        List<Long> groupKeysWithRelations = PersistenceHelper.toKeys(groups);
        List<BGRepositoryEntryRelation> resources = businessGroupService.findRelationToRepositoryEntries(groupKeysWithRelations, 0, -1);
        List<GroupWrapper> groupWrappers = new ArrayList<GroupWrapper>();
        for (BusinessGroup group : groups) {
            StringBuilder sb = new StringBuilder();
            for (BGRepositoryEntryRelation resource : resources) {
                if (resource.getGroupKey().equals(group.getKey())) {
                    if (sb.length() > 0)
                        sb.append(", ");
                    sb.append(resource.getRepositoryEntryDisplayName());
                }
            }
            GroupWrapper wrapper = new GroupWrapper(group, sb.toString());
            wrapper.setTutor(createSelection("tutor_" + group.getKey()));
            wrapper.setParticipant(createSelection("participant_" + group.getKey()));
            groupWrappers.add(wrapper);
        }
        table.reset();
        tableDataModel.setObjects(groupWrappers);
        errorComp.clearError();
    }
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) BGRepositoryEntryRelation(org.olat.group.model.BGRepositoryEntryRelation) HashSet(java.util.HashSet)

Example 62 with SearchBusinessGroupParams

use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.

the class PersistingCourseGroupManager method getOwnedBusinessGroups.

/**
 * @see org.olat.course.groupsandrights.CourseGroupManager#getOwnedBusinessGroups(org.olat.core.id.Identity)
 */
@Override
public List<BusinessGroup> getOwnedBusinessGroups(Identity identity) {
    if (identity == null)
        return new ArrayList<>();
    SearchBusinessGroupParams params = new SearchBusinessGroupParams(identity, true, false);
    List<BusinessGroup> allGroups = businessGroupService.findBusinessGroups(params, getCourseEntry(), 0, -1);
    return allGroups;
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams)

Example 63 with SearchBusinessGroupParams

use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.

the class BusinessGroupServiceImpl method dedupSingleRepositoryentry.

private int dedupSingleRepositoryentry(Identity ureqIdentity, RepositoryEntry entry, boolean coaches, boolean participants, boolean dryRun) {
    int count = 0;
    // load only if needed
    List<BusinessGroup> groups = null;
    if (coaches) {
        List<Identity> repoTutorList = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.defaultGroup, GroupRoles.coach.name());
        if (!repoTutorList.isEmpty()) {
            SearchBusinessGroupParams params = new SearchBusinessGroupParams();
            groups = businessGroupDAO.findBusinessGroups(params, entry, 0, -1);
            List<Identity> ownerList = getMembers(groups, GroupRoles.participant.name());
            repoTutorList.retainAll(ownerList);
            if (!dryRun) {
                repositoryManager.removeTutors(ureqIdentity, repoTutorList, entry, new MailPackage(false));
            }
            count += repoTutorList.size();
        }
    }
    if (participants) {
        List<Identity> repoParticipantList = repositoryEntryRelationDao.getMembers(entry, RepositoryEntryRelationType.defaultGroup, GroupRoles.participant.name());
        if (!repoParticipantList.isEmpty()) {
            if (groups == null) {
                SearchBusinessGroupParams params = new SearchBusinessGroupParams();
                groups = businessGroupDAO.findBusinessGroups(params, entry, 0, -1);
            }
            List<Identity> participantList = getMembers(groups, GroupRoles.participant.name());
            repoParticipantList.retainAll(participantList);
            if (!dryRun) {
                repositoryManager.removeParticipants(ureqIdentity, repoParticipantList, entry, null, false);
            }
            count += repoParticipantList.size();
        }
    }
    return count;
}
Also used : MailPackage(org.olat.core.util.mail.MailPackage) BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams)

Example 64 with SearchBusinessGroupParams

use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.

the class BusinessGroupServiceImpl method leave.

@Override
public void leave(Identity identity, RepositoryEntry entry, LeavingStatusList status, MailPackage mailing) {
    SearchBusinessGroupParams params = new SearchBusinessGroupParams();
    params.setIdentity(identity);
    params.setAttendee(true);
    List<BusinessGroup> groups = businessGroupDAO.findBusinessGroups(params, entry, 0, -1);
    List<BusinessGroupModifiedEvent.Deferred> events = new ArrayList<BusinessGroupModifiedEvent.Deferred>();
    for (BusinessGroup group : groups) {
        if (BusinessGroupManagedFlag.isManaged(group, BusinessGroupManagedFlag.membersmanagement)) {
            status.setWarningManagedGroup(true);
        } else if (businessGroupRelationDAO.countResources(group) > 1) {
            status.setWarningGroupWithMultipleResources(true);
        } else {
            removeParticipant(identity, identity, group, mailing, null);
        }
    }
    dbInstance.commit();
    BusinessGroupModifiedEvent.fireDeferredEvents(events);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) BusinessGroupModifiedEvent(org.olat.group.ui.edit.BusinessGroupModifiedEvent)

Example 65 with SearchBusinessGroupParams

use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.

the class GroupfoldersWebDAVMergeSource method loadMergedContainers.

@Override
protected List<VFSContainer> loadMergedContainers() {
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    Set<Long> addedGroupKeys = new HashSet<Long>();
    Set<String> addedGroupNames = new HashSet<String>();
    List<VFSContainer> containers = new ArrayList<>();
    SearchBusinessGroupParams params = new SearchBusinessGroupParams(getIdentity(), true, false);
    params.addTools(CollaborationTools.TOOL_FOLDER);
    List<BusinessGroup> tutorGroups = bgs.findBusinessGroups(params, null, 0, -1);
    for (BusinessGroup group : tutorGroups) {
        addContainer(group, addedGroupKeys, addedGroupNames, containers, true);
    }
    SearchBusinessGroupParams paramsParticipants = new SearchBusinessGroupParams(getIdentity(), false, true);
    paramsParticipants.addTools(CollaborationTools.TOOL_FOLDER);
    List<BusinessGroup> participantsGroups = bgs.findBusinessGroups(paramsParticipants, null, 0, -1);
    for (BusinessGroup group : participantsGroups) {
        addContainer(group, addedGroupKeys, addedGroupNames, containers, false);
    }
    return containers;
}
Also used : VFSContainer(org.olat.core.util.vfs.VFSContainer) ArrayList(java.util.ArrayList) SearchBusinessGroupParams(org.olat.group.model.SearchBusinessGroupParams) 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