01: /**
02: * Objective Database Abstraction Layer (ODAL)
03: * Copyright (c) 2004, The ODAL Development Group
04: * All rights reserved.
05: * For definition of the ODAL Development Group please refer to LICENCE.txt file
06: *
07: * Distributable under LGPL license.
08: * See terms of license at gnu.org.
09: */package com.odal.petstore.domain;
10:
11: import com.odal.petstore.persistence.gen.bean.OrderPoBean;
12:
13: import java.util.Date;
14: import java.util.Iterator;
15: import java.util.List;
16:
17: /**
18: * @author Gennady Krizhevsky
19: */
20: public class Order extends OrderPoBean {
21:
22: public Order() {
23: }
24:
25: public Order(long orderid) {
26: super (orderid);
27: }
28:
29: public void initOrder(Account account, Cart cart) {
30:
31: setUserId(account.getUserName());
32: setOrderDate(new Date());
33:
34: setShipToFirstName(account.getFirstName());
35: setShipToLastName(account.getLastName());
36: setShipAddress1(account.getAddress1());
37: setShipAddress2(account.getAddress2());
38: setShipCity(account.getCity());
39: setShipState(account.getState());
40: setShipZip(account.getZip());
41: setShipCountry(account.getCountry());
42:
43: setBillToFirstName(account.getFirstName());
44: setBillToLastName(account.getLastName());
45: setBillAddress1(account.getAddress1());
46: setBillAddress2(account.getAddress2());
47: setBillCity(account.getCity());
48: setBillState(account.getState());
49: setBillZip(account.getZip());
50: setBillCountry(account.getCountry());
51:
52: setTotalPrice(cart.getSubTotal());
53:
54: setCreditCard("999 9999 9999 9999");
55: setExpiryDate("12/03");
56: setCardType("Visa");
57: setCourier("UPS");
58: setLocale("CA");
59: setStatus("P");
60:
61: Iterator i = cart.getAllCartItems();
62: while (i.hasNext()) {
63: CartItem cartItem = (CartItem) i.next();
64: addLineItem(cartItem);
65: }
66:
67: }
68:
69: public void addLineItem(CartItem cartItem) {
70: List lineItems = getLineItems();
71: LineItem lineItem = new LineItem(lineItems.size() + 1, cartItem);
72: addLineItem(lineItem);
73: }
74:
75: }
|