コード例 #1
0
  @RequestMapping(value = "/waiter/bills/{billId}", method = RequestMethod.GET)
  public String showBillInWaiter(
      @PathVariable("billId") String billId, Model uiModel, Locale locale) {

    // warmup stuff
    Bill bill = warmupRestaurant(billId, uiModel);
    Restaurant resto = bill.getDiningTable().getRestaurant();

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

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

    uiModel.addAttribute(
        "message",
        new Message(
            "info",
            messageSource.getMessage("label_bill_amount", new Object[] {}, locale)
                + ": "
                + bill.getPriceAllOrders()
                + " "
                + messageSource.getMessage("label_currency", new Object[] {}, locale)));

    return "hartigehap/waiter";
  }
コード例 #2
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";
  }
コード例 #3
0
 private Bill warmupRestaurant(String billId, Model uiModel) {
   Bill bill = billService.findById(Long.valueOf(billId));
   Collection<Restaurant> restaurants = restaurantService.findAll();
   uiModel.addAttribute("restaurants", restaurants);
   Restaurant restaurant =
       restaurantService.fetchWarmedUp(bill.getDiningTable().getRestaurant().getId());
   uiModel.addAttribute("restaurant", restaurant);
   return bill;
 }
コード例 #4
0
 private void billHasBeenPaid(Bill bill) {
   try {
     billService.billHasBeenPaid(bill);
   } catch (StateException e) {
     log.error(
         "Internal error has occurred! Order "
             + Long.valueOf(bill.getId())
             + "has not been changed to served state!",
         e);
   }
 }
コード例 #5
0
  @RequestMapping(value = "/restaurants/{restaurantName}/waiter", method = RequestMethod.GET)
  public String showWaiter(@PathVariable("restaurantName") String restaurantName, Model uiModel) {

    // warmup stuff
    Collection<Restaurant> restaurants = restaurantService.findAll();
    uiModel.addAttribute("restaurants", restaurants);
    Restaurant restaurant = restaurantService.fetchWarmedUp(restaurantName);
    uiModel.addAttribute("restaurant", restaurant);

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

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

    return "hartigehap/waiter";
  }