From dc27e180e53c40bd1b1e516e0737c52ea3b88ccd Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Thu, 28 Jun 2012 08:18:36 +0200
Subject: [PATCH] OMA-78: implement REST API for calendar

---
 .../commons/calendar/restapi/CalendarVO.java  | 22 ++++++++--
 .../calendar/restapi/CalendarWebService.java  |  8 +++-
 .../commons/calendar/restapi/EventVO.java     | 43 +++++++++++++++++--
 3 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/olat/commons/calendar/restapi/CalendarVO.java b/src/main/java/org/olat/commons/calendar/restapi/CalendarVO.java
index ab258957059..a98c2e86627 100644
--- a/src/main/java/org/olat/commons/calendar/restapi/CalendarVO.java
+++ b/src/main/java/org/olat/commons/calendar/restapi/CalendarVO.java
@@ -34,6 +34,9 @@ public class CalendarVO {
 	private String type;
 	private boolean subscribed;
 	
+	private String css;
+	private String displayName;
+	
 	public CalendarVO() {
 		//
 	}
@@ -42,6 +45,8 @@ public class CalendarVO {
 		id = wrapper.getKalendar().getType() + "_" + wrapper.getKalendar().getCalendarID();
 		subscribed = wrapper.isSubscribed();
 		type = wrapper.getKalendar().getType();
+		css = wrapper.getKalendarConfig().getCss();
+		displayName = wrapper.getKalendarConfig().getDisplayName();
 	}
 	
 	public String getId() {
@@ -67,9 +72,20 @@ public class CalendarVO {
 	public void setSubscribed(boolean subscribed) {
 		this.subscribed = subscribed;
 	}
-	
 
-	
-	
+	public String getCss() {
+		return css;
+	}
 
+	public void setCss(String css) {
+		this.css = css;
+	}
+
+	public String getDisplayName() {
+		return displayName;
+	}
+
+	public void setDisplayName(String displayName) {
+		this.displayName = displayName;
+	}
 }
diff --git a/src/main/java/org/olat/commons/calendar/restapi/CalendarWebService.java b/src/main/java/org/olat/commons/calendar/restapi/CalendarWebService.java
index 09a5a520ea1..b131cd9350a 100644
--- a/src/main/java/org/olat/commons/calendar/restapi/CalendarWebService.java
+++ b/src/main/java/org/olat/commons/calendar/restapi/CalendarWebService.java
@@ -174,23 +174,29 @@ public class CalendarWebService {
 		if(event.getId() == null) {
 			String id = UUID.randomUUID().toString();
 			KalendarEvent kalEvent = new KalendarEvent(id, event.getSubject(), event.getBegin(), event.getEnd());
+			transfer(event, kalEvent);
 			calendarManager.addEventTo(calendar.getKalendar(), kalEvent);
 		} else {
 			KalendarEvent kalEvent = calendar.getKalendar().getEvent(event.getId());
 			if(kalEvent == null) {
 				kalEvent = new KalendarEvent(event.getId(), event.getSubject(), event.getBegin(), event.getEnd());
+				transfer(event, kalEvent);
 				calendarManager.addEventTo(calendar.getKalendar(), kalEvent);
 			} else {
 				kalEvent.setBegin(event.getBegin());
 				kalEvent.setEnd(event.getEnd());
 				kalEvent.setSubject(event.getSubject());
-				kalEvent.setDescription(event.getDescription());
+				transfer(event, kalEvent);
 			}
 		}
 
 		return Response.ok().build();
 	}
 	
+	private void transfer(EventVO event, KalendarEvent kalEvent) {
+		kalEvent.setDescription(event.getDescription());
+		kalEvent.setLocation(event.getLocation());
+	}
 	
 	@GET
 	@Path("events")
diff --git a/src/main/java/org/olat/commons/calendar/restapi/EventVO.java b/src/main/java/org/olat/commons/calendar/restapi/EventVO.java
index 9fff994bcb1..dbf162d0c3e 100644
--- a/src/main/java/org/olat/commons/calendar/restapi/EventVO.java
+++ b/src/main/java/org/olat/commons/calendar/restapi/EventVO.java
@@ -34,10 +34,15 @@ public class EventVO {
 	private String id;
 	private String subject;
 	private String description;
+	private String location;
+	private String calendarId;
 	
 	private Date begin;
 	private Date end;
 	
+	private Date creationDate;
+	private String createdBy;
+	
 	public EventVO() {
 		//
 	}
@@ -46,9 +51,11 @@ public class EventVO {
 		id = event.getID();
 		subject = event.getSubject();
 		description = event.getDescription();
-		
+		location = event.getLocation();
 		begin = event.getBegin();
 		end = event.getEnd();
+		calendarId = event.getCalendar().getType() + "_" + event.getCalendar().getCalendarID();
+		creationDate = new Date(event.getCreated());
 	}
 
 	public String getId() {
@@ -75,6 +82,14 @@ public class EventVO {
 		this.description = description;
 	}
 
+	public String getLocation() {
+		return location;
+	}
+
+	public void setLocation(String location) {
+		this.location = location;
+	}
+
 	public Date getBegin() {
 		return begin;
 	}
@@ -90,8 +105,28 @@ public class EventVO {
 	public void setEnd(Date end) {
 		this.end = end;
 	}
-	
-	
-	
 
+	public Date getCreationDate() {
+		return creationDate;
+	}
+
+	public void setCreationDate(Date creationDate) {
+		this.creationDate = creationDate;
+	}
+
+	public String getCreatedBy() {
+		return createdBy;
+	}
+
+	public void setCreatedBy(String createdBy) {
+		this.createdBy = createdBy;
+	}
+
+	public String getCalendarId() {
+		return calendarId;
+	}
+
+	public void setCalendarId(String calendarId) {
+		this.calendarId = calendarId;
+	}
 }
-- 
GitLab