Пример #1
0
  @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";
  }
Пример #2
0
 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;
 }
 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;
 }
Пример #4
0
 private void orderHasBeenServed(Order order) {
   try {
     orderService.orderServed(order);
   } catch (StateException e) {
     log.error(
         "Internal error has occurred! Order "
             + Long.valueOf(order.getId())
             + "has not been changed to served state!",
         e);
   }
 }
Пример #5
0
  @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";
  }