Class StaffDB

java.lang.Object
sc2002.repositories.StaffDB

public class StaffDB extends Object
Represents the database for managing staff records, including adding, updating, retrieving, and removing staff members.
  • Constructor Details

    • StaffDB

      public StaffDB()
  • Method Details

    • getStaff

      public static List<Staff> getStaff(StaffFilter selectedFilter) throws IOException
      Retrieves a list of staff members filtered by the specified criteria.
      Parameters:
      selectedFilter - The filter criteria to apply to the staff records.
      Returns:
      A list of staff members that match the filter criteria.
      Throws:
      IOException - If there is an issue reading the file.
    • addStaff

      public static void addStaff(Staff newStaff) throws IOException
      Adds a new staff member to the Staff and User databases.
      Parameters:
      newStaff - The staff member to add.
      Throws:
      IOException - If there is an issue writing to the file.
    • updateStaff

      public static void updateStaff(String staffID, Staff updatedStaff) throws IOException
      Updates an existing staff member's information in the database.
      Parameters:
      staffID - The ID of the staff member to update.
      updatedStaff - The updated staff details.
      Throws:
      IOException - If there is an issue updating the file.
    • removeStaff

      public static void removeStaff(String staffID) throws IOException
      Removes a staff member from both the Staff and User databases.
      Parameters:
      staffID - The ID of the staff member to remove.
      Throws:
      IOException - If there is an issue updating the file.
    • findStaff

      public static int findStaff(String staffID)
      Finds if a staff member exists in the database.
      Parameters:
      staffID - The ID of the staff member.
      Returns:
      1 if the staff member exists; otherwise, 0.