use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class CollaborationTools method createCalendarController.
/**
* Creates a calendar controller
* @param ureq
* @param wControl
* @param resourceableId
* @return Configured WeeklyCalendarController
*/
public CalendarController createCalendarController(UserRequest ureq, WindowControl wControl, BusinessGroup businessGroup, boolean isAdmin, boolean isMember) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
KalendarRenderWrapper calRenderWrapper = collaborationManager.getCalendar(businessGroup, ureq, isAdmin);
calRenderWrapper.setPrivateEventsVisible(isAdmin || isMember);
// add linking
List<RepositoryEntry> repoEntries = CoreSpringFactory.getImpl(BusinessGroupService.class).findRepositoryEntries(Collections.singleton(businessGroup), 0, -1);
List<ICourse> courses = new ArrayList<>(repoEntries.size());
for (RepositoryEntry repoEntry : repoEntries) {
if (repoEntry.getOlatResource().getResourceableTypeName().equals(CourseModule.getCourseTypeName())) {
ICourse course = CourseFactory.loadCourse(repoEntry);
courses.add(course);
}
}
if (!courses.isEmpty()) {
CourseLinkProviderController clp = new CourseLinkProviderController(null, courses, ureq, wControl);
calRenderWrapper.setLinkProvider(clp);
}
List<KalendarRenderWrapper> calendars = new ArrayList<>();
calendars.add(calRenderWrapper);
return new WeeklyCalendarController(ureq, wControl, calendars, WeeklyCalendarController.CALLER_COLLAB, businessGroup, false);
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class CopyEventToCalendarController method formOK.
@Override
protected void formOK(UserRequest ureq) {
for (MultipleSelectionElement copyEl : copyEls) {
if (copyEl.isEnabled() && copyEl.isAtLeastSelected(1)) {
KalendarRenderWrapper calendarWrapper = (KalendarRenderWrapper) copyEl.getUserObject();
Kalendar cal = calendarWrapper.getKalendar();
KalendarEvent clonedKalendarEvent = (KalendarEvent) XStreamHelper.xstreamClone(kalendarEvent);
if (clonedKalendarEvent.getKalendarEventLinks().size() > 0) {
clonedKalendarEvent.setKalendarEventLinks(new ArrayList<KalendarEventLink>());
}
calendarManager.addEventTo(cal, clonedKalendarEvent);
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project openolat by klemens.
the class CopyEventToCalendarController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
setFormTitle("cal.copy.title");
copyEls = new ArrayList<>(calendars.size());
for (KalendarRenderWrapper calendarWrapper : calendars) {
String calId = calendarWrapper.getKalendar().getCalendarID();
String value = calendarWrapper.getDisplayName();
MultipleSelectionElement copyEl = uifactory.addCheckboxesHorizontal("cal_" + calId, null, formLayout, copy, new String[] { value });
copyEl.setUserObject(calendarWrapper);
if (calendarWrapper.getKalendar().getCalendarID().equals(kalendarEvent.getCalendar().getCalendarID())) {
// this is the calendar, the event comes from
copyEl.select(copy[0], true);
copyEl.setEnabled(false);
} else {
copyEl.setEnabled(calendarWrapper.getAccess() == KalendarRenderWrapper.ACCESS_READ_WRITE);
}
}
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.
the class CalendarTest method testDeletePersonalCalendarEvents.
@Test
public void testDeletePersonalCalendarEvents() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login(id2.getName(), "A6B7C8"));
// check if the event is saved
KalendarRenderWrapper calendarWrapper = calendarManager.getPersonalCalendar(id2);
KalendarEvent kalEvent = new KalendarEvent(UUID.randomUUID().toString(), null, "Rendez-vous", new Date(), new Date());
calendarManager.addEventTo(calendarWrapper.getKalendar(), kalEvent);
URI eventUri = UriBuilder.fromUri(getContextURI()).path("users").path(id2.getKey().toString()).path("calendars").path("user_" + calendarWrapper.getKalendar().getCalendarID()).path("events").path(kalEvent.getID()).build();
HttpDelete delEventMethod = conn.createDelete(eventUri, MediaType.APPLICATION_JSON);
HttpResponse delEventResponse = conn.execute(delEventMethod);
assertEquals(200, delEventResponse.getStatusLine().getStatusCode());
EntityUtils.consume(delEventResponse.getEntity());
conn.shutdown();
// check if the event is saved
Collection<KalendarEvent> savedEvents = calendarWrapper.getKalendar().getEvents();
for (KalendarEvent savedEvent : savedEvents) {
Assert.assertFalse(savedEvent.getID().equals(kalEvent.getID()));
}
}
use of org.olat.commons.calendar.ui.components.KalendarRenderWrapper in project OpenOLAT by OpenOLAT.
the class CalendarTest method putCalendarEvent.
@Test
public void putCalendarEvent() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
assertTrue(conn.login(id2.getName(), "A6B7C8"));
URI calUri = UriBuilder.fromUri(getContextURI()).path("users").path(id2.getKey().toString()).path("calendars").build();
HttpGet calMethod = conn.createGet(calUri, MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(calMethod);
assertEquals(200, response.getStatusLine().getStatusCode());
List<CalendarVO> vos = parseArray(response);
assertNotNull(vos);
assertTrue(2 <= vos.size());
CalendarVO calendar = getCourseCalendar(vos, course2);
Assert.assertNotNull(calendar);
// create an event
EventVO event = new EventVO();
Calendar cal = Calendar.getInstance();
event.setBegin(cal.getTime());
cal.add(Calendar.HOUR_OF_DAY, 1);
event.setEnd(cal.getTime());
String subject = UUID.randomUUID().toString();
event.setSubject(subject);
URI eventUri = UriBuilder.fromUri(getContextURI()).path("users").path(id2.getKey().toString()).path("calendars").path(calendar.getId()).path("event").build();
HttpPut putEventMethod = conn.createPut(eventUri, MediaType.APPLICATION_JSON, true);
conn.addJsonEntity(putEventMethod, event);
HttpResponse putEventResponse = conn.execute(putEventMethod);
assertEquals(200, putEventResponse.getStatusLine().getStatusCode());
EntityUtils.consume(putEventResponse.getEntity());
// check if the event is saved
KalendarRenderWrapper calendarWrapper = calendarManager.getCourseCalendar(course2);
Collection<KalendarEvent> savedEvents = calendarWrapper.getKalendar().getEvents();
boolean found = false;
for (KalendarEvent savedEvent : savedEvents) {
if (subject.equals(savedEvent.getSubject())) {
found = true;
}
}
Assert.assertTrue(found);
conn.shutdown();
}
Aggregations