com.opnworks.timesheet.core
Class TimesheetSystem

java.lang.Object
  extended bycom.opnworks.timesheet.core.TimesheetSystem
All Implemented Interfaces:
IActivityLister

public class TimesheetSystem
extends java.lang.Object
implements IActivityLister

This class implements the Singleton pattern and provide a series of services for the Timesheet system

Author:
laurent

Field Summary
static TimesheetSystem INSTANCE
          Field referring to the singleton instance
 
Constructor Summary
TimesheetSystem()
          Default constructor
 
Method Summary
 void addActivityType(ActivityType activityType)
          Adds a feature to the ActivityType attribute of the TimesheetSystem object
 void addChangeListener(IViewer viewer)
           
 void addTimesheet(Timesheet timesheet)
          Add a timesheet
 void closePersistenceSession()
          Description of the Method
 net.sf.hibernate.Query createQuery(java.lang.String string)
           
 void delete(IPersistent object, java.lang.Class clazz)
          Description of the Method
 java.util.List getActivityTypes()
          Return the collection of activity types
 java.util.List getChangeListeners(java.lang.Class clazz)
          Return a collection of change listeners
 TimesheetSystemConfiguration getConfig()
           
 IPerson getEmployee()
          Return the employee
 IOrganization getEmployer()
           
 Invoice getInvoice(IOrganization customer, java.util.Calendar startDate, java.util.Calendar endDate)
           
 java.util.List getInvoices(IOrganization customer)
          Return the collection of invoices associated with customer
 java.util.Locale getLocale()
          Return the locale
 java.lang.Object getObject(java.lang.Class clazz, java.lang.Long id)
           
 java.util.List getObjectsWithName(java.lang.Class clazz, java.lang.String name)
          Return the collection of INamedObject(s) of a given class.
 java.util.List getOrganizations()
           
 java.util.List getProjects()
           
 java.util.List getProjects(IOrganization sponsor)
          Return a collection of projects sponsored by sponsor
 java.util.List getRootActivityTypes()
          Return the collection of root activity types (parent activities)
 Timesheet getTimesheetForWeek(Week week, IPerson owner)
          Return the timesheets for a specific week and person
 java.util.List getTimesheets()
          Return the collection of timesheets
 java.util.List getTimesheetsForWeek(Week week)
          Return the collection of timesheets for a specific week
 java.util.List getTimesheetsForWeek(Week week, IPerson owner)
          Deprecated.  
 Week getWeekForDate(java.sql.Date date)
           
 java.util.List getWeeks()
          Return the collection of weeks.
 boolean isConnected()
          Returns a boolean if the session is connected
 net.sf.hibernate.Session persistenceSession()
          Description of the Method
 java.util.List processQueryString(java.lang.String qString)
          Description of the Method
 void removeActivityType(ActivityType activityType)
          Remove an activity type
 void removeChangeListener(IViewer viewer)
           
 void removeLineItem(TimesheetLineItem lineItem)
           
 void removeOrganization(IOrganization organization)
           
 void removeProject(Project project)
           
 void removeTimesheet(Timesheet timesheet)
           
 void removeWeek(Week week)
           
 void save(IPersistent object, java.lang.Class clazz)
          Description of the Method
 void saveActivityType(ActivityType activityType)
           
 void saveConfig()
          Persist the configuration
 void saveInvoice(Invoice invoice)
           
 void saveLineItem(TimesheetLineItem lineItem)
           
 void saveParty(IParty party)
           
 void saveProject(Project project)
           
 void saveTimesheet(Timesheet timesheet)
          Save a timesheet
 void saveWeek(Week week)
          Save an instance of a Week
 void setConnectionProperties(java.util.Properties props)
          Sets the ConnectionProperties attribute of the instance
 void setEmployee(IPerson person)
          Set the employee for the instance
 void setEmployer(IOrganization organization)
          Set the employer for the instance
 void setLocale(java.util.Locale locale)
          Set the locale of the receiver
 void setProperties(java.util.Properties props)
          Sets the Properties attribute of the TimesheetSystem object
 void shutdownDatabase()
          Perform a Shutdown
 void triggerAddEvent(java.lang.Class clazz, java.lang.Object object)
          Trigger an "Add" event for the class clazz
 void triggerRemoveEvent(java.lang.Class clazz, java.lang.Object object)
          Trigger a "Remove" event for the class clazz
 void triggerUpdateEvent(java.lang.Class clazz, java.lang.Object object)
          Trigger an "Update" event for the class clazz
 void update(IPersistent object, java.lang.Class clazz)
          Description of the Method
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final TimesheetSystem INSTANCE
Field referring to the singleton instance

Constructor Detail

TimesheetSystem

public TimesheetSystem()
Default constructor

Method Detail

setLocale

public void setLocale(java.util.Locale locale)
Set the locale of the receiver

Parameters:
locale -

setEmployee

public void setEmployee(IPerson person)
                 throws TimesheetException
Set the employee for the instance

Parameters:
person -
Throws:
TimesheetException

setEmployer

public void setEmployer(IOrganization organization)
                 throws TimesheetException
Set the employer for the instance

