org.jasig.schedassist.model
Class DefaultEventUtilsImpl

java.lang.Object
  extended by org.jasig.schedassist.model.DefaultEventUtilsImpl
All Implemented Interfaces:
IEventUtils

public class DefaultEventUtilsImpl
extends Object
implements IEventUtils

Default IEventUtils implementation.

Author:
Nicholas Blair

Field Summary
static String ICAL_DATETIME_FORMAT
          Date/time format for iCalendar.
protected  org.apache.commons.logging.Log LOG
           
static net.fortuna.ical4j.model.property.ProdId PROD_ID
          ProdId attached to Calendars sent to the CalDAV server by the Scheduling Assistant.
 
Constructor Summary
DefaultEventUtilsImpl()
          Default constructor, sets the IAffiliationSource to the NullAffiliationSourceImpl implementation.
DefaultEventUtilsImpl(IAffiliationSource affiliationSource)
           
 
Method Summary
 boolean attendeeMatchesPerson(net.fortuna.ical4j.model.Property attendee, ICalendarAccount calendarAccount)
           
 net.fortuna.ical4j.model.PeriodList calculateRecurrence(net.fortuna.ical4j.model.component.VEvent event, Date startBoundary, Date endBoundary)
          Calculate recurrence dates for the specified events between the 2 date boundaries.
 net.fortuna.ical4j.model.component.VEvent constructAvailableAppointment(AvailableBlock block, IScheduleOwner owner, IScheduleVisitor visitor, String eventDescription)
          Construct an iCalendar EVENT for the Scheduling Assistant system.
 net.fortuna.ical4j.model.property.Organizer constructOrganizer(ICalendarAccount calendarAccount)
          Construct an Organizer property for the specified ICalendarAccount.
 net.fortuna.ical4j.model.property.Attendee constructSchedulingAssistantAttendee(ICalendarAccount calendarAccount, AppointmentRole role)
          Construct an Attendee property for the specified user and role.
protected  String constructSummaryValueForReflectionEvent(AvailableBlock block)
           
protected  net.fortuna.ical4j.model.component.VEvent convertBlockToReflectionEvent(AvailableBlock block)
          Convert the AvailableBlock into a VEvent that can be stored in the calendar system to represent that same block.
 List<net.fortuna.ical4j.model.Calendar> convertScheduleForReflection(AvailableSchedule availableSchedule)
          Convert the AvailableSchedule into an iCalendar Calendar for the purposes of reflection back into the calendar system.
static String convertToICalendarFormat(Date date)
          Helper method to convert the Date into the String representation required for iCalendar.
protected  net.fortuna.ical4j.model.property.Clazz determineAppropriateClassProperty(ICalendarAccount calendarAccount)
          Called by constructAvailableAppointment(AvailableBlock, IScheduleOwner, IScheduleVisitor, String); returns an appropriate Clazz depending on whether or not the ICalendarAccount is a resource account.
static URI emailToURI(String emailAddress)
          Convert the String argument to a mailto URI if possible.
 net.fortuna.ical4j.model.property.Uid extractUid(net.fortuna.ical4j.model.Calendar calendar)
          If the Calendar contains one and only one event (series), return the Uid.
 net.fortuna.ical4j.model.property.Uid generateNewUid()
          Generate a new Uid, intended for use with Scheduling Assistant VEvents.
 IAffiliationSource getAffiliationSource()
           
 net.fortuna.ical4j.model.Property getAttendeeForUserFromEvent(net.fortuna.ical4j.model.component.VEvent event, ICalendarAccount calendarUser)
          Walk through the attendee list in the VEvent argument.
 net.fortuna.ical4j.model.PropertyList getAttendeeListFromEvent(net.fortuna.ical4j.model.component.VEvent event)
          If the event is a Scheduling Assistant event, retrieve only the attendees on the event set by the Available system.
 String getEventClassForPersonOwners()
           
 String getEventClassForResourceOwners()
           
 Integer getEventVisitorLimit(net.fortuna.ical4j.model.component.VEvent event)
          If the event argument is an event created by the Scheduling Assistant, return the value of it's VisitorLimit property.
 int getScheduleVisitorCount(net.fortuna.ical4j.model.component.VEvent event)
          Return the number of Attendees in the event that have the role AppointmentRole.VISITOR.
protected  boolean isAllDayEvent(net.fortuna.ical4j.model.component.VEvent event)
           
