[Building Sakai] Calendar Events for a site

David Wafula davidwaf at gmail.com
Fri Nov 4 06:59:51 PDT 2011


Thanks Joaquín,

This gave me exactly what i needed. I am afraid i might need same
directions with announcements, but will open a new thread if i get stuck.

david.


2011/11/4 Joaquín Marqués Alós <joaquin.marques.sakai at gmail.com>

> I use this code to get calendar events. This is an example of code:
>
>
> java.util.Calendar cal = new
> java.util.GregorianCalendar(getUserTimeZone(sessionManager.getCurrentSessionUserId()));
>
> long initTime = cal.getTimeInMillis();
> long duration = xxxx; /// period to get events. In milliseconds, but I am
> not sure exactly
>
> TimeRange range = timeService.newTimeRange(initTime, duration);
>
> String ref = calendarService.calendarReference(siteId,
> SiteService.MAIN_CONTAINER);
> Calendar c = calendarService.getCalendar(ref);
>
> for(CalendarEvent event : (List<CalendarEvent>)c.getEvents(range, null))
> {
>     ...
> }
>
>
> private TimeZone getUserTimeZone(String userId)
> {
>     TimeZone m_timeZone = null;
>
>     try
>     {
>         m_timeZone = TimeZone.getDefault();
>
>         Preferences preferences =
> preferencesService.getPreferences(userId);
>         ResourceProperties properties =
> preferences.getProperties(TimeService.APPLICATION_ID);
>         String timeZone = properties.getProperty(TimeService.TIMEZONE_KEY);
>
>         if (timeZone != null && !timeZone.equals(""))
>             m_timeZone = TimeZone.getTimeZone(timeZone);
>     }catch(Exception e)
>     {
>         log.warn("getUserTimeZone -> "+e);
>     }
>
>     return m_timeZone;
>
> }
>
>
> 2011/11/4 David Wafula <davidwaf at gmail.com>
>
>>
>> Thanks Steve. I do have all the javadocs. But i guess that still doesn't
>> really answer my question (probably i was not that clear). Take for
>> instance, javadocs say
>>
>> references - The List of calendar References
>>
>> I still battle to figure out where  to get valid values for this. In this
>> case,  a List is rather abstract.  I suppose i could could do with some
>> sample code, or some pointers where this method is used in a module
>> somewhere.
>>
>>
>> Regards,
>>
>> david.
>>
>>
>>
>> On Fri, Nov 4, 2011 at 12:14 AM, Steve Swinsburg <
>> steve.swinsburg at gmail.com> wrote:
>>
>>> Hi David,
>>>
>>> I recommend you build the javadocs for your Sakai source:
>>>
>>> mvn javadoc:javadoc -Daggregate=true
>>>
>>> getEvents
>>>
>>> CalendarEventVector *getEvents*(List <http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html?is-external=true> references,
>>>                               org.sakaiproject.time.api.TimeRange range)
>>>
>>> Takes several calendar References and merges their events from within a
>>> given time range.
>>>
>>> *Parameters:*references - The List of calendar References.range - The
>>> time period to use to select events.*Returns:* CalendarEventVector
>>> object with the union of all events from the list of calendars in the given
>>> time range.
>>>
>>> cheers,
>>> Steve
>>>
>>> On 04/11/2011, at 8:15 AM, David Wafula wrote:
>>>
>>> Team,
>>> I have CalendarService object instantiated correctly, via spring. I need
>>> to get calendar events for a site.
>>> I was thinking:
>>>
>>>  calendarService.getEvents(list, timerange)
>>>
>>> is it appropriate? If so, i need help with arguments to the method: what
>>> exactly is List ? And how do you instantiate TimeRange object ?
>>>
>>> Kind regards,
>>> --
>>> David Wafula
>>>  _______________________________________________
>>> sakai-dev mailing list
>>> sakai-dev at collab.sakaiproject.org
>>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>>
>>> TO UNSUBSCRIBE: send email to
>>> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
>>> "unsubscribe"
>>>
>>>
>>>
>>
>>
>> --
>> David Wafula
>>
>> _______________________________________________
>> sakai-dev mailing list
>> sakai-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>
>> TO UNSUBSCRIBE: send email to
>> sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of
>> "unsubscribe"
>>
>
>


-- 
David Wafula
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20111104/5faa6a1a/attachment.html 


More information about the sakai-dev mailing list