1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package com.ibatis.jpetstore.domain;
17
18 import java.io.Serializable;
19 import java.math.BigDecimal;
20 import java.util.ArrayList;
21 import java.util.Date;
22 import java.util.Iterator;
23 import java.util.List;
24
25
26 public class Order implements Serializable {
27
28
29
30 private int orderId;
31 private String username;
32 private Date orderDate;
33 private String shipAddress1;
34 private String shipAddress2;
35 private String shipCity;
36 private String shipState;
37 private String shipZip;
38 private String shipCountry;
39 private String billAddress1;
40 private String billAddress2;
41 private String billCity;
42 private String billState;
43 private String billZip;
44 private String billCountry;
45 private String courier;
46 private BigDecimal totalPrice;
47 private String billToFirstName;
48 private String billToLastName;
49 private String shipToFirstName;
50 private String shipToLastName;
51 private String creditCard;
52 private String expiryDate;
53 private String cardType;
54 private String locale;
55 private String status;
56 private List lineItems = new ArrayList();
57
58
59
60 public int getOrderId() {
61 return orderId;
62 }
63
64 public void setOrderId(int orderId) {
65 this.orderId = orderId;
66 }
67
68 public String getUsername() {
69 return username;
70 }
71
72 public void setUsername(String username) {
73 this.username = username;
74 }
75
76 public Date getOrderDate() {
77 return orderDate;
78 }
79
80 public void setOrderDate(Date orderDate) {
81 this.orderDate = orderDate;
82 }
83
84 public String getShipAddress1() {
85 return shipAddress1;
86 }
87
88 public void setShipAddress1(String shipAddress1) {
89 this.shipAddress1 = shipAddress1;
90 }
91
92 public String getShipAddress2() {
93 return shipAddress2;
94 }
95
96 public void setShipAddress2(String shipAddress2) {
97 this.shipAddress2 = shipAddress2;
98 }
99
100 public String getShipCity() {
101 return shipCity;
102 }
103
104 public void setShipCity(String shipCity) {
105 this.shipCity = shipCity;
106 }
107
108 public String getShipState() {
109 return shipState;
110 }
111
112 public void setShipState(String shipState) {
113 this.shipState = shipState;
114 }
115
116 public String getShipZip() {
117 return shipZip;
118 }
119
120 public void setShipZip(String shipZip) {
121 this.shipZip = shipZip;
122 }
123
124 public String getShipCountry() {
125 return shipCountry;
126 }
127
128 public void setShipCountry(String shipCountry) {
129 this.shipCountry = shipCountry;
130 }
131
132 public String getBillAddress1() {
133 return billAddress1;
134 }
135
136 public void setBillAddress1(String billAddress1) {
137 this.billAddress1 = billAddress1;
138 }
139
140 public String getBillAddress2() {
141 return billAddress2;
142 }
143
144 public void setBillAddress2(String billAddress2) {
145 this.billAddress2 = billAddress2;
146 }
147
148 public String getBillCity() {
149 return billCity;
150 }
151
152 public void setBillCity(String billCity) {
153 this.billCity = billCity;
154 }
155
156 public String getBillState() {
157 return billState;
158 }
159
160 public void setBillState(String billState) {
161 this.billState = billState;
162 }
163
164 public String getBillZip() {
165 return billZip;
166 }
167
168 public void setBillZip(String billZip) {
169 this.billZip = billZip;
170 }
171
172 public String getBillCountry() {
173 return billCountry;
174 }
175
176 public void setBillCountry(String billCountry) {
177 this.billCountry = billCountry;
178 }
179
180 public String getCourier() {
181 return courier;
182 }
183
184 public void setCourier(String courier) {
185 this.courier = courier;
186 }
187
188 public BigDecimal getTotalPrice() {
189 return totalPrice;
190 }
191
192 public void setTotalPrice(BigDecimal totalPrice) {
193 this.totalPrice = totalPrice;
194 }
195
196 public String getBillToFirstName() {
197 return billToFirstName;
198 }
199
200 public void setBillToFirstName(String billToFirstName) {
201 this.billToFirstName = billToFirstName;
202 }
203
204 public String getBillToLastName() {
205 return billToLastName;
206 }
207
208 public void setBillToLastName(String billToLastName) {
209 this.billToLastName = billToLastName;
210 }
211
212 public String getShipToFirstName() {
213 return shipToFirstName;
214 }
215
216 public void setShipToFirstName(String shipFoFirstName) {
217 this.shipToFirstName = shipFoFirstName;
218 }
219
220 public String getShipToLastName() {
221 return shipToLastName;
222 }
223
224 public void setShipToLastName(String shipToLastName) {
225 this.shipToLastName = shipToLastName;
226 }
227
228 public String getCreditCard() {
229 return creditCard;
230 }
231
232 public void setCreditCard(String creditCard) {
233 this.creditCard = creditCard;
234 }
235
236 public String getExpiryDate() {
237 return expiryDate;
238 }
239
240 public void setExpiryDate(String expiryDate) {
241 this.expiryDate = expiryDate;
242 }
243
244 public String getCardType() {
245 return cardType;
246 }
247
248 public void setCardType(String cardType) {
249 this.cardType = cardType;
250 }
251
252 public String getLocale() {
253 return locale;
254 }
255
256 public void setLocale(String locale) {
257 this.locale = locale;
258 }
259
260 public String getStatus() {
261 return status;
262 }
263
264 public void setStatus(String status) {
265 this.status = status;
266 }
267
268 public void setLineItems(List lineItems) {
269 this.lineItems = lineItems;
270 }
271
272 public List getLineItems() {
273 return lineItems;
274 }
275
276
277
278 public void initOrder(Account account, Cart cart) {
279
280 username = account.getUsername();
281 orderDate = new Date();
282
283 shipToFirstName = account.getFirstName();
284 shipToLastName = account.getLastName();
285 shipAddress1 = account.getAddress1();
286 shipAddress2 = account.getAddress2();
287 shipCity = account.getCity();
288 shipState = account.getState();
289 shipZip = account.getZip();
290 shipCountry = account.getCountry();
291
292 billToFirstName = account.getFirstName();
293 billToLastName = account.getLastName();
294 billAddress1 = account.getAddress1();
295 billAddress2 = account.getAddress2();
296 billCity = account.getCity();
297 billState = account.getState();
298 billZip = account.getZip();
299 billCountry = account.getCountry();
300
301 totalPrice = cart.getSubTotal();
302
303 creditCard = "999 9999 9999 9999";
304 expiryDate = "12/03";
305 cardType = "Visa";
306 courier = "UPS";
307 locale = "CA";
308 status = "P";
309
310
311 Iterator i = cart.getAllCartItems();
312 while (i.hasNext()) {
313 CartItem cartItem = (CartItem) i.next();
314 addLineItem(cartItem);
315 }
316
317 }
318
319 public void addLineItem(CartItem cartItem) {
320 LineItem lineItem = new LineItem(lineItems.size() + 1, cartItem);
321 addLineItem(lineItem);
322 }
323
324 public void addLineItem(LineItem lineItem) {
325 lineItems.add(lineItem);
326 }
327
328
329 }