Class EmployeeSQL

java.lang.Object
csce331.group13.project2.backend.EmployeeSQL

public class EmployeeSQL extends Object
Provides data access methods for employee records in the database. Handles all CRUD operations for the employees table.
Author:
Varish Kongara
  • Constructor Details

    • EmployeeSQL

      public EmployeeSQL()
  • Method Details

    • addEmployee

      public static boolean addEmployee(Employee employee)
      Adds a new employee to the database.
      Parameters:
      employee - The Employee object to add.
      Returns:
      true if the employee was successfully added; false otherwise.
    • getActiveEmployees

      public static List<Employee> getActiveEmployees()
      Retrieves all active employees from the database.
      Returns:
      A list of active Employee objects.
    • getAllEmployees

      public static List<Employee> getAllEmployees()
      Retrieves all employees from the database, including inactive ones.
      Returns:
      A list of all Employee objects, sorted alphabetically by name.
    • getEmployeeById

      public static Optional<Employee> getEmployeeById(UUID employeeId)
      Retrieves an employee by their unique identifier.
      Parameters:
      employeeId - The UUID of the employee to retrieve.
      Returns:
      An Optional containing the Employee if found, or empty if not found.
    • updateEmployee

      public static boolean updateEmployee(Employee employee)
      Updates an existing employee's information in the database.
      Parameters:
      employee - The Employee object with updated values.
      Returns:
      true if the update was successful; false otherwise.
    • deleteEmployee

      public static boolean deleteEmployee(UUID employeeId)
      Deletes an employee from the database by their unique identifier.
      Parameters:
      employeeId - The UUID of the employee to delete.
      Returns:
      true if the deletion was successful; false otherwise.