コード例 #1
0
  private String deletePizza(Pizzeria pizzeria, Pizza pizza, PizzeriaPizzaForm form) {
    List<RelationPizzeriaPizza> pizzeriaPizzas = pizzeria.getPizzasPriceList();

    /*
     * Only update the pizza if the pizzeria has already a
     * RelationPizzeriaPizza with the same id.
     */
    for (RelationPizzeriaPizza pizzeriaPizza : pizzeriaPizzas) {
      if (pizzeriaPizza.getId() == form.getId()) {

        /*
         * FIXME - Prevent the elimination of RelationPizzeriaPizzas
         * which belong to an OrderItem which has not yet been
         * collected.
         */

        RelationPizzeriaPizzaDAO dao =
            (RelationPizzeriaPizzaDAO) context.getBean("relationPizzeriaPizzaDAO");
        pizzeriaPizza.setAvailable(false);
        dao.update(pizzeriaPizza);
        return buildOkResponse(pizzeriaPizza);
      }
    }

    return buildErrorResponse();
  }
コード例 #2
0
  private String updatePizza(Pizzeria pizzeria, Pizza pizza, PizzeriaPizzaForm form) {
    List<RelationPizzeriaPizza> pizzeriaPizzas = pizzeria.getPizzasPriceList();

    /*
     * Only update the pizza if the pizzeria has already a
     * RelationPizzeriaPizza with the same id.
     */
    for (RelationPizzeriaPizza pizzeriaPizza : pizzeriaPizzas) {
      if (pizzeriaPizza.getId() == form.getId()) {
        pizzeriaPizza.setPizza(pizza);
        pizzeriaPizza.setPizzaSize(form.getSize());
        pizzeriaPizza.setPreparationTime(form.getPreparationTimeInSeconds());
        pizzeriaPizza.setGlutenFree(form.getGlutenFree());
        pizzeriaPizza.setPrice(form.getPrice());

        RelationPizzeriaPizzaDAO dao =
            (RelationPizzeriaPizzaDAO) context.getBean("relationPizzeriaPizzaDAO");
        dao.update(pizzeriaPizza);

        return buildOkResponse(pizzeriaPizza);
      }
    }

    return buildErrorResponse();
  }