Package com.bookstore.domain.model

Examples of com.bookstore.domain.model.Order


    orders = new ArrayList<Order>();
   
    // Set up the fake data
   
    // ORDER 1
    Order order1 = new Order();
    order1.setId("0");
    order1.setCustomer(mct.customers.get(0));
    order1.setBillingAddress(mct.customers.get(0).getAddresses().get(0));
    order1.setShippingAddress(mct.customers.get(0).getAddresses().get(0));
    order1.setCreditCard(mct.customers.get(0).getCreditCards().get(0));
    order1.addBook(mbt.books.get(0), 2);
    order1.addBook(mbt.books.get(3), 1);
    order1.addBook(mbt.books.get(8), 1);
   
    orders.addAll(Arrays.asList(order1));
  }
View Full Code Here


  public Order addOrder(Customer customer, Address billingAddress, Address shippingAddress,
              CreditCard creditCard, ShippingCompany shippingCompany, List<Line> lines, boolean paymentReceived,
              String orderState) {
   
    // Create the new Order
    Order order = new Order();
    order.setId(String.valueOf(db.orders.size()));
    order.setCustomer(customer);
    order.setBillingAddress(billingAddress);
    order.setShippingAddress(shippingAddress);
    order.setCreditCard(creditCard);
    order.setShippingCompany(shippingCompany);
    order.setLines(lines);
    order.setPaymentReceived(paymentReceived);
    order.setOrderState(orderState);
   
    // Add the new order
    db.orders.add(order);
   
    // Return the newly created order
View Full Code Here

   * @param paymentReceived
   */
  public void updateCustomer(String id, Customer customer, Address billingAddress, Address shippingAddress,
              CreditCard creditCard, ShippingCompany shippingCompany, boolean paymentReceived) {
   
    Order order = db.orders.get(Integer.parseInt(id));
    order.setId(String.valueOf(db.orders.size() -1));
    order.setCustomer(customer);
    order.setBillingAddress(billingAddress);
    order.setShippingAddress(shippingAddress);
    order.setCreditCard(creditCard);
    order.setShippingCompany(shippingCompany);
    order.setPaymentReceived(paymentReceived);
  }
View Full Code Here

   * @return
   */
  public OrderRepresentation addBookToOrder(String customerId, String bookId) {

    // Get the order
    Order order = orderDao.getCustomerCurrentOrder(customerId);
   
    // Get the book
    Book book = bookDao.getBook(bookId);
   
    // Update the order
    // We can only do these actions in the Open state
    if (order != null) {
      boolean exists = false;
      for (Line line : order.getLines()) {
        if (line.getBook().getId().equals(book.getId())) {
          line.setQuantity(line.getQuantity() +1);
          exists = true;
        }
      }
      if (!exists) {
        order.addBook(book, 1);
      }
    } else {
      Customer customer = customerDao.getCustomer(customerId);
      order = orderDao.addOrder(customer, customer.getAddresses().get(0),
          customer.getAddresses().get(0), customer.getCreditCards().get(0),
          shippingCompanyDao.getShippingCompanies().get(0), new ArrayList<Line>(),
          false, "Open");
      order.addBook(book, 1);
    }

    return createRepresentation(order);
  }
View Full Code Here

   * Translates an order model to an order representation.
   * @param id
   * @return
   */
  public OrderRepresentation getOrder(String id, String customerId) {
    Order order = orderDao.getCustomerOrder(id, customerId);
   
    return createRepresentation(order);
  }
View Full Code Here

   */
  public OrderRepresentation createOrder(String customerId) {
   
    // If an open order exists, send back that one
    //  If it doesn't, send back a new, empty one
    Order order = orderDao.getCustomerCurrentOrder(customerId);
    Customer customer = customerDao.getCustomer(customerId);
   
    if (order == null) {
      order = orderDao.addOrder(customer, customer.getAddresses().get(0),
          customer.getAddresses().get(0), customer.getCreditCards().get(0),
View Full Code Here

  public OrderRepresentation updateOrder(String id, Customer customer, Address billingAddress, Address shippingAddress,
      CreditCard creditCard, ShippingCompany shippingCompany, List<Line> lines, boolean paymentReceived,
      String orderState) {

    // Get the order
    Order order = orderDao.getOrder(id);
   
    // Update the order
    // We can only do these actions in the Open state
    if (order.getOrderState().equals("Open")) {
      order.setCustomer(customer);
      order.setBillingAddress(billingAddress);
      order.setShippingAddress(shippingAddress);
      order.setCreditCard(creditCard);
      order.setShippingCompany(shippingCompany);
      order.setLines(lines);
    }
   
    // We can only do these actions in the Open or Ordered sate
    if (order.getOrderState().equals("Open") || order.getOrderState().equals("Ordered")) {
      order.setPaymentReceived(paymentReceived);
    }
   
    // We can do this in any state, except canceled.
    if (!order.getOrderState().equals("Canceled")) {
      order.setOrderState(orderState);
    }

    return createRepresentation(order);
  }
View Full Code Here

TOP

Related Classes of com.bookstore.domain.model.Order

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.