Package edu.ntnu.stud.model.database
Class JsonToDb
java.lang.Object
edu.ntnu.stud.model.database.JsonToDb
This class is responsible for seeding the database with data from JSON files.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
getJsonFromDb
(String listName) Gets the entire shopping list or inventory table from the database and populates the corresponding Json file.static void
Populates the cookbook and recipeIngredient tables from a Json file.static void
updateFromJson
(String jsonFileName) Updates either the shopping list or inventory table in the database with data from a JSON file.static void
Updates the inventory table in the database with data from a JSON file.
-
Constructor Details
-
JsonToDb
public JsonToDb()
-
-
Method Details
-
initRecipeFromJson
public static void initRecipeFromJson()Populates the cookbook and recipeIngredient tables from a Json file.- See Also:
-
updateInventoryFromJson
Updates the inventory table in the database with data from a JSON file.- Throws:
DbConnectionErrorException
- If an error occurs while connecting to the database.
-
getJsonFromDb
Gets the entire shopping list or inventory table from the database and populates the corresponding Json file.- Parameters:
listName
- The name of both the list and the table to get.- Throws:
DbConnectionErrorException
- If an error occurs while connecting to the database.
-
updateFromJson
Updates either the shopping list or inventory table in the database with data from a JSON file.- Parameters:
jsonFileName
- The name of the JSON file to update from, is also used to determine what table to insert into.- Throws:
IllegalArgumentException
-