Search in sources :

Example 61 with BusinessGroupService

use of org.olat.group.BusinessGroupService in project OpenOLAT by OpenOLAT.

the class ENWebService method getGroups.

/**
 * Retrieves the groups where the enrollment happens
 * @response.representation.200.qname {http://www.example.com}groupVO
 * @response.representation.200.mediaType application/xml, application/json
 * @response.representation.200.doc The groups
 * @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVO}
 * @response.representation.401.doc The roles of the authenticated user are not sufficient
 * @response.representation.404.doc The course or course node not found
 * @param nodeId The node's id
 * @param httpRequest The HTTP request
 * @return An array of groups
 */
@GET
@Path("{nodeId}/groups")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getGroups(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest httpRequest) {
    if (!isAuthor(httpRequest)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    ICourse course = CoursesWebService.loadCourse(courseId);
    if (course == null) {
        return Response.serverError().status(Status.NOT_FOUND).build();
    } else if (!isAuthorEditor(course, httpRequest)) {
        return Response.serverError().status(Status.UNAUTHORIZED).build();
    }
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    CourseNode node = getParentNode(course, nodeId);
    ModuleConfiguration config = node.getModuleConfiguration();
    String groupNames = (String) config.get(ENCourseNode.CONFIG_GROUPNAME);
    @SuppressWarnings("unchecked") List<Long> groupKeys = (List<Long>) config.get(ENCourseNode.CONFIG_GROUP_IDS);
    if (groupKeys == null && StringHelper.containsNonWhitespace(groupNames)) {
        groupKeys = bgs.toGroupKeys(groupNames, course.getCourseEnvironment().getCourseGroupManager().getCourseEntry());
    }
    if (groupKeys == null || groupKeys.isEmpty()) {
        return Response.ok(new GroupVO[0]).build();
    }
    List<GroupVO> voes = new ArrayList<GroupVO>();
    List<BusinessGroup> groups = bgs.loadBusinessGroups(groupKeys);
    for (BusinessGroup group : groups) {
        voes.add(get(group));
    }
    GroupVO[] voArr = new GroupVO[voes.size()];
    voes.toArray(voArr);
    return Response.ok(voArr).build();
}
Also used : ModuleConfiguration(org.olat.modules.ModuleConfiguration) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) GroupVO(org.olat.restapi.support.vo.GroupVO) BusinessGroupService(org.olat.group.BusinessGroupService) ArrayList(java.util.ArrayList) List(java.util.List) ENCourseNode(org.olat.course.nodes.ENCourseNode) CourseNode(org.olat.course.nodes.CourseNode) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 62 with BusinessGroupService

use of org.olat.group.BusinessGroupService in project OpenOLAT by OpenOLAT.

the class ProjectGroupManagerImpl method changeProjectGroupName.

/**
 * Change group-name and description. Check if new group-name does not already exist in the course-group-context.
 * If the goup-name already exist, it will be automatically try another one with suffix e.g. ' _2'
 * @see org.olat.course.nodes.projectbroker.service.ProjectGroupManager#changeProjectGroupName(org.olat.group.BusinessGroup, java.lang.String, java.lang.String)
 */
@Override
public BusinessGroup changeProjectGroupName(Identity ureqIdentity, BusinessGroup projectGroup, String groupName, String groupDescription, OLATResource courseResource) {
    BusinessGroupService bgs = businessGroupService;
    BusinessGroup reloadedBusinessGroup = bgs.loadBusinessGroup(projectGroup);
    return bgs.updateBusinessGroup(ureqIdentity, reloadedBusinessGroup, groupName, groupDescription, reloadedBusinessGroup.getExternalId(), reloadedBusinessGroup.getManagedFlagsString(), reloadedBusinessGroup.getMinParticipants(), reloadedBusinessGroup.getMaxParticipants());
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup)

Example 63 with BusinessGroupService

use of org.olat.group.BusinessGroupService in project OpenOLAT by OpenOLAT.

the class ProjectGroupManagerImpl method updateAccountManagerGroupName.

@Override
public BusinessGroup updateAccountManagerGroupName(Identity ureqIdentity, String groupName, String groupDescription, BusinessGroup accountManagerGroup) {
    // group could have been deleted, see FXOLAT-295
    if (accountManagerGroup != null) {
        BusinessGroupService bgs = businessGroupService;
        BusinessGroup reloadedBusinessGroup = bgs.loadBusinessGroup(accountManagerGroup);
        return bgs.updateBusinessGroup(ureqIdentity, reloadedBusinessGroup, groupName, groupDescription, reloadedBusinessGroup.getExternalId(), reloadedBusinessGroup.getManagedFlagsString(), reloadedBusinessGroup.getMinParticipants(), reloadedBusinessGroup.getMaxParticipants());
    }
    return null;
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup)

Example 64 with BusinessGroupService

use of org.olat.group.BusinessGroupService in project OpenOLAT by OpenOLAT.

the class ProjectGroupManagerImpl method setProjectGroupMaxMembers.

