Search in sources :

Example 36 with KalendarRenderWrapper

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);
}
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 37 with KalendarRenderWrapper

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

Example 38 with KalendarRenderWrapper

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;
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 39 with KalendarRenderWrapper

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);
}
Also used : BusinessGroupService(org.olat.group.BusinessGroupService) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) CourseLinkProviderController(org.olat.course.run.calendar.CourseLinkProviderController) WeeklyCalendarController(org.olat.commons.calendar.ui.WeeklyCalendarController) RepositoryEntry(org.olat.repository.RepositoryEntry) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 40 with KalendarRenderWrapper

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);
}
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)

Aggregations

KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)134 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)46 ArrayList (java.util.ArrayList)28 Test (org.junit.Test)28 Identity (org.olat.core.id.Identity)26 Date (java.util.Date)24 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)24 Calendar (java.util.Calendar)22 Kalendar (org.olat.commons.calendar.model.Kalendar)22 ICourse (org.olat.course.ICourse)20 File (java.io.File)18 BusinessGroup (org.olat.group.BusinessGroup)16 URI (java.net.URI)14 HttpResponse (org.apache.http.HttpResponse)14 CalendarImportTest (org.olat.commons.calendar.CalendarImportTest)14 URL (java.net.URL)12 EventVO (org.olat.commons.calendar.restapi.EventVO)12 CalendarManager (org.olat.commons.calendar.CalendarManager)10 HttpGet (org.apache.http.client.methods.HttpGet)8 UserRequest (org.olat.core.gui.UserRequest)8