Class ReminderScheduler

java.lang.Object
com.ehealthsystem.reminder.ReminderScheduler

public class ReminderScheduler extends Object
Manager for ReminderTasks (using java.util.TimerTask) Sets up reminders on application start. Gets notified by the UI controllers whenever a reminder time changes. Checks the reminder time for validity by itself. Does not schedule reminders that should have already been sent. Application's process keeps running in the background even though UI was closed, if there are still reminders scheduled.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final boolean
     
    (package private) static Map<Integer,Timer>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    Create a reminder for a given appointment.
    static void
    Remove a reminder for an appointment.
    private static void
    log(String message)
    Display messages to the console for verbosity purposes.
    static void
    Set up (schedule) all reminders on application start.
    static void
    Update the reminder time when an appointment's time was changed (appointment shifted) AppointmentShiftController is responsible for triggering this method to keep the reminder time in sync with the appointment's time Works by deleting a potentially existing reminder and then creating a new reminder for that appointment.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ReminderScheduler

      public ReminderScheduler()
  • Method Details

    • log

      private static void log(String message)
      Display messages to the console for verbosity purposes.
      Parameters:
      message - The message to display to the console.
    • setupReminders

      public static void setupReminders() throws SQLException, javax.activation.UnsupportedDataTypeException
      Set up (schedule) all reminders on application start. Do not call from Main before the database file is created on initial setup.
      Throws:
      SQLException
      javax.activation.UnsupportedDataTypeException
    • createReminder

      public static void createReminder(Appointment appointment)
      Create a reminder for a given appointment. Called on application load and creation of a new appointment.
      Parameters:
      appointment - the appointment in question to create a reminder for
    • deleteReminder

      public static void deleteReminder(Appointment appointment)
      Remove a reminder for an appointment. To be called before an appointment gets cancelled/deleted (e.g. patient cancels appointment). Also used as helper method for updateReminder.
      Parameters:
      appointment - the appointment to delete the reminder for
    • updateReminder

      public static void updateReminder(Appointment appointment)
      Update the reminder time when an appointment's time was changed (appointment shifted) AppointmentShiftController is responsible for triggering this method to keep the reminder time in sync with the appointment's time Works by deleting a potentially existing reminder and then creating a new reminder for that appointment. Has effectively no own code because it only calls the according functions.
      Parameters:
      appointment - the appointment to update the reminder for