use of org.olat.commons.calendar.model.KalendarEvent 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.model.KalendarEvent 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);
}
use of org.olat.commons.calendar.model.KalendarEvent in project openolat by klemens.
the class FullCalendarElement method doResize.
protected void doResize(UserRequest ureq, String eventId, String minuteDelta, String allDayStr) {
Long minute = null;
if (StringHelper.isLong(minuteDelta)) {
minute = Long.parseLong(minuteDelta);
}
Boolean allDay = null;
if ("true".equals(allDayStr)) {
allDay = Boolean.TRUE;
} else if ("false".equals(allDayStr)) {
allDay = Boolean.FALSE;
}
if (component.isOccurenceOfCalendarEvent(eventId)) {
String uid = component.getCalendarEventUid(eventId);
KalendarRenderWrapper cal = component.getCalendarById(uid);
KalendarRecurEvent rEvent = getCurrenceKalendarEvent(cal, eventId);
getRootForm().fireFormEvent(ureq, new CalendarGUIResizeEvent(this, rEvent, cal, minute, allDay));
} else if (component.isReccurenceOfCalendarEvent(eventId)) {
String uid = component.getCalendarEventUid(eventId);
KalendarRenderWrapper cal = component.getCalendarById(uid);
KalendarRecurEvent rEvent = getCurrenceKalendarEvent(cal, eventId);
getRootForm().fireFormEvent(ureq, new CalendarGUIResizeEvent(this, rEvent, cal, minute, allDay));
} else {
KalendarEvent event = component.getCalendarEvent(eventId);
KalendarRenderWrapper calWrapper = component.getCalendarByNormalizedId(eventId);
getRootForm().fireFormEvent(ureq, new CalendarGUIResizeEvent(this, event, calWrapper, minute, allDay));
}
}
use of org.olat.commons.calendar.model.KalendarEvent in project openolat by klemens.
the class FullCalendarElement method getCurrenceKalendarEvent.
private KalendarRecurEvent getCurrenceKalendarEvent(KalendarRenderWrapper cal, String eventId) {
boolean privateEventsVisible = cal.isPrivateEventsVisible();
CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
Date currentDate = component.getCurrentDate();
Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDate);
calendar.add(Calendar.MONTH, -2);
Date from = calendar.getTime();
calendar.add(Calendar.MONTH, +4);
Date to = calendar.getTime();
List<KalendarEvent> events = calendarManager.getEvents(cal.getKalendar(), from, to, privateEventsVisible);
for (KalendarEvent event : events) {
if (event instanceof KalendarRecurEvent) {
KalendarRecurEvent kEvent = (KalendarRecurEvent) event;
if (eventId.equals(FullCalendarComponent.normalizeId(event))) {
return kEvent;
}
}
}
return null;
}
use of org.olat.commons.calendar.model.KalendarEvent in project openolat by klemens.
the class DENEditTableDataModel method getValueAt.
@Override
public Object getValueAt(int row, int col) {
KalendarEvent event = getObject(row);
switch(col) {
case 0:
return event.getSubject();
case 1:
// begin
return event.getBegin();
case 2:
// duration
Date begin = event.getBegin();
Date end = event.getEnd();
long milliSeconds = denManager.getDuration(begin, end);
return denManager.formatDuration(milliSeconds, translator);
case 3:
// location
return event.getLocation();
case 4:
return event.getComment();
case 5:
return event.getNumParticipants();
default:
return "error";
}
}
Aggregations