Search in sources :

Example 56 with KalendarRenderWrapper

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

the class ImportCalendarManager method importCalendar.

public KalendarRenderWrapper importCalendar(Identity identity, String calendarName, String type, File file) throws IOException {
    KalendarRenderWrapper calendarWrapper = null;
    Calendar calendar = calendarManager.readCalendar(file);
    if (calendar != null) {
        String calendarID = getImportedCalendarID(identity, calendarName);
        File calendarFile = calendarManager.getCalendarFile(type, calendarID);
        if (!file.renameTo(calendarFile)) {
            Files.copy(file.toPath(), calendarFile.toPath());
        }
        importedCalendarDao.createImportedCalendar(identity, calendarName, calendarID, type, null, new Date());
        calendarWrapper = calendarManager.getImportedCalendar(identity, calendarID);
        calendarWrapper.setDisplayName(calendarName);
        calendarWrapper.setPrivateEventsVisible(true);
    }
    return calendarWrapper;
}
Also used : ImportedCalendar(org.olat.commons.calendar.model.ImportedCalendar) Calendar(net.fortuna.ical4j.model.Calendar) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) File(java.io.File) Date(java.util.Date)

Example 57 with KalendarRenderWrapper

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

the class ImportCalendarManager method getImportedCalendarsForIdentity.

/**
 * Get imported calendars for a user.
 * @param ureq
 * @return
 */
public List<KalendarRenderWrapper> getImportedCalendarsForIdentity(Identity identity, boolean reload) {
    // initialize the calendars list
    List<KalendarRenderWrapper> calendars = new ArrayList<KalendarRenderWrapper>();
    if (calendarModule.isEnabled() && calendarModule.isEnablePersonalCalendar()) {
        long timestamp = System.currentTimeMillis();
        List<ImportedCalendar> importedCalendars = importedCalendarDao.getImportedCalendars(identity);
        KalendarEventFilter filter = new KalendarEventFilter(identity, importedCalendars);
        for (ImportedCalendar importedCalendar : importedCalendars) {
            try {
                if (reload) {
                    reloadImportCalendar(importedCalendar, timestamp, filter);
                }
                String calendarId = importedCalendar.getCalendarId();
                KalendarRenderWrapper calendarWrapper = calendarManager.getImportedCalendar(identity, calendarId);
                calendarWrapper.setDisplayName(importedCalendar.getDisplayName());
                calendarWrapper.setAccess(KalendarRenderWrapper.ACCESS_READ_ONLY);
                calendarWrapper.setImported(true);
                CalendarUserConfiguration config = calendarManager.findCalendarConfigForIdentity(calendarWrapper.getKalendar(), identity);
                if (config != null) {
                    calendarWrapper.setConfiguration(config);
                }
                calendars.add(calendarWrapper);
            } catch (Exception e) {
                log.error("Cannot read an imported file", e);
            }
        }
        Collections.sort(calendars, KalendarComparator.getInstance());
    }
    return calendars;
}
Also used : ImportedCalendar(org.olat.commons.calendar.model.ImportedCalendar) ArrayList(java.util.ArrayList) CalendarUserConfiguration(org.olat.commons.calendar.model.CalendarUserConfiguration) KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper) IOException(java.io.IOException)

Example 58 with KalendarRenderWrapper

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

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 59 with KalendarRenderWrapper

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

the class CalendarPersonalConfigurationController method doToogleAggregated.

private void doToogleAggregated(UserRequest ureq, CalendarPersonalConfigurationRow row) {
    KalendarRenderWrapper calendarWrapper = row.getWrapper();
    calendarWrapper.setInAggregatedFeed(!calendarWrapper.isInAggregatedFeed());
    calendarManager.saveCalendarConfigForIdentity(calendarWrapper, getIdentity());
    enableDisableIcons(row.getAggregatedLink(), calendarWrapper.isInAggregatedFeed());
    fireEvent(ureq, Event.CHANGED_EVENT);
}
Also used : KalendarRenderWrapper(org.olat.commons.calendar.ui.components.KalendarRenderWrapper)

Example 60 with KalendarRenderWrapper

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

the class CalendarPersonalConfigurationController method doSetColor.

private void doSetColor(UserRequest ureq, CalendarPersonalConfigurationRow row, String cssColor) {
    KalendarRenderWrapper calendarWrapper = row.getWrapper();
    calendarWrapper.setCssClass(cssColor);
    calendarManager.saveCalendarConfigForIdentity(calendarWrapper, getIdentity());
    row.getColorLink().setIconLeftCSS("o_cal_config_color ".concat(row.getCssClass()));
    fireEvent(ureq, new CalendarGUISettingEvent(calendarWrapper));
}
Also used : CalendarGUISettingEvent(org.olat.commons.calendar.ui.events.CalendarGUISettingEvent) 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