Ejemplo n.º 1
0
  @RequestMapping(value = "/{orderId}/order", params = "status", method = RequestMethod.POST)
  ResponseEntity<Void> changeOrderStatus(@PathVariable Long orderId, @RequestParam String status)
      throws ResourceNotFoundException, IllegalArgumentException {
    LOGGER.info("Request to change status if order with id " + orderId);

    EOrderStatus orderStatus = EOrderStatus.valueOf(status);
    orderService.changeOrderStatus(orderId, orderStatus);

    return new ResponseEntity<>(HttpStatus.ACCEPTED);
  }
Ejemplo n.º 2
0
  @RequestMapping(
      value = "/business/{businessID}",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  ResponseEntity<Collection<OrderViewDTO>> getOrdersByBusinessId(@PathVariable Long businessID)
      throws ResourceNotFoundException {
    Collection<OrderViewDTO> businessOrders = orderService.fetchOrdersByBusinessID(businessID);
    LOGGER.info("Request for business orders.\nFetchedList size is " + businessOrders.size());

    return new ResponseEntity<>(businessOrders, HttpStatus.OK);
  }
Ejemplo n.º 3
0
  @RequestMapping(
      value = "/{orderID}",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  ResponseEntity<OrderViewDTO> getOrdersById(@PathVariable Long orderID)
      throws ResourceNotFoundException {
    LOGGER.info("Request for order with id " + orderID);

    OrderViewDTO orderView = orderService.fetchOrderById(orderID);

    return new ResponseEntity<>(orderView, HttpStatus.OK);
  }
Ejemplo n.º 4
0
  @RequestMapping(
      value = "/business/{businessID}",
      method = RequestMethod.POST,
      consumes = MediaType.APPLICATION_JSON_VALUE)
  ResponseEntity<Void> createOrder(@PathVariable Long businessID, @RequestBody OrderDTO orderDTO)
      throws ResourceNotFoundException {
    LOGGER.info("Request for order submit");
    long orderID = orderService.submitOrder(businessID, orderDTO);

    URI location = URI.create(EDomainLinkProvider.INSTANCE.getLocationFor(EEntity.ORDER) + orderID);
    HttpHeaders headers = new HttpHeaders();
    headers.setLocation(location);

    return new ResponseEntity<>(headers, HttpStatus.CREATED);
  }
Ejemplo n.º 5
0
  @RequestMapping(
      value = "/business/{businessID}/order",
      params = "status",
      method = RequestMethod.GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  ResponseEntity<Collection<OrderViewDTO>> getOrdersByStatus(
      @PathVariable Long businessID, @RequestParam String status)
      throws ResourceNotFoundException, IllegalArgumentException {
    EOrderStatus orderStatus = EOrderStatus.valueOf(status);
    Collection<OrderViewDTO> businessOrders =
        orderService.fetchOrdersByStatus(businessID, orderStatus);
    LOGGER.info(
        "Request for business orders with status query.\nFetchedList size is "
            + businessOrders.size());

    return new ResponseEntity<>(businessOrders, HttpStatus.OK);
  }