1 19 package com.lutris.airsent.business.delivery; 20 21 import com.lutris.airsent.spec.AirSentException; 22 23 import com.lutris.airsent.business.AirSentBusinessException; 24 import com.lutris.airsent.spec.address.Address; 25 26 import com.lutris.airsent.spec.delivery.OrderForm; 27 import com.lutris.airsent.spec.delivery.Delivery; 28 31 public class OrderFormImpl implements OrderForm,java.io.Serializable { 32 33 private String orderid; 34 private String pickupname; 35 private String pickupaddress; 36 private String pickupphone; 37 private String pickupdirections; 38 private String dropoffname; 39 private String dropoffaddress; 40 private String dropoffphone; 41 private String dropoffdirections; 42 private boolean fragile; 43 private boolean urgent; 44 private String size; 45 private String description; 46 47 50 public OrderFormImpl() { 51 } 53 54 60 public OrderFormImpl(Delivery delivery) 61 throws AirSentException { 62 if (delivery == null) { 63 throw new AirSentBusinessException("Error delivery is null"); 64 } 65 Address pua = delivery.getPickUp(); 66 setPickUpName(pua.getName()); 67 setPickUpAddress1(pua.getStreet1()); 68 setPickUpPhone(pua.getLocalNumber()); 69 setPickUpDirections(pua.getDirections()); 70 71 Address doa = delivery.getDropOff(); 72 setDropOffName(doa.getName()); 73 setDropOffAddress1(doa.getStreet1()); 74 setDropOffPhone(doa.getLocalNumber()); 75 setDropOffDirections(doa.getDirections()); 76 77 setOrderId(delivery.getHandle()); 78 if(delivery.isFragile()) { 79 setFragile(true); 80 } 81 if(delivery.isUrgent()) { 82 setUrgent(true); 83 } 84 setSize(delivery.getSize()); 85 setDescription(String.valueOf(delivery.getDescription())); 86 } 87 88 93 public String getOrderId() { 94 return orderid; 95 } 96 97 102 public void setOrderId(String id) { 103 orderid = id; 104 } 105 106 111 public String getPickUpName() { 112 return pickupname; 113 } 114 115 120 public void setPickUpName(String name) 121 throws AirSentBusinessException { 122 if (name.length() > Address.MAX_NAME) { 123 throw new AirSentBusinessException("Exceeds maximum size"); 124 } 125 pickupname = name; 126 } 127 128 133 public String getPickUpAddress1() { 134 return pickupaddress; 135 } 136 137 142 public void setPickUpAddress1(String addr) 143 throws AirSentBusinessException { 144 if (addr.length() > Address.MAX_ADDRESS) { 145 throw new AirSentBusinessException("Exceeds maximum size"); 146 } 147 pickupaddress = addr; 148 } 149 150 155 public String getPickUpPhone() { 156 return pickupphone; 157 } 158 159 164 public void setPickUpPhone(String phone) 165 throws AirSentBusinessException { 166 if (phone.length() > Address.MAX_PHONE) { 167 throw new AirSentBusinessException("Exceeds maximum size"); 168 } 169 pickupphone = phone; 170 } 171 172 177 public String getPickUpDirections() { 178 return pickupdirections; 179 } 180 181 186 public void setPickUpDirections(String dir) 187 throws AirSentBusinessException { 188 if (dir.length() > Address.MAX_DIRECTIONS) { 189 throw new AirSentBusinessException("Exceeds maximum size"); 190 } 191 pickupdirections = dir; 192 } 193 194 199 public String getDropOffName() { 200 return dropoffname; 201 } 202 203 208 public void setDropOffName(String name) 209 throws AirSentBusinessException { 210 if (name.length() > Address.MAX_NAME) { 211 throw new AirSentBusinessException("Exceeds maximum size"); 212 } 213 dropoffname = name; 214 } 215 216 221 public String getDropOffAddress1() { 222 return dropoffaddress; 223 } 224 225 230 public void setDropOffAddress1(String addr) 231 throws AirSentBusinessException { 232 if (addr.length() > Address.MAX_ADDRESS) { 233 throw new AirSentBusinessException("Exceeds maximum size"); 234 } 235 dropoffaddress = addr; 236 } 237 238 243 public String getDropOffPhone() { 244 return dropoffphone; 245 } 246 247 252 public void setDropOffPhone(String phone) 253 throws AirSentBusinessException { 254 if (phone.length() > Address.MAX_PHONE) { 255 throw new AirSentBusinessException("Exceeds maximum size"); 256 } 257 dropoffphone = phone; 258 } 259 260 261 266 public String getDropOffDirections() { 267 return dropoffdirections; 268 } 269 270 275 public void setDropOffDirections(String dir) 276 throws AirSentBusinessException { 277 if (dir.length() > Address.MAX_DIRECTIONS) { 278 throw new AirSentBusinessException("Exceeds maximum size"); 279 } 280 dropoffdirections = dir; 281 } 282 283 284 289 public boolean getFragile() { 290 return fragile; 291 } 292 293 294 299 public void setFragile(boolean f) { 300 fragile = f; 301 } 302 303 308 public boolean getUrgent() { 309 return urgent; 310 } 311 312 317 public void setUrgent(boolean u) { 318 urgent = u; 319 } 320 321 326 public String getSize() { 327 return size; 328 } 329 330 335 public void setSize(String s) { 336 size = s; 337 } 338 339 344 public String getDescription() { 345 return description; 346 } 347 348 353 public void setDescription(String d) 354 throws AirSentBusinessException { 355 if (d.length() > Delivery.MAX_DESC) { 356 throw new AirSentBusinessException("Exceeds maximum size"); 357 } 358 description = d; 359 } 360 361 364 public void dump() { 365 System.out.println("OrderFrom"); 366 System.out.println(" orderid: " + orderid); 367 System.out.println(" pickupname: " + pickupname); 368 System.out.println(" pickupaddress: " + pickupaddress); 369 System.out.println(" pickupphone: " + pickupphone); 370 System.out.println(" pickupdirections: " + pickupdirections); 371 System.out.println(" dropoffname: " + dropoffname); 372 System.out.println(" dropoffaddress: " + dropoffaddress); 373 System.out.println(" dropoffphone: " + dropoffphone); 374 System.out.println(" dropoffdirections: " + dropoffdirections); 375 System.out.println(" fragile: " + fragile); 376 System.out.println(" urgent: " + urgent); 377 System.out.println(" size: " + size); 378 System.out.println(" description: " + description); 379 System.out.println(""); 380 } 381 } 382 | Popular Tags |