Package Utils

Class DatabaseUtils

java.lang.Object
Utils.DatabaseUtils

public class DatabaseUtils extends Object
Utilities for the database. Included common queries and standardizes formats
Since:
2023-03-07
  • Field Details

  • Constructor Details

    • DatabaseUtils

      public DatabaseUtils()
      Constructor
  • Method Details

    • hasItem

      public static final boolean hasItem(DatabaseConnect database, long itemID, String table)
      Check if an item exists with in the database
      Parameters:
      database - DatabaseConnect to the database
      itemID - identification number of the item to search for
      table - name of the table to query
      Returns:
      true if the item exists. false otherwise.
    • getLastId

      public static final long getLastId(DatabaseConnect database, String table)
      Returns the last ID in a given table
      Parameters:
      database - DatabaseConnect to the database
      table - table name
      Returns:
      the last ID in the table
    • getEmployeeName

      public static final String getEmployeeName(DatabaseConnect database, long id)
      Gets the employee name from the database based on the employee ID
      Parameters:
      database - DatabaseConnect to the database
      id - identification number of the employee to find
      Returns:
      String of the employee name
    • getMenuItems

      public static final Map<String,Long> getMenuItems(DatabaseConnect database, List<Long> menuIds)
      Gets the menu items from the database based on Menu IDs
      Parameters:
      database - DatabaseConnect to the database
      menuIds - List of Long holding all Menu IDs to look up
      Returns:
      HashMap of String and Long of the menu items
    • initInventoryUse

      public static final Map<Long,Long> initInventoryUse(DatabaseConnect database)
      Initializes inventory useage map. The Map holds an InventoryItem ID number as the key and its initialized quantity as value.
      Parameters:
      database - DatabaseConnect
      Returns:
      Map
    • getMenuUse

      public static final Map<Long,Long> getMenuUse(DatabaseConnect database, String start, String end)
      Gets the menu items ordered from the start to the end date. The Map holds a MenuItem as the key and the number of times ordered as value.
      Parameters:
      database - DatabaseConnect
      start - start date
      end - end date
      Returns:
      Map
    • getMenuId

      public static final List<Long> getMenuId(DatabaseConnect database, long orderID)
      Gets the Menu IDs from the database based on the order ID
      Parameters:
      database - DatabaseConnect to the database
      orderID - identification number of the order
      Returns:
      ArrayList of Long of the menu IDs
    • getMenuCost

      public static final double getMenuCost(DatabaseConnect database, String name)
      Gets the menu cost from the database based on the menu name
      Parameters:
      database - DatabaseConnect to the database
      name - of the customer making the order
      Returns:
      Double of the menu cost