protected  boolean isAllDayPeriod(net.fortuna.ical4j.model.Period period)
           
 boolean isAttendingAsOwner(net.fortuna.ical4j.model.component.VEvent event, ICalendarAccount proposedOwner)
           
 boolean isAttendingAsVisitor(net.fortuna.ical4j.model.component.VEvent event, ICalendarAccount proposedVisitor)
           
 boolean isAttendingMatch(net.fortuna.ical4j.model.component.VEvent event, IScheduleVisitor visitor, IScheduleOwner owner)
          Check the event to see if this event represents an existing available appointment that the visitor is "visiting" and the owner is "owning" (including the special case when visitor and owner are the same person) Will return true if the event's attendees match the roles passed in.
 boolean isEventRecurring(net.fortuna.ical4j.model.component.VEvent event)
           
static boolean isPartStatNeedsAction(net.fortuna.ical4j.model.Property attendee)
           
 void setEventClassForPersonOwners(String eventClassForPersonOwners)
           
 void setEventClassForResourceOwners(String eventClassForResourceOwners)
           
 boolean willEventCauseConflict(ICalendarAccount calendarAccount, net.fortuna.ical4j.model.component.VEvent event)
          This method defines our criteria for which VEvents will cause a conflict (either a red/busy block in the visible schedule or cause ConflictExistsExceptions).
 net.fortuna.ical4j.model.Calendar wrapEventInCalendar(net.fortuna.ical4j.model.component.VEvent event)
          Wrap the VEvent argument in a Calendar.
protected  net.fortuna.ical4j.model.Calendar wrapInternal(net.fortuna.ical4j.model.ComponentList components)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICAL_DATETIME_FORMAT

public static final String ICAL_DATETIME_FORMAT
Date/time format for iCalendar.

See Also:
Constant Field Values

PROD_ID

public static final net.fortuna.ical4j.model.property.ProdId PROD_ID
ProdId attached to Calendars sent to the CalDAV server by the Scheduling Assistant.


LOG

protected final org.apache.commons.logging.Log LOG
Constructor Detail

DefaultEventUtilsImpl

public DefaultEventUtilsImpl()
Default constructor, sets the IAffiliationSource to the NullAffiliationSourceImpl implementation.


DefaultEventUtilsImpl

public DefaultEventUtilsImpl(IAffiliationSource affiliationSource)
Parameters:
affiliationSource -
Method Detail

getAffiliationSource

public IAffiliationSource getAffiliationSource()
Returns:
the affiliationSource

getEventClassForPersonOwners

public String getEventClassForPersonOwners()
Returns:
the eventClassForPersonOwners

getEventClassForResourceOwners

public String getEventClassForResourceOwners()
Returns:
the eventClassForResourceOwners

setEventClassForPersonOwners

public void setEventClassForPersonOwners(String eventClassForPersonOwners)
Parameters:
eventClassForPersonOwners - the eventClassForPersonOwners to set

setEventClassForResourceOwners

public void setEventClassForResourceOwners(String eventClassForResourceOwners)
Parameters:
eventClassForResourceOwners - the eventClassForResourceOwners to set

attendeeMatchesPerson

public boolean attendeeMatchesPerson(net.fortuna.ical4j.model.Property attendee,
                                     ICalendarAccount calendarAccount)
Specified by:
attendeeMatchesPerson in interface IEventUtils
Returns:
true if the Property is an attendee that matches the ICalendarAccount

constructAvailableAppointment

public net.fortuna.ical4j.model.component.VEvent constructAvailableAppointment(AvailableBlock block,
                                                                               IScheduleOwner owner,
                                                                               IScheduleVisitor visitor,
                                                                               String eventDescription)
Description copied from interface: IEventUtils
Construct an iCalendar EVENT for the Scheduling Assistant system. The SUMMARY of the EVENT will start with the owner's MEETING_PREFIX preference and end with the full name of the visitor. The LOCATION of the EVENT will be set to the owner's location preference. The CLASS property will be set to "NORMAL". The STATUS property will be set to "CONFIRMED". If the owner and visitor represent the same person, only one ATTENDEE will be added, and will be marked with AppointmentRole#BOTH. Otherwise, owner and visitor will be added as ATTENDEEs with the corresponding AppointmentRole. The eventDescription argument will be added to the DESCRIPTION of the event. If the owner is detected as an academic advisor, and the visitor is a student, the student's "wiscedustudentid" value will be appended to the DESCRIPTION.

Specified by:
constructAvailableAppointment in interface IEventUtils
Parameters:
block - the selected AvailableBlock
owner - the owner of the appointment
visitor - the visitor to the appointment
eventDescription - text to enter into the DESCRIPTION property for the appointment
Returns:
the new event

determineAppropriateClassProperty

