use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
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 klemens.
the class SystemRegistrationManager method getRegistrationPropertiesMessage.
public Map<String, String> getRegistrationPropertiesMessage() {
Map<String, String> msgProperties = new HashMap<String, String>();
boolean website = registrationModule.isPublishWebsite();
boolean notify = registrationModule.isNotifyReleases();
// OLAT version
msgProperties.put("appName", Settings.getApplicationName());
msgProperties.put("version", Settings.getFullVersionInfo());
// Location
msgProperties.put("location", registrationModule.getLocation());
msgProperties.put("locationCSV", registrationModule.getLocationCoordinates());
// System config
msgProperties.put("instantMessagingEnabled", String.valueOf(CoreSpringFactory.getImpl(InstantMessagingModule.class).isEnabled()));
msgProperties.put("enabledLanguages", CoreSpringFactory.getImpl(I18nModule.class).getEnabledLanguageKeys().toString());
msgProperties.put("clusterEnabled", clusterMode);
msgProperties.put("debuggingEnabled", String.valueOf(Settings.isDebuging()));
// Course counts
int allCourses = repositoryManager.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_OWNERS);
int publishedCourses = repositoryManager.countByTypeLimitAccess(CourseModule.ORES_TYPE_COURSE, RepositoryEntry.ACC_USERS);
msgProperties.put("courses", String.valueOf(allCourses));
msgProperties.put("coursesPublished", String.valueOf(publishedCourses));
// User counts
SecurityGroup olatuserGroup = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
int users = securityManager.countIdentitiesOfSecurityGroup(olatuserGroup);
long disabled = securityManager.countIdentitiesByPowerSearch(null, null, true, null, null, null, null, null, null, null, Identity.STATUS_LOGIN_DENIED);
msgProperties.put("usersEnabled", String.valueOf(users - disabled));
PermissionOnResourceable[] permissions = { new PermissionOnResourceable(Constants.PERMISSION_HASROLE, Constants.ORESOURCE_AUTHOR) };
long authors = securityManager.countIdentitiesByPowerSearch(null, null, true, null, permissions, null, null, null, null, null, null);
msgProperties.put("authors", String.valueOf(authors));
// Activity
Calendar lastLoginLimit = Calendar.getInstance();
// -1 - 6 = -7 for last week
lastLoginLimit.add(Calendar.DAY_OF_YEAR, -6);
Long activeUsersLastWeek = securityManager.countUniqueUserLoginsSince(lastLoginLimit.getTime());
msgProperties.put("activeUsersLastWeek", String.valueOf(activeUsersLastWeek));
lastLoginLimit = Calendar.getInstance();
lastLoginLimit.add(Calendar.MONTH, -1);
Long activeUsersLastMonth = securityManager.countUniqueUserLoginsSince(lastLoginLimit.getTime());
msgProperties.put("activeUsersLastMonth", String.valueOf(activeUsersLastMonth));
// Groups
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
int groups = businessGroupService.countBusinessGroups(params, null);
msgProperties.put("buddyGroups", String.valueOf(groups));
msgProperties.put("learningGroups", String.valueOf(groups));
msgProperties.put("rightGroups", String.valueOf(groups));
msgProperties.put("groups", String.valueOf(groups));
// URL
msgProperties.put("url", Settings.getServerContextPathURI());
msgProperties.put("publishWebsite", String.valueOf(website));
// Description
String desc = registrationModule.getWebsiteDescription();
msgProperties.put("description", desc);
if (notify) {
// Email
String email = registrationModule.getEmail();
msgProperties.put("email", email);
}
return msgProperties;
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class CourseGroupWebService method getGroupList.
/**
* Lists all learn groups of the specified course.
* @response.representation.200.qname {http://www.example.com}groupVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The list of all learning group of the course
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVOes}
* @response.representation.404.doc The context of the group not found
* @param request The HTTP request
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getGroupList() {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
List<BusinessGroup> groups = bgs.findBusinessGroups(params, courseEntryRef, 0, -1);
int count = 0;
GroupVO[] vos = new GroupVO[groups.size()];
for (BusinessGroup group : groups) {
vos[count++] = ObjectFactory.get(group);
}
return Response.ok(vos).build();
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
the class MyGroupWebService method getGroupList.
private Response getGroupList(Integer start, Integer limit, String externalId, Boolean managed, boolean owner, boolean participant, HttpServletRequest httpRequest, Request request) {
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, owner, participant);
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;
GroupVO[] groupVOs = new GroupVO[groups.size()];
for (BusinessGroup group : groups) {
groupVOs[count++] = ObjectFactory.get(group);
}
GroupVOes voes = new GroupVOes();
voes.setGroups(groupVOs);
voes.setTotalCount(totalCount);
return Response.ok(voes).build();
} else {
groups = bgs.findBusinessGroups(params, null, 0, -1);
int count = 0;
GroupVO[] groupVOs = new GroupVO[groups.size()];
for (BusinessGroup group : groups) {
groupVOs[count++] = ObjectFactory.get(group);
}
return Response.ok(groupVOs).build();
}
}
use of org.olat.group.model.SearchBusinessGroupParams in project OpenOLAT by OpenOLAT.
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();
}
}
Aggregations