Search in sources :

Example 91 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CalendarEntryDetailsController method doSave.

private void doSave(UserRequest ureq) {
    // ok, save edited entry
    kalendarEvent = eventForm.getUpdatedKalendarEvent();
    if (isNew) {
        boolean doneSuccessfully = true;
        // this is a new event, add event to calendar
        String calendarID = eventForm.getChoosenKalendarID();
        for (Iterator<KalendarRenderWrapper> iter = availableCalendars.iterator(); iter.hasNext(); ) {
            KalendarRenderWrapper calendarWrapper = iter.next();
            if (!calendarWrapper.getKalendar().getCalendarID().equals(calendarID)) {
                continue;
            }
            Kalendar cal = calendarWrapper.getKalendar();
            boolean result = calendarManager.addEventTo(cal, kalendarEvent);
            if (result == false) {
                // if one failed => done not successfully
                doneSuccessfully = false;
            }
        }
        reportSaveStatus(ureq, doneSuccessfully);
    } else if (kalendarEvent instanceof KalendarRecurEvent && !StringHelper.containsNonWhitespace(kalendarEvent.getRecurrenceID())) {
        updateCtr = new ConfirmUpdateController(ureq, getWindowControl(), (KalendarRecurEvent) kalendarEvent);
        listenTo(updateCtr);
        String title = translate("cal.edit.update");
        cmc = new CloseableModalController(getWindowControl(), translate("close"), updateCtr.getInitialComponent(), true, title);
        listenTo(cmc);
        cmc.activate();
    } else {
        // this is an existing event, so we get the previousely assigned calendar from the event
        Kalendar cal = kalendarEvent.getCalendar();
        boolean doneSuccessfully = calendarManager.updateEventFrom(cal, kalendarEvent);
        reportSaveStatus(ureq, doneSuccessfully);
    }
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) KalendarRecurEvent(org.olat.commons.calendar.model.KalendarRecurEvent) CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 92 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class WeeklyCalendarController method getCallerKalendarRenderWrapper.

private KalendarRenderWrapper getCallerKalendarRenderWrapper() {
    if (callerOres == null || calendarWrappers == null)
        return null;
    String callerResId = callerOres.getResourceableId().toString();
    for (KalendarRenderWrapper calendarWrapper : calendarWrappers) {
        String calendarType = calendarWrapper.getKalendar().getType();
        String calendarId = calendarWrapper.getKalendar().getCalendarID();
        if (callerResId.equals(calendarId)) {
            if ((WeeklyCalendarController.CALLER_COLLAB.equals(caller) && CalendarManager.TYPE_GROUP.equals(calendarType)) || (WeeklyCalendarController.CALLER_COURSE.equals(caller) && CalendarManager.TYPE_COURSE.equals(calendarType))) {
                return calendarWrapper;
            }
        } else if ((WeeklyCalendarController.CALLER_PROFILE.equals(caller) || WeeklyCalendarController.CALLER_HOME.equals(caller)) && CalendarManager.TYPE_USER.equals(calendarType) && calendarId.equals(callerOres.getResourceableTypeName())) {
            return calendarWrapper;
        }
    }
    return null;
}
Also used : KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 93 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class WeeklyCalendarController method pushEditEventController.

/**
 * @param ureq
 * @param kalendarEvent
 * @param kalendarWrapper
 */
