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