Search in sources :

Example 16 with KalendarEventLink

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

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 17 with KalendarEventLink

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

the class CourseLinkProviderController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    List<KalendarEventLink> kalendarEventLinks = kalendarEvent.getKalendarEventLinks();
    TreeNode rootNode = courseNodeTreeModel.getRootNode();
    for (Iterator<KalendarEventLink> linkIt = kalendarEventLinks.iterator(); linkIt.hasNext(); ) {
        KalendarEventLink link = linkIt.next();
        if (COURSE_LINK_PROVIDER.equals(link.getProvider())) {
            linkIt.remove();
        }
    }
    clearSelection(rootNode);
    Collection<String> nodeIds = multiSelectTree.getSelectedKeys();
    rebuildKalendarEventLinks(rootNode, nodeIds, kalendarEventLinks);
    // the calendar event.
    if (kalendarEvent.getCalendar() != null) {
        calendarManager.updateEventFrom(kalendarEvent.getCalendar(), kalendarEvent);
    }
    fireEvent(ureq, Event.DONE_EVENT);
}
Also used : GenericTreeNode(org.olat.core.gui.components.tree.GenericTreeNode) TreeNode(org.olat.core.gui.components.tree.TreeNode) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink)

Example 18 with KalendarEventLink

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

the class CourseLinkProviderController method rebuildKalendarEventLinks.

private void rebuildKalendarEventLinks(INode node, Collection<String> selectedNodeIDs, List<KalendarEventLink> kalendarEventLinks) {
    if (selectedNodeIDs.contains(node.getIdent()) && node instanceof LinkTreeNode) {
        // assemble link
        LinkTreeNode treeNode = (LinkTreeNode) node;
        OLATResourceable courseOres = treeNode.getCourse();
        if (courseOres != null) {
            RepositoryEntry re = RepositoryManager.getInstance().lookupRepositoryEntry(courseOres, true);
            List<ContextEntry> ces = new ArrayList<ContextEntry>();
            ces.add(BusinessControlFactory.getInstance().createContextEntry(re));
            if (treeNode.getCourseNode() != null) {
                String courseNodeId = treeNode.getCourseNode().getIdent();
                OLATResourceable oresNode = OresHelper.createOLATResourceableInstance("CourseNode", Long.valueOf(courseNodeId));
                ces.add(BusinessControlFactory.getInstance().createContextEntry(oresNode));
            }
            String extLink = BusinessControlFactory.getInstance().getAsURIString(ces, false);
            KalendarEventLink link = new KalendarEventLink(COURSE_LINK_PROVIDER, node.getIdent(), treeNode.getTitle(), extLink, treeNode.getIconCssClass());
            kalendarEventLinks.add(link);
            treeNode.setSelected(true);
        }
    }
    for (int i = 0; i < node.getChildCount(); i++) {
        rebuildKalendarEventLinks(node.getChildAt(i), selectedNodeIDs, kalendarEventLinks);
    }
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) RepositoryEntry(org.olat.repository.RepositoryEntry) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink) ContextEntry(org.olat.core.id.context.ContextEntry)

Example 19 with KalendarEventLink

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

the class CalendarDetailsController method renderEventLinks.

private List<LinkWrapper> renderEventLinks() {
    List<LinkWrapper> linkWrappers = new ArrayList<>();
    List<KalendarEventLink> kalendarEventLinks = calEvent.getKalendarEventLinks();
    if (kalendarEventLinks != null && !kalendarEventLinks.isEmpty()) {
        String rootUri = Settings.getServerContextPathURI();
        for (KalendarEventLink link : kalendarEventLinks) {
            LinkWrapper wrapper = new LinkWrapper();
            String uri = link.getURI();
            String iconCssClass = link.getIconCssClass();
            if (!StringHelper.containsNonWhitespace(iconCssClass)) {
                String displayName = link.getDisplayName();
                iconCssClass = CSSHelper.createFiletypeIconCssClassFor(displayName);
            }
            wrapper.setUri(uri);
            wrapper.setDisplayName(link.getDisplayName());
            wrapper.setTitle(StringEscapeUtils.escapeHtml(link.getDisplayName()));
            if (StringHelper.containsNonWhitespace(iconCssClass)) {
                wrapper.setCssClass(iconCssClass);
            }
            if (uri.startsWith(rootUri)) {
                // intern link with absolute URL
                wrapper.setIntern(true);
            } else if (uri.contains("://")) {
                // extern link with absolute URL
                wrapper.setIntern(false);
            } else {
                wrapper.setIntern(true);
            }
            if (wrapper.isIntern()) {
                Link ooLink = LinkFactory.createLink("link-intern-" + CodeHelper.getRAMUniqueID(), "intern.link", getTranslator(), mainVC, this, Link.NONTRANSLATED);
                ooLink.setCustomDisplayText(StringHelper.escapeHtml(link.getDisplayName()));
                ooLink.setUserObject(wrapper);
                if (StringHelper.containsNonWhitespace(wrapper.getCssClass())) {
                    ooLink.setIconLeftCSS("o_icon ".concat(wrapper.getCssClass()));
                }
                wrapper.setLink(ooLink);
            }
            linkWrappers.add(wrapper);
        }
    }
    return linkWrappers;
}
Also used : ArrayList(java.util.ArrayList) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink) Link(org.olat.core.gui.components.link.Link)

Example 20 with KalendarEventLink

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

the class MediaLinksController method formInnerEvent.

@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    if (source == newButton) {
        String id = UUID.randomUUID().toString().replaceAll("-", "");
        KalendarEventLink link = new KalendarEventLink(provider, id, "", "", "");
        LinkWrapper linkWrapper = new LinkWrapper(link);
        externalLinks.add(linkWrapper);
        addNewFormLink(linkWrapper, linksContainer);
    } else if (source.getUserObject() instanceof LinkWrapper) {
        currentLink = (LinkWrapper) source.getUserObject();
        if (currentLink.getDelButton().equals(source)) {
            externalLinks.remove(currentLink);
        } else if (currentLink.getAddButton().equals(source)) {
            int index = externalLinks.indexOf(currentLink);
            LinkWrapper newLinkWrapper = createLinkWrapper();
            addNewFormLink(newLinkWrapper, linksContainer);
            if (index >= 0 && index + 1 < externalLinks.size()) {
                externalLinks.add(index + 1, newLinkWrapper);
            } else {
                externalLinks.add(newLinkWrapper);
            }
        } else if (currentLink.getMediaButton().equals(source)) {
            removeAsListenerAndDispose(mediaDialogBox);
            mediaDialogBox = new CloseableModalController(getWindowControl(), translate("choose"), mediaChooserController.getInitialComponent());
            mediaDialogBox.activate();
            listenTo(mediaDialogBox);
        }
    }
}
Also used : CloseableModalController(org.olat.core.gui.control.generic.closablewrapper.CloseableModalController) KalendarEventLink(org.olat.commons.calendar.model.KalendarEventLink)

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