Class MenuSQL

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

public class MenuSQL extends Object
Provides data access methods for menu items in the database. Handles all CRUD (Create, Read, Update, Delete) operations for the menu table.
Author:
Varish Kongara, William Clymire, Austin Glander
  • Constructor Details

    • MenuSQL

      public MenuSQL()
  • Method Details

    • getAllMenuItems

      public static List<MenuItem> getAllMenuItems()
      Retrieves all menu items from the database.
      Returns:
      A list of all MenuItem objects, sorted alphabetically by name.
    • addMenuItem

      public static boolean addMenuItem(Connection conn, MenuItem item) throws SQLException
      Inserts a new menu item into the database.
      Parameters:
      conn - An active database connection.
      item - The MenuItem object to insert.
      Returns:
      true if the insert was successful; false otherwise.
      Throws:
      SQLException - if a database error occurs during insertion.
    • updateMenuItem

      public static boolean updateMenuItem(Connection conn, MenuItem item) throws SQLException
      Updates an existing menu item in the database.
      Parameters:
      conn - An active database connection.
      item - The MenuItem object with updated values.
      Returns:
      true if the update was successful; false otherwise.
      Throws:
      SQLException - if a database error occurs during update.
    • deleteMenuItem

      public static boolean deleteMenuItem(Connection conn, UUID id)
      Deletes a menu item by its unique identifier.
      Parameters:
      conn - An active database connection.
      id - The UUID of the menu item to delete.
      Returns:
      true if the deletion was successful; false otherwise.
    • getMenuItemById

      public static Optional<MenuItem> getMenuItemById(UUID id)
      Retrieves a menu item by its unique identifier.
      Parameters:
      id - The UUID of the menu item to retrieve.
      Returns:
      An Optional containing the MenuItem if found, or empty if not found.
    • getAllCombos

      public static List<String> getAllCombos()
      Retrieves all active combo menu items (category = 'Combo').
      Returns:
      A list of combo item names, sorted alphabetically.
    • getItemsByCategoryName

      public static List<String> getItemsByCategoryName(String category)
      Retrieves all active menu items for a specific category.
      Parameters:
      category - The category name to filter by (e.g., "Entree", "Side", "Drink").
      Returns:
      A list of item names in the specified category, sorted alphabetically.
    • getMenuItemByName

      public static Optional<MenuItem> getMenuItemByName(String name)
      Retrieves an active menu item by its name.
      Parameters:
      name - The name of the menu item to retrieve.
      Returns:
      An Optional containing the MenuItem if found and active, or empty if not found.