diff --git a/src/main/java/org/jasig/portlet/calendar/adapter/CalendarEventsDao.java b/src/main/java/org/jasig/portlet/calendar/adapter/CalendarEventsDao.java index e5259bca..3922800e 100644 --- a/src/main/java/org/jasig/portlet/calendar/adapter/CalendarEventsDao.java +++ b/src/main/java/org/jasig/portlet/calendar/adapter/CalendarEventsDao.java @@ -120,7 +120,8 @@ public Set getEvents( CalendarConfiguration calendar, Interval interval, PortletRequest request, - DateTimeZone usersConfiguredDateTimeZone) { + DateTimeZone usersConfiguredDateTimeZone, + int calendarIndex) { // Get the set of calendar events for the requested period. // We invoke the adapter before checking cache because we expect the adapter @@ -159,7 +160,7 @@ public Set getEvents( for (VEvent event : eventSet.getEvents()) { try { displayEvents.addAll( - getDisplayEvents(event, interval, request.getLocale(), usersConfiguredDateTimeZone)); + getDisplayEvents(event, interval, request.getLocale(), usersConfiguredDateTimeZone, calendarIndex)); } catch (ParseException e) { log.error("Exception parsing event", e); } catch (IOException e) { @@ -214,7 +215,7 @@ public Set getEvents( * @throws ParseException */ protected Set getDisplayEvents( - VEvent e, Interval interval, Locale locale, DateTimeZone usersConfiguredDateTimeZone) + VEvent e, Interval interval, Locale locale, DateTimeZone usersConfiguredDateTimeZone, int calendarIndex) throws IOException, URISyntaxException, ParseException { final VEvent event = (VEvent) e.copy(); @@ -280,7 +281,7 @@ protected Set getDisplayEvents( */ if (theSpecificDay.getStart().isEqual(eventStart) || theSpecificDay.overlaps(eventInterval)) { final CalendarDisplayEvent json = - new CalendarDisplayEvent(event, eventInterval, theSpecificDay, df, tf); + new CalendarDisplayEvent(event, eventInterval, theSpecificDay, df, tf, calendarIndex); events.add(json); } diff --git a/src/main/java/org/jasig/portlet/calendar/mvc/CalendarDisplayEvent.java b/src/main/java/org/jasig/portlet/calendar/mvc/CalendarDisplayEvent.java index 7b271375..0ec1079a 100644 --- a/src/main/java/org/jasig/portlet/calendar/mvc/CalendarDisplayEvent.java +++ b/src/main/java/org/jasig/portlet/calendar/mvc/CalendarDisplayEvent.java @@ -52,6 +52,8 @@ public class CalendarDisplayEvent implements Comparable { private final String startDate; private final String endDate; + private final int calendarIndex; + /** * Constructs an object from specified data. * @@ -66,7 +68,8 @@ public CalendarDisplayEvent( Interval eventInterval, Interval theSpecificDay, DateTimeFormatter df, - DateTimeFormatter tf) { + DateTimeFormatter tf, + int calendarIndex) { assert theSpecificDay.abuts(eventInterval) || theSpecificDay.overlaps(eventInterval) : "Event interval is not in the specified day!"; @@ -74,6 +77,8 @@ public CalendarDisplayEvent( this.description = event.getDescription() != null ? event.getDescription().getValue() : null; this.location = event.getLocation() != null ? event.getLocation().getValue() : null; + this.calendarIndex = calendarIndex; + boolean multi = false; if (eventInterval.getStart().isBefore(theSpecificDay.getStart())) { dayStart = theSpecificDay.getStart(); @@ -162,6 +167,8 @@ public DateTime getDayEnd() { return this.dayEnd; } + public int getCalendarIndex(){ return this.calendarIndex; } + public int compareTo(CalendarDisplayEvent event) { // Order events by start date, then end date, then summary. // If all properties are equal, use the calendar and event ids to diff --git a/src/main/java/org/jasig/portlet/calendar/mvc/CalendarHelper.java b/src/main/java/org/jasig/portlet/calendar/mvc/CalendarHelper.java index dbc4d595..209caf8f 100644 --- a/src/main/java/org/jasig/portlet/calendar/mvc/CalendarHelper.java +++ b/src/main/java/org/jasig/portlet/calendar/mvc/CalendarHelper.java @@ -97,6 +97,7 @@ public Set getEventList( DateTimeZone tz = DateTimeZone.forID(timezone); Set events = new TreeSet(); + int calendarIndex=0; //to keep the color of the calendar consistent with the order in the main controller for (CalendarConfiguration callisting : calendars) { // don't bother to fetch hidden calendars if (hiddenCalendars.get(callisting.getId()) == null) { @@ -105,7 +106,7 @@ public Set getEventList( ICalendarAdapter adapter = (ICalendarAdapter) applicationContext.getBean(callisting.getCalendarDefinition().getClassName()); - events.addAll(calendarEventsDao.getEvents(adapter, callisting, interval, request, tz)); + events.addAll(calendarEventsDao.getEvents(adapter, callisting, interval, request, tz, calendarIndex)); } catch (NoSuchBeanDefinitionException ex) { log.error("Calendar class instance could not be found: " + ex.getMessage()); } catch (UserFeedbackCalendarException sce) { @@ -123,6 +124,7 @@ public Set getEventList( + "\" is currently unavailable."); } } + calendarIndex++; } return events; } diff --git a/src/main/java/org/jasig/portlet/calendar/mvc/controller/AjaxCalendarController.java b/src/main/java/org/jasig/portlet/calendar/mvc/controller/AjaxCalendarController.java index a80abfd6..fc2fa9b2 100644 --- a/src/main/java/org/jasig/portlet/calendar/mvc/controller/AjaxCalendarController.java +++ b/src/main/java/org/jasig/portlet/calendar/mvc/controller/AjaxCalendarController.java @@ -106,10 +106,10 @@ public ModelAndView getEventList(ResourceRequest request, ResourceResponse respo final Set calendarEvents = helper.getEventList(errors, interval, request); - int index = 0; + final Set events = new TreeSet(); for (CalendarDisplayEvent e : calendarEvents) { - events.add(new JsonCalendarEventWrapper(e, index++)); + events.add(new JsonCalendarEventWrapper(e, e.getCalendarIndex())); } /* diff --git a/src/main/webapp/less/_base.less b/src/main/webapp/less/_base.less index 3dff0082..8ba05ba7 100644 --- a/src/main/webapp/less/_base.less +++ b/src/main/webapp/less/_base.less @@ -110,82 +110,166 @@ margin-bottom: 15px; } +@color-0:#1062a5; +@color-1:#2ca200; +@color-2:#990000; +@color-3:#683099; +@color-4:#824100; +@color-5:#008b78; +@color-6:#d62876; +@color-7:#bb5b1d; +@color-8:#7b7b7b; +@color-9:#000000; +@color-10:#cfca00; +@color-11:#002aa2; +@color-12:#BB0000; +@color-13:#8800d6; +@color-14:#be8219; +@color-15:#04a5b4; +@color-16:#b6479b; +@color-17:#ff7321; + .color-0, a.color-0 { - color: #1062a5; + color: @color-0; } .color-1, a.color-1 { - color: #477300; + color: @color-1; } .color-2, a.color-2 { - color: #990000; + color: @color-2; } .color-3, a.color-3 { - color: #683099; + color: @color-3; } .color-4, a.color-4 { - color: #8b4500; + color: @color-4; } .color-5, a.color-5 { - color: #008b78; + color: @color-5; } .color-6, a.color-6 { - color: #b62162; + color: @color-6; } .color-7, a.color-7 { - color: #bb5b1d; + color: @color-7; } .color-8, a.color-8 { - color: #7b7b7b; + color: @color-8; } .color-9, a.color-9 { - color: #000000; + color: @color-9; +} + +.color-10, a.color-10 { + color: @color-10; +} + +.color-11, a.color-11 { + color: @color-11; +} + +.color-12, a.color-12 { + color: @color-12; +} + +.color-13, a.color-13 { + color: @color-13; +} + +.color-14, a.color-14 { + color: @color-14; +} + +.color-15, a.color-15 { + color: @color-15; +} + +.color-16, a.color-16 { + color: @color-16; +} + +.color-17, a.color-17 { + color: @color-17; } + .upcal-color-0 .upcal-event-cal { - background-color: #1062a5; + background-color: @color-0; } .upcal-color-1 .upcal-event-cal { - background-color: #477300; + background-color: @color-1; } .upcal-color-2 .upcal-event-cal { - background-color: #990000; + background-color: @color-2; } .upcal-color-3 .upcal-event-cal { - background-color: #683099; + background-color: @color-3; } .upcal-color-4 .upcal-event-cal { - background-color: #8b4500; + background-color: @color-4; } .upcal-color-5 .upcal-event-cal { - background-color: #008b78; + background-color: @color-5; } .upcal-color-6 .upcal-event-cal { - background-color: #b62162; + background-color: @color-6; } .upcal-color-7 .upcal-event-cal { - background-color: #bb5b1d; + background-color: @color-7; } .upcal-color-8 .upcal-event-cal { - background-color: #7b7b7b; + background-color: @color-8; } .upcal-color-9 .upcal-event-cal { - background-color: #000000; + background-color: @color-9; +} + +.upcal-color-10 .upcal-event-cal { + background-color: @color-10; +} + +.upcal-color-11 .upcal-event-cal { + background-color: @color-11; +} + +.upcal-color-12 .upcal-event-cal { + background-color: @color-12; +} + +.upcal-color-13 .upcal-event-cal { + background-color: @color-13; +} + +.upcal-color-14 .upcal-event-cal { + background-color: @color-14; +} + +.upcal-color-15 .upcal-event-cal { + background-color: @color-15; +} + +.upcal-color-16 .upcal-event-cal { + background-color: @color-16; +} + +.upcal-color-17 .upcal-event-cal { + background-color: @color-17; } \ No newline at end of file diff --git a/src/test/java/org/jasig/portlet/calendar/adapter/CalendarEventDaoTest.java b/src/test/java/org/jasig/portlet/calendar/adapter/CalendarEventDaoTest.java index f7733632..fe7df3fa 100644 --- a/src/test/java/org/jasig/portlet/calendar/adapter/CalendarEventDaoTest.java +++ b/src/test/java/org/jasig/portlet/calendar/adapter/CalendarEventDaoTest.java @@ -109,7 +109,9 @@ public void testGetDisplayEvents() throws IOException, URISyntaxException, Parse DateMidnight intervalStop = new DateMidnight(2012, 1, 5, tz); Interval interval = new Interval(intervalStart, intervalStop); - Set events = eventDao.getDisplayEvents(event, interval, Locale.US, tz); + int calendarIndex=0; + + Set events = eventDao.getDisplayEvents(event, interval, Locale.US, tz,calendarIndex); assertEquals(1, events.size()); } @@ -134,7 +136,9 @@ public void testGetDisplayEventsSameStartEnd() throws Exception { DateMidnight intervalStop = new DateMidnight(2012, 1, 31, tz); Interval interval = new Interval(intervalStart, intervalStop); - Set events = eventDao.getDisplayEvents(event, interval, Locale.US, tz); + int calendarIndex=0; + + Set events = eventDao.getDisplayEvents(event, interval, Locale.US, tz, calendarIndex); assertEquals(1, events.size()); } @@ -155,7 +159,9 @@ public void testGetDisplayEventsForLongEvent() DateMidnight intervalStop = new DateMidnight(2012, 1, 5, tz); Interval interval = new Interval(intervalStart, intervalStop); - Set events = eventDao.getDisplayEvents(event, interval, Locale.US, tz); + int calendarIndex=0; + + Set events = eventDao.getDisplayEvents(event, interval, Locale.US, tz, calendarIndex); assertEquals(2, events.size()); } @@ -174,7 +180,9 @@ public void testGetDisplayEventsForNoEndDate() DateMidnight intervalStop = new DateMidnight(2012, 1, 5, tz); Interval interval = new Interval(intervalStart, intervalStop); - Set events = eventDao.getDisplayEvents(event, interval, Locale.US, tz); + int calendarIndex=0; + + Set events = eventDao.getDisplayEvents(event, interval, Locale.US, tz, calendarIndex); assertEquals(1, events.size()); } @@ -193,7 +201,9 @@ public void testGetDisplayEventsForNoEndDateStartAbutment() DateMidnight intervalStop = new DateMidnight(2012, 1, 5, tz); Interval interval = new Interval(intervalStart, intervalStop); - Set events = eventDao.getDisplayEvents(event, interval, Locale.US, tz); + int calendarIndex=0; + + Set events = eventDao.getDisplayEvents(event, interval, Locale.US, tz, calendarIndex); assertEquals(1, events.size()); } diff --git a/src/test/java/org/jasig/portlet/calendar/adapter/CalendarEventsDaoIntegrationTest.java b/src/test/java/org/jasig/portlet/calendar/adapter/CalendarEventsDaoIntegrationTest.java index 9f1f2dad..f5fb47f2 100644 --- a/src/test/java/org/jasig/portlet/calendar/adapter/CalendarEventsDaoIntegrationTest.java +++ b/src/test/java/org/jasig/portlet/calendar/adapter/CalendarEventsDaoIntegrationTest.java @@ -82,8 +82,10 @@ public void testGetEvents() throws IOException, URISyntaxException, ParseExcepti List displayEvents = new ArrayList(); + int calendarIndex=0; + for (VEvent event : events) { - displayEvents.addAll(eventsDao.getDisplayEvents(event, interval, Locale.US, tz)); + displayEvents.addAll(eventsDao.getDisplayEvents(event, interval, Locale.US, tz, calendarIndex)); } Collections.sort(displayEvents); @@ -109,8 +111,10 @@ public void testGetEventsAlternateTimezone() List displayEvents = new ArrayList(); + int calendarIndex=0; + for (VEvent event : events) { - displayEvents.addAll(eventsDao.getDisplayEvents(event, interval, Locale.US, tz)); + displayEvents.addAll(eventsDao.getDisplayEvents(event, interval, Locale.US, tz, calendarIndex)); } Collections.sort(displayEvents); @@ -135,8 +139,10 @@ public void testGetArizonaEvent() throws IOException, URISyntaxException, ParseE List displayEvents = new ArrayList(); + int calendarIndex=0; + for (VEvent event : events) { - displayEvents.addAll(eventsDao.getDisplayEvents(event, interval, Locale.US, tz)); + displayEvents.addAll(eventsDao.getDisplayEvents(event, interval, Locale.US, tz, calendarIndex)); } Collections.sort(displayEvents); @@ -158,8 +164,10 @@ public void testGetUTCEvent() throws IOException, URISyntaxException, ParseExcep List displayEvents = new ArrayList(); + int calendarIndex=0; + for (VEvent event : events) { - displayEvents.addAll(eventsDao.getDisplayEvents(event, interval, Locale.US, tz)); + displayEvents.addAll(eventsDao.getDisplayEvents(event, interval, Locale.US, tz, calendarIndex)); } Collections.sort(displayEvents); @@ -181,8 +189,10 @@ public void testGetBedeworkEvent() throws IOException, URISyntaxException, Parse List displayEvents = new ArrayList(); + int calendarIndex=0; + for (VEvent event : events) { - displayEvents.addAll(eventsDao.getDisplayEvents(event, interval, Locale.US, tz)); + displayEvents.addAll(eventsDao.getDisplayEvents(event, interval, Locale.US, tz, calendarIndex)); } Collections.sort(displayEvents); diff --git a/src/test/java/org/jasig/portlet/calendar/mvc/JsonCalendarEventTest.java b/src/test/java/org/jasig/portlet/calendar/mvc/JsonCalendarEventTest.java index ce6302f8..8a25eaea 100644 --- a/src/test/java/org/jasig/portlet/calendar/mvc/JsonCalendarEventTest.java +++ b/src/test/java/org/jasig/portlet/calendar/mvc/JsonCalendarEventTest.java @@ -75,9 +75,11 @@ public void testStartDate() { "Test Event"); Interval eventInterval = new Interval(start, end); + int calendarIndex=0; + DateMidnight dateStart = new DateMidnight(date, tz); Interval day = new Interval(dateStart, dateStart.plusDays(1)); - CalendarDisplayEvent json = new CalendarDisplayEvent(event, eventInterval, day, df, tf); + CalendarDisplayEvent json = new CalendarDisplayEvent(event, eventInterval, day, df, tf, calendarIndex); assertEquals("4:00 AM", json.getDateStartTime()); assertEquals("12:00 AM", json.getDateEndTime()); assertEquals("Monday January 3", json.getStartDate()); @@ -88,14 +90,14 @@ public void testStartDate() { assertFalse(json.isAllDay()); day = new Interval(dateStart.plusDays(1), dateStart.plusDays(2)); - json = new CalendarDisplayEvent(event, eventInterval, day, df, tf); + json = new CalendarDisplayEvent(event, eventInterval, day, df, tf, calendarIndex); assertEquals("12:00 AM", json.getDateStartTime()); assertEquals("12:00 AM", json.getDateEndTime()); assertTrue(json.isMultiDay()); assertTrue(json.isAllDay()); day = new Interval(dateStart.plusDays(2), dateStart.plusDays(3)); - json = new CalendarDisplayEvent(event, eventInterval, day, df, tf); + json = new CalendarDisplayEvent(event, eventInterval, day, df, tf, calendarIndex); assertEquals("12:00 AM", json.getDateStartTime()); assertEquals("4:00 AM", json.getDateEndTime()); assertTrue(json.isMultiDay()); diff --git a/src/test/java/org/jasig/portlet/calendar/mvc/controller/AjaxCalendarControllerTest.java b/src/test/java/org/jasig/portlet/calendar/mvc/controller/AjaxCalendarControllerTest.java index 4180159e..d1903741 100644 --- a/src/test/java/org/jasig/portlet/calendar/mvc/controller/AjaxCalendarControllerTest.java +++ b/src/test/java/org/jasig/portlet/calendar/mvc/controller/AjaxCalendarControllerTest.java @@ -147,7 +147,9 @@ private CalendarDisplayEvent createEvent(org.joda.time.DateTime eventStart, Dura DateTimeFormatter timeFormatter = new DateTimeFormatterBuilder().appendPattern("HH:mm:ss").toFormatter(); + int calendarIndex=0; + return new CalendarDisplayEvent( - event, eventInterval, specificDayInterval, dateFormatter, timeFormatter); + event, eventInterval, specificDayInterval, dateFormatter, timeFormatter, calendarIndex); } }