Package scheduler.model
Class Scheduler
- java.lang.Object
-
- scheduler.model.Scheduler
-
public class Scheduler extends java.lang.ObjectThe Scheduler object manages business layer functionality for the overall application.
-
-
Field Summary
Fields Modifier and Type Field Description private static javafx.collections.ObservableList<java.lang.String>AppointmentTypesprivate static javafx.collections.ObservableList<java.time.LocalTime>hour_pickerprivate static java.util.TimeZonetzprivate static intUserID
-
Constructor Summary
Constructors Constructor Description Scheduler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static voidaddAppointment(Appointment A)Adds a new appointment to the application.static voidaddCustomer(Customer C)Adds a new customer.static java.util.LinkedList<Appointment>allAppointmentsByCustomer(int CustomerID)Returns a linked list of all appointments associated with the given customer.static voidcascadingDeleteAppointmentByCustomer(int CustID)Deletes all appointments associated with a customer.static voiddeleteAppointment(Appointment A)Delete an existing Appointment record.static voiddeleteCustomer(Customer C)Deletes a Customer.static javafx.collections.ObservableList<Appointment>getAllAppointments()Returns all Appointments to the UIstatic javafx.collections.ObservableList<Contact>getAllContacts()Returns all contacts back to the UIstatic javafx.collections.ObservableList<Country>getAllCountries()Returns a list of all Countriesstatic javafx.collections.ObservableList<Customer>getAllCustomers()Retrieves an list of all Customersstatic ContactgetContactByID(int id)Returns a Contact object, given their Contact IDstatic CountrygetCountry(int country_id)Given country_id will return the associated country object.static DivisiongetDivision(int division_id)Given a Division ID, will return the associated Division objectstatic javafx.collections.ObservableList<Division>getDivision(Country country_id)Returns a list of division id's based on country idstatic intgetUserID()Returns the user id of the user who logged inbooleanloginToApplication(java.lang.String username, java.lang.String password)Authenticates a user based on their username and password.voidlogLoginAttempt(java.lang.String user, boolean success)Writes to the log file whenever a login attempt is made.static voidmodifyAppointment(Appointment A)Modify an already established Appointment recordstatic javafx.collections.ObservableList<Appointment>returnAppointmentsByDayInterval(int interval)Returns appointment view of appointments with start dates in the next x days.static javafx.collections.ObservableList<java.lang.String>returnAppointmentTypes()Returns a list of allowable appointment typesstatic CustomerreturnCustomer(int CustID)Given a particular customer id, returns the whole customer objectstatic java.lang.StringreturnCustomerName(int CustID)Returns the Name of the Customer with the given IDstatic voidsetUserID(int user)Sets the value of user id to the user who is logged in.static voidupdateCustomer(Customer C)Updates a customer's record in the application.
-
-
-
Method Detail
-
setUserID
public static void setUserID(int user)
Sets the value of user id to the user who is logged in.- Parameters:
user- Integer, UserId
-
getUserID
public static int getUserID()
Returns the user id of the user who logged in- Returns:
- Integer, user id
-
loginToApplication
public boolean loginToApplication(java.lang.String username, java.lang.String password) throws java.sql.SQLException, java.io.IOExceptionAuthenticates a user based on their username and password. Uses the DAO package to handle backend operations. Displays Appointment alerts or error messaging as appropriate.- Parameters:
username- is the username for loginpassword- is the password for login- Returns:
- boolean is true if the user / password combination authenticates. Returns false if it does not.
- Throws:
java.sql.SQLException- in case of errorjava.io.IOException
-
logLoginAttempt
public void logLoginAttempt(java.lang.String user, boolean success) throws java.io.IOExceptionWrites to the log file whenever a login attempt is made. Writes the following to the log: Username, date and timestamp, and whether or not the login attempt was successful. Username is recorded as "Unknown" if the username field was left blank during the login attempt. Called by checkAuthentication in the dialogueHandling class.- Parameters:
user- the user namesuccess- a boolean that represents whether a login attempt was successful. True = Successful attempt. False = Unsuccessful Login attempt.- Throws:
java.io.IOException
-
getAllCustomers
public static javafx.collections.ObservableList<Customer> getAllCustomers()
Retrieves an list of all Customers- Returns:
- an observable list of all customers
-
addCustomer
public static void addCustomer(Customer C)
Adds a new customer.- Parameters:
C- is the customer object to be added.
-
deleteCustomer
public static void deleteCustomer(Customer C)
Deletes a Customer.- Parameters:
C- is the customer object to be deleted.
-
updateCustomer
public static void updateCustomer(Customer C)
Updates a customer's record in the application. It is assumed that the data has already been validated.- Parameters:
C- Customer object
-
getAllCountries
public static javafx.collections.ObservableList<Country> getAllCountries()
Returns a list of all Countries- Returns:
- Observable list of all countries
-
getDivision
public static javafx.collections.ObservableList<Division> getDivision(Country country_id)
Returns a list of division id's based on country id- Parameters:
country_id- for country for which division is desired- Returns:
- Observable list of divisions
-
getCountry
public static Country getCountry(int country_id)
Given country_id will return the associated country object.- Parameters:
country_id-- Returns:
-
getDivision
public static Division getDivision(int division_id)
Given a Division ID, will return the associated Division object- Parameters:
division_id-- Returns:
-
getAllContacts
public static javafx.collections.ObservableList<Contact> getAllContacts()
Returns all contacts back to the UI- Returns:
- Observable List
-
getAllAppointments
public static javafx.collections.ObservableList<Appointment> getAllAppointments()
Returns all Appointments to the UI- Returns:
- Observable list of all appointments.
-
getContactByID
public static Contact getContactByID(int id)
Returns a Contact object, given their Contact ID- Parameters:
id- , Integer contact ID- Returns:
- Contact object
-
returnAppointmentTypes
public static javafx.collections.ObservableList<java.lang.String> returnAppointmentTypes()
Returns a list of allowable appointment types- Returns:
- Observable list of appointment types
-
addAppointment
public static void addAppointment(Appointment A)
Adds a new appointment to the application. Assumes error validation has already been completed.- Parameters:
A- Appointment object
-
returnCustomerName
public static java.lang.String returnCustomerName(int CustID)
Returns the Name of the Customer with the given ID- Parameters:
CustID- Integer- Returns:
- String, Customer name
-
returnCustomer
public static Customer returnCustomer(int CustID)
Given a particular customer id, returns the whole customer object- Parameters:
CustID- Integer, Customer ID- Returns:
- Customer object
-
modifyAppointment
public static void modifyAppointment(Appointment A)
Modify an already established Appointment record- Parameters:
A- in appointment object.
-
deleteAppointment
public static void deleteAppointment(Appointment A)
Delete an existing Appointment record.- Parameters:
A- the appointment object that is the record to be deleted.
-
allAppointmentsByCustomer
public static java.util.LinkedList<Appointment> allAppointmentsByCustomer(int CustomerID)
Returns a linked list of all appointments associated with the given customer.- Parameters:
CustomerID- , Integer customer id- Returns:
- Linked List of appointment objects.
-
cascadingDeleteAppointmentByCustomer
public static void cascadingDeleteAppointmentByCustomer(int CustID)
Deletes all appointments associated with a customer. Takes no action if there are no associated appointments.- Parameters:
CustID- , Integer customer ID
-
returnAppointmentsByDayInterval
public static javafx.collections.ObservableList<Appointment> returnAppointmentsByDayInterval(int interval)
Returns appointment view of appointments with start dates in the next x days.- Parameters:
interval- Number of days in the future in which the appointment should occur. Starts with the value of now()- Returns:
- Observable list of appointments. Returns an empty list if there are no appointments in the time period.
-
-