protected net.fortuna.ical4j.model.property.Clazz determineAppropriateClassProperty(ICalendarAccount calendarAccount)
Called by constructAvailableAppointment(AvailableBlock, IScheduleOwner, IScheduleVisitor, String); returns an appropriate Clazz depending on whether or not the ICalendarAccount is a resource account.

Parameters:
calendarAccount -
Returns:
an appropriate Clazz property to attach to the event

constructSchedulingAssistantAttendee

public net.fortuna.ical4j.model.property.Attendee constructSchedulingAssistantAttendee(ICalendarAccount calendarAccount,
                                                                                       AppointmentRole role)
Construct an Attendee property for the specified user and role. The PARTSTAT parameter will be set to ACCEPTED. The RSVP parameter will be set to FALSE. The X-UW-AVAILABLE-APPOINTMENT-ROLE parameter will be set according to the role argument. The CN parameter will be set to the ICalendarAccount's display name. The value will be a mailto address for the ICalendarAccount's email address.

Specified by:
constructSchedulingAssistantAttendee in interface IEventUtils
Returns:
an appropriate attendee property
See Also:
IEventUtils.constructSchedulingAssistantAttendee(org.jasig.schedassist.model.ICalendarAccount, org.jasig.schedassist.model.AppointmentRole)

constructOrganizer

public net.fortuna.ical4j.model.property.Organizer constructOrganizer(ICalendarAccount calendarAccount)
Construct an Organizer property for the specified ICalendarAccount.

Parameters:
calendarAccount -
Returns:
an Organizer property for the ICalendarAccount

getAttendeeForUserFromEvent

public net.fortuna.ical4j.model.Property getAttendeeForUserFromEvent(net.fortuna.ical4j.model.component.VEvent event,
                                                                     ICalendarAccount calendarUser)
Walk through the attendee list in the VEvent argument. Return the matching Attendee for the ICalendarAccount argument, or null if the ICalendarAccount is not in the attendee list.

Specified by:
getAttendeeForUserFromEvent in interface IEventUtils
Returns:
the matching attendee property, or null
See Also:
IEventUtils.attendeeMatchesPerson(Property, ICalendarAccount)

getAttendeeListFromEvent

public net.fortuna.ical4j.model.PropertyList getAttendeeListFromEvent(net.fortuna.ical4j.model.component.VEvent event)
Description copied from interface: IEventUtils
If the event is a Scheduling Assistant event, retrieve only the attendees on the event set by the Available system. Otherwise, return an empty PropertyList.

Specified by:
getAttendeeListFromEvent in interface IEventUtils
Returns:
only the Available attendees from the provided event

getScheduleVisitorCount

public int getScheduleVisitorCount(net.fortuna.ical4j.model.component.VEvent event)
Description copied from interface: IEventUtils
Return the number of Attendees in the event that have the role AppointmentRole.VISITOR.

Specified by:
getScheduleVisitorCount in interface IEventUtils
Returns:
a count of schedule visitors in the attendee list of the event argument

willEventCauseConflict

public boolean willEventCauseConflict(ICalendarAccount calendarAccount,
                                      net.fortuna.ical4j.model.component.VEvent event)
Description copied from interface: IEventUtils
This method defines our criteria for which VEvents will cause a conflict (either a red/busy block in the visible schedule or cause ConflictExistsExceptions).

Specified by:
willEventCauseConflict in interface IEventUtils
event - an VEvent, including non-scheduling assistant appointments
Returns:
true if the specified VEvent will cause a conflict for the ICalendarAccount

isAttendingMatch

public boolean isAttendingMatch(net.fortuna.ical4j.model.component.VEvent event,
                                IScheduleVisitor visitor,
                                IScheduleOwner owner)
Check the event to see if this event represents an existing available appointment that the visitor is "visiting" and the owner is "owning" (including the special case when visitor and owner are the same person) Will return true if the event's attendees match the roles passed in. The purpose is to test if this event should be marked with ATTENDING status for the visitor.

Specified by:
isAttendingMatch in interface IEventUtils
Parameters:
event -
visitor -
owner -
Returns:
true if and only if the event if is an available appointment with attendees that match the visitor and owner with the matching roles

isAttendingAsVisitor

public boolean isAttendingAsVisitor(net.fortuna.ical4j.model.component.VEvent event,
                                    ICalendarAccount proposedVisitor)
Specified by:
isAttendingAsVisitor in interface IEventUtils
Returns:
true if proposedVisitor is in the VEvent's attendee list as an IScheduleVisitor

isAttendingAsOwner

public boolean isAttendingAsOwner(net.fortuna.ical4j.model.component.VEvent event,
                                  ICalendarAccount proposedOwner)
