public final class GroceryListDB extends ObjectDB
Constructor and Description |
---|
GroceryListDB()
Class constructor that fetches the connection to the production database.
|
GroceryListDB(DatabaseConnection databaseConnection)
Class constructor that stores the given database connection for later use.
|
Modifier and Type | Method and Description |
---|---|
void |
addGroceryList(User listOwner,
GroceryList list)
Insert a new GroceryList in the database
|
void |
addItemToGroceryList(User listOwner,
java.lang.String listName,
ProductAmount item)
Add a GroceryListItem to a given GroceryList
|
void |
deleteGroceryList(User listOwner,
java.lang.String listName)
Delete a GroceryList from the database
|
java.util.List<java.lang.String> |
getAllGroceryListsName(User owner)
Get all the names of the GroceryLists of a user from the database
|
GroceryList |
getGroceryList(User listOwner,
java.lang.String listName)
Get a GroceryList from the database
|
emptyAllTables, getDatabaseConnection
public GroceryListDB() throws DatabaseConnectionException
DatabaseConnectionException
public GroceryListDB(DatabaseConnection databaseConnection)
databaseConnection
- public void addGroceryList(User listOwner, GroceryList list) throws GroceryListInsertionException, GroceryListItemInsertException
listOwner
- The owner of the listlist
- the GroceryListGroceryListInsertionException
GroceryListItemInsertException
public java.util.List<java.lang.String> getAllGroceryListsName(User owner)
owner
- The owner of the listpublic GroceryList getGroceryList(User listOwner, java.lang.String listName) throws DatabaseException
listOwner
- The owner of the listlistName
- The name of the listDatabaseException
public void deleteGroceryList(User listOwner, java.lang.String listName) throws DatabaseException
listOwner
- the user whose the list belongs tolistName
- the name of the listDatabaseException
public void addItemToGroceryList(User listOwner, java.lang.String listName, ProductAmount item) throws GroceryListItemInsertException
listOwner
- the user whose the list belongs tolistName
- the name of the list the item should be inserted initem
- the item we want to insertGroceryListItemInsertException