Source Code Cross Referenced for DeliveryManagerImpl.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: DeliveryManagerImpl.java,v 1.1 2004/05/19 18:15:19
018:         */
019:
020:        package com.lutris.airsent.business.delivery;
021:
022:        import com.lutris.airsent.spec.AirSentException;
023:
024:        import com.lutris.airsent.business.*;
025:
026:        import com.lutris.airsent.business.delivery.*;
027:        import com.lutris.airsent.spec.delivery.DeliveryManager;
028:
029:        import com.lutris.airsent.spec.delivery.*;
030:        import com.lutris.airsent.data.delivery.*;
031:        import com.lutris.airsent.spec.address.Address;
032:        import com.lutris.airsent.spec.messenger.Messenger;
033:        import com.lutris.airsent.data.person.MessengerDO;
034:        import com.lutris.airsent.spec.customer.Customer;
035:
036:        import com.lutris.airsent.data.person.CustomerDO;
037:        import com.lutris.appserver.server.sql.*;
038:        import com.lutris.dods.builder.generator.query.*;
039:        import java.sql.Date;
040:
041:        /**
042:         * Implementation of the delivery manger.
043:         */
044:        public class DeliveryManagerImpl implements  DeliveryManager {
045:
046:            private Update update = null;
047:
048:            /**
049:             * creates the Manager
050:             */
051:            public DeliveryManagerImpl() {
052:                this .update = new UpdateImpl(System.currentTimeMillis());
053:            }
054:
055:            /**
056:             * Gets the last update time.
057:             * 
058:             * @param browserState
059:             * @param wait
060:             * @return update time
061:             * @exception if an error occurs
062:             */
063:            public long getUpdate(long browserState, long wait)
064:                    throws AirSentBusinessException {
065:                try {
066:                    return update.needUpdate(browserState, wait);
067:                } catch (Exception e) {
068:                    throw new AirSentBusinessException(e);
069:                }
070:            }
071:
072:            /**
073:             * Create a new delivery.
074:             *
075:             * @param customer customer associated with the order
076:             * @return delivey object
077:             * @exception if an error occurs
078:             */
079:            public Delivery create(Customer customer)
080:                    throws AirSentBusinessException {
081:                try {
082:                    return new DeliveryImpl(update, customer);
083:                } catch (Exception e) {
084:                    throw new AirSentBusinessException(e);
085:                }
086:            }
087:
088:            /**
089:             * Create a delivery based on an order.
090:             *
091:             * @return delivey object
092:             * @exception if an error occurs
093:             * @exception if business rules are violated
094:             */
095:            public Delivery create(Customer customer, OrderForm orderForm)
096:                    throws AirSentException, AirSentBusinessException {
097:                try {
098:                    Delivery d;
099:                    if (orderForm.getOrderId() == null) {
100:                        d = new DeliveryImpl(update, customer);
101:                    } else {
102:                        d = new DeliveryImpl(update, orderForm.getOrderId());
103:                    }
104:                    d.setIsFragile(orderForm.getFragile());
105:                    d.setIsUrgent(orderForm.getUrgent());
106:                    d.setSize(orderForm.getSize());
107:                    d.setDescription(orderForm.getDescription());
108:
109:                    Address pua = d.getPickUp();
110:                    pua.setName(orderForm.getPickUpName());
111:                    pua.setStreet1(orderForm.getPickUpAddress1());
112:                    pua.setLocalNumber(orderForm.getPickUpPhone());
113:                    pua.setDirections(orderForm.getPickUpDirections());
114:
115:                    Address doa = d.getDropOff();
116:                    doa.setName(orderForm.getDropOffName());
117:                    doa.setStreet1(orderForm.getDropOffAddress1());
118:                    doa.setLocalNumber(orderForm.getDropOffPhone());
119:                    doa.setDirections(orderForm.getDropOffDirections());
120:                    return d;
121:                } catch (AirSentBusinessException be) {
122:                    throw be;
123:                } catch (Exception e) {
124:                    throw new AirSentException(e);
125:                }
126:            }
127:
128:            /**
129:             * Find deliver by database id
130:             *
131:             * @param handle database id
132:             * @return delivery
133:             * @exception if an error occurs
134:             */
135:            public Delivery findByHandle(String handle)
136:                    throws AirSentBusinessException {
137:                try {
138:                    DeliveryQuery query = new DeliveryQuery();
139:                    query.requireUniqueInstance();
140:                    query.setQueryOId(new ObjectId(handle));
141:                    DeliveryDO theDeliveryDO = query.getNextDO();
142:                    return new DeliveryImpl(update, theDeliveryDO);
143:                } catch (Exception e) {
144:                    throw new AirSentBusinessException(e);
145:                }
146:            }
147:
148:            /**
149:             * Find deliveries associated with a given customer
150:             *
151:             * @param customer the customer
152:             * @return delivery
153:             * @exception if an error occurs
154:             */
155:            public Delivery[] findByCustomer(Customer customer)
156:                    throws AirSentBusinessException {
157:
158:                Delivery[] theDeliveryArray = null;
159:                try {
160:                    DeliveryQuery query = new DeliveryQuery();
161:                    QueryBuilder qb = query.getQueryBuilder();
162:                    qb.addEndClause(" order by oid");
163:                    query.setQueryCustomerID(CustomerDO.createExisting(customer
164:                            .getHandle()));
165:                    DeliveryDO[] DOarray = query.getDOArray();
166:                    theDeliveryArray = new Delivery[DOarray.length];
167:                    for (int i = 0; i < DOarray.length; i++) {
168:                        theDeliveryArray[i] = new DeliveryImpl(update,
169:                                DOarray[i]);
170:                    }
171:                } catch (Exception e) {
172:                    throw new AirSentBusinessException(e);
173:                }
174:                return theDeliveryArray;
175:            }
176:
177:            /**
178:             * Find all the deliveries.
179:             *
180:             * @return delivery objects
181:             * @exception if an error occurs
182:             */
183:            public Delivery[] findAll() throws AirSentBusinessException {
184:                Delivery[] theDeliveryArray = null;
185:                try {
186:                    DeliveryQuery query = new DeliveryQuery();
187:                    QueryBuilder qb = query.getQueryBuilder();
188:                    qb.addEndClause(" order by oid");
189:                    DeliveryDO[] DOarray = query.getDOArray();
190:                    theDeliveryArray = new Delivery[DOarray.length];
191:                    for (int i = 0; i < DOarray.length; i++) {
192:                        theDeliveryArray[i] = new DeliveryImpl(update,
193:                                DOarray[i]);
194:                    }
195:                } catch (Exception e) {
196:                    throw new AirSentBusinessException(e);
197:                }
198:                return theDeliveryArray;
199:            }
200:
201:            /**
202:             * Find the specified number the deliveries. 
203:             *
204:             * @param subset desired number of deliveries 
205:             * @return delivery objects
206:             * @exception if an error occurs
207:             */
208:            public Delivery[] findSubset(int subset)
209:                    throws AirSentBusinessException {
210:                Delivery[] theDeliveryArray = null;
211:                try {
212:                    DeliveryQuery query = new DeliveryQuery();
213:                    QueryBuilder qb = query.getQueryBuilder();
214:                    qb.addEndClause(" order by oid");
215:                    DeliveryDO[] DOarray = query.getDOArray();
216:                    int count = 0;
217:                    if (DOarray.length <= subset) {
218:                        count = DOarray.length;
219:                    } else {
220:                        count = subset;
221:                    }
222:                    theDeliveryArray = new Delivery[count];
223:                    for (int i = 0; i < count; i++) {
224:                        theDeliveryArray[i] = new DeliveryImpl(update,
225:                                DOarray[i]);
226:                    }
227:                } catch (Exception e) {
228:                    throw new AirSentBusinessException(e);
229:                }
230:                return theDeliveryArray;
231:            }
232:
233:            /**
234:             * find all deliveries associated with a given messenger
235:             *
236:             * @param messenger messenger
237:             * @return delivery objects
238:             * @exception if an error occurs
239:             */
240:            public Delivery[] findByMessenger(Messenger messenger)
241:                    throws AirSentBusinessException {
242:                Delivery[] theDeliveryArray = null;
243:                try {
244:                    DeliveryQuery query = new DeliveryQuery();
245:                    query.setQueryMessengerID(MessengerDO
246:                            .createExisting(messenger.getHandle()));
247:                    //SV query.openParen();
248:                    //SV query.setQueryIsPickedUp(false);
249:                    //SV query.or();
250:                    //SV query.setQueryIsDroppedOff(false);
251:                    //SV query.closeParen();
252:                    DeliveryDO[] DOarray = query.getDOArray();
253:                    int len = 0;
254:                    for (int i = 0; i < DOarray.length; i++) {
255:                        if ((!DOarray[i].getIsPickedUp())
256:                                || (!DOarray[i].getIsDroppedOff())) {
257:                            len = len + 1;
258:                        }
259:                    }
260:                    theDeliveryArray = new Delivery[len];
261:                    int j = 0;
262:                    for (int i = 0; i < DOarray.length; i++) {
263:                        if ((!DOarray[i].getIsPickedUp())
264:                                || (!DOarray[i].getIsDroppedOff())) {
265:                            theDeliveryArray[j] = new DeliveryImpl(update,
266:                                    DOarray[i]);
267:                            j = j + 1;
268:                        }
269:                    }
270:                } catch (Exception e) {
271:                    e.printStackTrace();
272:                    throw new AirSentBusinessException(e);
273:                }
274:                return theDeliveryArray;
275:            }
276:
277:            // -----------------------------------------------------------------
278:            // not currenty used
279:            // -----------------------------------------------------------------
280:
281:            /**
282:             * find all delivery objects not delivered
283:             *
284:             * @return delivery objects
285:             * @exception if an error occurs
286:             */
287:            public Delivery[] findUndelivered() throws AirSentBusinessException {
288:                Delivery[] theDeliveryArray = null;
289:                try {
290:                    DeliveryQuery query = new DeliveryQuery();
291:                    query.setQueryIsPickedUp(false);
292:                    query.or();
293:                    query.setQueryIsDroppedOff(false);
294:                    DeliveryDO[] DOarray = query.getDOArray();
295:                    theDeliveryArray = new Delivery[DOarray.length];
296:                    for (int i = 0; i < DOarray.length; i++) {
297:                        theDeliveryArray[i] = new DeliveryImpl(update,
298:                                DOarray[i]);
299:                    }
300:                } catch (Exception e) {
301:                    throw new AirSentBusinessException(e);
302:                }
303:                return theDeliveryArray;
304:            }
305:
306:            /**
307:             * Find deliveries by invoice
308:             *
309:             * @param invoice invoice id
310:             * @return delivery
311:             * @exception if an error occurs
312:             */
313:            public Delivery findByInvoice(int invoice)
314:                    throws AirSentBusinessException {
315:                Delivery theDelivery = null;
316:                try {
317:                    DeliveryQuery query = new DeliveryQuery();
318:                    query.requireUniqueInstance();
319:                    query.setQueryInvoice(invoice);
320:                    DeliveryDO theDeliveryDO = query.getNextDO();
321:                    theDelivery = new DeliveryImpl(update, theDeliveryDO);
322:                    return theDelivery;
323:                } catch (Exception e) {
324:                    throw new AirSentBusinessException(e);
325:                }
326:            }
327:
328:            /**
329:             * Find all the deliveries after a given time.
330:             *
331:             * @param data time 
332:             * @return delivery objects
333:             * @exception if an error occurs
334:             */
335:            public Delivery[] findAllAfter(long date)
336:                    throws AirSentBusinessException {
337:                Delivery[] theDeliveryArray = null;
338:                Date searchDate = new Date(date);
339:                try {
340:                    DeliveryQuery query = new DeliveryQuery();
341:                    QueryBuilder builder = query.getQueryBuilder();
342:                    builder.addWhere(DeliveryDO.PickedUpTime, searchDate,
343:                            QueryBuilder.GREATER_THAN);
344:                    builder.addWhereOr();
345:                    builder.addWhere(DeliveryDO.DroppedOffTime, searchDate,
346:                            QueryBuilder.GREATER_THAN);
347:                    DeliveryDO[] DOarray = query.getDOArray();
348:                    theDeliveryArray = new Delivery[DOarray.length];
349:                    for (int i = 0; i < DOarray.length; i++) {
350:                        theDeliveryArray[i] = new DeliveryImpl(update,
351:                                DOarray[i]);
352:                    }
353:                } catch (Exception e) {
354:                    throw new AirSentBusinessException(e);
355:                }
356:                return theDeliveryArray;
357:            }
358:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.