Specified by:
isAttendingAsOwner in interface IEventUtils
Returns:
true if proposedOwner is in the VEvent's attendee list as an IScheduleOwner

convertScheduleForReflection

public List<net.fortuna.ical4j.model.Calendar> convertScheduleForReflection(AvailableSchedule availableSchedule)
Description copied from interface: IEventUtils
Convert the AvailableSchedule into an iCalendar Calendar for the purposes of reflection back into the calendar system.

Specified by:
convertScheduleForReflection in interface IEventUtils
Returns:
the owner's availability schedule as a list of Calendars appropriate for storing in the calendar system
See Also:
ICalendarDataDao.reflectAvailableSchedule(IScheduleOwner, AvailableSchedule)

wrapEventInCalendar

public net.fortuna.ical4j.model.Calendar wrapEventInCalendar(net.fortuna.ical4j.model.component.VEvent event)
Description copied from interface: IEventUtils
Wrap the VEvent argument in a Calendar.

Specified by:
wrapEventInCalendar in interface IEventUtils
Returns:

wrapInternal

protected net.fortuna.ical4j.model.Calendar wrapInternal(net.fortuna.ical4j.model.ComponentList components)
Parameters:
components -
Returns:

generateNewUid

public net.fortuna.ical4j.model.property.Uid generateNewUid()
Description copied from interface: IEventUtils
Generate a new Uid, intended for use with Scheduling Assistant VEvents.

Specified by:
generateNewUid in interface IEventUtils
Returns:
a new Uid

convertBlockToReflectionEvent

protected net.fortuna.ical4j.model.component.VEvent convertBlockToReflectionEvent(AvailableBlock block)
Convert the AvailableBlock into a VEvent that can be stored in the calendar system to represent that same block. This event MUST not cause conflicts.

Parameters:
block -
Returns:
an appropriate event

constructSummaryValueForReflectionEvent

protected String constructSummaryValueForReflectionEvent(AvailableBlock block)
Parameters:
block -
Returns:

convertToICalendarFormat

public static String convertToICalendarFormat(Date date)
Helper method to convert the Date into the String representation required for iCalendar. The returned date/time will be in the UTC timezone.

Parameters:
date -
Returns:
the date as a string
Throws:
IllegalArgumentException - if the date argument was null

isPartStatNeedsAction

public static boolean isPartStatNeedsAction(net.fortuna.ical4j.model.Property attendee)
Parameters:
attendee -
Returns:
true if if the attendee property has PARSTAT=NEEDS_ACTION

emailToURI

public static URI emailToURI(String emailAddress)
Convert the String argument to a mailto URI if possible.

Parameters:
emailAddress -
Returns:
the email as a URI
Throws:
IllegalArgumentException - if conversion failed, or if the argument was empty

getEventVisitorLimit

public Integer getEventVisitorLimit(net.fortuna.ical4j.model.component.VEvent event)
Description copied from interface: IEventUtils
If the event argument is an event created by the Scheduling Assistant, return the value of it's VisitorLimit property. If the event argument is not a Scheduling Assistant event, this method returns null.

Specified by:
getEventVisitorLimit in interface IEventUtils
Returns:
the value of the VisitorLimit if the event is a scheduling assistant appointment; if not return null

isEventRecurring

public boolean isEventRecurring(net.fortuna.ical4j.model.component.VEvent event)
Specified by:
isEventRecurring in interface IEventUtils
Returns:
true if the event recurs (either by RRULE or RDATE)

calculateRecurrence

public net.fortuna.ical4j.model.PeriodList calculateRecurrence(net.fortuna.ical4j.model.component.VEvent event,
                                                               Date startBoundary,
                                                               Date endBoundary)
Description copied from interface: IEventUtils
Calculate recurrence dates for the specified events between the 2 date boundaries.

Specified by:
calculateRecurrence in interface IEventUtils
Returns:
a never null, but possibly empty, PeriodList

isAllDayPeriod

protected boolean isAllDayPeriod(net.fortuna.ical4j.model.Period period)

isAllDayEvent

protected boolean isAllDayEvent(net.fortuna.ical4j.model.component.VEvent event)
Parameters:
event -
Returns:

extractUid

public net.fortuna.ical4j.model.property.Uid extractUid(net.fortuna.ical4j.model.Calendar calendar)
Description copied from interface: IEventUtils
If the Calendar contains one and only one event (series), return the Uid.

Specified by:
extractUid in interface IEventUtils
Returns:
the distinct Uid contains by the event in this calendar


Copyright © 2012 Jasig. All Rights Reserved.