public class RecipeController extends ControllerWithMenuThatSaves
Modifier and Type | Field and Description |
---|---|
private boolean |
isRecipeInfoModified |
private Recipe |
recipe |
private RecipeDB |
recipeDB |
private RecipeView |
view |
master
Constructor and Description |
---|
RecipeController(ControllerMaster master,
java.lang.String recipeName)
Constructor: Fetches the recipe from the DB and creates the view.
|
Modifier and Type | Method and Description |
---|---|
void |
acknowledgeChange()
Whenever a change is made, the boolean variable isRecipeInfoModified is set to true.
|
protected void |
askSaveConfirmation()
Asks the user whether he wants to save the recipe changes and saves it if he does.
|
void |
generateGroceryList()
Saves the recipe, generates the grocery list from the recipe, saves it in the DB
and then shows it.
|
private GroceryList |
getGroceryListFromView()
Creates a GroceryList bases on the content of the recipe view
|
java.lang.String |
getInstructions()
Returns the Instructions of the recipe
|
int |
getNumberPeople()
Returns the number of people for which the recipe is made
|
java.lang.String |
getRecipeName() |
private void |
saveOrOverWriteGroceryListInDb(GroceryList groceryList)
Saves the grocery list to the database.
|
void |
saveRecipe()
Creates a new Recipe, fills it with all the items retrieved from the
view and saves it in the database.
|
private void |
saveRecipeInDB(Recipe recipeToSave)
Saves the GroceryList in the database.
|
onLogout, onShowAllGroceryLists, onShowAllRecipes, onShowEditProfile, onShowMap
onHelpViewStatusChanged, onShowHelp, setView
isHelpOpen
private RecipeView view
private RecipeDB recipeDB
private Recipe recipe
private boolean isRecipeInfoModified
public RecipeController(ControllerMaster master, java.lang.String recipeName) throws NoSuchRecipeException, RecipeCreationException
master
- ControllerMasterrecipeName
- NoSuchRecipeException
RecipeCreationException
public java.lang.String getRecipeName()
public void generateGroceryList()
public void saveRecipe() throws RecipeCreationException
RecipeCreationException
protected void askSaveConfirmation()
askSaveConfirmation
in class ControllerWithMenuThatSaves
public void acknowledgeChange()
private GroceryList getGroceryListFromView()
private void saveOrOverWriteGroceryListInDb(GroceryList groceryList) throws DatabaseConnectionException, DatabaseException
groceryList
- DatabaseConnectionException
DatabaseException
private void saveRecipeInDB(Recipe recipeToSave)
recipeToSave
- public java.lang.String getInstructions()
public int getNumberPeople()