Search in sources :

Example 46 with KalendarEvent

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

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)

Example 47 with KalendarEvent

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

the class DENManager method deleteParticipants.

/**
 * Delete all participants in the events with the given IDs
 * @param course
 * @param courseNode
 * @param eventIDs of the events, where all participants should be deleted
 * @return list with the actualized events
 */
protected List<KalendarEvent> deleteParticipants(OLATResourceable ores, DENCourseNode courseNode, List<String> eventIDs) {
    List<KalendarEvent> events = getDENEvents(ores.getResourceableId(), courseNode.getIdent());
    for (KalendarEvent event : events) {
        if (eventIDs.contains(event.getID())) {
            removeDateInUserCalendar(event);
            event.setParticipants(new String[0]);
        }
    }
    persistDENSettings(events, ores, courseNode);
    return events;
}
Also used : KalendarEvent(org.olat.commons.calendar.model.KalendarEvent)

Example 48 with KalendarEvent

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

the class DENManager method updateMultipleDatesInList.

/**
 * Update multiple dates in a list of KalendarEvents with the given informations from a manage dates form
 * @param datesForm of type DENEditManageDatesForm
 * @param dataList
 * @param selectedDates
 * @return list with actualized KalendarEvents
 */
protected List<KalendarEvent> updateMultipleDatesInList(String subjectStr, String commentStr, String locationStr, String movementGapStr, int numParticipants, List<KalendarEvent> dataList, BitSet selectedDates) {
    for (int i = 0; i < dataList.size(); i++) {
        if (selectedDates.get(i)) {
            KalendarEvent oldEvent = dataList.get(i);
            StringTokenizer strTok = new StringTokenizer(movementGapStr.substring(1), ":", false);
            int gap = 1000 * 60 * 60 * Integer.parseInt(strTok.nextToken()) + 1000 * 60 * Integer.parseInt(strTok.nextToken());
            Date newBegin, newEnd;
            if (movementGapStr.startsWith("+")) {
                newBegin = new Date(oldEvent.getBegin().getTime() + gap);
                newEnd = new Date(oldEvent.getEnd().getTime() + gap);
            } else {
                newBegin = new Date(oldEvent.getBegin().getTime() - gap);
                newEnd = new Date(oldEvent.getEnd().getTime() - gap);
            }
            String eventId = oldEvent.getID();
            KalendarEvent newEvent = new KalendarEvent(eventId, null, subjectStr.equals(new String()) ? oldEvent.getSubject() : subjectStr, newBegin, newEnd);
            if (numParticipants != 0)
                newEvent.setNumParticipants(numParticipants);
            else
                newEvent.setNumParticipants(oldEvent.getNumParticipants());
            if (!locationStr.equals(new String()))
                newEvent.setLocation(locationStr);
            else
                newEvent.setLocation(oldEvent.getLocation());
            if (!commentStr.equals(new String()))
                newEvent.setComment(commentStr);
            else
                newEvent.setComment(oldEvent.getComment());
            newEvent.setParticipants(oldEvent.getParticipants());
            newEvent.setSourceNodeId(oldEvent.getSourceNodeId());
            dataList.remove(i);
            dataList.add(i, newEvent);
        }
    }
    return dataList;
}
Also used : StringTokenizer(java.util.StringTokenizer) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) Date(java.util.Date)

Example 49 with KalendarEvent

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

the class DENRunController method event.

@Override
protected void event(UserRequest ureq, Controller source, Event event) {
    if (runDENTable == source) {
        // the link to enroll or cancel enrollment is clicked
        if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
            TableEvent tableEvent = (TableEvent) event;
            KalendarEvent calEvent = runTableData.getObject(tableEvent.getRowId());
            if (tableEvent.getActionId().equals(DENRunTableDataModel.CMD_ENROLL_IN_DATE)) {
                // do enroll
                status = denManager.doEnroll(ureq.getIdentity(), calEvent, ores, courseNode);
                if (!status.isEnrolled())
                    showError();
            } else if (tableEvent.getActionId().equals(DENRunTableDataModel.CMD_ENROLLED_CANCEL)) {
                // cancel enrollment
                status = denManager.cancelEnroll(ureq.getIdentity(), calEvent, ores);
                if (!status.isCancelled())
                    showError();
            }
            createOrUpdateDateTable(ureq, courseNode);
            runDENTable.setTableDataModel(runTableData);
            fireEvent(ureq, Event.DONE_EVENT);
            // inform subscription context about changes
            NotificationsManager.getInstance().markPublisherNews(subsContext, ureq.getIdentity(), true);
        // </OPAL-122>
        }
    }
}
Also used : TableEvent(org.olat.core.gui.components.table.TableEvent) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent)

Example 50 with KalendarEvent

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

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

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