Source Code Cross Referenced for AdminMain.java in  » J2EE » Enhydra-Demos » com » lutris » airsent » presentation » admin » 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.presentation.admin 
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:         */
016:
017:        package com.lutris.airsent.presentation.admin;
018:
019:        import org.enhydra.xml.xmlc.XMLObject;
020:        import com.lutris.appserver.server.httpPresentation.*;
021:        import com.lutris.appserver.server.session.*;
022:        import com.lutris.util.*; //import com.lutris.xml.xmlc.*;
023:        //import com.lutris.xml.xmlc.html.*;
024:        import org.w3c.dom.*;
025:        import org.w3c.dom.html.*;
026:        import java.util.*;
027:        import com.lutris.airsent.presentation.BasePO;
028:        import com.lutris.airsent.spec.AirSentException;
029:
030:        import com.lutris.airsent.presentation.AirSentPresentationException;
031:        import com.lutris.airsent.presentation.AirSentConstants;
032:        import com.lutris.airsent.spec.delivery.Delivery;
033:        import com.lutris.airsent.spec.messenger.Messenger;
034:        import com.lutris.airsent.spec.address.*;
035:
036:        /**
037:         * AdminMain is the main interactive page for the AirSent
038:         * administrator. AdminMain shows current(and past) delivies
039:         * allows for Detailed viewing of Deliveries and Messengers.
040:         * 
041:         */
042:        public class AdminMain extends BasePO {
043:
044:            /**
045:             * Constants
046:             */
047:            private static final int AUTH_LEVEL = AirSentConstants.ADMINISTRATOR_USER;
048:            private static final int TOP_TEN_DELIVERIES = 10;
049:            private static final int TOP_TWENTY_DELIVERIES = 20;
050:            private static final int ALL_DELIVERIES = 0;
051:            private static final long TIME_OUT = 60;
052:
053:            /**
054:             * Superclass method override.
055:             * returns the authorization level necessary to access this po.
056:             * 
057:             * @return int required authorization level
058:             */
059:            public int getRequiredAuthLevel() {
060:                return AUTH_LEVEL;
061:            }
062:
063:            /**
064:             * Default event. Just show the page.
065:             */
066:            public XMLObject handleDefault() throws HttpPresentationException {
067:                return showPage(null);
068:            }
069:
070:            /**
071:             * 
072:             * @param error messages
073:             * @return page.
074:             */
075:            public XMLObject showPage(String errorMsg)
076:                    throws AirSentPresentationException {
077:                // Build the page, checking for errors first.
078:                AdminMainHTML page = (AdminMainHTML) myComms.xmlcFactory
079:                        .create(AdminMainHTML.class);
080:
081:                try {
082:
083:                    if (null != errorMsg
084:                            || null != (errorMsg = getSessionData()
085:                                    .getAndClearUserMessage())) {
086:                        page.setTextErrorText(errorMsg);
087:                    } else {
088:                        page.getElementErrorText().getParentNode().removeChild(
089:                                page.getElementErrorText());
090:                    }
091:
092:                    /**
093:                     * If the ServerPush tecnique is specified in the
094:                     * conf file, then server push will be enabled. Essentially
095:                     * server push is a page that is continously loading, or  until
096:                     * rather, waiting to load until the page has a)changed, or b)
097:                     * the TCP/IP timeout of 60 seconds has expired.
098:                     */
099:
100:                    if (getApplication().useServerPush()) {
101:                        if (getComms().request
102:                                .getParameter(AirSentConstants.REFRESH) != null) {
103:
104:                            // 
105:                            // Do the update or wait
106:                            // 
107:                            getSessionData().setBrowserState(
108:                                    getApplication().getHomeManager()
109:                                            .getDeliveryManager().getUpdate(
110:                                                    getSessionData()
111:                                                            .getBrowserState(),
112:                                                    TIME_OUT));
113:                        } else {
114:                            getSessionData().setBrowserState(
115:                                    getApplication().getHomeManager()
116:                                            .getDeliveryManager().getUpdate(0,
117:                                                    TIME_OUT));
118:                        }
119:                    } else {
120:
121:                        //Remove the javascript that reloads the
122:                        //page as the mechanism fo ServerPush.
123:                        page.getElementRefreshScript().getParentNode()
124:                                .removeChild(page.getElementRefreshScript());
125:                    }
126:
127:                    // Decide how to sort each table by delivery.
128:                    String pickupSort = null;
129:                    int currentPickupSort = 0;
130:
131:                    if ((pickupSort = getComms().request
132:                            .getParameter(AirSentConstants.PICKUP_FILTER)) != null) {
133:                        currentPickupSort = Integer.parseInt(pickupSort);
134:                    }
135:
136:                    String dropoffSort = null;
137:                    int currentDropoffSort = 0;
138:
139:                    if ((dropoffSort = getComms().request
140:                            .getParameter(AirSentConstants.PICKUP_FILTER)) != null) {
141:                        currentDropoffSort = Integer.parseInt(dropoffSort);
142:                    }
143:
144:                    // Build each table based on the delivery filters.
145:                    buildPickUpTable(page, currentPickupSort);
146:                    buildDropOffTable(page, currentDropoffSort);
147:                    /*
148:                     * Catch Null pointer exception ( we canot make a instances of classes from business layer  when we run AirSent_pres ) 
149:                     * We need  to allow AirSent_pres to be functional ,  response
150:                     * will be default HTML page with message
151:                     *	
152:                     */
153:                } catch (NullPointerException e) {
154:                    page
155:                            .setTextErrorText("You cannot delete order while runnig AirSent_pres");
156:                } catch (Exception e) {
157:                    throw new AirSentPresentationException(
158:                            "Trouble showing page", e);
159:                }
160:                return page;
161:            }
162:
163:            /**
164:             * Builds the PickUp table
165:             * 
166:             * 
167:             */
168:            protected void buildPickUpTable(AdminMainHTML page, int type)
169:                    throws AirSentPresentationException {
170:                String messenger = null;
171:
172:                try {
173:                    HTMLTableRowElement templatePickUpRow = page
174:                            .getElementPickuprow();
175:                    Node pickupTable = templatePickUpRow.getParentNode();
176:
177:                    // Get the template elements
178:                    HTMLElement pickupnameCellTemplate = page
179:                            .getElementPickupname();
180:                    HTMLElement pickupaddressCellTemplate = page
181:                            .getElementPickupaddress();
182:                    HTMLImageElement pickupisurgentCellTemplate = page
183:                            .getElementPickupurgent();
184:                    HTMLElement pickupmessengerCellTemplate = page
185:                            .getElementPickupmessenger();
186:                    HTMLAnchorElement pickupeditCellTemplate = page
187:                            .getElementPickupedit();
188:                    HTMLAnchorElement deletepickupCellTemplate = page
189:                            .getElementDeletepickuporder();
190:                    HTMLAnchorElement messengerURL = page
191:                            .getElementPickupmessengerURL();
192:
193:                    // Remove ids to prevent duplicates
194:                    // (browsers don't care, but the DOM does)
195:                    templatePickUpRow.removeAttribute("id");
196:                    pickupnameCellTemplate.removeAttribute("id");
197:                    pickupaddressCellTemplate.removeAttribute("id");
198:                    pickupisurgentCellTemplate.removeAttribute("id");
199:                    pickupeditCellTemplate.removeAttribute("id");
200:                    deletepickupCellTemplate.removeAttribute("id");
201:                    messengerURL.removeAttribute("id");
202:
203:                    // Get the array of deliveries.
204:                    Delivery[] deliveryList = getDeliveries(type);
205:
206:                    // Create a row for each delivery
207:                    for (int numDeliveries = 0; numDeliveries < deliveryList.length; numDeliveries++) {
208:                        Delivery currentDelivery = deliveryList[numDeliveries];
209:
210:                        // set text of new cells to values from string array
211:                        page.setTextPickupname(currentDelivery.getPickUp()
212:                                .getName());
213:                        page.setTextPickupaddress(currentDelivery.getPickUp()
214:                                .getStreet1());
215:
216:                        messenger = AirSentConstants.NOT_ASSIGNED;
217:
218:                        if (currentDelivery.getMessenger() != null) {
219:                            messenger = currentDelivery.getMessenger()
220:                                    .getFirstName();
221:
222:                            messengerURL
223:                                    .setHref(AirSentConstants.NEW_MESSENGER_PAGE
224:                                            + "?"
225:                                            + AirSentConstants.MESSENGER_NAME
226:                                            + "="
227:                                            + currentDelivery.getMessenger()
228:                                                    .getBadge());
229:                        } else {
230:                            messengerURL
231:                                    .setHref(AirSentConstants.ADMINDETAILS_PAGE
232:                                            + "?deliveryID="
233:                                            + currentDelivery.getHandle());
234:                        }
235:
236:                        page.setTextPickupmessenger(messenger);
237:                        page.setTextPickuptime(currentDelivery
238:                                .getPickedUpTime());
239:                        page.setTextPickupordernumber(currentDelivery
240:                                .getHandle());
241:                        pickupeditCellTemplate
242:                                .setHref(AirSentConstants.ADMINDETAILS_PAGE
243:                                        + "?deliveryID="
244:                                        + currentDelivery.getHandle());
245:                        deletepickupCellTemplate
246:                                .setHref(AirSentConstants.ADMIN_MAIN_PAGE
247:                                        + "?event=delete" + "&deliveryID="
248:                                        + currentDelivery.getHandle());
249:
250:                        if (currentDelivery.isUrgent()) {
251:                            pickupisurgentCellTemplate
252:                                    .setSrc(AirSentConstants.URGENT_IMAGE);
253:                        } else {
254:                            pickupisurgentCellTemplate
255:                                    .setSrc(AirSentConstants.BLANK_IMAGE);
256:                        }
257:
258:                        HTMLTableRowElement tempPickUpRow = (HTMLTableRowElement) templatePickUpRow
259:                                .cloneNode(true);
260:
261:                        if (currentDelivery.isPickedUp()) {
262:                            tempPickUpRow.setBgColor("cccccc");
263:                        } else {
264:                            tempPickUpRow.setBgColor("yellow");
265:                            page.setTextPickuptime("-");
266:                        }
267:
268:                        // Add a deep clone of the row to the DOM
269:                        pickupTable.appendChild(tempPickUpRow);
270:                    }
271:
272:                    // Finally remove the template row and template select option
273:                    // from the page
274:                    templatePickUpRow.getParentNode().removeChild(
275:                            templatePickUpRow);
276:                    //same thing
277:                } catch (NullPointerException e) {
278:                } catch (Exception e) {
279:                    throw new AirSentPresentationException(
280:                            "Trouble showing page", e);
281:                }
282:            }
283:
284:            /**
285:             * Builds the DropOff table
286:             * 
287:             * 
288:             */
289:            protected void buildDropOffTable(AdminMainHTML page, int type)
290:                    throws AirSentPresentationException {
291:                String messenger = AirSentConstants.NOT_ASSIGNED;
292:
293:                try {
294:                    HTMLTableRowElement templateDropOffRow = page
295:                            .getElementDropoffrow();
296:                    Node dropoffTable = templateDropOffRow.getParentNode();
297:
298:                    // Get the elements
299:                    HTMLElement dropoffnameCellTemplate = page
300:                            .getElementDropoffname();
301:                    HTMLElement dropoffaddressCellTemplate = page
302:                            .getElementDropoffaddress();
303:                    HTMLElement dropoffmessengerCellTemplate = page
304:                            .getElementDropoffmessenger();
305:                    HTMLImageElement dropoffisurgentCellTemplate = page
306:                            .getElementDropoffurgent();
307:                    HTMLAnchorElement dropoffeditCellTemplate = page
308:                            .getElementDropoffedit();
309:                    HTMLAnchorElement deletedropoffCellTemplate = page
310:                            .getElementDeletedropofforder();
311:                    HTMLAnchorElement messengerURL = page
312:                            .getElementDropoffmessengerURL();
313:
314:                    // Remove ids to prevent duplicates
315:                    // (browsers don't care, but the DOM does)
316:                    templateDropOffRow.removeAttribute("id");
317:                    dropoffnameCellTemplate.removeAttribute("id");
318:                    dropoffaddressCellTemplate.removeAttribute("id");
319:                    dropoffmessengerCellTemplate.removeAttribute("id");
320:                    dropoffisurgentCellTemplate.removeAttribute("id");
321:                    dropoffeditCellTemplate.removeAttribute("id");
322:
323:                    // Get the delivery array
324:                    Delivery[] deliveryList = getDeliveries(type);
325:
326:                    for (int numDeliveries = 0; numDeliveries < deliveryList.length; numDeliveries++) {
327:                        Delivery currentDelivery = deliveryList[numDeliveries];
328:
329:                        // set text of new cells to values from string array
330:                        page.setTextDropoffname(currentDelivery.getDropOff()
331:                                .getName());
332:                        page.setTextDropoffaddress(currentDelivery.getDropOff()
333:                                .getStreet1());
334:
335:                        messenger = AirSentConstants.NOT_ASSIGNED;
336:
337:                        if (currentDelivery.getMessenger() != null) {
338:                            messenger = currentDelivery.getMessenger()
339:                                    .getFirstName();
340:
341:                            messengerURL
342:                                    .setHref(AirSentConstants.NEW_MESSENGER_PAGE
343:                                            + "?"
344:                                            + AirSentConstants.MESSENGER_NAME
345:                                            + "="
346:                                            + currentDelivery.getMessenger()
347:                                                    .getBadge());
348:                        } else {
349:                            messengerURL
350:                                    .setHref(AirSentConstants.ADMINDETAILS_PAGE
351:                                            + "?deliveryID="
352:                                            + currentDelivery.getHandle());
353:
354:                        }
355:
356:                        page.setTextDropoffmessenger(messenger);
357:                        page.setTextDropoffordernumber(currentDelivery
358:                                .getHandle());
359:                        page.setTextDropofftime(currentDelivery
360:                                .getDroppedOffTime());
361:                        dropoffeditCellTemplate
362:                                .setHref(AirSentConstants.ADMINDETAILS_PAGE
363:                                        + "?deliveryID="
364:                                        + currentDelivery.getHandle());
365:                        deletedropoffCellTemplate
366:                                .setHref(AirSentConstants.ADMIN_MAIN_PAGE
367:                                        + "?event=delete" + "&deliveryID="
368:                                        + currentDelivery.getHandle());
369:
370:                        if (currentDelivery.isUrgent()) {
371:                            dropoffisurgentCellTemplate
372:                                    .setSrc(AirSentConstants.URGENT_IMAGE);
373:                        } else {
374:                            dropoffisurgentCellTemplate
375:                                    .setSrc(AirSentConstants.BLANK_IMAGE);
376:                        }
377:
378:                        HTMLTableRowElement tempDropOffRow = (HTMLTableRowElement) templateDropOffRow
379:                                .cloneNode(true);
380:
381:                        if (currentDelivery.isDroppedOff()) {
382:                            tempDropOffRow.setBgColor("cccccc");
383:                        } else {
384:                            tempDropOffRow.setBgColor("yellow");
385:                            page.setTextDropofftime("-");
386:                        }
387:
388:                        // Add a deep clone of the row to the DOM
389:                        dropoffTable.appendChild(tempDropOffRow);
390:                    }
391:
392:                    // Finally remove the template row and template select option
393:                    // from the page
394:                    templateDropOffRow.getParentNode().removeChild(
395:                            templateDropOffRow);
396:
397:                } catch (NullPointerException e) {
398:                } catch (Exception e) {
399:                    throw new AirSentPresentationException(
400:                            "Trouble showing page", e);
401:                }
402:            }
403:
404:            /**
405:             * Gets a collection of deliveries based on the type.
406:             * 
407:             * 
408:             */
409:            protected Delivery[] getDeliveries(int type)
410:                    throws AirSentPresentationException {
411:                try {
412:                    switch (type) {
413:
414:                    case TOP_TEN_DELIVERIES:
415:                        return getApplication().getHomeManager()
416:                                .getDeliveryManager().findSubset(
417:                                        TOP_TEN_DELIVERIES);
418:
419:                    case TOP_TWENTY_DELIVERIES:
420:                        return getApplication().getHomeManager()
421:                                .getDeliveryManager().findSubset(
422:                                        TOP_TWENTY_DELIVERIES);
423:
424:                    case ALL_DELIVERIES:
425:                        return getApplication().getHomeManager()
426:                                .getDeliveryManager().findAll();
427:
428:                    default:
429:                        return getApplication().getHomeManager()
430:                                .getDeliveryManager().findAll();
431:                    }
432:
433:                } catch (NullPointerException e) {
434:                    throw new NullPointerException();
435:                } catch (Exception e) {
436:                    throw new AirSentPresentationException(
437:                            "Trouble getting deliveries:", e);
438:                }
439:            }
440:
441:            /**
442:             *Handles the deletion of an Order. 
443:             * 
444:             * 
445:             */
446:            public XMLObject handleDelete() throws AirSentPresentationException {
447:                try {
448:                    String deliveryID = getComms().request
449:                            .getParameter(AirSentConstants.DELIVERYID);
450:                    Delivery delivery = null;
451:
452:                    if ((delivery = getApplication().getHomeManager()
453:                            .getDeliveryManager().findByHandle(deliveryID)) != null) {
454:                        delivery.delete();
455:
456:                    }
457:                    //We need  to allow AirSent_pres to be functional , response will be default HTML page        
458:                } catch (NullPointerException e) {
459:
460:                    AdminMainHTML defaultPage = (AdminMainHTML) myComms.xmlcFactory
461:                            .create(AdminMainHTML.class);
462:                    defaultPage
463:                            .setTextErrorText("You cannot delete delivery while running AirSent_pres");
464:                    return defaultPage;
465:                } catch (Exception ex) {
466:                    throw new AirSentPresentationException(
467:                            "Error in confimation", ex);
468:                }
469:                throw new ClientPageRedirectException(
470:                        AirSentConstants.ADMIN_MAIN_PAGE);
471:            }
472:
473:            /**
474:             * Update the AdminMain page.
475:             * 
476:             * 
477:             */
478:            public XMLObject handleUpdate() throws AirSentPresentationException {
479:                return showPage(null);
480:            }
481:
482:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.