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