Search in sources :

Example 31 with KalendarEventLink

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

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

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

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)

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