View Javadoc

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