Class MenuInventorySQL

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

public class MenuInventorySQL extends Object
Provides data access methods for menu-inventory relationships in the database. Manages the many-to-many relationship between menu items and inventory items.
Author:
Varish Kongara, William Clymire, Austin Glander
  • Constructor Details

    • MenuInventorySQL

      public MenuInventorySQL()
  • Method Details

    • getInventoryForMenuItem

      public static List<MenuInventory> getInventoryForMenuItem(UUID menuItemId)
      Retrieves all inventory items and their quantities for a specific menu item.
      Parameters:
      menuItemId - The UUID of the menu item.
      Returns:
      A list of MenuInventory records representing the inventory relationships.
    • getMenuInventoryRelationships

      public static Map<UUID, List<MenuInventory>> getMenuInventoryRelationships()
      Retrieves all menu-inventory relationships from the database.
      Returns:
      A map where keys are menu item UUIDs and values are lists of MenuInventory records for each menu item.
    • addMenuInventory

      public static boolean addMenuInventory(Connection conn, MenuInventory menuInventory) throws SQLException
      Adds a new menu-inventory relationship to the database.
      Parameters:
      conn - An active database connection.
      menuInventory - The MenuInventory record to add.
      Returns:
      true if the relationship was successfully added; false otherwise.
      Throws:
      SQLException - if a database error occurs during insertion.
    • deleteByMenuItemId

      public static boolean deleteByMenuItemId(Connection conn, UUID menuItemId)
      Deletes all menu-inventory relationships for a specific menu item.
      Parameters:
      conn - An active database connection.
      menuItemId - The UUID of the menu item whose relationships should be deleted.
      Returns:
      true if the deletion was successful; false otherwise.
    • delete

      public static boolean delete(Connection conn, MenuInventory menuInventory)
      Deletes a specific menu-inventory relationship.
      Parameters:
      conn - An active database connection.
      menuInventory - The MenuInventory record to delete.
      Returns:
      true if the deletion was successful; false otherwise.