Class MenuInventorySQL
java.lang.Object
csce331.group13.project2.backend.MenuInventorySQL
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddMenuInventory(Connection conn, MenuInventory menuInventory) Adds a new menu-inventory relationship to the database.static booleandelete(Connection conn, MenuInventory menuInventory) Deletes a specific menu-inventory relationship.static booleandeleteByMenuItemId(Connection conn, UUID menuItemId) Deletes all menu-inventory relationships for a specific menu item.static List<MenuInventory> getInventoryForMenuItem(UUID menuItemId) Retrieves all inventory items and their quantities for a specific menu item.static Map<UUID, List<MenuInventory>> Retrieves all menu-inventory relationships from the database.
-
Constructor Details
-
MenuInventorySQL
public MenuInventorySQL()
-
-
Method Details
-
getInventoryForMenuItem
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
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
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
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.
-