public class RecipeDB extends ObjectDB
Constructor and Description |
---|
RecipeDB()
Class constructor that fetches the connection to the production database.
|
RecipeDB(DatabaseConnection databaseConnection)
Class constructor that stores the given database connection for later use.
|
Modifier and Type | Method and Description |
---|---|
void |
addProductAmountToRecipe(User recipeOwner,
java.lang.String recipeName,
ProductAmount item)
Add a ProductAmount to a given Recipe
|
void |
addRecipe(User recipeOwner,
Recipe recipe)
Insert a new Recipe in the database
|
void |
deleteRecipe(User recipeOwner,
java.lang.String recipeName)
Deletes a Recipe from the database
|
java.util.List<java.lang.String> |
getAllRecipesName(User owner)
Gets all the names of the Recipes of a user from the database
|
Recipe |
getRecipe(User recipeOwner,
java.lang.String recipeName)
Get a Recipe from the database
|
private javafx.util.Pair<java.lang.Integer,java.lang.String> |
getRecipeGeneralInfos(java.lang.String recipeName,
User recipeOwner)
Gets the Instructions of a recipe and the number of people from the database
|
private java.util.List<ProductAmount> |
getRecipeProductAmounts(java.lang.String recipeName,
User recipeOwner)
Gets all the ProductAmounts of a recipe
|
emptyAllTables, getDatabaseConnection
public RecipeDB() throws DatabaseConnectionException
DatabaseConnectionException
public RecipeDB(DatabaseConnection databaseConnection)
databaseConnection
- public void addRecipe(User recipeOwner, Recipe recipe) throws RecipeInsertionException, RecipeItemInsertException
recipeOwner
- The owner of the reciperecipe
- the RecipeRecipeInsertionException
RecipeItemInsertException
public Recipe getRecipe(User recipeOwner, java.lang.String recipeName) throws DatabaseException, NoSuchRecipeException, RecipeCreationException
recipeOwner
- The owner of the reciperecipeName
- The name of the recipeNoSuchRecipeException
RecipeCreationException
DatabaseException
private javafx.util.Pair<java.lang.Integer,java.lang.String> getRecipeGeneralInfos(java.lang.String recipeName, User recipeOwner) throws NoSuchRecipeException
recipeName
- The name of the reciperecipeOwner
- The owner of the recipeNoSuchRecipeException
private java.util.List<ProductAmount> getRecipeProductAmounts(java.lang.String recipeName, User recipeOwner) throws ProductAmountsFetchException
recipeName
- The name of the reciperecipeOwner
- The owner of the recipeProductAmountsFetchException
public java.util.List<java.lang.String> getAllRecipesName(User owner) throws DatabaseException
owner
- The owner of the recipeDatabaseException
public void deleteRecipe(User recipeOwner, java.lang.String recipeName) throws DatabaseException
recipeOwner
- The user whose the recipe belongs torecipeName
- The name of the recipeDatabaseException
public void addProductAmountToRecipe(User recipeOwner, java.lang.String recipeName, ProductAmount item) throws RecipeItemInsertException
recipeOwner
- the user whose the recipe belongs torecipeName
- the name of the recipe the item should be inserted initem
- the item we want to insertRecipeItemInsertException