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