001: package com.ibatis.jpetstore.domain;
002:
003: import java.io.Serializable;
004: import java.math.BigDecimal;
005: import java.util.ArrayList;
006: import java.util.Date;
007: import java.util.Iterator;
008: import java.util.List;
009:
010: public class Order implements Serializable {
011:
012: /* Private Fields */
013:
014: private int orderId;
015:
016: private String username;
017:
018: private Date orderDate;
019:
020: private String shipAddress1;
021:
022: private String shipAddress2;
023:
024: private String shipCity;
025:
026: private String shipState;
027:
028: private String shipZip;
029:
030: private String shipCountry;
031:
032: private String billAddress1;
033:
034: private String billAddress2;
035:
036: private String billCity;
037:
038: private String billState;
039:
040: private String billZip;
041:
042: private String billCountry;
043:
044: private String courier;
045:
046: private BigDecimal totalPrice;
047:
048: private String billToFirstName;
049:
050: private String billToLastName;
051:
052: private String shipToFirstName;
053:
054: private String shipToLastName;
055:
056: private String creditCard;
057:
058: private String expiryDate;
059:
060: private String cardType;
061:
062: private String locale;
063:
064: private String status;
065:
066: private List lineItems = new ArrayList();
067:
068: /* JavaBeans Properties */
069:
070: public int getOrderId() {
071: return orderId;
072: }
073:
074: public void setOrderId(int orderId) {
075: this .orderId = orderId;
076: }
077:
078: public String getUsername() {
079: return username;
080: }
081:
082: public void setUsername(String username) {
083: this .username = username;
084: }
085:
086: public Date getOrderDate() {
087: return orderDate;
088: }
089:
090: public void setOrderDate(Date orderDate) {
091: this .orderDate = orderDate;
092: }
093:
094: public String getShipAddress1() {
095: return shipAddress1;
096: }
097:
098: public void setShipAddress1(String shipAddress1) {
099: this .shipAddress1 = shipAddress1;
100: }
101:
102: public String getShipAddress2() {
103: return shipAddress2;
104: }
105:
106: public void setShipAddress2(String shipAddress2) {
107: this .shipAddress2 = shipAddress2;
108: }
109:
110: public String getShipCity() {
111: return shipCity;
112: }
113:
114: public void setShipCity(String shipCity) {
115: this .shipCity = shipCity;
116: }
117:
118: public String getShipState() {
119: return shipState;
120: }
121:
122: public void setShipState(String shipState) {
123: this .shipState = shipState;
124: }
125:
126: public String getShipZip() {
127: return shipZip;
128: }
129:
130: public void setShipZip(String shipZip) {
131: this .shipZip = shipZip;
132: }
133:
134: public String getShipCountry() {
135: return shipCountry;
136: }
137:
138: public void setShipCountry(String shipCountry) {
139: this .shipCountry = shipCountry;
140: }
141:
142: public String getBillAddress1() {
143: return billAddress1;
144: }
145:
146: public void setBillAddress1(String billAddress1) {
147: this .billAddress1 = billAddress1;
148: }
149:
150: public String getBillAddress2() {
151: return billAddress2;
152: }
153:
154: public void setBillAddress2(String billAddress2) {
155: this .billAddress2 = billAddress2;
156: }
157:
158: public String getBillCity() {
159: return billCity;
160: }
161:
162: public void setBillCity(String billCity) {
163: this .billCity = billCity;
164: }
165:
166: public String getBillState() {
167: return billState;
168: }
169:
170: public void setBillState(String billState) {
171: this .billState = billState;
172: }
173:
174: public String getBillZip() {
175: return billZip;
176: }
177:
178: public void setBillZip(String billZip) {
179: this .billZip = billZip;
180: }
181:
182: public String getBillCountry() {
183: return billCountry;
184: }
185:
186: public void setBillCountry(String billCountry) {
187: this .billCountry = billCountry;
188: }
189:
190: public String getCourier() {
191: return courier;
192: }
193:
194: public void setCourier(String courier) {
195: this .courier = courier;
196: }
197:
198: public BigDecimal getTotalPrice() {
199: return totalPrice;
200: }
201:
202: public void setTotalPrice(BigDecimal totalPrice) {
203: this .totalPrice = totalPrice;
204: }
205:
206: public String getBillToFirstName() {
207: return billToFirstName;
208: }
209:
210: public void setBillToFirstName(String billToFirstName) {
211: this .billToFirstName = billToFirstName;
212: }
213:
214: public String getBillToLastName() {
215: return billToLastName;
216: }
217:
218: public void setBillToLastName(String billToLastName) {
219: this .billToLastName = billToLastName;
220: }
221:
222: public String getShipToFirstName() {
223: return shipToFirstName;
224: }
225:
226: public void setShipToFirstName(String shipFoFirstName) {
227: this .shipToFirstName = shipFoFirstName;
228: }
229:
230: public String getShipToLastName() {
231: return shipToLastName;
232: }
233:
234: public void setShipToLastName(String shipToLastName) {
235: this .shipToLastName = shipToLastName;
236: }
237:
238: public String getCreditCard() {
239: return creditCard;
240: }
241:
242: public void setCreditCard(String creditCard) {
243: this .creditCard = creditCard;
244: }
245:
246: public String getExpiryDate() {
247: return expiryDate;
248: }
249:
250: public void setExpiryDate(String expiryDate) {
251: this .expiryDate = expiryDate;
252: }
253:
254: public String getCardType() {
255: return cardType;
256: }
257:
258: public void setCardType(String cardType) {
259: this .cardType = cardType;
260: }
261:
262: public String getLocale() {
263: return locale;
264: }
265:
266: public void setLocale(String locale) {
267: this .locale = locale;
268: }
269:
270: public String getStatus() {
271: return status;
272: }
273:
274: public void setStatus(String status) {
275: this .status = status;
276: }
277:
278: public void setLineItems(List lineItems) {
279: this .lineItems = lineItems;
280: }
281:
282: public List getLineItems() {
283: return lineItems;
284: }
285:
286: /* Public Methods */
287:
288: public void initOrder(Account account, Cart cart) {
289:
290: username = account.getUsername();
291: orderDate = new Date();
292:
293: shipToFirstName = account.getFirstName();
294: shipToLastName = account.getLastName();
295: shipAddress1 = account.getAddress1();
296: shipAddress2 = account.getAddress2();
297: shipCity = account.getCity();
298: shipState = account.getState();
299: shipZip = account.getZip();
300: shipCountry = account.getCountry();
301:
302: billToFirstName = account.getFirstName();
303: billToLastName = account.getLastName();
304: billAddress1 = account.getAddress1();
305: billAddress2 = account.getAddress2();
306: billCity = account.getCity();
307: billState = account.getState();
308: billZip = account.getZip();
309: billCountry = account.getCountry();
310:
311: totalPrice = cart.getSubTotal();
312:
313: creditCard = "999 9999 9999 9999";
314: expiryDate = "12/03";
315: cardType = "Visa";
316: courier = "UPS";
317: locale = "CA";
318: status = "P";
319:
320: Iterator i = cart.getAllCartItems();
321: while (i.hasNext()) {
322: CartItem cartItem = (CartItem) i.next();
323: addLineItem(cartItem);
324: }
325:
326: }
327:
328: public void addLineItem(CartItem cartItem) {
329: LineItem lineItem = new LineItem(lineItems.size() + 1, cartItem);
330: addLineItem(lineItem);
331: }
332:
333: public void addLineItem(LineItem lineItem) {
334: lineItems.add(lineItem);
335: }
336:
337: }
|