net.sf.borg.model
Class AppointmentModel

java.lang.Object
  extended by net.sf.borg.model.Model
      extended by net.sf.borg.model.AppointmentModel
All Implemented Interfaces:
CategoryModel.CategorySource, Model.Listener, Searchable<Appointment>

public class AppointmentModel
extends Model
implements Model.Listener, CategoryModel.CategorySource, Searchable<Appointment>

the appointment model provides the model layer APIs for working with Appointment Entities


Nested Class Summary
 
Nested classes/interfaces inherited from class net.sf.borg.model.Model
Model.Listener
 
Method Summary
 void delAppt(Appointment appt)
          Delete an appt.
 void delAppt(Appointment appt, boolean undo)
          Delete an appt.
 void delAppt(int key)
          Delete an appt by key.
 void delOneOnly(int key, Date rptDate)
          delete one occurrence of a repeating appointment
 void do_todo(int key, boolean del)
          Mark a todo appointment as done.
 void export(Writer fw)
          Export appointments as XML.
 Collection<Appointment> get_todos()
          Gets all appointments that are marked as todos.
 Collection<Appointment> getAllAppts()
          Get all appts.
 Appointment getAppt(int key)
          Gets an appt by key.
 List<Integer> getAppts(Date d)
          Get a list of appointment ids for a given day
 Collection<String> getCategories()
          Gets the list of all categories from all entities in the source model
 EntityDB<Appointment> getDB()
          Deprecated. 
 Appointment getDefaultAppointment()
          get the default appointment from prefs
static AppointmentModel getReference()
          Gets the singleton reference.
static SimpleDateFormat getTimeFormat()
          Gets the time format to use for all time processing.
 boolean haveTodos()
          return true if there are any todos in the entire appointment table
 void importXml(String fileName)
          Import xml.
static boolean isNote(Appointment appt)
          Checks an appointment is a note (not associated with a time of day).
static boolean isSkipped(Appointment ap, Calendar cal)
          Checks if an appointment is skipped on a particular date
 Appointment newAppt()
          create a new appointment.
 void refresh()
          Called to notify Listener when the Model is changed.
 void saveAppt(Appointment r)
          Save an appointment.
 void saveAppt(Appointment r, boolean undo)
          Save an appointment.
 void saveDefaultAppointment(Appointment appt)
          save the default appointment in the prefs
 Collection<Appointment> search(SearchCriteria criteria)
          Return a collection of all records that match the given search criteria
 void sync()
          Sync with the db.
 double vacationCount(Date d)
          determine the number of vacation days up to and including the given day in a particular year
 
Methods inherited from class net.sf.borg.model.Model
addListener, refreshListeners, remove, removeListener, removeListeners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getReference

public static AppointmentModel getReference()
Gets the singleton reference.

Returns:
the singleton reference

getTimeFormat

public static SimpleDateFormat getTimeFormat()
Gets the time format to use for all time processing.

Returns:
the time format

isNote

public static boolean isNote(Appointment appt)
Checks an appointment is a note (not associated with a time of day).

Parameters:
appt - the appointment
Returns:
true, if it is a note

isSkipped

public static boolean isSkipped(Appointment ap,
                                Calendar cal)
Checks if an appointment is skipped on a particular date

Parameters:
ap - the Appointment
cal - the date
Returns:
true, if is skipped

delAppt

public void delAppt(Appointment appt)
Delete an appt.

Parameters:
appt - the appt

delAppt

public void delAppt(Appointment appt,
                    boolean undo)
Delete an appt.

Parameters:
appt - the appt
undo - true if we are executing an undo

delAppt

public void delAppt(int key)
Delete an appt by key.

Parameters:
key - the key

delOneOnly

public void delOneOnly(int key,
                       Date rptDate)
delete one occurrence of a repeating appointment

Parameters:
key - the appointment key
rptDate - the date of the repeat to be deleted

do_todo

public void do_todo(int key,
                    boolean del)
             throws Exception
Mark a todo appointment as done. If the appointment repeats, adjust the next todo value. If the todo is all done (including repeats), optionally delete it

Parameters:
key - the appointment key
del - if true, delete the todo when all done. Otherwise, mark it as no longer being a todo.
Throws:
Exception - the exception

export

public void export(Writer fw)
            throws Exception
Export appointments as XML.

Parameters:
fw - the Writer to write XML to
Throws:
Exception - the exception

get_todos

public Collection<Appointment> get_todos()
Gets all appointments that are marked as todos.

Returns:
the todos

getAllAppts

public Collection<Appointment> getAllAppts()
                                    throws Exception
Get all appts.

Returns:
all appts
Throws:
Exception - the exception

getAppt

public Appointment getAppt(int key)
                    throws Exception
Gets an appt by key.

Parameters:
key - the key
Returns:
the appt
Throws:
Exception - the exception

getAppts

public List<Integer> getAppts(Date d)
Get a list of appointment ids for a given day

Parameters:
d - the date
Returns:
the appts

getCategories

public Collection<String> getCategories()
Description copied from interface: CategoryModel.CategorySource
Gets the list of all categories from all entities in the source model

Specified by:
getCategories in interface CategoryModel.CategorySource
Returns:
the categories

getDB

@Deprecated
public EntityDB<Appointment> getDB()
Deprecated. 

Gets the underlying dB.

Returns:
the dB

haveTodos

public boolean haveTodos()
return true if there are any todos in the entire appointment table

Returns:
true, if any todos exist

importXml

public void importXml(String fileName)
               throws Exception
Import xml.

Parameters:
fileName - the file name of the file containing the XML
Throws:
Exception - the exception

newAppt

public Appointment newAppt()
create a new appointment.

Returns:
the appointment

refresh

public void refresh()
Description copied from interface: Model.Listener
Called to notify Listener when the Model is changed.

Specified by:
refresh in interface Model.Listener

saveAppt

public void saveAppt(Appointment r)
Save an appointment.

Parameters:
r - the appointment

saveAppt

public void saveAppt(Appointment r,
                     boolean undo)
Save an appointment.

Parameters:
r - the appointment
undo - true if we are executing an undo

sync

public void sync()
Sync with the db.


vacationCount

public double vacationCount(Date d)
determine the number of vacation days up to and including the given day in a particular year

Parameters:
d - the Date
Returns:
the double

saveDefaultAppointment

public void saveDefaultAppointment(Appointment appt)
save the default appointment in the prefs

Parameters:
appt - the appointment

getDefaultAppointment

public Appointment getDefaultAppointment()
get the default appointment from prefs

Returns:
the default appointment

search

public Collection<Appointment> search(SearchCriteria criteria)
Description copied from interface: Searchable
Return a collection of all records that match the given search criteria

Specified by:
search in interface Searchable<Appointment>
Parameters:
criteria - the search criteria
Returns:
collection of matching records


Generated September 24 2010 by mbb using Apache Ant version 1.7.1 compiled on June 27 2008 and Java version 1.6.0_20 from Sun Microsystems Inc. on Linux i386 2.6.24-28-generic