use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
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 klemens.
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 klemens.
the class GTANotifications method createIndividualSubscriptionInfo.
private void createIndividualSubscriptionInfo(Identity subscriberIdentity) {
RepositoryEntry entry = courseEnv.getCourseGroupManager().getCourseEntry();
List<String> roles = repositoryService.getRoles(subscriberIdentity, entry);
boolean owner = roles.contains(GroupRoles.owner.name());
boolean coach = roles.contains(GroupRoles.coach.name());
if (owner || coach) {
Set<Identity> duplicateKiller = new HashSet<>();
List<Identity> assessableIdentities = new ArrayList<>();
List<Identity> participants;
List<BusinessGroup> coachedGroups = null;
if (owner) {
participants = businessGroupService.getMembersOf(entry, false, true);
} else {
SearchBusinessGroupParams params = new SearchBusinessGroupParams(subscriberIdentity, true, false);
coachedGroups = businessGroupService.findBusinessGroups(params, entry, 0, -1);
participants = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name());
}
for (Identity participant : participants) {
if (!duplicateKiller.contains(participant)) {
assessableIdentities.add(participant);
duplicateKiller.add(participant);
}
}
boolean repoTutor = owner || (coachedGroups.isEmpty() && repositoryService.hasRole(subscriberIdentity, entry, GroupRoles.coach.name()));
if (repoTutor) {
List<Identity> courseParticipants = repositoryService.getMembers(entry, GroupRoles.participant.name());
for (Identity participant : courseParticipants) {
if (!duplicateKiller.contains(participant)) {
assessableIdentities.add(participant);
duplicateKiller.add(participant);
}
}
}
for (Identity assessedIdentity : assessableIdentities) {
createIndividualSubscriptionInfo(assessedIdentity, true);
}
createCoachSolutionItems();
} else {
Task task = gtaManager.getTask(subscriberIdentity, taskList);
if (task != null) {
header = translator.translate("notifications.individual.header.task", new String[] { getTaskName(task), displayName });
}
}
if (roles.contains(GroupRoles.participant.name())) {
createIndividualSubscriptionInfo(subscriberIdentity, false);
Task task = gtaManager.getTask(subscriberIdentity, taskList);
if (isSolutionVisible(subscriberIdentity, null, task)) {
createParticipantSolutionItems(task, subscriberIdentity, null);
}
if (task != null && task.getTaskStatus() == TaskProcess.graded) {
createAssessmentItem(task, subscriberIdentity, false);
}
}
}
use of org.olat.group.model.SearchBusinessGroupParams in project openolat by klemens.
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 klemens.
the class EditLectureBlockController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_repo_edit_lecture_form");
if (lectureBlock != null && StringHelper.containsNonWhitespace(lectureBlock.getManagedFlagsString())) {
setFormWarning("form.managedflags.intro.short", null);
}
String title = lectureBlock == null ? null : lectureBlock.getTitle();
titleEl = uifactory.addTextElement("title", "lecture.title", 128, title, formLayout);
titleEl.setElementCssClass("o_sel_repo_lecture_title");
titleEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.title));
titleEl.setMandatory(true);
plannedLecturesEl = uifactory.addDropdownSingleselect("planned.lectures", "planned.lectures", formLayout, plannedLecturesKeys, plannedLecturesKeys, null);
plannedLecturesEl.setMandatory(true);
String plannedlectures = lectureBlock == null ? "4" : Integer.toString(lectureBlock.getPlannedLecturesNumber());
for (String plannedLecturesKey : plannedLecturesKeys) {
if (plannedlectures.equals(plannedLecturesKey)) {
plannedLecturesEl.select(plannedLecturesKey, true);
break;
}
}
// freeze it after roll call done
boolean plannedLecturesEditable = (lectureBlock == null || (lectureBlock.getStatus() != LectureBlockStatus.done && lectureBlock.getRollCallStatus() != LectureRollCallStatus.closed && lectureBlock.getRollCallStatus() != LectureRollCallStatus.autoclosed)) && !lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.plannedLectures);
plannedLecturesEl.setEnabled(plannedLecturesEditable);
String[] onValues = new String[] { "" };
boolean compulsory = lectureBlock == null ? true : lectureBlock.isCompulsory();
compulsoryEl = uifactory.addCheckboxesVertical("compulsory", "lecture.compulsory", formLayout, onKeys, onValues, 1);
compulsoryEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.compulsory));
compulsoryEl.addActionListener(FormEvent.ONCHANGE);
if (compulsory) {
compulsoryEl.select(onKeys[0], true);
}
List<Identity> coaches = repositoryService.getMembers(entry, GroupRoles.coach.name());
teacherKeys = new String[coaches.size() + 1];
teacherValues = new String[coaches.size() + 1];
for (int i = coaches.size() + 1; i-- > 1; ) {
Identity coach = coaches.get(i - 1);
teacherKeys[i] = coach.getKey().toString();
teacherValues[i] = userManager.getUserDisplayName(coach);
}
teacherKeys[0] = "-";
teacherValues[0] = translate("no.teachers");
teacherEl = uifactory.addCheckboxesVertical("teacher", "lecture.teacher", formLayout, teacherKeys, teacherValues, 2);
teacherEl.setElementCssClass("o_sel_repo_lecture_teachers");
teacherEl.setMandatory(true);
teacherEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.teachers));
boolean found = false;
if (teachers != null && teachers.size() > 0) {
for (Identity teacher : teachers) {
String currentTeacherKey = teacher.getKey().toString();
for (String teacherKey : teacherKeys) {
if (currentTeacherKey.equals(teacherKey)) {
teacherEl.select(currentTeacherKey, true);
found = true;
}
}
}
}
if (!found) {
teacherEl.select(teacherKeys[0], true);
}
Group entryBaseGroup = repositoryService.getDefaultGroup(entry);
groupBox = new ArrayList<>();
groupBox.add(new GroupBox(entry, entryBaseGroup));
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
List<BusinessGroup> businessGroups = businessGroupService.findBusinessGroups(params, entry, 0, -1, BusinessGroupOrder.nameAsc);
for (BusinessGroup businessGroup : businessGroups) {
groupBox.add(new GroupBox(businessGroup));
}
String[] groupKeys = new String[groupBox.size()];
String[] groupValues = new String[groupBox.size()];
for (int i = groupBox.size(); i-- > 0; ) {
groupKeys[i] = Integer.toString(i);
groupValues[i] = groupBox.get(i).getName();
}
groupsEl = uifactory.addCheckboxesVertical("lecture.groups", "lecture.groups", formLayout, groupKeys, groupValues, 2);
groupsEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.groups));
groupsEl.setMandatory(true);
if (lectureBlock != null) {
List<Group> selectedGroups = lectureService.getLectureBlockToGroups(lectureBlock);
for (int i = 0; i < groupBox.size(); i++) {
if (selectedGroups.contains(groupBox.get(i).getBaseGroup())) {
groupsEl.select(Integer.toString(i), true);
}
}
} else if (groupKeys.length == 1) {
groupsEl.select(groupKeys[0], true);
}
String description = lectureBlock == null ? "" : lectureBlock.getDescription();
descriptionEl = uifactory.addTextAreaElement("lecture.descr", 4, 72, description, formLayout);
descriptionEl.setElementCssClass("o_sel_repo_lecture_description");
descriptionEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.description));
String preparation = lectureBlock == null ? "" : lectureBlock.getPreparation();
preparationEl = uifactory.addTextAreaElement("lecture.preparation", 4, 72, preparation, formLayout);
preparationEl.setElementCssClass("o_sel_repo_lecture_preparation");
preparationEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.preparation));
String location = lectureBlock == null ? "" : lectureBlock.getLocation();
locationEl = uifactory.addTextElementWithAutoCompleter("location", "lecture.location", 128, location, formLayout);
locationEl.setElementCssClass("o_sel_repo_lecture_location");
locationEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.location));
locationEl.setListProvider(new LocationListProvider(), ureq.getUserSession());
locationEl.setMinLength(1);
Date startDate = lectureBlock == null ? null : lectureBlock.getStartDate();
dateEl = uifactory.addDateChooser("lecture.date", startDate, formLayout);
dateEl.setElementCssClass("o_sel_repo_lecture_date");
dateEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.dates));
dateEl.setDomReplacementWrapperRequired(false);
dateEl.setMandatory(true);
String datePage = velocity_root + "/date_start_end.html";
FormLayoutContainer dateCont = FormLayoutContainer.createCustomFormLayout("start_end", getTranslator(), datePage);
dateCont.setLabel("lecture.time", null);
formLayout.add(dateCont);
startHourEl = uifactory.addTextElement("lecture.start.hour", null, 2, "", dateCont);
startHourEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.dates));
startHourEl.setDomReplacementWrapperRequired(false);
startHourEl.setDisplaySize(2);
startHourEl.setMandatory(true);
startMinuteEl = uifactory.addTextElement("lecture.start.minute", null, 2, "", dateCont);
startMinuteEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.dates));
startMinuteEl.setDomReplacementWrapperRequired(false);
startMinuteEl.setDisplaySize(2);
endHourEl = uifactory.addTextElement("lecture.end.hour", null, 2, "", dateCont);
endHourEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.dates));
endHourEl.setDomReplacementWrapperRequired(false);
endHourEl.setDisplaySize(2);
endHourEl.setMandatory(true);
endMinuteEl = uifactory.addTextElement("lecture.end.minute", null, 2, "", dateCont);
endMinuteEl.setEnabled(!lectureManagementManaged && !LectureBlockManagedFlag.isManaged(lectureBlock, LectureBlockManagedFlag.dates));
endMinuteEl.setDomReplacementWrapperRequired(false);
endMinuteEl.setDisplaySize(2);
if (lectureBlock != null) {
Calendar cal = Calendar.getInstance();
if (lectureBlock.getStartDate() != null) {
cal.setTime(lectureBlock.getStartDate());
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
startHourEl.setValue(Integer.toString(hour));
startMinuteEl.setValue(formatMinute(minute));
}
if (lectureBlock.getEndDate() != null) {
cal.setTime(lectureBlock.getEndDate());
int hour = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
endHourEl.setValue(Integer.toString(hour));
endMinuteEl.setValue(formatMinute(minute));
}
}
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
uifactory.addFormSubmitButton("save", buttonsCont);
}
Aggregations