com.mycompany.controller
Class EventController

java.lang.Object
  extended by com.mycompany.controller.AbstractController
      extended by com.mycompany.controller.EventController
All Implemented Interfaces:
java.io.Serializable

public class EventController
extends AbstractController

This class implements controller behavior for a number of screens in the application. It supports the member dashboard, shows, and reviews screens. This class is responsible for handling any calendar event related data and functionality for the application.

Author:
Ian Hlavats (ian@tarantulaconsulting.com)
See Also:
Serialized Form

Constructor Summary
EventController()
           
 
Method Summary
 void dateSelected(org.primefaces.event.SelectEvent evt)
          This method is called when the user clicks on a date in the calendar.
 void eventMoved(org.primefaces.event.ScheduleEntryMoveEvent evt)
          This method is called when the user moves a calendar Event from one date/time to another date/time.
 void eventResized(org.primefaces.event.ScheduleEntryResizeEvent evt)
          This method is called when the user resizes an event.
 void eventSelected(org.primefaces.event.SelectEvent evt)
          This method is called when the user clicks on an existing event in the schedule.
 java.util.List<Event> getAllEvents()
          This method returns all Event objects in the database.
 java.util.List<EventAttendance> getAllEventsAttendance()
          This method returns a list of EventAttendance objects encapsulating information about a user's attendance for a particular event.
 Event getEvent()
          This method returns the currently selected Event.
 EventType[] getEventTypes()
          This method returns an array of EventType enum objects.
 org.primefaces.model.ScheduleModel getUserScheduleModel()
          This method provides a LazyScheduleModel for the PrimeFaces schedule component.
 void init(javax.faces.event.ComponentSystemEvent evt)
          This method is called by JSF when the view is first loaded.
 void newEvent(javax.faces.event.ActionEvent evt)
          This method is called when the user clicks on the "New Event" button in the mobile web application.
 void refreshAttendance(javax.faces.event.ActionEvent event)
          This method is called from the reviews screen to refresh the EventAttendance data.
 void saveEvent(javax.faces.event.ActionEvent evt)
          This method is called when the user clicks the "Save" button in the new event dialog.
 void setEvent(Event event)
          Sets the Event.
 void setEventService(EventService eventService)
           
 void updateAttendance(EventAttendance attendance)
           This method updates the current user's EventAttendance object for a particular event.
 
Methods inherited from class com.mycompany.controller.AbstractController
setUserSession
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventController

public EventController()
Method Detail

dateSelected

public void dateSelected(org.primefaces.event.SelectEvent evt)
This method is called when the user clicks on a date in the calendar. It sets the start and end date of the calendar Event object.

Parameters:
evt - The SelectEvent object.

eventMoved

public void eventMoved(org.primefaces.event.ScheduleEntryMoveEvent evt)
This method is called when the user moves a calendar Event from one date/time to another date/time. It updates the object and saves the changes to the database.

Parameters:
evt - The ScheduleEntryMoveEvent object.

eventResized

public void eventResized(org.primefaces.event.ScheduleEntryResizeEvent evt)
This method is called when the user resizes an event. It handles changing the start and/or end dates of the Event object and updates the database.

Parameters:
evt - The ScheduleEntryResizeEvent object.

eventSelected

public void eventSelected(org.primefaces.event.SelectEvent evt)
This method is called when the user clicks on an existing event in the schedule. It assigns the selected event to an instance variable so it can be used for editing.

Parameters:
evt - The SelectEvent object.

getAllEvents

public java.util.List<Event> getAllEvents()
This method returns all Event objects in the database.

Returns:
A List of all objects.

getAllEventsAttendance

public java.util.List<EventAttendance> getAllEventsAttendance()
This method returns a list of EventAttendance objects encapsulating information about a user's attendance for a particular event.

Returns:
A List of EventAttendance objects.

getEvent

public Event getEvent()
This method returns the currently selected Event.

Returns:
An object.

getEventTypes

public EventType[] getEventTypes()
This method returns an array of EventType enum objects.

Returns:
An array of EventType objects.

getUserScheduleModel

public org.primefaces.model.ScheduleModel getUserScheduleModel()
This method provides a LazyScheduleModel for the PrimeFaces schedule component. It loads all events for the current user that have a start date between two dates. The overridden LazyScheduleModel.loadEvents(Date, Date) method is called by PrimeFaces when data is needed for a particular date range.

Returns:
A ScheduleModel object.

init

public void init(javax.faces.event.ComponentSystemEvent evt)
This method is called by JSF when the view is first loaded. It loads all the Event objects from the database so they can be displayed in the UI, and prepares the EventAttendance model for the current user.

Parameters:
evt - The JSF ComponentSystemEvent object.

newEvent

public void newEvent(javax.faces.event.ActionEvent evt)
This method is called when the user clicks on the "New Event" button in the mobile web application. It simply creates a new Event object and assigns it to the event instance variable.

Parameters:
evt - The JSF ActionEvent object.

refreshAttendance

public void refreshAttendance(javax.faces.event.ActionEvent event)
This method is called from the reviews screen to refresh the EventAttendance data. When the user reloads the dashboard, the getAllEventsAttendance() method will see that this instance variable is null, and reload the data to update the graph.

Parameters:
event - The JSF ActionEvent object.

saveEvent

public void saveEvent(javax.faces.event.ActionEvent evt)
This method is called when the user clicks the "Save" button in the new event dialog. It saves the Event object to the database.

Parameters:
evt - The JSF ActionEvent object.

setEvent

public void setEvent(Event event)
Sets the Event.

Parameters:
event - The Event object.

setEventService

public void setEventService(EventService eventService)

updateAttendance

public void updateAttendance(EventAttendance attendance)

This method updates the current user's EventAttendance object for a particular event. It uses the JPA EntityManager.merge(Object) method to save the object's changes to the database, and then replaces this object in the allEventsAttendance list to ensure the latest object is loaded in the UI.

Note: this method is called directly from the UI since it takes advantage of the Expression Language (EL) 2.2 feature that allows method argument passing from JSF.

Parameters:
attendance - The EventAttendance object.