Parameters:
organization -
Throws:
TimesheetException

setConnectionProperties

public void setConnectionProperties(java.util.Properties props)
                             throws TimesheetException
Sets the ConnectionProperties attribute of the instance

Parameters:
props - The new ConnectionProperties value
Throws:
TimesheetException

setProperties

public void setProperties(java.util.Properties props)
                   throws TimesheetException
Sets the Properties attribute of the TimesheetSystem object

Parameters:
props - The new Properties value
Throws:
TimesheetException - Description of Exception

getLocale

public java.util.Locale getLocale()
Return the locale

Returns:

getActivityTypes

public java.util.List getActivityTypes()
                                throws TimesheetException
Return the collection of activity types

Specified by:
getActivityTypes in interface IActivityLister
Returns:
Throws:
TimesheetException

getRootActivityTypes

public java.util.List getRootActivityTypes()
                                    throws TimesheetException
Return the collection of root activity types (parent activities)

Returns:
Throws:
TimesheetException

getTimesheets

public java.util.List getTimesheets()
                             throws TimesheetException
Return the collection of timesheets

Returns:
Throws:
TimesheetException

getTimesheetsForWeek

public java.util.List getTimesheetsForWeek(Week week)
                                    throws TimesheetException
Return the collection of timesheets for a specific week

Parameters:
week - a Week instance
Returns:
Throws:
TimesheetException

getTimesheetForWeek

public Timesheet getTimesheetForWeek(Week week,
                                     IPerson owner)
                              throws TimesheetException
Return the timesheets for a specific week and person

Parameters:
week - Description of Parameter
owner - Description of Parameter
Returns:
Throws:
TimesheetException - Description of Exception

getTimesheetsForWeek

public java.util.List getTimesheetsForWeek(Week week,
                                           IPerson owner)
                                    throws TimesheetException
Deprecated.  

Parameters:
week - Description of Parameter
owner - Description of Parameter
Returns:
Throws:
TimesheetException - Description of Exception

getEmployee

public IPerson getEmployee()
                    throws TimesheetException
Return the employee

Returns:
Throws:
TimesheetException - Description of Exception

getEmployer

public IOrganization getEmployer()
                          throws TimesheetException
Returns:
Throws:
TimesheetException - Description of Exception

getWeeks

public java.util.List getWeeks()
                        throws TimesheetException
Return the collection of weeks. If the list is empty, insert a week entry for the current date.

Returns:
a Collection of weeks
Throws:
TimesheetException - Description of Exception

getObjectsWithName

public java.util.List getObjectsWithName(java.lang.Class clazz,
                                         java.lang.String name)
                                  throws TimesheetException
Return the collection of INamedObject(s) of a given class. If the class does not implement INamedObject throw an exception.

Parameters:
clazz - Description of Parameter
name - Description of Parameter
Returns:
a Collection of INamedObject instances
Throws:
TimesheetException - Description of Exception

getWeekForDate

public Week getWeekForDate(java.sql.Date date)
                    throws TimesheetException
Parameters:
date - A java.sql.Date
Returns:
The Week object for the specified date
Throws:
TimesheetException - Description of Exception

getChangeListeners

public java.util.List getChangeListeners(java.lang.Class clazz)
Return a collection of change listeners

Parameters:
clazz - Description of Parameter
Returns:
The collection of change listeners

getOrganizations

public java.util.List getOrganizations()
                                throws TimesheetException
Returns:
a Collection of Organization instances representing the customers
Throws:
TimesheetException

getObject

public java.lang.Object getObject(java.lang.Class clazz,
                                  java.lang.Long id)
                           throws TimesheetException
Parameters:
clazz - Description of Parameter
id - Description of Parameter
Returns:
An object of class clazz with ID id
Throws:
TimesheetException

getProjects

public java.util.List getProjects()
                           throws TimesheetException
Returns:
the Collection of project instances
Throws:
TimesheetException

getProjects

public java.util.List getProjects(IOrganization sponsor)
                           throws TimesheetException
Return a collection of projects sponsored by sponsor

Parameters:
sponsor - An Organization
Returns:
the Collection of Project instances sponsored by sponsor
Throws:
TimesheetException

getInvoices

public java.util.List getInvoices(IOrganization customer)
                           throws TimesheetException
Return the collection of invoices associated with customer

Parameters:
customer - An Organization
Returns:
the Collection of Invoice instances sponsored by sponsor
Throws:
TimesheetException

getInvoice

public Invoice getInvoice(IOrganization customer,
                          java.util.Calendar startDate,
                          java.util.Calendar endDate)
                   throws TimesheetException
Parameters:
customer - An Organization
startDate - The invoice start date
endDate - Description of Parameter
Returns:
the Invoice matching the criteria or null
Throws:
TimesheetException

isConnected

public boolean isConnected()
Returns a boolean if the session is connected

Returns:
The Connected value

getConfig

public TimesheetSystemConfiguration getConfig()
                                       throws TimesheetException
Returns:
The configuration of the instance
Throws:
TimesheetException

saveActivityType

public void saveActivityType(ActivityType activityType)
                      throws TimesheetException
Parameters:
activityType - An ActivityType
Throws:
TimesheetException

