Search in sources :

Example 21 with KalendarEventLink

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

the class MediaLinksController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    List<KalendarEventLink> links = kalendarEvent.getKalendarEventLinks();
    List<LinkWrapper> filledWrappers = new ArrayList<LinkWrapper>();
    for (LinkWrapper linkWrapper : externalLinks) {
        if (!linkWrapper.isEmpty()) {
            filledWrappers.add(linkWrapper);
        }
    }
    // add and update links
    Set<String> usedUuids = new HashSet<String>();
    for (LinkWrapper linkWrapper : filledWrappers) {
        boolean found = false;
        usedUuids.add(linkWrapper.getId());
        for (KalendarEventLink link : links) {
            if (link.getId().equals(linkWrapper.getId())) {
                link.setURI(linkWrapper.getUrl().getValue());
                link.setDisplayName(linkWrapper.getName().getValue());
                link.setIconCssClass(linkWrapper.getCssClass());
                found = true;
            }
        }
        if (!found) {
            KalendarEventLink newLink = linkWrapper.getLink();
            newLink.setURI(linkWrapper.getUrl().getValue());
            newLink.setDisplayName(linkWrapper.getName().getValue());
            newLink.setIconCssClass(linkWrapper.getCssClass());
            links.add(newLink);
        }
    }
    // remove deleted links
    for (Iterator<KalendarEventLink> it = links.iterator(); it.hasNext(); ) {
        KalendarEventLink link = it.next();
        if (provider.equals(link.getProvider()) && !usedUuids.contains(link.getId())) {
            it.remove();
        }
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : ArrayList(java.util.ArrayList) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink) HashSet(java.util.HashSet)

Example 22 with KalendarEventLink

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

the class CalendarEntryDetailsController method event.

@Override
public void event(UserRequest ureq, Controller source, Event event) {
    if (source == deleteCtr) {
        if (event instanceof CalendarGUIDeleteEvent) {
            doDelete((CalendarGUIDeleteEvent) event);
            cmc.deactivate();
            cleanUp();
            fireEvent(ureq, Event.DONE_EVENT);
        } else {
            cmc.deactivate();
            cleanUp();
        }
    } else if (source == activeLinkProvider) {
        if (kalendarEvent.getCalendar() != null) {
            fireEvent(ureq, Event.DONE_EVENT);
        }
    } else if (source == eventForm) {
        if (event == Event.DONE_EVENT) {
            doSave(ureq);
        } else if ("delete".equals(event.getCommand())) {
            doConfirmDelete(ureq);
        } else if (event == Event.CANCELLED_EVENT) {
            eventForm.setEntry(kalendarEvent);
            // user canceled, finish workflow
            fireEvent(ureq, Event.DONE_EVENT);
        }
    } else if (source == updateCtr) {
        if (event instanceof CalendarGUIUpdateEvent) {
            doUpdate((CalendarGUIUpdateEvent) event);
            cmc.deactivate();
            cleanUp();
            fireEvent(ureq, Event.DONE_EVENT);
        } else {
            cmc.deactivate();
            cleanUp();
        }
    } else if (source == customMediaChooserCtr) {
        boolean doneSuccessfully = true;
        if (event instanceof URLChoosenEvent) {
            URLChoosenEvent urlEvent = (URLChoosenEvent) event;
            String url = urlEvent.getURL();
            List<KalendarEventLink> links = kalendarEvent.getKalendarEventLinks();
            String provider = customMediaChooserCtr.getClass().getSimpleName();
            String id = url;
            String displayName = StringHelper.containsNonWhitespace(urlEvent.getDisplayName()) ? urlEvent.getDisplayName() : url;
            String uri = url.contains("://") ? url : (Settings.getServerContextPathURI() + url);
            String iconCssClass = urlEvent.getIconCssClass();
            if (!StringHelper.containsNonWhitespace(iconCssClass)) {
                iconCssClass = CSSHelper.createFiletypeIconCssClassFor(url);
            }
            links.add(new KalendarEventLink(provider, id, displayName, uri, iconCssClass));
            Kalendar cal = kalendarEvent.getCalendar();
            doneSuccessfully = calendarManager.updateEventFrom(cal, kalendarEvent);
        }
        if (doneSuccessfully) {
            fireEvent(ureq, event);
        } else {
            showError("cal.error.save");
            fireEvent(ureq, Event.FAILED_EVENT);
        }
    } else if (source == externalLinksController || source == mediaLinksController) {
        // save externals links
        Kalendar cal = kalendarEvent.getCalendar();
        if (kalendarEvent.getCalendar() != null) {
            boolean doneSuccessfully = calendarManager.updateEventFrom(cal, kalendarEvent);
            if (doneSuccessfully) {
                fireEvent(ureq, Event.DONE_EVENT);
            } else {
                showError("cal.error.save");
                fireEvent(ureq, Event.FAILED_EVENT);
            }
        }
    } else if (cmc == source) {
        cleanUp();
    }
}
Also used : CalendarGUIDeleteEvent(org.olat.commons.calendar.ui.events.CalendarGUIDeleteEvent) Kalendar(org.olat.commons.calendar.model.Kalendar) CalendarGUIUpdateEvent(org.olat.commons.calendar.ui.events.CalendarGUIUpdateEvent) URLChoosenEvent(org.olat.core.commons.controllers.linkchooser.URLChoosenEvent) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink)

