use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
the class LearningGroupWebService method getGroupList.
/**
* Return the list of all groups if you have group manager permission, or all
* learning group that you particip with or owne.
* @response.representation.200.qname {http://www.example.com}groupVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc This is the list of all groups in OLAT system
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVOes}
* @param externalId Search with an external ID
* @param managed (true / false) Search only managed / not managed groups
* @param request The HTTP Request
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getGroupList(@QueryParam("externalId") String externalId, @QueryParam("managed") Boolean managed, @Context HttpServletRequest request) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
List<BusinessGroup> groups;
SearchBusinessGroupParams params;
if (isGroupManager(request)) {
params = new SearchBusinessGroupParams();
} else {
Identity identity = RestSecurityHelper.getIdentity(request);
params = new SearchBusinessGroupParams(identity, true, true);
}
if (StringHelper.containsNonWhitespace(externalId)) {
params.setExternalId(externalId);
}
params.setManaged(managed);
groups = bgs.findBusinessGroups(params, null, 0, -1);
int count = 0;
GroupVO[] groupVOs = new GroupVO[groups.size()];
for (BusinessGroup bg : groups) {
groupVOs[count++] = ObjectFactory.get(bg);
}
return Response.ok(groupVOs).build();
}
use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
the class MyGroupWebService method getUserGroupInfosList.
/**
* Return all groups with information of a user. Paging is mandatory!
* @response.representation.200.qname {http://www.example.com}groupInfoVO
* @response.representation.200.mediaType application/xml;pagingspec=1.0, application/json;pagingspec=1.0
* @response.representation.200.doc The groups of the user
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPINFOVOes}
* @response.representation.406.doc The request hasn't paging information
* @param start The first result
* @param limit The maximum results
* @param externalId Search with an external ID
* @param managed (true / false) Search only managed / not managed groups
* @param httpRequest The HTTP request
* @param request The REST request
* @return The list of groups with additional informations
*/
@GET
@Path("infos")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getUserGroupInfosList(@QueryParam("start") @DefaultValue("0") Integer start, @QueryParam("limit") @DefaultValue("25") Integer limit, @QueryParam("externalId") String externalId, @QueryParam("managed") Boolean managed, @Context HttpServletRequest httpRequest, @Context Request request) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, true, true);
if (StringHelper.containsNonWhitespace(externalId)) {
params.setExternalId(externalId);
}
params.setManaged(managed);
List<BusinessGroup> groups;
if (MediaTypeVariants.isPaged(httpRequest, request)) {
int totalCount = bgs.countBusinessGroups(params, null);
groups = bgs.findBusinessGroups(params, null, start, limit);
int count = 0;
GroupInfoVO[] groupVOs = new GroupInfoVO[groups.size()];
for (BusinessGroup group : groups) {
groupVOs[count++] = ObjectFactory.getInformation(retrievedUser, group);
}
GroupInfoVOes voes = new GroupInfoVOes();
voes.setGroups(groupVOs);
voes.setTotalCount(totalCount);
return Response.ok(voes).build();
} else {
return Response.serverError().status(Status.NOT_ACCEPTABLE).build();
}
}
use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
the class UserCalendarWebService method getCalendars.
private void getCalendars(CalendarVisitor calVisitor, UserRequest ureq) {
Roles roles = ureq.getUserSession().getRoles();
Identity retrievedUser = ureq.getIdentity();
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (calendarModule.isEnabled()) {
if (calendarModule.isEnablePersonalCalendar()) {
KalendarRenderWrapper personalWrapper = getPersonalCalendar(ureq.getIdentity());
calVisitor.visit(personalWrapper);
}
if (calendarModule.isEnableCourseToolCalendar() || calendarModule.isEnableCourseElementCalendar()) {
RepositoryManager rm = RepositoryManager.getInstance();
ACService acManager = CoreSpringFactory.getImpl(ACService.class);
SearchRepositoryEntryParameters repoParams = new SearchRepositoryEntryParameters(retrievedUser, roles, "CourseModule");
repoParams.setOnlyExplicitMember(true);
repoParams.setIdentity(retrievedUser);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(retrievedUser);
ienv.setRoles(roles);
List<RepositoryEntry> entries = rm.genericANDQueryWithRolesRestriction(repoParams, 0, -1, true);
for (RepositoryEntry entry : entries) {
AccessResult result = acManager.isAccessible(entry, retrievedUser, false);
if (result.isAccessible()) {
try {
final ICourse course = CourseFactory.loadCourse(entry);
CourseConfig config = course.getCourseEnvironment().getCourseConfig();
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
if (config.isCalendarEnabled()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
} else {
CalCourseNodeVisitor visitor = new CalCourseNodeVisitor();
new CourseTreeVisitor(course, ienv).visit(visitor, new VisibleTreeFilter());
if (visitor.isFound()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
}
}
} catch (Exception e) {
log.error("", e);
}
}
}
}
if (calendarModule.isEnableGroupCalendar()) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
// start found forums in groups
BusinessGroupService bgm = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, true, true);
params.addTools(CollaborationTools.TOOL_CALENDAR);
List<BusinessGroup> groups = bgm.findBusinessGroups(params, null, 0, -1);
for (BusinessGroup group : groups) {
KalendarRenderWrapper wrapper = collaborationManager.getCalendar(group, ureq, false);
calVisitor.visit(wrapper);
}
}
}
}
use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
the class PersistingCourseGroupManager method getParticipatingBusinessGroups.
/**
* @see org.olat.course.groupsandrights.CourseGroupManager#getParticipatingBusinessGroups(org.olat.core.id.Identity)
*/
@Override
public List<BusinessGroup> getParticipatingBusinessGroups(Identity identity) {
if (identity == null)
return new ArrayList<>();
SearchBusinessGroupParams params = new SearchBusinessGroupParams(identity, false, true);
List<BusinessGroup> allGroups = businessGroupService.findBusinessGroups(params, getCourseEntry(), 0, -1);
return allGroups;
}
use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
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;
}
Aggregations