mirror of
https://gitlab.com/etc404/software-engineering-project.git
synced 2026-05-10 20:52:58 +00:00
got rid of odd duplicate lines
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package com.example.demo.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -56,11 +58,13 @@ public class Recipe {
|
||||
// Recipe ingredients relationship
|
||||
@OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
@NotEmpty(message = "At least one ingredient is required")
|
||||
private Set<RecipeIngredient> recipeIngredients = new HashSet<>();
|
||||
|
||||
@OrderBy("orderIndex ASC")
|
||||
private List<RecipeIngredient> recipeIngredients = new ArrayList<>();
|
||||
|
||||
// Recipe Steps relationship
|
||||
@OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private Set<Step> steps = new HashSet<>();
|
||||
@OrderBy("stepNumber ASC")
|
||||
private List<Step> steps = new ArrayList<>();
|
||||
|
||||
// Recipe Images relationship
|
||||
@OneToMany(mappedBy = "recipe", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
@@ -172,21 +176,22 @@ public class Recipe {
|
||||
|
||||
public void setUpdatedAt(LocalDateTime updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Set<RecipeIngredient> getRecipeIngredients() {
|
||||
public List<RecipeIngredient> getRecipeIngredients(){
|
||||
return recipeIngredients;
|
||||
}
|
||||
|
||||
public void setRecipeIngredients(Set<RecipeIngredient> recipeIngredients) {
|
||||
public void setRecipeIngredients(List<RecipeIngredient> recipeIngredients) {
|
||||
this.recipeIngredients = recipeIngredients;
|
||||
}
|
||||
|
||||
public Set<Step> getSteps() {
|
||||
public List<Step> getSteps(){
|
||||
return steps;
|
||||
}
|
||||
|
||||
public void setSteps(Set<Step> steps) {
|
||||
public void setSteps(List<Step> steps) {
|
||||
this.steps = steps;
|
||||
}
|
||||
|
||||
@@ -221,4 +226,4 @@ public class Recipe {
|
||||
public void setCost(Integer cost) {
|
||||
this.cost = cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ public class RecipeIngredient {
|
||||
@Column(columnDefinition = "TEXT")
|
||||
@Size(max = 128, message = "Note cannot be longer than 128 characters")
|
||||
private String notes;
|
||||
|
||||
// To help keep in order
|
||||
@Column(name = "order_index")
|
||||
private Integer orderIndex;
|
||||
|
||||
public RecipeIngredient() {
|
||||
}
|
||||
@@ -99,4 +103,13 @@ public class RecipeIngredient {
|
||||
public void setNotes(String notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
}
|
||||
|
||||
//to help keep in order
|
||||
public Integer getOrderIndex() {
|
||||
return orderIndex;
|
||||
}
|
||||
|
||||
public void setOrderIndex(Integer orderIndex) {
|
||||
this.orderIndex = orderIndex;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user