1 package org.springframework.samples.jpetstore.domain; 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 private int orderId; 14 private String username; 15 private Date orderDate; 16 private String shipAddress1; 17 private String shipAddress2; 18 private String shipCity; 19 private String shipState; 20 private String shipZip; 21 private String shipCountry; 22 private String billAddress1; 23 private String billAddress2; 24 private String billCity; 25 private String billState; 26 private String billZip; 27 private String billCountry; 28 private String courier; 29 private double totalPrice; 30 private String billToFirstName; 31 private String billToLastName; 32 private String shipToFirstName; 33 private String shipToLastName; 34 private String creditCard; 35 private String expiryDate; 36 private String cardType; 37 private String locale; 38 private String status; 39 private List lineItems = new ArrayList (); 40 41 42 43 public int getOrderId() { return orderId; } 44 public void setOrderId(int orderId) { this.orderId = orderId; } 45 46 public String getUsername() { return username; } 47 public void setUsername(String username) { this.username = username; } 48 49 public Date getOrderDate() { return orderDate; } 50 public void setOrderDate(Date orderDate) { this.orderDate = orderDate; } 51 52 public String getShipAddress1() { return shipAddress1; } 53 public void setShipAddress1(String shipAddress1) { this.shipAddress1 = shipAddress1; } 54 55 public String getShipAddress2() { return shipAddress2; } 56 public void setShipAddress2(String shipAddress2) { this.shipAddress2 = shipAddress2; } 57 58 public String getShipCity() { return shipCity; } 59 public void setShipCity(String shipCity) { this.shipCity = shipCity; } 60 61 public String getShipState() { return shipState; } 62 public void setShipState(String shipState) { this.shipState = shipState; } 63 64 public String getShipZip() { return shipZip; } 65 public void setShipZip(String shipZip) { this.shipZip = shipZip; } 66 67 public String getShipCountry() { return shipCountry; } 68 public void setShipCountry(String shipCountry) { this.shipCountry = shipCountry; } 69 70 public String getBillAddress1() { return billAddress1; } 71 public void setBillAddress1(String billAddress1) { this.billAddress1 = billAddress1; } 72 73 public String getBillAddress2() { return billAddress2; } 74 public void setBillAddress2(String billAddress2) { this.billAddress2 = billAddress2; } 75 76 public String getBillCity() { return billCity; } 77 public void setBillCity(String billCity) { this.billCity = billCity; } 78 79 public String getBillState() { return billState; } 80 public void setBillState(String billState) { this.billState = billState; } 81 82 public String getBillZip() { return billZip; } 83 public void setBillZip(String billZip) { this.billZip = billZip; } 84 85 public String getBillCountry() { return billCountry; } 86 public void setBillCountry(String billCountry) { this.billCountry = billCountry; } 87 88 public String getCourier() { return courier; } 89 public void setCourier(String courier) { this.courier = courier; } 90 91 public double getTotalPrice() { return totalPrice; } 92 public void setTotalPrice(double totalPrice) { this.totalPrice = totalPrice; } 93 94 public String getBillToFirstName() { return billToFirstName; } 95 public void setBillToFirstName(String billToFirstName) { this.billToFirstName = billToFirstName; } 96 97 public String getBillToLastName() { return billToLastName; } 98 public void setBillToLastName(String billToLastName) { this.billToLastName = billToLastName; } 99 100 public String getShipToFirstName() { return shipToFirstName; } 101 public void setShipToFirstName(String shipFoFirstName) { this.shipToFirstName = shipFoFirstName; } 102 103 public String getShipToLastName() { return shipToLastName; } 104 public void setShipToLastName(String shipToLastName) { this.shipToLastName = shipToLastName; } 105 106 public String getCreditCard() { return creditCard; } 107 public void setCreditCard(String creditCard) { this.creditCard = creditCard; } 108 109 public String getExpiryDate() { return expiryDate; } 110 public void setExpiryDate(String expiryDate) { this.expiryDate = expiryDate; } 111 112 public String getCardType() { return cardType; } 113 public void setCardType(String cardType) { this.cardType = cardType; } 114 115 public String getLocale() { return locale; } 116 public void setLocale(String locale) { this.locale = locale; } 117 118 public String getStatus() { return status; } 119 public void setStatus(String status) { this.status = status; } 120 121 public void setLineItems(List lineItems) { this.lineItems = lineItems; } 122 public List getLineItems() { return lineItems; } 123 124 125 126 public void initOrder(Account account, Cart cart) { 127 username = account.getUsername(); 128 orderDate = new Date (); 129 130 shipToFirstName = account.getFirstName(); 131 shipToLastName = account.getLastName(); 132 shipAddress1 = account.getAddress1(); 133 shipAddress2 = account.getAddress2(); 134 shipCity = account.getCity(); 135 shipState = account.getState(); 136 shipZip = account.getZip(); 137 shipCountry = account.getCountry(); 138 139 billToFirstName = account.getFirstName(); 140 billToLastName = account.getLastName(); 141 billAddress1 = account.getAddress1(); 142 billAddress2 = account.getAddress2(); 143 billCity = account.getCity(); 144 billState = account.getState(); 145 billZip = account.getZip(); 146 billCountry = account.getCountry(); 147 148 totalPrice = cart.getSubTotal(); 149 150 creditCard = "999 9999 9999 9999"; 151 expiryDate = "12/03"; 152 cardType = "Visa"; 153 courier = "UPS"; 154 locale = "CA"; 155 status = "P"; 156 157 Iterator i = cart.getAllCartItems(); 158 while (i.hasNext()) { 159 CartItem cartItem = (CartItem) i.next(); 160 addLineItem(cartItem); 161 } 162 } 163 164 public void addLineItem(CartItem cartItem) { 165 LineItem lineItem = new LineItem(lineItems.size() + 1, cartItem); 166 addLineItem(lineItem); 167 } 168 169 public void addLineItem(LineItem lineItem) { 170 lineItems.add(lineItem); 171 } 172 173 174 } 175 | Popular Tags |