Package Controllers

Class StaffManager

java.lang.Object
Controllers.StaffManager

public class StaffManager extends Object
The StaffManager class provides functionalities for managing staff accounts. It allows adding, removing, editing, and displaying staff information based on various filters.
  • Constructor Details

    • StaffManager

      public StaffManager(AccountDatabase accountDatabase)
      Constructs a StaffManager with the specified account database.
      Parameters:
      accountDatabase - the AccountDatabase used to manage staff accounts
  • Method Details

    • addStaff

      public boolean addStaff(Account account) throws Exception
      Adds a new staff member to the database.
      Parameters:
      account - the Account object representing the staff member to be added
      Returns:
      true if the staff member was added successfully; false otherwise
      Throws:
      Exception - if the role of the account is PAT or ADM, as they cannot be added
    • removeStaff

      public boolean removeStaff(String userId) throws Exception
      Removes a staff member from the database by user ID.
      Parameters:
      userId - the unique identifier of the user to be removed
      Returns:
      true if the staff member was removed successfully; false if not found
      Throws:
      Exception - if trying to remove patients or admins
    • getUserInfo

      public Account getUserInfo(String userId)
      Retrieves user information by user ID.
      Parameters:
      userId - the unique identifier of the user whose information is to be retrieved
      Returns:
      the Account object representing the user, or null if not found
    • editName

      public boolean editName(String userId, String name)
      Edits the name of a staff member by user ID.
      Parameters:
      userId - the unique identifier of the user whose name is to be edited
      name - the new name for the user
      Returns:
      true if the name was updated successfully; false if not found
    • editPassword

      public boolean editPassword(String userId, String password)
      Edits the password of a staff member by user ID.
      Parameters:
      userId - the unique identifier of the user whose password is to be edited
      password - the new password for the user
      Returns:
      true if the password was updated successfully; false if not found
    • editGender

      public boolean editGender(String userId, Gender gender)
      Edits the gender of a staff member by user ID.
      Parameters:
      userId - the unique identifier of the user whose gender is to be edited
      gender - the new gender for the user
      Returns:
      true if the gender was updated successfully; false if not found
    • editAge

      public boolean editAge(String userId, int age)
      Edits the age of a staff member by user ID.
      Parameters:
      userId - the unique identifier of the user whose age is to be edited
      age - the new age for the user
      Returns:
      true if the age was updated successfully; false if not found
    • displayStaffs

      public void displayStaffs(FilterParam filter, String param)
      Displays all staff members filtered by specified parameter and value.
      Parameters:
      filter - parameter by which to filter staff members (e.g., ROLE or GENDER)
      param - value used for filtering based on specified parameter
    • displayStaffs

      public void displayStaffs(FilterParam filter, int lowerBound, int upperBound)
      Displays all staff members filtered by age range.
      Parameters:
      filter - parameter by which to filter staff members, must be AGE
      lowerBound - lower bound of age range for filtering
      upperBound - upper bound of age range for filtering
    • displayAllStaff

      public void displayAllStaff()
      Displays all staff members who are doctors or pharmacists.