Class IngredientService

java.lang.Object
balu.pizza.webapp.services.IngredientService

@Service @Transactional(readOnly=true) public class IngredientService extends Object
Ingredient Service
  • Constructor Details

    • IngredientService

      @Autowired public IngredientService(IngredientRepository ingredientRepository, TypesRepository typesRepository)
      Parameters:
      ingredientRepository - Ingredient Repository
      typesRepository - Type of Ingredient Repository
  • Method Details

    • findAll

      public List<Ingredient> findAll()
    • findByPizza

      public List<Ingredient> findByPizza(Pizza pizza)
      List of all ingredients by Pizza
      Parameters:
      pizza -
      Returns:
      Sorted list of ingredients that are part of the pizza
    • findAllSort

      public List<Ingredient> findAllSort()
      Returns:
      List of all ingredients from DB
    • findIngredientByName

      public Optional<Ingredient> findIngredientByName(String name)
      Searches for an Ingredient by Name
      Parameters:
      name -
      Returns:
      An object that may contain a Ingredient or be empty
    • create

      @Transactional public Ingredient create(Ingredient ingredient, TypeIngredient typeIngredient)
      Creates a new ingredient based on the data from the form
      Parameters:
      ingredient - ingredient
      typeIngredient - Type of ingredient
      Returns:
      Saved Ingredient
    • findById

      public Ingredient findById(int ingrId)
      Searches for an ingredient by ID
      Parameters:
      ingrId -
      Returns:
      An object that may contain a Ingredient or be empty
    • update

      @Transactional public Ingredient update(Ingredient ingredient)
      Updates Ingredient in DB
      Parameters:
      ingredient -
      Returns:
      updated Ingredient