1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.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
27
28
29
30 public class Order implements Serializable {
31
32
33 private static final long serialVersionUID = 6321792448424424931L;
34
35
36 private int orderId;
37
38 private String username;
39
40 private Date orderDate;
41
42 private String shipAddress1;
43
44 private String shipAddress2;
45
46 private String shipCity;
47
48 private String shipState;
49
50 private String shipZip;
51
52 private String shipCountry;
53
54 private String billAddress1;
55
56 private String billAddress2;
57
58 private String billCity;
59
60 private String billState;
61
62 private String billZip;
63
64 private String billCountry;
65
66 private String courier;
67
68 private BigDecimal totalPrice;
69
70 private String billToFirstName;
71
72 private String billToLastName;
73
74 private String shipToFirstName;
75
76 private String shipToLastName;
77
78 private String creditCard;
79
80 private String expiryDate;
81
82 private String cardType;
83
84 private String locale;
85
86 private String status;
87
88 private List<LineItem> lineItems = new ArrayList<>();
89
90
91
92
93
94
95 public int getOrderId() {
96 return orderId;
97 }
98
99
100
101
102
103
104
105 public void setOrderId(int orderId) {
106 this.orderId = orderId;
107 }
108
109
110
111
112
113
114 public String getUsername() {
115 return username;
116 }
117
118
119
120
121
122
123
124 public void setUsername(String username) {
125 this.username = username;
126 }
127
128
129
130
131
132
133 public Date getOrderDate() {
134 return orderDate;
135 }
136
137
138
139
140
141
142
143 public void setOrderDate(Date orderDate) {
144 this.orderDate = orderDate;
145 }
146
147
148
149
150
151
152 public String getShipAddress1() {
153 return shipAddress1;
154 }
155
156
157
158
159
160
161
162 public void setShipAddress1(String shipAddress1) {
163 this.shipAddress1 = shipAddress1;
164 }
165
166
167
168
169
170
171 public String getShipAddress2() {
172 return shipAddress2;
173 }
174
175
176
177
178
179
180
181 public void setShipAddress2(String shipAddress2) {
182 this.shipAddress2 = shipAddress2;
183 }
184
185
186
187
188
189
190 public String getShipCity() {
191 return shipCity;
192 }
193
194
195
196
197
198
199
200 public void setShipCity(String shipCity) {
201 this.shipCity = shipCity;
202 }
203
204
205
206
207
208
209 public String getShipState() {
210 return shipState;
211 }
212
213
214
215
216
217
218
219 public void setShipState(String shipState) {
220 this.shipState = shipState;
221 }
222
223
224
225
226
227
228 public String getShipZip() {
229 return shipZip;
230 }
231
232
233
234
235
236
237
238 public void setShipZip(String shipZip) {
239 this.shipZip = shipZip;
240 }
241
242
243
244
245
246
247 public String getShipCountry() {
248 return shipCountry;
249 }
250
251
252
253
254
255
256
257 public void setShipCountry(String shipCountry) {
258 this.shipCountry = shipCountry;
259 }
260
261
262
263
264
265
266 public String getBillAddress1() {
267 return billAddress1;
268 }
269
270
271
272
273
274
275
276 public void setBillAddress1(String billAddress1) {
277 this.billAddress1 = billAddress1;
278 }
279
280
281
282
283
284
285 public String getBillAddress2() {
286 return billAddress2;
287 }
288
289
290
291
292
293
294
295 public void setBillAddress2(String billAddress2) {
296 this.billAddress2 = billAddress2;
297 }
298
299
300
301
302
303
304 public String getBillCity() {
305 return billCity;
306 }
307
308
309
310
311
312
313
314 public void setBillCity(String billCity) {
315 this.billCity = billCity;
316 }
317
318
319
320
321
322
323 public String getBillState() {
324 return billState;
325 }
326
327
328
329
330
331
332
333 public void setBillState(String billState) {
334 this.billState = billState;
335 }
336
337
338
339
340
341
342 public String getBillZip() {
343 return billZip;
344 }
345
346
347
348
349
350
351
352 public void setBillZip(String billZip) {
353 this.billZip = billZip;
354 }
355
356
357
358
359
360
361 public String getBillCountry() {
362 return billCountry;
363 }
364
365
366
367
368
369
370
371 public void setBillCountry(String billCountry) {
372 this.billCountry = billCountry;
373 }
374
375
376
377
378
379
380 public String getCourier() {
381 return courier;
382 }
383
384
385
386
387
388
389
390 public void setCourier(String courier) {
391 this.courier = courier;
392 }
393
394
395
396
397
398
399 public BigDecimal getTotalPrice() {
400 return totalPrice;
401 }
402
403
404
405
406
407
408
409 public void setTotalPrice(BigDecimal totalPrice) {
410 this.totalPrice = totalPrice;
411 }
412
413
414
415
416
417
418 public String getBillToFirstName() {
419 return billToFirstName;
420 }
421
422
423
424
425
426
427
428 public void setBillToFirstName(String billToFirstName) {
429 this.billToFirstName = billToFirstName;
430 }
431
432
433
434
435
436
437 public String getBillToLastName() {
438 return billToLastName;
439 }
440
441
442
443
444
445
446
447 public void setBillToLastName(String billToLastName) {
448 this.billToLastName = billToLastName;
449 }
450
451
452
453
454
455
456 public String getShipToFirstName() {
457 return shipToFirstName;
458 }
459
460
461
462
463
464
465
466 public void setShipToFirstName(String shipFoFirstName) {
467 this.shipToFirstName = shipFoFirstName;
468 }
469
470
471
472
473
474
475 public String getShipToLastName() {
476 return shipToLastName;
477 }
478
479
480
481
482
483
484
485 public void setShipToLastName(String shipToLastName) {
486 this.shipToLastName = shipToLastName;
487 }
488
489
490
491
492
493
494 public String getCreditCard() {
495 return creditCard;
496 }
497
498
499
500
501
502
503
504 public void setCreditCard(String creditCard) {
505 this.creditCard = creditCard;
506 }
507
508
509
510
511
512
513 public String getExpiryDate() {
514 return expiryDate;
515 }
516
517
518
519
520
521
522
523 public void setExpiryDate(String expiryDate) {
524 this.expiryDate = expiryDate;
525 }
526
527
528
529
530
531
532 public String getCardType() {
533 return cardType;
534 }
535
536
537
538
539
540
541
542 public void setCardType(String cardType) {
543 this.cardType = cardType;
544 }
545
546
547
548
549
550
551 public String getLocale() {
552 return locale;
553 }
554
555
556
557
558
559
560
561 public void setLocale(String locale) {
562 this.locale = locale;
563 }
564
565
566
567
568
569
570 public String getStatus() {
571 return status;
572 }
573
574
575
576
577
578
579
580 public void setStatus(String status) {
581 this.status = status;
582 }
583
584
585
586
587
588
589
590 public void setLineItems(List<LineItem> lineItems) {
591 this.lineItems = lineItems;
592 }
593
594
595
596
597
598
599 public List<LineItem> getLineItems() {
600 return lineItems;
601 }
602
603
604
605
606
607
608
609
610
611 public void initOrder(Account account, Cart cart) {
612
613 username = account.getUsername();
614 orderDate = new Date();
615
616 shipToFirstName = account.getFirstName();
617 shipToLastName = account.getLastName();
618 shipAddress1 = account.getAddress1();
619 shipAddress2 = account.getAddress2();
620 shipCity = account.getCity();
621 shipState = account.getState();
622 shipZip = account.getZip();
623 shipCountry = account.getCountry();
624
625 billToFirstName = account.getFirstName();
626 billToLastName = account.getLastName();
627 billAddress1 = account.getAddress1();
628 billAddress2 = account.getAddress2();
629 billCity = account.getCity();
630 billState = account.getState();
631 billZip = account.getZip();
632 billCountry = account.getCountry();
633
634 totalPrice = cart.getSubTotal();
635
636 creditCard = "999 9999 9999 9999";
637 expiryDate = "12/03";
638 cardType = "Visa";
639 courier = "UPS";
640 locale = "CA";
641 status = "P";
642
643 Iterator<CartItem> i = cart.getAllCartItems();
644 while (i.hasNext()) {
645 CartItem cartItem = i.next();
646 addLineItem(cartItem);
647 }
648
649 }
650
651
652
653
654
655
656
657 public void addLineItem(CartItem cartItem) {
658 LineItem lineItem = new LineItem(lineItems.size() + 1, cartItem);
659 addLineItem(lineItem);
660 }
661
662
663
664
665
666
667
668 public void addLineItem(LineItem lineItem) {
669 lineItems.add(lineItem);
670 }
671
672 }