001: /*
002: * Copyright (c) 1999-2001 Lutris Technologies, Inc. All Rights
003: * Reserved.
004: *
005: * This source code file is distributed by Lutris Technologies, Inc. for
006: * use only by licensed users of product(s) that include this source
007: * file. Use of this source file or the software that uses it is covered
008: * by the terms and conditions of the Lutris Enhydra Development License
009: * Agreement included with this product.
010: *
011: * This Software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
012: * ANY KIND, either express or implied. See the License for the specific terms
013: * governing rights and limitations under the License.
014: *
015: * Contributor(s):
016: *
017: * $Id: OrderFormImpl.java,v 1.1 2006-09-11 12:27:25 sinisa Exp $
018: */
019: package com.lutris.airsent.business.delivery;
020:
021: import com.lutris.airsent.spec.AirSentException;
022:
023: import com.lutris.airsent.business.AirSentBusinessException;
024: import com.lutris.airsent.spec.address.Address;
025:
026: import com.lutris.airsent.spec.delivery.OrderForm;
027: import com.lutris.airsent.spec.delivery.Delivery;
028:
029: /**
030: * Container object holds data collected for a delivery
031: */
032: public class OrderFormImpl implements OrderForm, java.io.Serializable {
033:
034: private String orderid;
035: private String pickupname;
036: private String pickupaddress;
037: private String pickupphone;
038: private String pickupdirections;
039: private String dropoffname;
040: private String dropoffaddress;
041: private String dropoffphone;
042: private String dropoffdirections;
043: private boolean fragile;
044: private boolean urgent;
045: private String size;
046: private String description;
047:
048: /**
049: * Creates a blank object.
050: */
051: public OrderFormImpl() {
052: // empty
053: }
054:
055: /**
056: * creates an object based on an exiting order
057: *
058: * @param deleivery existing order
059: * @exception if an error occurs reading the deleivery
060: */
061: public OrderFormImpl(Delivery delivery) throws AirSentException {
062: if (delivery == null) {
063: throw new AirSentBusinessException("Error delivery is null");
064: }
065: Address pua = delivery.getPickUp();
066: setPickUpName(pua.getName());
067: setPickUpAddress1(pua.getStreet1());
068: setPickUpPhone(pua.getLocalNumber());
069: setPickUpDirections(pua.getDirections());
070:
071: Address doa = delivery.getDropOff();
072: setDropOffName(doa.getName());
073: setDropOffAddress1(doa.getStreet1());
074: setDropOffPhone(doa.getLocalNumber());
075: setDropOffDirections(doa.getDirections());
076:
077: setOrderId(delivery.getHandle());
078: if (delivery.isFragile()) {
079: setFragile(true);
080: }
081: if (delivery.isUrgent()) {
082: setUrgent(true);
083: }
084: setSize(delivery.getSize());
085: setDescription(String.valueOf(delivery.getDescription()));
086: }
087:
088: /**
089: * returns the orderid
090: *
091: * @return orderid
092: */
093: public String getOrderId() {
094: return orderid;
095: }
096:
097: /**
098: * sets the orderid
099: *
100: * @param id orderid
101: */
102: public void setOrderId(String id) {
103: orderid = id;
104: }
105:
106: /**
107: * returns the pick up name
108: *
109: * @return pick up name
110: */
111: public String getPickUpName() {
112: return pickupname;
113: }
114:
115: /**
116: * sets the pick up name
117: *
118: * @param name pick up name
119: */
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: /**
129: * returns the pick up adderss
130: *
131: * @return pick up adderss
132: */
133: public String getPickUpAddress1() {
134: return pickupaddress;
135: }
136:
137: /**
138: * sets the pick up adderss
139: *
140: * @param addr pick up adderss
141: */
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: /**
151: * returns the pick up phone
152: *
153: * @return pick up phone
154: */
155: public String getPickUpPhone() {
156: return pickupphone;
157: }
158:
159: /**
160: * sets the pick up phone
161: *
162: * @param phone pick up phone
163: */
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: /**
173: * returns the pick up directions
174: *
175: * @return pick up directions
176: */
177: public String getPickUpDirections() {
178: return pickupdirections;
179: }
180:
181: /**
182: * sets the pick up directions
183: *
184: * @param dir pick up directions
185: */
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: /**
195: * returns the drop off name
196: *
197: * @return drop off name
198: */
199: public String getDropOffName() {
200: return dropoffname;
201: }
202:
203: /**
204: * sets the drop off name
205: *
206: * @param name drop off name
207: */
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: /**
217: * returns the drop off address
218: *
219: * @return drop off address
220: */
221: public String getDropOffAddress1() {
222: return dropoffaddress;
223: }
224:
225: /**
226: * sets the drop off address
227: *
228: * @param addr drop off address
229: */
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: /**
239: * returns the
240: *
241: * @return drop off phone
242: */
243: public String getDropOffPhone() {
244: return dropoffphone;
245: }
246:
247: /**
248: * sets the drop off phone
249: *
250: * @param phone drop off phone
251: */
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: * returns the drop off directions
262: *
263: * @return drop off directions
264: */
265: public String getDropOffDirections() {
266: return dropoffdirections;
267: }
268:
269: /**
270: * sets the drop off directions
271: *
272: * @param dir drop off directions
273: */
274: public void setDropOffDirections(String dir)
275: throws AirSentBusinessException {
276: if (dir.length() > Address.MAX_DIRECTIONS) {
277: throw new AirSentBusinessException("Exceeds maximum size");
278: }
279: dropoffdirections = dir;
280: }
281:
282: /**
283: * returns the fragile
284: *
285: * @return fragile state
286: */
287: public boolean getFragile() {
288: return fragile;
289: }
290:
291: /**
292: * sets the fragile state
293: *
294: * @param f fragile
295: */
296: public void setFragile(boolean f) {
297: fragile = f;
298: }
299:
300: /**
301: * returns the usrgent state
302: *
303: * @return usrgent state
304: */
305: public boolean getUrgent() {
306: return urgent;
307: }
308:
309: /**
310: * sets the usrgent state
311: *
312: * @param u usrgent state
313: */
314: public void setUrgent(boolean u) {
315: urgent = u;
316: }
317:
318: /**
319: * returns the size
320: *
321: * @return size
322: */
323: public String getSize() {
324: return size;
325: }
326:
327: /**
328: * sets the size
329: *
330: * @param s size
331: */
332: public void setSize(String s) {
333: size = s;
334: }
335:
336: /**
337: * returns the descriptions
338: *
339: * @return descriptions
340: */
341: public String getDescription() {
342: return description;
343: }
344:
345: /**
346: * sets the descriptions
347: *
348: * @param d descriptions
349: */
350: public void setDescription(String d)
351: throws AirSentBusinessException {
352: if (d.length() > Delivery.MAX_DESC) {
353: throw new AirSentBusinessException("Exceeds maximum size");
354: }
355: description = d;
356: }
357:
358: /*
359: *
360: */
361: public void dump() {
362: System.out.println("OrderFrom");
363: System.out.println(" orderid: " + orderid);
364: System.out.println(" pickupname: " + pickupname);
365: System.out.println(" pickupaddress: " + pickupaddress);
366: System.out.println(" pickupphone: " + pickupphone);
367: System.out.println(" pickupdirections: " + pickupdirections);
368: System.out.println(" dropoffname: " + dropoffname);
369: System.out.println(" dropoffaddress: " + dropoffaddress);
370: System.out.println(" dropoffphone: " + dropoffphone);
371: System.out.println(" dropoffdirections: " + dropoffdirections);
372: System.out.println(" fragile: " + fragile);
373: System.out.println(" urgent: " + urgent);
374: System.out.println(" size: " + size);
375: System.out.println(" description: " + description);
376: System.out.println("");
377: }
378: }
|