Source Code Cross Referenced for DeliveryImpl.java in  » J2EE » Enhydra-Demos » com » lutris » airsent » business » delivery » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Enhydra Demos » com.lutris.airsent.business.delivery 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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: DeliveryImpl.java,v 1.1 2006-09-11 12:27:25 sinisa Exp $
018:         */
019:
020:        package com.lutris.airsent.business.delivery;
021:
022:        import com.lutris.airsent.spec.AirSentException;
023:        import com.lutris.airsent.spec.delivery.Delivery;
024:        import com.lutris.airsent.spec.delivery.Update;
025:        import com.lutris.airsent.spec.messenger.Messenger;
026:
027:        import com.lutris.airsent.business.*;
028:        import com.lutris.airsent.business.delivery.*;
029:        import com.lutris.airsent.data.delivery.DeliveryDO;
030:
031:        import com.lutris.airsent.business.address.AddressManager;
032:
033:        import com.lutris.airsent.business.address.AddressImpl;
034:        import com.lutris.airsent.business.address.AddressManager;
035:
036:        import com.lutris.airsent.spec.address.Address;
037:        import com.lutris.airsent.spec.messenger.MessengerManager;
038:
039:        import com.lutris.airsent.spec.customer.Customer;
040:
041:        import com.lutris.airsent.business.customer.CustomerImpl;
042:        import com.lutris.airsent.data.person.CustomerDO;
043:        import com.lutris.airsent.business.messenger.*;
044:        import com.lutris.airsent.data.person.MessengerDO;
045:        import com.lutris.dods.builder.generator.query.DataObjectException;
046:        import java.util.*;
047:        import java.text.*;
048:
049:        /**
050:         * Delivery Implementation
051:         */
052:        public class DeliveryImpl implements  Delivery {
053:
054:            DeliveryDO deliveryDO;
055:            private Update update;
056:            private AddressImpl pickUpAddress;
057:            private AddressImpl dropOffAddress;
058:            private Customer customer;
059:            private Messenger messenger;
060:
061:            /**
062:             * Constructs DeliveryImpl object
063:             *
064:             * 
065:             * @exception if an error occurs
066:             */
067:            DeliveryImpl(Update update, Customer customer)
068:                    throws AirSentException {
069:
070:                try {
071:                    deliveryDO = DeliveryDO.createVirgin();
072:                    AddressManager af = HomeManagerImpl.getInstance()
073:                            .getAddressManager();
074:                    pickUpAddress = af.create();
075:                    deliveryDO.setPickup(pickUpAddress.getDataObject());
076:                    dropOffAddress = af.create();
077:                    deliveryDO.setDropoff(dropOffAddress.getDataObject());
078:                    setCustomer(customer);
079:                    this .update = update;
080:                } catch (Exception e) {
081:                    throw new AirSentException(e);
082:                }
083:            }
084:
085:            /**
086:             * Constructs DeliveryImpl object
087:             *
088:             * 
089:             * @exception if an error occurs
090:             */
091:            DeliveryImpl(Update update, DeliveryDO d)
092:                    throws AirSentBusinessException {
093:                if (d == null) {
094:                    throw new AirSentBusinessException(
095:                            "Error: data object is null");
096:                }
097:                try {
098:                    deliveryDO = d;
099:                    this .update = update;
100:                    this .customer = new CustomerImpl(deliveryDO.getCustomerID());
101:                } catch (Exception e) {
102:                    throw new AirSentBusinessException(e);
103:                }
104:            }
105:
106:            /**
107:             * Constructs DeliveryImpl object
108:             *
109:             * 
110:             * @exception if an error occurs
111:             */
112:            DeliveryImpl(Update update, String id) throws AirSentException,
113:                    AirSentBusinessException {
114:                if (id == null) {
115:                    throw new AirSentBusinessException(
116:                            "Error: data object is null");
117:                }
118:                try {
119:                    deliveryDO = DeliveryDO.createExisting(id);
120:                    this .update = update;
121:                    this .customer = new CustomerImpl(deliveryDO.getCustomerID());
122:                } catch (Exception e) {
123:                    throw new AirSentBusinessException(e);
124:                }
125:            }
126:
127:            /**
128:             * Gets the handle.
129:             *
130:             * @return handle
131:             * @exception if an error occurs
132:             */
133:            public String getHandle() throws AirSentException {
134:                try {
135:                    return deliveryDO.getHandle();
136:                } catch (Exception e) {
137:                    throw new AirSentException(e);
138:                }
139:            }
140:
141:            /**
142:             * Gets pick up address for the order.
143:             *
144:             * @return pick up address
145:             * @exception if an error occurs
146:             */
147:            public Address getPickUp() throws AirSentException {
148:                if (pickUpAddress == null) {
149:                    try {
150:                        AddressManager af = HomeManagerImpl.getInstance()
151:                                .getAddressManager();
152:                        pickUpAddress = af.create(deliveryDO.getPickup());
153:                    } catch (Exception e) {
154:                        throw new AirSentException(e);
155:                    }
156:                }
157:                return pickUpAddress;
158:            }
159:
160:            /**
161:             * Gets the drop off address for the order
162:             *
163:             * @return drop off address
164:             * @exception if an error occurs
165:             */
166:            public Address getDropOff() throws AirSentException {
167:                if (dropOffAddress == null) {
168:                    try {
169:                        AddressManager af = HomeManagerImpl.getInstance()
170:                                .getAddressManager();
171:                        dropOffAddress = af.create(deliveryDO.getDropoff());
172:                    } catch (Exception e) {
173:                        throw new AirSentException(e);
174:                    }
175:                }
176:                return dropOffAddress;
177:            }
178:
179:            /**
180:             * gets the customer
181:             * 
182:             * @return customer
183:             * @exception if an error occurs
184:             */
185:            public Customer getCustomer() throws AirSentException {
186:                if (customer == null) {
187:                    throw new AirSentException("customer is null");
188:                }
189:                return customer;
190:            }
191:
192:            /*
193:             *
194:             */
195:            private void setCustomer(Customer c) throws AirSentException,
196:                    AirSentBusinessException {
197:                try {
198:                    deliveryDO.setCustomerID(CustomerDO.createExisting(c
199:                            .getHandle()));
200:                    customer = c;
201:                } catch (DataObjectException doe) {
202:                    // object can't be found
203:                    throw new AirSentBusinessException(doe);
204:                } catch (Exception e) {
205:                    throw new AirSentException(e);
206:                }
207:            }
208:
209:            /**
210:             * Gets the messenger.
211:             *
212:             * @return messenger
213:             * @exception if an error occurs
214:             */
215:            public Messenger getMessenger() throws AirSentException {
216:                try {
217:                    if (messenger == null) {
218:                        if (deliveryDO.getMessengerID() != null) {
219:                            MessengerManager mf = HomeManagerImpl.getInstance()
220:                                    .getMessengerManager();
221:                            messenger = mf.create(deliveryDO.getMessengerID()
222:                                    .getHandle());
223:                        }
224:                    }
225:                    return messenger;
226:                } catch (Exception e) {
227:                    throw new AirSentException(e);
228:                }
229:            }
230:
231:            /**
232:             * Sets the messenger.
233:             *
234:             * @exception if an error occurs
235:             * @exception if a business rule is violated
236:             */
237:            public void setMessenger(Messenger m) throws AirSentException,
238:                    AirSentBusinessException {
239:                try {
240:                    deliveryDO.setMessengerID(MessengerDO.createExisting(m
241:                            .getHandle()));
242:                    messenger = m;
243:                } catch (DataObjectException doe) {
244:                    // object can't be found
245:                    throw new AirSentBusinessException(doe);
246:                } catch (Exception e) {
247:                    throw new AirSentException(e);
248:                }
249:            }
250:
251:            /**
252:             * gets the fragile flag
253:             *
254:             * @return true if fragile
255:             * @exception if an error occurs
256:             */
257:            public boolean isFragile() throws AirSentException {
258:                try {
259:                    return deliveryDO.getFragile();
260:                } catch (Exception e) {
261:                    throw new AirSentException(e);
262:                }
263:            }
264:
265:            /**
266:             * sets the fragile flag
267:             *
268:             * @param fragile true if fragile
269:             * @exception if an error occurs
270:             */
271:            public void setIsFragile(boolean fragile) throws AirSentException {
272:                try {
273:                    this .deliveryDO.setFragile(fragile);
274:                } catch (Exception e) {
275:                    throw new AirSentException(e);
276:                }
277:            }
278:
279:            /**
280:             * gets the urgent flag
281:             * 
282:             * @return true if urgent
283:             * @exception if an error occurs
284:             */
285:            public boolean isUrgent() throws AirSentException {
286:                try {
287:                    return deliveryDO.getUrgent();
288:                } catch (Exception e) {
289:                    throw new AirSentException(e);
290:                }
291:            }
292:
293:            /**
294:             * sets the urgent flag
295:             * 
296:             * @param urgent true if urgent
297:             * @exception if an error occurs
298:             */
299:            public void setIsUrgent(boolean urgent) throws AirSentException {
300:                try {
301:                    deliveryDO.setUrgent(urgent);
302:                } catch (Exception e) {
303:                    throw new AirSentException(e);
304:                }
305:            }
306:
307:            /**
308:             * gets the size description
309:             * 
310:             * @return size
311:             * @exception if an error occurs
312:             */
313:            public String getSize() throws AirSentException {
314:                try {
315:                    return deliveryDO.getSize();
316:                } catch (Exception e) {
317:                    throw new AirSentException(e);
318:                }
319:            }
320:
321:            /**
322:             * sets the size for the order
323:             *
324:             * @param size size description
325:             * @exception if an error occurs
326:             */
327:            public void setSize(String size) throws AirSentException,
328:                    AirSentBusinessException {
329:                if (size.length() > Delivery.MAX_DESC) {
330:                    throw new AirSentBusinessException("Exceeds maximum size");
331:                }
332:                try {
333:                    deliveryDO.setSize(size);
334:                } catch (Exception e) {
335:                    throw new AirSentException(e);
336:                }
337:            }
338:
339:            /**
340:             * gets the descriton of the order
341:             *
342:             * @return descriotn
343:             * @exception if an error occurs
344:             */
345:            public String getDescription() throws AirSentException {
346:                try {
347:                    return deliveryDO.getDescription();
348:                } catch (Exception e) {
349:                    throw new AirSentException(e);
350:                }
351:            }
352:
353:            /**
354:             * sets the order description
355:             * 
356:             * @param description order description
357:             * @exception if an error occurs
358:             * @exception if the description is invalid
359:             */
360:            public void setDescription(String description)
361:                    throws AirSentException, AirSentBusinessException {
362:                if (description.length() > Delivery.MAX_DESC) {
363:                    throw new AirSentBusinessException("Exceeds maximum size");
364:                }
365:                try {
366:                    deliveryDO.setDescription(description);
367:                } catch (Exception e) {
368:                    throw new AirSentException(e);
369:                }
370:            }
371:
372:            /**
373:             * saves the order
374:             *
375:             * @exception if an error occurs
376:             */
377:            public void save() throws AirSentException {
378:                try {
379:                    deliveryDO.commit();
380:                } catch (Exception e) {
381:                    e.printStackTrace();
382:                    throw new AirSentException(e);
383:                }
384:                update.setUpdateState(System.currentTimeMillis());
385:            }
386:
387:            /**
388:             * deletes the order
389:             *
390:             * @exception if an error occurs
391:             */
392:            public void delete() throws AirSentException {
393:                try {
394:                    deliveryDO.delete();
395:                } catch (Exception e) {
396:                    throw new AirSentException(e);
397:                }
398:                update.setUpdateState(System.currentTimeMillis());
399:            }
400:
401:            /**
402:             * returns the pick up time
403:             *
404:             * @return pick up time 
405:             * @exception if an error occurs
406:             */
407:            public String getPickedUpTime() throws AirSentException {
408:                long time = 0;
409:                try {
410:                    if ((time = deliveryDO.getPickedUpTime()) == 0) {
411:                        return "-";
412:                    } else {
413:                        return formatTime(time);
414:                    }
415:                } catch (Exception e) {
416:                    throw new AirSentException(e);
417:                }
418:            }
419:
420:            /**
421:             * returns the drop off time
422:             * 
423:             * @return drop off time  
424:             * @exception if an error occurs
425:             */
426:            public String getDroppedOffTime() throws AirSentException {
427:                long time = 0;
428:                try {
429:                    if ((time = deliveryDO.getDroppedOffTime()) == 0) {
430:                        return "-";
431:                    } else {
432:                        return formatTime(time);
433:                    }
434:                } catch (Exception e) {
435:                    throw new AirSentException(e);
436:                }
437:            }
438:
439:            /**
440:             * Chnages the order to be 'picked up'
441:             *
442:             * @exception if an error occurs
443:             */
444:            public void pickUp() throws AirSentException {
445:                try {
446:                    deliveryDO.setIsPickedUp(true);
447:                    deliveryDO.setPickedUpTime(System.currentTimeMillis());
448:                    save();
449:                } catch (Exception e) {
450:                    throw new AirSentException(e);
451:                }
452:            }
453:
454:            /**
455:             * Changes the order to be in the 'drop off' state
456:             *
457:             * @exception if an error occurs
458:             */
459:            public void dropOff() throws AirSentException {
460:                try {
461:                    deliveryDO.setIsDroppedOff(true);
462:                    deliveryDO.setDroppedOffTime(System.currentTimeMillis());
463:                    save();
464:                } catch (Exception e) {
465:                    throw new AirSentException(e);
466:                }
467:            }
468:
469:            /**
470:             * returns the pick up statues
471:             *
472:             * @return true if order has been pickup
473:             * @exception if an error occurs
474:             */
475:            public boolean isPickedUp() throws AirSentException {
476:                try {
477:                    return deliveryDO.getIsPickedUp();
478:                } catch (Exception e) {
479:                    throw new AirSentException(e);
480:                }
481:            }
482:
483:            /**
484:             * returns the drop off status
485:             * 
486:             * @return true if the order has been dropped off
487:             * @exception if an error occurs
488:             */
489:            public boolean isDroppedOff() throws AirSentException {
490:                try {
491:                    return deliveryDO.getIsDroppedOff();
492:                } catch (Exception e) {
493:                    throw new AirSentException(e);
494:                }
495:            }
496:
497:            /*
498:             * Get invoice number.
499:             */
500:            public int getInvoice() throws AirSentException {
501:                try {
502:                    return deliveryDO.getInvoice();
503:                } catch (Exception e) {
504:                    throw new AirSentException(e);
505:                }
506:            }
507:
508:            /*
509:             * Set invoice number.
510:             */
511:            public void setInvoice(int invoice) throws AirSentException {
512:                try {
513:                    deliveryDO.setInvoice(invoice);
514:                } catch (Exception e) {
515:                    throw new AirSentException(e);
516:                }
517:            }
518:
519:            /*
520:             * Format the time for the day.
521:             *
522:             * @param long mSeconds
523:             * @return String
524:             */
525:            private String formatTime(long time) {
526:                return new Date(time).toGMTString();
527:            }
528:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.