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();
}
}
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;
}
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;
}
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);
}
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;
}
Aggregations