@RequestMapping(value = "/waiter/orders/{orderId}", method = RequestMethod.GET)
  public String showOrderInWaiter(
      @PathVariable("orderId") String orderId, Model uiModel, Locale locale) {

    // warmup stuff
    Order order = warmupRestaurantByOrder(orderId, uiModel);
    Restaurant resto = order.getBill().getDiningTable().getRestaurant();

    List<Order> allPreparedOrders = orderService.findPreparedOrdersForRestaurant(resto);
    uiModel.addAttribute("allPreparedOrders", allPreparedOrders);

    List<Bill> allSubmittedBills = billService.findSubmittedBillsForRestaurant(resto);
    uiModel.addAttribute("allSubmittedBills", allSubmittedBills);

    String orderContent = "";
    for (OrderItem orderItem : order.getOrderItems()) {
      orderContent +=
          orderItem.getMenuItem().getId() + " (" + orderItem.getQuantity() + "x)" + "; ";
    }

    uiModel.addAttribute(
        "message",
        new Message(
            "info",
            messageSource.getMessage("label_order_content", new Object[] {}, locale)
                + ": "
                + orderContent));

    return "hartigehap/waiter";
  }
 private Restaurant warmupRestaurant(Order order, Model uiModel) {
   Collection<Restaurant> restaurants = restaurantService.findAll();
   uiModel.addAttribute("restaurants", restaurants);
   Restaurant restaurant =
       restaurantService.fetchWarmedUp(order.getBill().getDiningTable().getRestaurant().getId());
   uiModel.addAttribute("restaurant", restaurant);
   return restaurant;
 }
 private Order warmupRestaurantByOrder(String orderId, Model uiModel) {
   Order order = orderService.findById(Long.valueOf(orderId));
   Collection<Restaurant> restaurants = restaurantService.findAll();
   uiModel.addAttribute("restaurants", restaurants);
   Restaurant restaurant =
       restaurantService.fetchWarmedUp(order.getBill().getDiningTable().getRestaurant().getId());
   uiModel.addAttribute("restaurant", restaurant);
   return order;
 }
  @RequestMapping(value = "/waiter/orders/{orderId}", method = RequestMethod.PUT)
  public String receiveOrderEvent(
      @PathVariable("orderId") String orderId, @RequestParam String event, Model uiModel) {

    Order order = warmupRestaurantByOrder(orderId, uiModel);

    switch (event) {
      case "orderHasBeenServed":
        orderHasBeenServed(order);
        break;

      default:
        log.error("Internal error: event " + event + " not recognized");
        break;
    }

    return "redirect:/restaurants/"
        + order.getBill().getDiningTable().getRestaurant().getId()
        + "/waiter";
  }