Search in sources :

Example 76 with Kalendar

use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.

the class ICalFileCalendarManager method getGroupCalendar.

@Override
public KalendarRenderWrapper getGroupCalendar(BusinessGroup businessGroup) {
    Kalendar cal = getCalendar(CalendarManager.TYPE_GROUP, businessGroup.getResourceableId().toString());
    KalendarRenderWrapper calendarWrapper = new KalendarRenderWrapper(cal, businessGroup.getName());
    calendarWrapper.setCssClass(KalendarRenderWrapper.CALENDAR_COLOR_ORANGE);
    calendarWrapper.setVisible(true);
    return calendarWrapper;
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 77 with Kalendar

use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.

the class ICalFileCalendarManager method getCalendarForDeletion.

@Override
public KalendarRenderWrapper getCalendarForDeletion(OLATResourceable resource) {
    String type;
    if ("CourseModule".equals(resource.getResourceableTypeName())) {
        type = CalendarManager.TYPE_COURSE;
    } else {
        type = CalendarManager.TYPE_GROUP;
    }
    Kalendar cal = getCalendar(type, resource.getResourceableId().toString());
    KalendarRenderWrapper calendarWrapper = new KalendarRenderWrapper(cal, "To delete");
    calendarWrapper.setCssClass(KalendarRenderWrapper.CALENDAR_COLOR_GREEN);
    calendarWrapper.setVisible(true);
    return calendarWrapper;
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 78 with Kalendar

use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.

the class ICalFileCalendarManager method addEventTo.

@Override
public boolean addEventTo(final Kalendar cal, final List<KalendarEvent> kalendarEvents) {
    OLATResourceable calOres = getOresHelperFor(cal);
    Boolean persistSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {

        @Override
        public Boolean execute() {
            Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
            for (KalendarEvent kalendarEvent : kalendarEvents) {
                loadedCal.addEvent(kalendarEvent);
                kalendarEvent.resetImmutableDates();
            }
            boolean successfullyPersist = persistCalendar(loadedCal);
            return new Boolean(successfullyPersist);
        }
    });
    // inform all controller about calendar change for reload
    CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
    return persistSuccessful.booleanValue();
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) Kalendar(org.olat.commons.calendar.model.Kalendar) OLATResourceable(org.olat.core.id.OLATResourceable) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) CalendarGUIModifiedEvent(org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)

Example 79 with Kalendar

use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.

the class ICalFileCalendarManager method saveCalendarConfigForIdentity.

@Override
public void saveCalendarConfigForIdentity(KalendarRenderWrapper wrapper, Identity identity) {
    Kalendar calendar = wrapper.getKalendar();
    CalendarUserConfiguration configuration = calendarUserConfigDao.getCalendarUserConfiguration(identity, calendar.getCalendarID(), calendar.getType());
    if (configuration == null) {
        configuration = calendarUserConfigDao.createCalendarUserConfiguration(wrapper.getKalendar(), identity, wrapper.getToken(), wrapper.isInAggregatedFeed(), wrapper.isVisible());
    } else {
        configuration.setVisible(wrapper.isVisible());
        configuration.setCssClass(wrapper.getCssClass());
        configuration.setToken(wrapper.getToken());
        configuration.setInAggregatedFeed(wrapper.isInAggregatedFeed());
        configuration = calendarUserConfigDao.update(configuration);
    }
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration)

Example 80 with Kalendar

use of org.olat.commons.calendar.model.Kalendar in project OpenOLAT by OpenOLAT.

the class ICalFileCalendarManager method updateEventsFrom.

@Override
public boolean updateEventsFrom(Kalendar cal, List<KalendarEvent> kalendarEvents) {
    final OLATResourceable calOres = getOresHelperFor(cal);
    Boolean updatedSuccessful = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(calOres, new SyncerCallback<Boolean>() {

        @Override
        public Boolean execute() {
            Kalendar loadedCal = getCalendarFromCache(cal.getType(), cal.getCalendarID());
            for (KalendarEvent kalendarEvent : kalendarEvents) {
                // remove old event
                loadedCal.removeEvent(kalendarEvent);
                // add changed event
                loadedCal.addEvent(kalendarEvent);
            }
            boolean successfullyPersist = persistCalendar(loadedCal);
            // inform all controller about calendar change for reload
            CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(new CalendarGUIModifiedEvent(cal), OresHelper.lookupType(CalendarManager.class));
            return successfullyPersist;
        }
    });
    return updatedSuccessful.booleanValue();
}
Also used : Kalendar(org.olat.commons.calendar.model.Kalendar) OLATResourceable(org.olat.core.id.OLATResourceable) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) CalendarGUIModifiedEvent(org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)

Aggregations

Kalendar (org.olat.commons.calendar.model.Kalendar)126 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)68 Identity (org.olat.core.id.Identity)40 Date (java.util.Date)38 Test (org.junit.Test)26 CalendarManager (org.olat.commons.calendar.CalendarManager)24 KalendarRenderWrapper (org.olat.commons.calendar.ui.components.KalendarRenderWrapper)22 ArrayList (java.util.ArrayList)20 CalendarImportTest (org.olat.commons.calendar.CalendarImportTest)20 OLATResourceable (org.olat.core.id.OLATResourceable)20 CalendarGUIModifiedEvent (org.olat.commons.calendar.ui.events.CalendarGUIModifiedEvent)18 Calendar (java.util.Calendar)14 CalendarUserConfiguration (org.olat.commons.calendar.model.CalendarUserConfiguration)12 URISyntaxException (java.net.URISyntaxException)10 ParseException (java.text.ParseException)10 ExDate (net.fortuna.ical4j.model.property.ExDate)10 IOException (java.io.IOException)8 InputStream (java.io.InputStream)8 ICourse (org.olat.course.ICourse)8 RepositoryEntry (org.olat.repository.RepositoryEntry)8