KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > samples > jpetstore > domain > Order


1 package org.springframework.samples.jpetstore.domain;
2
3 import java.io.Serializable JavaDoc;
4 import java.util.ArrayList JavaDoc;
5 import java.util.Date JavaDoc;
6 import java.util.Iterator JavaDoc;
7 import java.util.List JavaDoc;
8
9 public class Order implements Serializable JavaDoc {
10
11   /* Private Fields */
12
13   private int orderId;
14   private String JavaDoc username;
15   private Date JavaDoc orderDate;
16   private String JavaDoc shipAddress1;
17   private String JavaDoc shipAddress2;
18   private String JavaDoc shipCity;
19   private String JavaDoc shipState;
20   private String JavaDoc shipZip;
21   private String JavaDoc shipCountry;
22   private String JavaDoc billAddress1;
23   private String JavaDoc billAddress2;
24   private String JavaDoc billCity;
25   private String JavaDoc billState;
26   private String JavaDoc billZip;
27   private String JavaDoc billCountry;
28   private String JavaDoc courier;
29   private double totalPrice;
30   private String JavaDoc billToFirstName;
31   private String JavaDoc billToLastName;
32   private String JavaDoc shipToFirstName;
33   private String JavaDoc shipToLastName;
34   private String JavaDoc creditCard;
35   private String JavaDoc expiryDate;
36   private String JavaDoc cardType;
37   private String JavaDoc locale;
38   private String JavaDoc status;
39   private List JavaDoc lineItems = new ArrayList JavaDoc();
40
41   /* JavaBeans Properties */
42
43   public int getOrderId() { return orderId; }
44   public void setOrderId(int orderId) { this.orderId = orderId; }
45
46   public String JavaDoc getUsername() { return username; }
47   public void setUsername(String JavaDoc username) { this.username = username; }
48
49   public Date JavaDoc getOrderDate() { return orderDate; }
50   public void setOrderDate(Date JavaDoc orderDate) { this.orderDate = orderDate; }
51
52   public String JavaDoc getShipAddress1() { return shipAddress1; }
53   public void setShipAddress1(String JavaDoc shipAddress1) { this.shipAddress1 = shipAddress1; }
54
55   public String JavaDoc getShipAddress2() { return shipAddress2; }
56   public void setShipAddress2(String JavaDoc shipAddress2) { this.shipAddress2 = shipAddress2; }
57
58   public String JavaDoc getShipCity() { return shipCity; }
59   public void setShipCity(String JavaDoc shipCity) { this.shipCity = shipCity; }
60
61   public String JavaDoc getShipState() { return shipState; }
62   public void setShipState(String JavaDoc shipState) { this.shipState = shipState; }
63
64   public String JavaDoc getShipZip() { return shipZip; }
65   public void setShipZip(String JavaDoc shipZip) { this.shipZip = shipZip; }
66
67   public String JavaDoc getShipCountry() { return shipCountry; }
68   public void setShipCountry(String JavaDoc shipCountry) { this.shipCountry = shipCountry; }
69
70   public String JavaDoc getBillAddress1() { return billAddress1; }
71   public void setBillAddress1(String JavaDoc billAddress1) { this.billAddress1 = billAddress1; }
72
73   public String JavaDoc getBillAddress2() { return billAddress2; }
74   public void setBillAddress2(String JavaDoc billAddress2) { this.billAddress2 = billAddress2; }
75
76   public String JavaDoc getBillCity() { return billCity; }
77   public void setBillCity(String JavaDoc billCity) { this.billCity = billCity; }
78
79   public String JavaDoc getBillState() { return billState; }
80   public void setBillState(String JavaDoc billState) { this.billState = billState; }
81
82   public String JavaDoc getBillZip() { return billZip; }
83   public void setBillZip(String JavaDoc billZip) { this.billZip = billZip; }
84
85   public String JavaDoc getBillCountry() { return billCountry; }
86   public void setBillCountry(String JavaDoc billCountry) { this.billCountry = billCountry; }
87
88   public String JavaDoc getCourier() { return courier; }
89   public void setCourier(String JavaDoc courier) { this.courier = courier; }
90
91   public double getTotalPrice() { return totalPrice; }
92   public void setTotalPrice(double totalPrice) { this.totalPrice = totalPrice; }
93
94   public String JavaDoc getBillToFirstName() { return billToFirstName; }
95   public void setBillToFirstName(String JavaDoc billToFirstName) { this.billToFirstName = billToFirstName; }
96
97   public String JavaDoc getBillToLastName() { return billToLastName; }
98   public void setBillToLastName(String JavaDoc billToLastName) { this.billToLastName = billToLastName; }
99
100   public String JavaDoc getShipToFirstName() { return shipToFirstName; }
101   public void setShipToFirstName(String JavaDoc shipFoFirstName) { this.shipToFirstName = shipFoFirstName; }
102
103   public String JavaDoc getShipToLastName() { return shipToLastName; }
104   public void setShipToLastName(String JavaDoc shipToLastName) { this.shipToLastName = shipToLastName; }
105
106   public String JavaDoc getCreditCard() { return creditCard; }
107   public void setCreditCard(String JavaDoc creditCard) { this.creditCard = creditCard; }
108
109   public String JavaDoc getExpiryDate() { return expiryDate; }
110   public void setExpiryDate(String JavaDoc expiryDate) { this.expiryDate = expiryDate; }
111
112   public String JavaDoc getCardType() { return cardType; }
113   public void setCardType(String JavaDoc cardType) { this.cardType = cardType; }
114
115   public String JavaDoc getLocale() { return locale; }
116   public void setLocale(String JavaDoc locale) { this.locale = locale; }
117
118   public String JavaDoc getStatus() { return status; }
119   public void setStatus(String JavaDoc status) { this.status = status; }
120
121   public void setLineItems(List JavaDoc lineItems) { this.lineItems = lineItems; }
122   public List JavaDoc getLineItems() { return lineItems; }
123
124   /* Public Methods */
125
126   public void initOrder(Account account, Cart cart) {
127     username = account.getUsername();
128     orderDate = new Date JavaDoc();
129
130     shipToFirstName = account.getFirstName();
131     shipToLastName = account.getLastName();
132     shipAddress1 = account.getAddress1();
133     shipAddress2 = account.getAddress2();
134     shipCity = account.getCity();
135     shipState = account.getState();
136     shipZip = account.getZip();
137     shipCountry = account.getCountry();
138
139     billToFirstName = account.getFirstName();
140     billToLastName = account.getLastName();
141     billAddress1 = account.getAddress1();
142     billAddress2 = account.getAddress2();
143     billCity = account.getCity();
144     billState = account.getState();
145     billZip = account.getZip();
146     billCountry = account.getCountry();
147
148     totalPrice = cart.getSubTotal();
149
150     creditCard = "999 9999 9999 9999";
151     expiryDate = "12/03";
152     cardType = "Visa";
153     courier = "UPS";
154     locale = "CA";
155     status = "P";
156
157     Iterator JavaDoc i = cart.getAllCartItems();
158     while (i.hasNext()) {
159       CartItem cartItem = (CartItem) i.next();
160       addLineItem(cartItem);
161     }
162   }
163
164   public void addLineItem(CartItem cartItem) {
165     LineItem lineItem = new LineItem(lineItems.size() + 1, cartItem);
166     addLineItem(lineItem);
167   }
168
169   public void addLineItem(LineItem lineItem) {
170     lineItems.add(lineItem);
171   }
172
173
174 }
175
Popular Tags