Search in sources :

Example 31 with KalendarEvent

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);
}
Also used : ArrayList(java.util.ArrayList) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) RestSecurityHelper.getUserRequest(org.olat.restapi.security.RestSecurityHelper.getUserRequest) UserRequest(org.olat.core.gui.UserRequest) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 32 with KalendarEvent

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);
}
Also used : MultipleSelectionElement(org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement) Kalendar(org.olat.commons.calendar.model.Kalendar) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 33 with KalendarEvent

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));
    }
}
Also used : CalendarGUIResizeEvent(org.olat.commons.calendar.ui.events.CalendarGUIResizeEvent) KalendarRecurEvent(org.olat.commons.calendar.model.KalendarRecurEvent) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent)

Example 34 with KalendarEvent

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;
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) KalendarRecurEvent(org.olat.commons.calendar.model.KalendarRecurEvent) Calendar(java.util.Calendar) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) Date(java.util.Date)

Example 35 with KalendarEvent

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";
    }
}
Also used : KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) Date(java.util.Date)

Aggregations

KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)172 Date (java.util.Date)80 Kalendar (org.olat.commons.calendar.model.Kalendar)68 Test (org.junit.Test)48 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)46 Identity (org.olat.core.id.Identity)46 ArrayList (java.util.ArrayList)42 Calendar (java.util.Calendar)40 CalendarImportTest (org.olat.commons.calendar.CalendarImportTest)34 CalendarManager (org.olat.commons.calendar.CalendarManager)32 OLATResourceable (org.olat.core.id.OLATResourceable)20 CalendarGUIModifiedEvent (org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)18 File (java.io.File)16 ExDate (net.fortuna.ical4j.model.property.ExDate)16 ICourse (org.olat.course.ICourse)16 URI (java.net.URI)14 HttpResponse (org.apache.http.HttpResponse)14 URL (java.net.URL)12 KalendarRecurEvent (org.olat.commons.calendar.model.KalendarRecurEvent)12 EventVO (org.olat.commons.calendar.restapi.EventVO)12