feat: language in recipes

This commit is contained in:
Natalia Cholewa 2026-01-09 14:54:42 +01:00
commit 74b6f25e24
6 changed files with 86 additions and 12 deletions

View file

@ -49,6 +49,10 @@ public class Recipe {
@Column(name = "name", nullable = false, unique = true)
private String name;
// Locale in which the recipe was created.
@Column(name = "locale", nullable = false)
private String locale = "en";
// Creates another table named recipe_ingredients which stores:
// recipe_ingredients(recipe_id -> recipes(id), ingredient).
// Example recipe_ingredients table:
@ -95,11 +99,15 @@ public class Recipe {
this.name = name;
}
// TODO: Replace String with Embeddable Ingredient Class for ingredients
public Recipe(Long id, String name, List<RecipeIngredient> ingredients, List<String> preparationSteps) {
public Recipe(Long id,
String name,
String locale,
List<RecipeIngredient> ingredients,
List<String> preparationSteps) {
// Not used by JPA/Spring
this.id = id;
this.name = name;
this.locale = locale;
this.ingredients = ingredients;
this.preparationSteps = preparationSteps;
}
@ -120,6 +128,14 @@ public class Recipe {
this.name = name;
}
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
// TODO: Replace String with Embeddable Ingredient Class
public List<RecipeIngredient> getIngredients() {
// Disallow modifying the returned list.
@ -159,7 +175,7 @@ public class Recipe {
@Override
public String toString() {
return "Recipe " + id +
" - " + name +
" - " + name + " (" + locale + ")" +
": " + ingredients.size() + " ingredients / " +
preparationSteps.size() + " steps";
}
@ -170,6 +186,7 @@ public class Recipe {
return "Recipe{" +
"id=" + id +
", name='" + name + '\'' +
", locale='" + locale + "'" +
", ingredients=" + ingredients +
", preparationSteps=" + preparationSteps +
'}';