use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class UserCalendarWebService method getEvents.
@GET
@Path("events")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getEvents(@PathParam("identityKey") Long identityKey, @QueryParam("start") @DefaultValue("0") Integer start, @QueryParam("limit") @DefaultValue("25") Integer limit, @QueryParam("onlyFuture") @DefaultValue("false") Boolean onlyFuture, @Context HttpServletRequest httpRequest, @Context Request request) {
UserRequest ureq = getUserRequest(httpRequest);
if (ureq.getIdentity() == null || !ureq.getUserSession().isAuthenticated()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
} else if (!ureq.getIdentity().getKey().equals(identityKey) && !isAdmin(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
CollectCalendars visitor = new CollectCalendars();
getCalendars(visitor, ureq);
List<KalendarRenderWrapper> wrappers = visitor.getWrappers();
List<EventVO> events = new ArrayList<>();
for (KalendarRenderWrapper wrapper : wrappers) {
Collection<KalendarEvent> kalEvents = wrapper.getKalendar().getEvents();
for (KalendarEvent kalEvent : kalEvents) {
EventVO eventVo = new EventVO(kalEvent);
events.add(eventVo);
}
}
return processEvents(events, onlyFuture, start, limit, httpRequest, request);
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class UserCalendarWebService method getCalendars.
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getCalendars(@PathParam("identityKey") Long identityKey, @Context HttpServletRequest httpRequest) {
UserRequest ureq = getUserRequest(httpRequest);
if (ureq.getIdentity() == null || !ureq.getUserSession().isAuthenticated()) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
} else if (!ureq.getIdentity().getKey().equals(identityKey) && !isAdmin(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
CollectCalendars visitor = new CollectCalendars();
getCalendars(visitor, ureq);
List<KalendarRenderWrapper> wrappers = visitor.getWrappers();
CalendarVO[] voes = new CalendarVO[wrappers.size()];
int count = 0;
for (KalendarRenderWrapper wrapper : wrappers) {
voes[count++] = new CalendarVO(wrapper, hasWriteAccess(wrapper));
}
return Response.ok(voes).build();
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class UserCalendarWebService method getPersonalCalendar.
private KalendarRenderWrapper getPersonalCalendar(Identity identity) {
// get the personal calendar
CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
KalendarRenderWrapper calendarWrapper = calendarManager.getPersonalCalendar(identity);
calendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
calendarWrapper.setPrivateEventsVisible(true);
CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(calendarWrapper.getKalendar(), identity);
if (config != null) {
calendarWrapper.setConfiguration(config);
}
return calendarWrapper;
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class CollaborationTools method createCalendarController.
/**
* Creates a calendar controller
* @param ureq
* @param wControl
* @param resourceableId
* @return Configured WeeklyCalendarController
*/
public CalendarController createCalendarController(UserRequest ureq, WindowControl wControl, BusinessGroup businessGroup, boolean isAdmin, boolean isMember) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
KalendarRenderWrapper calRenderWrapper = collaborationManager.getCalendar(businessGroup, ureq, isAdmin);
calRenderWrapper.setPrivateEventsVisible(isAdmin || isMember);
// add linking
List<RepositoryEntry> repoEntries = CoreSpringFactory.getImpl(BusinessGroupService.class).findRepositoryEntries(Collections.singleton(businessGroup), 0, -1);
List<ICourse> courses = new ArrayList<>(repoEntries.size());
for (RepositoryEntry repoEntry : repoEntries) {
if (repoEntry.getOlatResource().getResourceableTypeName().equals(CourseModule.getCourseTypeName())) {
ICourse course = CourseFactory.loadCourse(repoEntry);
courses.add(course);
}
}
if (!courses.isEmpty()) {
CourseLinkProviderController clp = new CourseLinkProviderController(null, courses, ureq, wControl);
calRenderWrapper.setLinkProvider(clp);
}
List<KalendarRenderWrapper> calendars = new ArrayList<>();
calendars.add(calRenderWrapper);
return new WeeklyCalendarController(ureq, wControl, calendars, WeeklyCalendarController.CALLER_COLLAB, businessGroup, false);
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class CopyEventToCalendarController method formOK.
@Override
protected void formOK(UserRequest ureq) {
for (MultipleSelectionElement copyEl : copyEls) {
if (copyEl.isEnabled() && copyEl.isAtLeastSelected(1)) {
KalendarRenderWrapper calendarWrapper = (KalendarRenderWrapper) copyEl.getUserObject();
Kalendar cal = calendarWrapper.getKalendar();
KalendarEvent clonedKalendarEvent = (KalendarEvent) XStreamHelper.xstreamClone(kalendarEvent);
if (clonedKalendarEvent.getKalendarEventLinks().size() > 0) {
clonedKalendarEvent.setKalendarEventLinks(new ArrayList<KalendarEventLink>());
}
calendarManager.addEventTo(cal, clonedKalendarEvent);
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
Aggregations