Example 23 with KalendarEventLink

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

the class ExternalLinksController method createLinkWrapper.

private LinkWrapper createLinkWrapper() {
    String id = UUID.randomUUID().toString().replaceAll("-", "");
    KalendarEventLink newLink = new KalendarEventLink(EXTERNAL_LINKS_PROVIDER, id, "", "", "");
    LinkWrapper newLinkWrapper = new LinkWrapper(newLink);
    return newLinkWrapper;
}
Also used : KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink)

Example 24 with KalendarEventLink

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

the class DENManager method addDateInUserCalendar.

/**
 * Add this event in the calendar of an enrolled user
 * @param newEvent
 */
private void addDateInUserCalendar(KalendarEvent newEvent) {
    String[] participants = newEvent.getParticipants();
    // no users to update, cancel
    if (participants == null)
        return;
    BaseSecurity manager = BaseSecurityManager.getInstance();
    CalendarManager calManager = CoreSpringFactory.getImpl(CalendarManager.class);
    for (String participant : participants) {
        Identity identity = manager.findIdentityByName(participant);
        if (identity != null) {
            Kalendar userCal = calManager.getPersonalCalendar(identity).getKalendar();
            List<KalendarEvent> userEvents = new ArrayList<>();
            userEvents.addAll(userCal.getEvents());
            String eventId = CodeHelper.getGlobalForeverUniqueID();
            KalendarEvent userNewEvent = new KalendarEvent(eventId, null, newEvent.getSubject(), newEvent.getBegin(), newEvent.getEnd());
            userNewEvent.setLocation(newEvent.getLocation());
            userNewEvent.setSourceNodeId(newEvent.getSourceNodeId());
            userNewEvent.setClassification(KalendarEvent.CLASS_PRIVATE);
            List<KalendarEventLink> kalendarEventLinks = userNewEvent.getKalendarEventLinks();
            kalendarEventLinks.clear();
            kalendarEventLinks.addAll(newEvent.getKalendarEventLinks());
            calManager.addEventTo(userCal, userNewEvent);
        }
    }
}
Also used : CalendarManager(org.olat.commons.calendar.CalendarManager) Kalendar(org.olat.commons.calendar.model.Kalendar) ArrayList(java.util.ArrayList) KalendarEvent(org.olat.commons.calendar.model.KalendarEvent) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink) Identity(org.olat.core.id.Identity) BaseSecurity(org.olat.basesecurity.BaseSecurity)

Example 25 with KalendarEventLink

use of org.olat.commons.calendar.model.KalendarEventLink in project openolat by klemens.

the class DENManager method createKalendarEventLinks.

private void createKalendarEventLinks(ICourse course, DENCourseNode courseNode, KalendarEvent event) {
    List<KalendarEventLink> kalendarEventLinks = event.getKalendarEventLinks();
    RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
    OLATResourceable oresNode = OresHelper.createOLATResourceableInstance("CourseNode", Long.valueOf(courseNode.getIdent()));
    List<ContextEntry> ces = new ArrayList<ContextEntry>();
    ces.add(BusinessControlFactory.getInstance().createContextEntry(re));
    ces.add(BusinessControlFactory.getInstance().createContextEntry(oresNode));
    String extLink = BusinessControlFactory.getInstance().getAsURIString(ces, false);
    String iconCssClass = CourseNodeFactory.getInstance().getCourseNodeConfiguration(courseNode.getType()).getIconCSSClass();
    KalendarEventLink link = new KalendarEventLink("COURSE", courseNode.getIdent(), courseNode.getShortTitle(), extLink, iconCssClass);
    kalendarEventLinks.clear();
    kalendarEventLinks.add(link);
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink) RepositoryEntry(org.olat.repository.RepositoryEntry) ContextEntry(org.olat.core.id.context.ContextEntry)

Aggregations

KalendarEventLink (org.olat.commons.calendar.model.KalendarEventLink)32 ArrayList (java.util.ArrayList)14 Kalendar (org.olat.commons.calendar.model.Kalendar)6 KalendarEvent (org.olat.commons.calendar.model.KalendarEvent)6 Date (java.util.Date)4 HashSet (java.util.HashSet)4 PropertyList (net.fortuna.ical4j.model.PropertyList)4 Contact (net.fortuna.ical4j.model.property.Contact)4 Created (net.fortuna.ical4j.model.property.Created)4 Description (net.fortuna.ical4j.model.property.Description)4 ExDate (net.fortuna.ical4j.model.property.ExDate)4 LastModified (net.fortuna.ical4j.model.property.LastModified)4 Location (net.fortuna.ical4j.model.property.Location)4 RecurrenceId (net.fortuna.ical4j.model.property.RecurrenceId)4 Uid (net.fortuna.ical4j.model.property.Uid)4 XProperty (net.fortuna.ical4j.model.property.XProperty)4 GenericTreeNode (org.olat.core.gui.components.tree.GenericTreeNode)4 TreeNode (org.olat.core.gui.components.tree.TreeNode)3 OLATResourceable (org.olat.core.id.OLATResourceable)3 ContextEntry (org.olat.core.id.context.ContextEntry)3