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.ChangeEvent, 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 do_todo(int key, boolean del, Date date)
          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
 String getExportName()
          get the root XML element name for this model's XML representation
 String getInfo()
          return user readable information about the model
static AppointmentModel getReference()
          Gets the singleton reference.
static SimpleDateFormat getTimeFormat()
          Gets the time format to use for all time processing.
 void importXml(InputStream is)
          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()
           
 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.
 void update(Model.ChangeEvent event)
          Called to notify Listener when the Model is changed.
 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, getExistingModels, refreshListeners, refreshListeners, remove, removeListener, removeListeners, syncModels
 
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

do_todo

public void do_todo(int key,
                    boolean del,
                    Date date)
             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.
date - date of the repeat that is being marked as done. If null, then the next todo is the one. If set, then all todos up to and including the date are marked as done.
Throws:
Exception - the exception

export

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

Specified by:
export in class Model
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

importXml

public void importXml(InputStream is)
               throws Exception
Import xml.

Specified by:
importXml in class Model
Parameters:
is - the input stream containing the XML
Throws:
Exception - the exception

newAppt

public Appointment newAppt()
create a new appointment.

Returns:
the appointment

update

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

Specified by:
update in interface Model.Listener

refresh

public void refresh()

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.

Overrides:
sync in class Model

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

getExportName

public String getExportName()
Description copied from class: Model
get the root XML element name for this model's XML representation

Specified by:
getExportName in class Model
Returns:
the XML root element name

getInfo

public String getInfo()
               throws Exception
Description copied from class: Model
return user readable information about the model

Specified by:
getInfo in class Model
Returns:
user readable information String
Throws:
Exception


Generated December 30 2011 by mbb using Apache Ant(TM) version 1.8.2 compiled on December 20 2010 and Java version 1.6.0_30 from Sun Microsystems Inc. on Linux i386 3.0.0-14-generic-pae