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
Modifier and TypeFieldDescriptionstatic final javafx.util.StringConverter<LocalDate>
StringConverter
ofLocalDate
to format the datestatic final DateTimeFormatter
DateTimeFormatter
to formatLocalDateTime
static final DateTimeFormatter
DateTimeFormatter
to formatLocalDateTime
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final String
getEmployeeName
(DatabaseConnect database, long id) Gets the employee name from the database based on the employee IDstatic final long
getLastId
(DatabaseConnect database, String table) Returns the last ID in a given tablestatic final double
getMenuCost
(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 boolean
hasItem
(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
DateTimeFormatter
to formatLocalDateTime
-
DATE_FORMAT
DateTimeFormatter
to formatLocalDateTime
-
CONVERTER
StringConverter
ofLocalDate
to format the date
-
-
Constructor Details
-
DatabaseUtils
public DatabaseUtils()Constructor
-
-
Method Details
-
hasItem
Check if an item exists with in the database- Parameters:
database
-DatabaseConnect
to the databaseitemID
- identification number of the item to search fortable
- name of the table to query- Returns:
true
if the item exists.false
otherwise.
-
getLastId
Returns the last ID in a given table- Parameters:
database
-DatabaseConnect
to 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
-DatabaseConnect
to the databaseid
- identification number of the employee to find- Returns:
String
of the employee name
-
getMenuItems
Gets the menu items from the database based on Menu IDs -
initInventoryUse
Initializes inventory useage map. TheMap
holds anInventoryItem
ID 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. TheMap
holds aMenuItem
as the key and the number of times ordered as value.- Parameters:
database
-DatabaseConnect
start
- start dateend
- end date- Returns:
Map
-
getMenuId
Gets the Menu IDs from the database based on the order ID- Parameters:
database
-DatabaseConnect
to the databaseorderID
- identification number of the order- Returns:
ArrayList
ofLong
of the menu IDs
-
getMenuCost
Gets the menu cost from the database based on the menu name- Parameters:
database
-DatabaseConnect
to the databasename
- of the customer making the order- Returns:
Double
of the menu cost
-