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