@Override
public BusinessGroup setProjectGroupMaxMembers(Identity ureqIdentity, BusinessGroup projectGroup, int maxMembers) {
    BusinessGroupService bgs = businessGroupService;
    BusinessGroup reloadedBusinessGroup = bgs.loadBusinessGroup(projectGroup);
    log.debug("ProjectGroup.name=" + reloadedBusinessGroup.getName() + " setMaxParticipants=" + maxMembers);
    return bgs.updateBusinessGroup(ureqIdentity, reloadedBusinessGroup, reloadedBusinessGroup.getName(), reloadedBusinessGroup.getDescription(), reloadedBusinessGroup.getExternalId(), reloadedBusinessGroup.getManagedFlagsString(), reloadedBusinessGroup.getMinParticipants(), maxMembers);
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) BusinessGroup(org.olat.group.BusinessGroup)

Example 65 with BusinessGroupService

use of org.olat.group.BusinessGroupService in project OpenOLAT by OpenOLAT.

the class MembersPeekViewController method readFormData.

protected void readFormData(ModuleConfiguration config) {
    CourseGroupManager cgm = courseEnv.getCourseGroupManager();
    RepositoryEntry courseRepositoryEntry = courseEnv.getCourseGroupManager().getCourseEntry();
    List<Identity> owners = MembersHelpers.getOwners(repositoryService, courseRepositoryEntry);
    List<Identity> coaches = new ArrayList<>();
    MembersHelpers.addCoaches(config, cgm, businessGroupService, coaches);
    List<Identity> participants = new ArrayList<>();
    MembersHelpers.addParticipants(config, cgm, businessGroupService, participants);
    Set<Long> duplicateCatcher = new HashSet<Long>();
    List<Identity> filteredOwners = owners.stream().filter(ident -> {
        if (duplicateCatcher.contains(ident.getKey())) {
            return false;
        }
        duplicateCatcher.add(ident.getKey());
        return true;
    }).collect(Collectors.toList());
    List<Identity> filteredCoaches = coaches.stream().filter(ident -> {
        if (duplicateCatcher.contains(ident.getKey())) {
            return false;
        }
        duplicateCatcher.add(ident.getKey());
        return true;
    }).collect(Collectors.toList());
    List<Identity> filteredParticipants = participants.stream().filter(ident -> {
        if (duplicateCatcher.contains(ident.getKey())) {
            return false;
        }
        duplicateCatcher.add(ident.getKey());
        return true;
    }).collect(Collectors.toList());
    entries.add(new Row(translate("members.owners"), Integer.toString(filteredOwners.size())));
    entries.add(new Row(translate("members.coaches"), Integer.toString(filteredCoaches.size())));
    entries.add(new Row(translate("members.participants"), Integer.toString(filteredParticipants.size())));
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) ColumnDescriptor(org.olat.core.gui.components.table.ColumnDescriptor) RepositoryService(org.olat.repository.RepositoryService) CourseEnvironment(org.olat.course.run.environment.CourseEnvironment) UserCourseEnvironment(org.olat.course.run.userview.UserCourseEnvironment) DefaultColumnDescriptor(org.olat.core.gui.components.table.DefaultColumnDescriptor) WindowControl(org.olat.core.gui.control.WindowControl) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) RepositoryEntry(org.olat.repository.RepositoryEntry) Component(org.olat.core.gui.components.Component) Collectors(java.util.stream.Collectors) ModuleConfiguration(org.olat.modules.ModuleConfiguration) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Event(org.olat.core.gui.control.Event) BasicController(org.olat.core.gui.control.controller.BasicController) CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) DefaultTableDataModel(org.olat.core.gui.components.table.DefaultTableDataModel) List(java.util.List) Identity(org.olat.core.id.Identity) UserRequest(org.olat.core.gui.UserRequest) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) TableController(org.olat.core.gui.components.table.TableController) CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) Identity(org.olat.core.id.Identity) HashSet(java.util.HashSet)

Aggregations

BusinessGroupService (org.olat.group.BusinessGroupService)102 BusinessGroup (org.olat.group.BusinessGroup)84 Identity (org.olat.core.id.Identity)58 Path (javax.ws.rs.Path)38 Produces (javax.ws.rs.Produces)30 GET (javax.ws.rs.GET)24 CollaborationTools (org.olat.collaboration.CollaborationTools)18 SearchBusinessGroupParams (org.olat.group.model.SearchBusinessGroupParams)18 ArrayList (java.util.ArrayList)16 GroupVO (org.olat.restapi.support.vo.GroupVO)16 RepositoryEntry (org.olat.repository.RepositoryEntry)14 List (java.util.List)12 UserRequest (org.olat.core.gui.UserRequest)12 ICourse (org.olat.course.ICourse)10 HashSet (java.util.HashSet)8 PUT (javax.ws.rs.PUT)8 IdentityEnvironment (org.olat.core.id.IdentityEnvironment)8 Roles (org.olat.core.id.Roles)8 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)6 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)6