Class PizzaService

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

@Service @Transactional(readOnly=true) public class PizzaService extends Object
Pizza service
  • Constructor Details

    • PizzaService

      @Autowired public PizzaService(PizzaRepository pizzaRepository, IngredientService ingredientService)
      Implementing dependencies
      Parameters:
      pizzaRepository - Pizza Repository
      ingredientService - Ingredient Service
  • Method Details

    • findAll

      public List<Pizza> findAll()
      Searches all pizzas
      Returns:
      Sorted by name list of all pizzas from DB
    • findByPizzaSize

      public List<Pizza> findByPizzaSize(String size)
      Searches all pizzas by base size
      Parameters:
      size - Base size
      Returns:
      Sorted by name list of all pizzas with size 'size'
    • findById

      public Pizza findById(int id)
      Searches pizza by id
      Parameters:
      id -
      Returns:
      if successful: Pizza
      Throws:
      NotFoundException - if pizza was not found
    • getCalculatedPrice

      public double getCalculatedPrice(Pizza pizza)
      The method calculates the cost of pizza the size of the pizza and all of its ingredients are taken into account
      Parameters:
      pizza -
      Returns:
      Calculated price
    • setNewPrice

      @Transactional public void setNewPrice(Pizza pizza, double newPrice)
      Method for changing the price of a pizza
      Parameters:
      pizza - Pizza
      newPrice - new Price
    • create

      @Transactional public Pizza create(Pizza pizza)
      saves new pizza to DB
      Parameters:
      pizza -
      Returns:
      saved pizza
    • findByName

      public Optional<Pizza> findByName(String name)
      Searches pizza by name
      Parameters:
      name - pizza name
      Returns:
      An object that may contain a Pizza or be empty
    • findByPerson

      public List<Pizza> findByPerson(Person person)
      Searches all pizzas associated with the user
      Parameters:
      person - Entity Person
      Returns:
      list of all pizzas associated with the user
    • findAllSortedBy

      public List<Pizza> findAllSortedBy(String param)
      Searches all pizza in DB
      Parameters:
      param - Pizza sorting parameter
      Returns:
      Sorted by param list of all pizzas from BD
    • update

      @Transactional public Pizza update(Pizza pizzaData)
      Method for updating pizza fields with data from a form
      Parameters:
      pizzaData - Data from form
      Returns:
      updated Pizza
    • findByCafe

      public List<Pizza> findByCafe(Cafe cafe)
      Searches of all pizzas associated with the cafe
      Parameters:
      cafe - Entity Cafe
      Returns:
      List of all pizzas associated with the cafe