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);
}
}
}
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);
}
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);
}
}
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;
}
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);
}
}
}
Aggregations