triggerAddEvent

public void triggerAddEvent(java.lang.Class clazz,
                            java.lang.Object object)
Trigger an "Add" event for the class clazz

Parameters:
clazz - Description of Parameter
object - Description of Parameter

triggerRemoveEvent

public void triggerRemoveEvent(java.lang.Class clazz,
                               java.lang.Object object)
Trigger a "Remove" event for the class clazz

Parameters:
clazz - Description of Parameter
object - Description of Parameter

triggerUpdateEvent

public void triggerUpdateEvent(java.lang.Class clazz,
                               java.lang.Object object)
Trigger an "Update" event for the class clazz

Parameters:
clazz - Description of Parameter
object - Description of Parameter

removeActivityType

public void removeActivityType(ActivityType activityType)
                        throws TimesheetException
Remove an activity type

Specified by:
removeActivityType in interface IActivityLister
Parameters:
activityType - An ActivityType
Throws:
TimesheetException

addTimesheet

public void addTimesheet(Timesheet timesheet)
                  throws TimesheetException
Add a timesheet

Parameters:
timesheet - A Timesheet
Throws:
TimesheetException

saveTimesheet

public void saveTimesheet(Timesheet timesheet)
                   throws TimesheetException
Save a timesheet

Parameters:
timesheet -
Throws:
TimesheetException - Description of Exception

removeTimesheet

public void removeTimesheet(Timesheet timesheet)
                     throws TimesheetException
Parameters:
timesheet - A Timesheet
Throws:
TimesheetException

saveWeek

public void saveWeek(Week week)
              throws TimesheetException
Save an instance of a Week

Parameters:
week - Description of Parameter
Throws:
TimesheetException

saveProject

public void saveProject(Project project)
                 throws TimesheetException
Parameters:
project - A Project
Throws:
TimesheetException

saveParty

public void saveParty(IParty party)
               throws TimesheetException
Parameters:
party - A party
Throws:
TimesheetException

saveInvoice

public void saveInvoice(Invoice invoice)
                 throws TimesheetException
Parameters:
invoice - An Invoice
Throws:
TimesheetException

saveConfig

public void saveConfig()
                throws TimesheetException
Persist the configuration

Throws:
TimesheetException - Description of Exception

removeOrganization

public void removeOrganization(IOrganization organization)
                        throws TimesheetException
Parameters:
organization - Description of Parameter
Throws:
TimesheetException

removeProject

public void removeProject(Project project)
                   throws TimesheetException
Parameters:
project - A Project
Throws:
TimesheetException

removeWeek

public void removeWeek(Week week)
                throws TimesheetException
Parameters:
week - A week
Throws:
TimesheetException

removeChangeListener

public void removeChangeListener(IViewer viewer)
Parameters:
viewer -

addChangeListener

public void addChangeListener(IViewer viewer)
Parameters:
viewer -

persistenceSession

public net.sf.hibernate.Session persistenceSession()
                                            throws net.sf.hibernate.HibernateException
Description of the Method

Returns:
Description of the Returned Value
Throws:
net.sf.hibernate.HibernateException

closePersistenceSession

public void closePersistenceSession()
                             throws TimesheetException
Description of the Method

Throws:
TimesheetException

addActivityType

public void addActivityType(ActivityType activityType)
                     throws TimesheetException
Adds a feature to the ActivityType attribute of the TimesheetSystem object

Specified by:
addActivityType in interface IActivityLister
Parameters:
activityType - The feature to be added to the ActivityType attribute
Throws:
TimesheetException

processQueryString

public java.util.List processQueryString(java.lang.String qString)
                                  throws TimesheetException
Description of the Method

Parameters:
qString - Description of Parameter
Returns:
Description of the Returned Value
Throws:
TimesheetException

saveLineItem

public void saveLineItem(TimesheetLineItem lineItem)
                  throws TimesheetException
Parameters:
lineItem -
Throws:
TimesheetException - Description of Exception

removeLineItem

public void removeLineItem(TimesheetLineItem lineItem)
                    throws TimesheetException
Parameters:
lineItem -
Throws:
TimesheetException

delete

public void delete(IPersistent object,
                   java.lang.Class clazz)
            throws TimesheetException
Description of the Method

Parameters:
object - Description of Parameter
clazz - Description of Parameter
Throws:
TimesheetException

save

public void save(IPersistent object,
                 java.lang.Class clazz)
          throws TimesheetException
Description of the Method

Parameters:
object - Description of Parameter
clazz - Description of Parameter
Throws:
TimesheetException

update

public void update(IPersistent object,
                   java.lang.Class clazz)
            throws TimesheetException
Description of the Method

Parameters:
object - Description of Parameter
clazz - Description of Parameter
Throws:
TimesheetException - Description of Exception

shutdownDatabase

public void shutdownDatabase()
                      throws org.eclipse.core.runtime.CoreException
Perform a Shutdown

Throws:
org.eclipse.core.runtime.CoreException

createQuery

public net.sf.hibernate.Query createQuery(java.lang.String string)
                                   throws TimesheetException
Parameters:
string -
Returns:
Throws:
TimesheetException - Description of Exception