Interface OrderManagement<T extends Order>


@Service public interface OrderManagement<T extends Order>
A service to manage Orders.
Author:
Thomas Dedek, Paul Henke, Oliver Gierke
  • Method Details

    • save

      T save(T order)
      Saves the given Order or persists changes to it.
      Parameters:
      order - the order to be saved, must not be null.
      Returns:
    • get

      Optional<T> get(Order.OrderIdentifier orderIdentifier)
      Returns the order identified by an Order.OrderIdentifier
      Parameters:
      orderIdentifier - identifier of the Order to be returned, must not be null.
      Returns:
      the order if the orderIdentifier matches, otherwise Optional.empty().
    • contains

      boolean contains(Order.OrderIdentifier orderIdentifier)
      Checks if this OrderManagement contains an order.
      Parameters:
      orderIdentifier - the Order.OrderIdentifier of the Order, must not be null.
      Returns:
      true if the OrderManager contains the order, false otherwise.
    • findBy

      Streamable<T> findBy(OrderStatus orderStatus)
      Returns all Orders having the OrderStatus status. If no orders with the specified status exist, an empty Iterable is returned.
      Parameters:
      orderStatus - Denoting the OrderStatus on which the Orders will be requested.
      Returns:
      a Streamable containing all Orders with the specified OrderStatus
    • findBy

      Streamable<T> findBy(Interval interval)
      Returns all Orders in between the Interval. So every entry with an time stamp ≤ and ≥ from is returned. If no Orders within the specified time span exist, an empty Iterable is returned.
      Parameters:
      interval - The time interval to find Orders in, must not be null.
      Returns:
      a Streamable containing all Orders in the given Interval.
    • findBy

      Streamable<T> findBy(UserAccount userAccount)
      Returns all Orders of the given UserAccount. If this user has no orders, an empty Iterable is returned.
      Parameters:
      userAccount - Denoting the UserAccount on which the orders will be requested, must not be null.
      Returns:
      a Streamable containing all orders of the specified user.
    • findBy

      Streamable<T> findBy(UserAccount userAccount, Interval interval)
      Returns all Orders from the given UserAccount in between the dates from and to, including from and to. So every entry with an time stamp ≤ to and ≥ from is returned. If this user has no Orders in this period, an empty Iterable is returned.
      Parameters:
      userAccount - The UserAccount whose Orders shall be returned, must not be null.
      interval - The time interval to find Orders in, must not be null.
      Returns:
      a Streamable containing all orders from the specified user in the specified period.
    • completeOrder

      void completeOrder(T order) throws OrderCompletionFailure
      Tries to complete this order, the OrderStatus has to be OrderStatus.PAID.
      Parameters:
      order - the order to complete, must not be null.
      Throws:
      OrderCompletionFailure - in case the order can't be completed.
      See Also:
    • payOrder

      boolean payOrder(T order)
      Pays the Order, OrderStatus must be OrderStatus.OPEN and PaymentMethod must be set.
      Parameters:
      order - the order to be payed, must not be null.
      Returns:
      true if the order could be paid
      See Also:
    • cancelOrder

      boolean cancelOrder(T order, String reason)
      Cancels an Order, no matter what state it is in.
      Parameters:
      order - the order to be canceled, must not be null.
      reason - the reason the order was canceled.
      Returns:
      true if the order could be canceled
      See Also:
    • delete

      T delete(T order)
      Deletes the given Order.
      Parameters:
      order - must not be null.
      Returns:
      the deleted Order
      Since:
      7.1
    • findAll

      Page<T> findAll(Pageable pageable)
      Returns the Page of orders specified by the given Pageable.
      Returns:
      the Page of orders specified by the given Pageable.
      Since:
      7.1