Package Utils
Class DatabaseUtils
java.lang.Object
Utils.DatabaseUtils
Utilities for the database. Included common queries and standardizes formats
- Since:
- 2023-03-07
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final javafx.util.StringConverter<LocalDate>StringConverterofLocalDateto format the datestatic final DateTimeFormatterDateTimeFormatterto formatLocalDateTimestatic final DateTimeFormatterDateTimeFormatterto formatLocalDateTime -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringgetEmployeeName(DatabaseConnect database, long id) Gets the employee name from the database based on the employee IDstatic final longgetLastId(DatabaseConnect database, String table) Returns the last ID in a given tablestatic final doublegetMenuCost(DatabaseConnect database, String name) Gets the menu cost from the database based on the menu namegetMenuId(DatabaseConnect database, long orderID) Gets the Menu IDs from the database based on the order IDgetMenuItems(DatabaseConnect database, List<Long> menuIds) Gets the menu items from the database based on Menu IDsgetMenuUse(DatabaseConnect database, String start, String end) Gets the menu items ordered from the start to the end date.static final booleanhasItem(DatabaseConnect database, long itemID, String table) Check if an item exists with in the databaseinitInventoryUse(DatabaseConnect database) Initializes inventory useage map.
-
Field Details
-
DATE_TIME_FORMAT
DateTimeFormatterto formatLocalDateTime -
DATE_FORMAT
DateTimeFormatterto formatLocalDateTime -
CONVERTER
StringConverterofLocalDateto format the date
-
-
Constructor Details
-
DatabaseUtils
public DatabaseUtils()Constructor
-
-
Method Details
-
hasItem
Check if an item exists with in the database- Parameters:
database-DatabaseConnectto the databaseitemID- identification number of the item to search fortable- name of the table to query- Returns:
trueif the item exists.falseotherwise.
-
getLastId
Returns the last ID in a given table- Parameters:
database-DatabaseConnectto the databasetable- table name- Returns:
- the last ID in the table
-
getEmployeeName
Gets the employee name from the database based on the employee ID- Parameters:
database-DatabaseConnectto the databaseid- identification number of the employee to find- Returns:
Stringof the employee name
-
getMenuItems
Gets the menu items from the database based on Menu IDs -
initInventoryUse
Initializes inventory useage map. TheMapholds anInventoryItemID number as the key and its initialized quantity as value.- Parameters:
database-DatabaseConnect- Returns:
Map
-
getMenuUse
Gets the menu items ordered from the start to the end date. TheMapholds aMenuItemas the key and the number of times ordered as value.- Parameters:
database-DatabaseConnectstart- start dateend- end date- Returns:
Map
-
getMenuId
Gets the Menu IDs from the database based on the order ID- Parameters:
database-DatabaseConnectto the databaseorderID- identification number of the order- Returns:
ArrayListofLongof the menu IDs
-
getMenuCost
Gets the menu cost from the database based on the menu name- Parameters:
database-DatabaseConnectto the databasename- of the customer making the order- Returns:
Doubleof the menu cost
-