private void pushEditEventController(UserRequest ureq, KalendarEvent kalendarEvent, KalendarRenderWrapper kalendarWrapper) {
    if (editController != null)
        return;
    removeAsListenerAndDispose(cmc);
    removeAsListenerAndDispose(editController);
    boolean canEdit = false;
    for (Iterator<KalendarRenderWrapper> iter = calendarWrappers.iterator(); iter.hasNext(); ) {
        KalendarRenderWrapper wrapper = iter.next();
        if (wrapper.getAccess() == KalendarRenderWrapper.ACCESS_READ_WRITE && kalendarWrapper.getKalendar().getCalendarID().equals(wrapper.getKalendar().getCalendarID())) {
            canEdit = true;
        }
    }
    if (canEdit) {
        editController = new CalendarEntryDetailsController(ureq, kalendarEvent, kalendarWrapper, calendarWrappers, false, caller, getWindowControl());
        listenTo(editController);
        removeAsListenerAndDispose(cmc);
        cmc = new CloseableModalController(getWindowControl(), translate("close"), editController.getInitialComponent());
        listenTo(cmc);
        cmc.activate();
        // set logging action
        setCalLoggingAction(CalendarLoggingAction.CALENDAR_ENTRY_MODIFIED);
    } else {
        showError("cal.error.readonly");
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 94 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CourseCalendars method createCourseCalendarsWrapper.

public static CourseCalendars createCourseCalendarsWrapper(UserRequest ureq, WindowControl wControl, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
    List<KalendarRenderWrapper> calendars = new ArrayList<>();
    ICourse course = CourseFactory.loadCourse(courseEnv.getCourseEnvironment().getCourseResourceableId());
    KalendarRenderWrapper courseKalendarWrapper = getCourseCalendarWrapper(ureq, courseEnv, ne);
    // add link provider
    CourseLinkProviderController clpc = new CourseLinkProviderController(course, Collections.singletonList(course), ureq, wControl);
    courseKalendarWrapper.setLinkProvider(clpc);
    calendars.add(courseKalendarWrapper);
    Identity identity = ureq.getIdentity();
    CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager();
    // add course group calendars
    boolean isGroupManager = ureq.getUserSession().getRoles().isOLATAdmin() || ureq.getUserSession().getRoles().isGroupManager() || cgm.isIdentityCourseAdministrator(identity) || cgm.hasRight(identity, CourseRights.RIGHT_GROUPMANAGEMENT);
    boolean readOnly = courseEnv.isCourseReadOnly();
    if (isGroupManager) {
        // learning groups
        List<BusinessGroup> allGroups = cgm.getAllBusinessGroups();
        addCalendars(ureq, courseEnv, allGroups, !readOnly, clpc, calendars);
    } else {
        // learning groups
        List<BusinessGroup> ownerGroups = cgm.getOwnedBusinessGroups(identity);
        addCalendars(ureq, courseEnv, ownerGroups, !readOnly, clpc, calendars);
        List<BusinessGroup> attendedGroups = cgm.getParticipatingBusinessGroups(identity);
        for (BusinessGroup ownerGroup : ownerGroups) {
            if (attendedGroups.contains(ownerGroup)) {
                attendedGroups.remove(ownerGroup);
            }
        }
        addCalendars(ureq, courseEnv, attendedGroups, false, clpc, calendars);
    }
    return new CourseCalendars(courseKalendarWrapper, calendars);
}
Also used : CourseGroupManager(org.olat.course.groupsandrights.CourseGroupManager) BusinessGroup(org.olat.group.BusinessGroup) ArrayList(java.util.ArrayList) ICourse(org.olat.course.ICourse) CourseLinkProviderController(org.olat.course.run.calendar.CourseLinkProviderController) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) Identity(org.olat.core.id.Identity)

Example 95 with KalendarRenderWrapper

use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.

the class CourseCalendars method addCalendars.

private static void addCalendars(UserRequest ureq, UserCourseEnvironment courseEnv, List<BusinessGroup> groups, boolean isOwner, LinkProvider linkProvider, List<KalendarRenderWrapper> calendars) {
    if (groups == null || groups.isEmpty())
        return;
    CollaborationToolsFactory collabFactory = CollaborationToolsFactory.getInstance();
    CalendarManager calendarManager = CoreSpringFactory.getImpl(CalendarManager.class);
    Map<CalendarKey, CalendarUserConfiguration> configMap = calendarManager.getCalendarUserConfigurationsMap(ureq.getIdentity(), CalendarManager.TYPE_GROUP);
    for (BusinessGroup bGroup : groups) {
        CollaborationTools collabTools = collabFactory.getOrCreateCollaborationTools(bGroup);
        if (!collabTools.isToolEnabled(CollaborationTools.TOOL_CALENDAR)) {
            continue;
        }
        boolean member = courseEnv.isIdentityInCourseGroup(bGroup.getKey());
        KalendarRenderWrapper groupCalendarWrapper = calendarManager.getGroupCalendar(bGroup);
        groupCalendarWrapper.setPrivateEventsVisible(member || isOwner);
        // set calendar access
        int iCalAccess = CollaborationTools.CALENDAR_ACCESS_OWNERS;
        Long lCalAccess = collabTools.lookupCalendarAccess();
        if (lCalAccess != null)
            iCalAccess = lCalAccess.intValue();
        if (iCalAccess == CollaborationTools.CALENDAR_ACCESS_OWNERS && !isOwner) {
            groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
        } else {
            groupCalendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_WRITE);
        }
        CalendarUserConfiguration config = configMap.get(groupCalendarWrapper.getCalendarKey());
        if (config != null) {
            groupCalendarWrapper.setConfiguration(config);
        }
        groupCalendarWrapper.setLinkProvider(linkProvider);
        calendars.add(groupCalendarWrapper);
    }
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) CalendarKey(org.olat.commons.calendar.model.CalendarKey) BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) CollaborationToolsFactory(org.olat.collaboration.CollaborationToolsFactory)

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