Source Code Cross Referenced for GenericWebEventProcessor.java in  » ERP-CRM-Financial » SourceTap-CRM » com » sourcetap » sfa » event » 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 » ERP CRM Financial » SourceTap CRM » com.sourcetap.sfa.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         * 
0003:         * Copyright (c) 2004 SourceTap - www.sourcetap.com
0004:         *
0005:         *  The contents of this file are subject to the SourceTap Public License 
0006:         * ("License"); You may not use this file except in compliance with the 
0007:         * License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
0008:         * Software distributed under the License is distributed on an  "AS IS"  basis,
0009:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
0010:         * the specific language governing rights and limitations under the License.
0011:         *
0012:         * The above copyright notice and this permission notice shall be included
0013:         * in all copies or substantial portions of the Software.
0014:         *
0015:         */
0016:
0017:        package com.sourcetap.sfa.event;
0018:
0019:        import java.util.ArrayList;
0020:        import java.util.Collection;
0021:        import java.util.Enumeration;
0022:        import java.util.HashMap;
0023:        import java.util.Iterator;
0024:        import java.util.LinkedList;
0025:        import java.util.List;
0026:        import java.util.StringTokenizer;
0027:        import java.util.Vector;
0028:
0029:        import javax.servlet.http.HttpServletRequest;
0030:        import javax.servlet.http.HttpServletResponse;
0031:
0032:        import org.ofbiz.base.util.Debug;
0033:        import org.ofbiz.base.util.UtilFormatOut;
0034:        import org.ofbiz.base.util.UtilMisc;
0035:        import org.ofbiz.base.util.UtilTimer;
0036:        import org.ofbiz.entity.GenericDelegator;
0037:        import org.ofbiz.entity.GenericEntityException;
0038:        import org.ofbiz.entity.GenericValue;
0039:        import org.ofbiz.entity.condition.EntityComparisonOperator;
0040:        import org.ofbiz.entity.condition.EntityOperator;
0041:        import org.ofbiz.entity.model.ModelEntity;
0042:
0043:        import com.sourcetap.sfa.replication.GenericReplicator;
0044:        import com.sourcetap.sfa.ui.UICache;
0045:        import com.sourcetap.sfa.ui.UIDisplayObject;
0046:        import com.sourcetap.sfa.ui.UIFieldInfo;
0047:        import com.sourcetap.sfa.ui.UIHistoryManager;
0048:        import com.sourcetap.sfa.ui.UIQuery;
0049:        import com.sourcetap.sfa.ui.UIScreenSection;
0050:        import com.sourcetap.sfa.ui.UIScreenSectionEntity;
0051:        import com.sourcetap.sfa.ui.UIUtility;
0052:        import com.sourcetap.sfa.ui.UIWebScreenSection;
0053:        import com.sourcetap.sfa.ui.UIWebUtility;
0054:        import com.sourcetap.sfa.util.DelimitedValueDecoder;
0055:        import com.sourcetap.sfa.util.Preference;
0056:        import com.sourcetap.sfa.util.QueryInfo;
0057:        import com.sourcetap.sfa.util.UserInfo;
0058:
0059:        /**
0060:         * DOCUMENT ME!
0061:         *
0062:         */
0063:        public class GenericWebEventProcessor {
0064:            public static final int STATUS_ERROR = -1;
0065:            public static final int STATUS_CANCEL = 0;
0066:            public static final int STATUS_CONTINUE = 1;
0067:            private static final boolean TIMER = false;
0068:            public static final String module = GenericWebEventProcessor.class
0069:                    .getName();
0070:
0071:            public GenericWebEventProcessor() {
0072:            }
0073:
0074:            /**
0075:             * DOCUMENT ME!
0076:             *
0077:             * @param screenName 
0078:             * @param sectionName 
0079:             * @param userInfo 
0080:             * @param request 
0081:             * @param response 
0082:             * @param delegator 
0083:             * @param eventProcessor 
0084:             * @param uiCache 
0085:             *
0086:             * @return 
0087:             *
0088:             * @throws GenericEntityException 
0089:             */
0090:            public String processEvents(String screenName, String sectionName,
0091:                    UserInfo userInfo, HttpServletRequest request,
0092:                    HttpServletResponse response, GenericDelegator delegator,
0093:                    GenericEventProcessor eventProcessor, UICache uiCache)
0094:                    throws GenericEntityException {
0095:                return processEvents(screenName, sectionName, userInfo,
0096:                        request, response, delegator, eventProcessor, uiCache,
0097:                        false, 0);
0098:            }
0099:
0100:            /**
0101:             * DOCUMENT ME!
0102:             *
0103:             * @param screenName 
0104:             * @param sectionName 
0105:             * @param userInfo 
0106:             * @param request 
0107:             * @param response 
0108:             * @param delegator 
0109:             * @param eventProcessor 
0110:             * @param uiCache 
0111:             * @param isSubsection 
0112:             *
0113:             * @return 
0114:             *
0115:             * @throws GenericEntityException 
0116:             */
0117:            public String processEvents(String screenName, String sectionName,
0118:                    UserInfo userInfo, HttpServletRequest request,
0119:                    HttpServletResponse response, GenericDelegator delegator,
0120:                    GenericEventProcessor eventProcessor, UICache uiCache,
0121:                    boolean isSubsection) throws GenericEntityException {
0122:                return processEvents(screenName, sectionName, userInfo,
0123:                        request, response, delegator, eventProcessor, uiCache,
0124:                        isSubsection, 0);
0125:            }
0126:
0127:            /**
0128:             * DOCUMENT ME!
0129:             *
0130:             * @param screenName 
0131:             * @param sectionName 
0132:             * @param userInfo 
0133:             * @param request 
0134:             * @param response 
0135:             * @param delegator 
0136:             * @param eventProcessor 
0137:             * @param uiCache 
0138:             * @param isSubsection 
0139:             * @param tabOffset 
0140:             *
0141:             * @return 
0142:             *
0143:             * @throws GenericEntityException 
0144:             */
0145:            public String processEvents(String screenName, String sectionName,
0146:                    UserInfo userInfo, HttpServletRequest request,
0147:                    HttpServletResponse response, GenericDelegator delegator,
0148:                    GenericEventProcessor eventProcessor, UICache uiCache,
0149:                    boolean isSubsection, int tabOffset)
0150:                    throws GenericEntityException {
0151:                UtilTimer timer = new UtilTimer();
0152:
0153:                if (TIMER) {
0154:                    timer
0155:                            .timerString("[GenericWebEventProcessor.processEvents] Start");
0156:                }
0157:
0158:                if ((screenName == null) || screenName.equals("")) {
0159:                    throw new GenericEntityException("Screen name is required.");
0160:                }
0161:
0162:                if ((sectionName == null) || sectionName.equals("")) {
0163:                    throw new GenericEntityException(
0164:                            "Screen section name is required.");
0165:                }
0166:
0167:                UIWebScreenSection uiWebScreenSection = getUiWebScreenSection(
0168:                        userInfo, screenName, sectionName, delegator, uiCache);
0169:
0170:                if (TIMER) {
0171:                    timer
0172:                            .timerString("[GenericWebEventProcessor.processEvents] Got web screen section");
0173:                }
0174:
0175:                // Get the additional parameters that are needed for this screen section.  These will be used
0176:                // for filtering a related entity on a tab page, or in completing keys in a SELECT screen.
0177:                evalUseQueryParameterList(uiWebScreenSection, request);
0178:
0179:                if (TIMER) {
0180:                    timer
0181:                            .timerString("[GenericWebEventProcessor.processEvents] Evaluated \"use\" query parameter list");
0182:                }
0183:
0184:                Debug.logVerbose("Returned from evalUseQueryParameterList.",
0185:                        module);
0186:
0187:                // Find out what needs to be done depending on the action passed in the request object.
0188:                String action = "";
0189:
0190:                if (request.getParameter("action") != null) {
0191:                    // Actions for Free Form sections:
0192:                    //   ACTION_SHOW          - Display the entity in non-edit mode
0193:                    //   ACTION_SHOW_UPDATE   - Display the entity so the user can edit it
0194:                    //   ACTION_SHOW_INSERT   - Show the form with empty cells so the user can enter a new entity
0195:                    //   ACTION_SHOW_QUERY    - Show the form in Query mode, and set next action to QUERY.
0196:                    //   ACTION_SHOW_QUERY_REPORT - Show the form in Query mode, and set next action to SHOW_REPORT.
0197:                    //   ACTION_SHOW_REPORT   - Show the form in Report mode, and set next action to SHOW_REPORT.
0198:                    //   ACTION_SHOW_SELECT   - Show the form in select mode, and set next action to UPDATE_SELECT.
0199:                    //   ACTION_SHOW_COPY     - Show the form with a copy of the specified entity from which a new
0200:                    //                entity will be created.  (Same as showCreate with values prefilled.)
0201:                    //   ACTION_UPDATE        - Save the entity into the database using the form values.
0202:                    //   ACTION_INSERT        - Insert a new entity into into the database using the form values
0203:                    //   ACTION_DELETE        - Delete the entity from the database.
0204:                    //   ACTION_BUTTON        - A button in the header was pushed to get here.  Look for a parameter with
0205:                    //                each possible button name until we know which button was pushed.
0206:                    // Actions for Tabular sections:
0207:                    //   ACTION_QUERY         - Search for values based on attibute values using a custom WHERE clause.
0208:                    //   ACTION_QUERY_UPDATE  - Search for values based on attibute values using a custom WHERE clause,
0209:                    //                and go into update mode.
0210:                    //   ACTION_QUERY_ALL     - Search for all values.
0211:                    //   ACTION_UPDATE        - Save the entit(ies) into the database using the form values.
0212:                    //   ACTION_UPDATE_SELECT - Add and remove entities in a many-to-many relationship table.
0213:                    action = request.getParameter("action");
0214:                } else {
0215:                    // No action specified.
0216:                    action = uiWebScreenSection.ACTION_NONE;
0217:                }
0218:
0219:                if (!action.equals(uiWebScreenSection.ACTION_BUTTON)
0220:                        && !action.equals(uiWebScreenSection.ACTION_COPY)
0221:                        && !action.equals(uiWebScreenSection.ACTION_DELETE)
0222:                        && !action.equals(uiWebScreenSection.ACTION_INSERT)
0223:                        && !action.equals(uiWebScreenSection.ACTION_NONE)
0224:                        && !action.equals(uiWebScreenSection.ACTION_QUERY)
0225:                        && !action
0226:                                .equals(uiWebScreenSection.ACTION_QUERY_UPDATE)
0227:                        && !action.equals(uiWebScreenSection.ACTION_QUERY_ALL)
0228:                        && !action.equals(uiWebScreenSection.ACTION_UPDATE)
0229:                        && !action
0230:                                .equals(uiWebScreenSection.ACTION_UPDATE_SELECT)
0231:                        && !action.equals(uiWebScreenSection.ACTION_SHOW)
0232:                        && !action.equals(uiWebScreenSection.ACTION_SHOW_COPY)
0233:                        && !action
0234:                                .equals(uiWebScreenSection.ACTION_SHOW_INSERT)
0235:                        && !action.equals(uiWebScreenSection.ACTION_SHOW_QUERY)
0236:                        && !action
0237:                                .equals(uiWebScreenSection.ACTION_SHOW_QUERY_REPORT)
0238:                        && !action
0239:                                .equals(uiWebScreenSection.ACTION_SHOW_REPORT)
0240:                        && !action
0241:                                .equals(uiWebScreenSection.ACTION_SHOW_SELECT)
0242:                        && !action
0243:                                .equals(uiWebScreenSection.ACTION_SHOW_UPDATE)) {
0244:                    Debug.logWarning("\"" + action
0245:                            + "\" is not a valid action.", module);
0246:
0247:                    throw new GenericEntityException(
0248:                            "[GenericWebEventProcessor.processEvents] \""
0249:                                    + action + "\" is not a valid action.");
0250:                }
0251:
0252:                Debug.logVerbose("Starting action is \"" + action + "\".",
0253:                        module);
0254:                Debug
0255:                        .logVerbose(
0256:                                "About to convert button action to regular action if necessary.",
0257:                                module);
0258:
0259:                action = UIWebUtility.convertButtonAction(action, request);
0260:
0261:                Debug.logVerbose("Final action is \"" + action + "\".", module);
0262:
0263:                if (TIMER) {
0264:                    timer
0265:                            .timerString("[GenericWebEventProcessor.processEvents] Determined action");
0266:                }
0267:
0268:                String queryId = "";
0269:
0270:                if (request.getParameter("queryId") != null) {
0271:                    queryId = request.getParameter("queryId");
0272:                } else if (request.getParameter("savedQueryName") != null) {
0273:                    // The calling link specified to use a named query if it exists.
0274:                    String savedQueryName = request
0275:                            .getParameter("savedQueryName");
0276:                    GenericValue queryGV = UIQuery.getUiQueryByName(delegator,
0277:                            userInfo.getPartyId(), sectionName, screenName,
0278:                            savedQueryName);
0279:
0280:                    if (queryGV == null) {
0281:                        // Named query was not found.  Don't use a query.
0282:                        queryId = "1"; // Query = All
0283:                        Debug.logWarning(
0284:                                "Named query not found for query name "
0285:                                        + savedQueryName + ", partyId "
0286:                                        + userInfo.getPartyId()
0287:                                        + ", sectionName " + sectionName
0288:                                        + ", and screenName " + screenName
0289:                                        + ".  queryId is now \"" + queryId
0290:                                        + "\"", module);
0291:                    } else {
0292:                        // Named query was found.
0293:                        queryId = (queryGV.getString("queryId") == null) ? "NONE"
0294:                                : queryGV.getString("queryId");
0295:
0296:                        Debug.logVerbose("Named query was found. queryId is \""
0297:                                + queryId + "\"", module);
0298:                    }
0299:                }
0300:
0301:                DataMatrix dataMatrix = new DataMatrix(delegator,
0302:                        uiWebScreenSection.getEntityParamVector());
0303:
0304:                if (TIMER) {
0305:                    timer
0306:                            .timerString("[GenericWebEventProcessor.processEvents] Constructed data matrix");
0307:                }
0308:
0309:                // ---------------------------------------------------------------------------------
0310:                // Process all events before generating the HTML to display the data on the screen.
0311:                // ---------------------------------------------------------------------------------
0312:                // --------
0313:                // INSERT
0314:                // --------
0315:                if (action.equals(uiWebScreenSection.ACTION_INSERT)) {
0316:                    // Insert the new record(s) into the database.
0317:                    int status = this .processInsert(userInfo,
0318:                            uiWebScreenSection, request, response, delegator,
0319:                            eventProcessor, dataMatrix, uiCache);
0320:
0321:                    if (TIMER) {
0322:                        timer
0323:                                .timerString("[GenericWebEventProcessor.processEvents] Finished insert");
0324:                    }
0325:
0326:                    switch (status) {
0327:                    case STATUS_ERROR:
0328:                        return "An error occurred while inserting the new information into the data base.";
0329:
0330:                    case STATUS_CANCEL:
0331:                        return "Insert canceled.";
0332:                    }
0333:
0334:                    // --------
0335:                    // UPDATE
0336:                    // --------
0337:                } else if (action.equals(uiWebScreenSection.ACTION_UPDATE)) {
0338:                    // Update the existing record(s) in the database.
0339:                    int status = this .processUpdate(userInfo,
0340:                            uiWebScreenSection, request, response, delegator,
0341:                            eventProcessor, dataMatrix, uiCache);
0342:
0343:                    if (TIMER) {
0344:                        timer
0345:                                .timerString("[GenericWebEventProcessor.processEvents] Finished update");
0346:                    }
0347:
0348:                    switch (status) {
0349:                    case STATUS_ERROR:
0350:                        return "An error occurred while updating the information in the data base.";
0351:
0352:                    case STATUS_CANCEL:
0353:                        return "Update canceled.";
0354:                    }
0355:
0356:                    // --------
0357:                    // UPDATE_SELECT
0358:                    // --------
0359:                } else if (action
0360:                        .equals(uiWebScreenSection.ACTION_UPDATE_SELECT)) {
0361:                    // Add and/or remove records in a many-to-many table.
0362:                    int status = this .processUpdateSelect(userInfo,
0363:                            uiWebScreenSection, request, response, delegator,
0364:                            eventProcessor);
0365:
0366:                    if (TIMER) {
0367:                        timer
0368:                                .timerString("[GenericWebEventProcessor.processEventsSelect] Finished update");
0369:                    }
0370:
0371:                    switch (status) {
0372:                    case STATUS_ERROR:
0373:                        return "An error occurred while updating the information in the data base.";
0374:
0375:                    case STATUS_CANCEL:
0376:                        return "Update canceled.";
0377:                    }
0378:
0379:                    // --------
0380:                    // DELETE
0381:                    // --------
0382:                } else if (action.equals(uiWebScreenSection.ACTION_DELETE)) {
0383:                    // Delete the current record.
0384:                    int status = this .processDelete(userInfo,
0385:                            uiWebScreenSection, request, response, delegator,
0386:                            eventProcessor, uiCache);
0387:
0388:                    switch (status) {
0389:                    case STATUS_ERROR:
0390:                        return "An error occurred while deleting the information.";
0391:
0392:                    case STATUS_CANCEL:
0393:                        return "Delete canceled.";
0394:                    }
0395:
0396:                    // Create an empty entity so the user can insert a new one.
0397:                    status = this .processCreate(userInfo, uiWebScreenSection,
0398:                            request, response, delegator, eventProcessor,
0399:                            dataMatrix);
0400:
0401:                    switch (status) {
0402:                    case STATUS_ERROR:
0403:                        return "An error occurred while creating an empty data form.";
0404:
0405:                    case STATUS_CANCEL:
0406:                        return "Create canceled.";
0407:                    }
0408:
0409:                    if (TIMER) {
0410:                        timer
0411:                                .timerString("[GenericWebEventProcessor.processEvents] Finished delete");
0412:                    }
0413:
0414:                    // --------
0415:                    // SHOW_INSERT
0416:                    // --------
0417:                } else if (action.equals(uiWebScreenSection.ACTION_SHOW_INSERT)) {
0418:                    // Create an empty entity so the user can insert a new one.
0419:                    int status = this .processCreate(userInfo,
0420:                            uiWebScreenSection, request, response, delegator,
0421:                            eventProcessor, dataMatrix);
0422:
0423:                    switch (status) {
0424:                    case STATUS_ERROR:
0425:                        return "An error occurred while creating an empty data form.";
0426:
0427:                    case STATUS_CANCEL:
0428:                        return "Create canceled.";
0429:                    }
0430:
0431:                    if (TIMER) {
0432:                        timer
0433:                                .timerString("[GenericWebEventProcessor.processEvents] Finished show_insert");
0434:                    }
0435:
0436:                    // --------
0437:                    // SHOW_QUERY or SHOW_QUERY_REPORT
0438:                    // --------
0439:                } else if (action.equals(uiWebScreenSection.ACTION_SHOW_QUERY)
0440:                        || action
0441:                                .equals(uiWebScreenSection.ACTION_SHOW_QUERY_REPORT)) {
0442:                    // Create an empty entity to be displayed for query mode.
0443:                    int status = this .processShowQuery(userInfo,
0444:                            uiWebScreenSection, request, response, delegator,
0445:                            eventProcessor, dataMatrix);
0446:
0447:                    switch (status) {
0448:                    case STATUS_ERROR:
0449:                        return "An error occurred while creating an empty query form.";
0450:
0451:                    case STATUS_CANCEL:
0452:                        return "Create canceled.";
0453:                    }
0454:
0455:                    if (TIMER) {
0456:                        timer
0457:                                .timerString("[GenericWebEventProcessor.processEvents] Finished show_query");
0458:                    }
0459:
0460:                    // --------
0461:                    // SHOW_REPORT
0462:                    // --------
0463:                } else if (action.equals(uiWebScreenSection.ACTION_SHOW_REPORT)) {
0464:                    // Load in the entered query criteria, and re-display them in query mode.
0465:                    int status = this .processShowReport(userInfo,
0466:                            uiWebScreenSection, request, response, delegator,
0467:                            eventProcessor, dataMatrix);
0468:
0469:                    switch (status) {
0470:                    case STATUS_ERROR:
0471:                        return "An error occurred while displaying the report.";
0472:
0473:                    case STATUS_CANCEL:
0474:                        return "Report canceled.";
0475:                    }
0476:
0477:                    if (TIMER) {
0478:                        timer
0479:                                .timerString("[GenericWebEventProcessor.processEvents] Finished show_report");
0480:                    }
0481:
0482:                    // --------
0483:                    // NO ACTION
0484:                    // --------
0485:                } else if (action.equals(uiWebScreenSection.ACTION_NONE)) {
0486:                    // No action was specified.  Allow a blank screen section to be displayed.
0487:                    if (TIMER) {
0488:                        timer
0489:                                .timerString("[GenericWebEventProcessor.processEvents] Finished no_action");
0490:                    }
0491:                }
0492:
0493:                // --------
0494:                // RETRIEVE
0495:                // --------
0496:                if (action.equals(uiWebScreenSection.ACTION_SHOW)
0497:                        || action.equals(uiWebScreenSection.ACTION_SHOW_UPDATE)
0498:                        || action.equals(uiWebScreenSection.ACTION_SHOW_COPY)
0499:                        || action.equals(uiWebScreenSection.ACTION_QUERY)
0500:                        || action
0501:                                .equals(uiWebScreenSection.ACTION_QUERY_UPDATE)
0502:                        || action.equals(uiWebScreenSection.ACTION_QUERY_ALL)
0503:                        || action.equals(uiWebScreenSection.ACTION_SHOW_SELECT)
0504:                        || action
0505:                                .equals(uiWebScreenSection.ACTION_UPDATE_SELECT)) {
0506:                    // Need to retrieve data from the data base.
0507:                    // Note:  ACTION_SHOW_SELECT and ACTION_UPDATE_SELECT are the only two actions that have something happen
0508:                    // in the previous IF statement, and then get retrieved.  In all other actions, the data matrix is either
0509:                    // filled from the HTML, or does not need to be filled.
0510:                    // Determine the retreive method.
0511:                    int retrieveMethod = eventProcessor.RETRIEVE_METHOD_ALL;
0512:
0513:                    switch (uiWebScreenSection.getLayoutTypeId()) {
0514:                    case UIWebScreenSection.LAYOUT_TYPE_FREEFORM:
0515:
0516:                        // Free form section should be retrieved using the primary key.
0517:                        retrieveMethod = eventProcessor.RETRIEVE_METHOD_PK;
0518:
0519:                        break;
0520:
0521:                    case UIWebScreenSection.LAYOUT_TYPE_TABULAR:
0522:
0523:                        // Tabular section can be retrieved multiple ways depending on the action
0524:                        // requested by the button or link that triggered it.
0525:                        if (action.equals(uiWebScreenSection.ACTION_QUERY)
0526:                                || action
0527:                                        .equals(uiWebScreenSection.ACTION_QUERY_UPDATE)) {
0528:                            retrieveMethod = eventProcessor.RETRIEVE_METHOD_CLAUSE;
0529:                        } else if (action
0530:                                .equals(uiWebScreenSection.ACTION_QUERY_ALL)) {
0531:                            retrieveMethod = eventProcessor.RETRIEVE_METHOD_ALL;
0532:                        } else {
0533:                            throw new GenericEntityException(
0534:                                    "Action \""
0535:                                            + action
0536:                                            + "\" is not valid for tabular layout type.");
0537:                        }
0538:
0539:                        break;
0540:
0541:                    case UIWebScreenSection.LAYOUT_TYPE_SELECT:
0542:
0543:                        // A select screen section is always retrieved as a query because it is always subordinate
0544:                        // to some other entity.
0545:                        retrieveMethod = eventProcessor.RETRIEVE_METHOD_CLAUSE;
0546:
0547:                        break;
0548:
0549:                    case UIWebScreenSection.LAYOUT_TYPE_CROSSTAB:
0550:                        throw new GenericEntityException(
0551:                                "Crosstab layout type not implemented yet.");
0552:
0553:                    default:
0554:                        throw new GenericEntityException("Invalid layout type.");
0555:                    }
0556:
0557:                    // handle paging of result sets.
0558:                    int startRow = 0;
0559:                    int rowsPerPage = uiWebScreenSection.getRowsPerPage();
0560:
0561:                    if (request.getParameter("startRow") != null) {
0562:                        startRow = Integer.parseInt(request
0563:                                .getParameter("startRow"));
0564:                    }
0565:
0566:                    uiWebScreenSection.setFirstVisibleRow(startRow);
0567:                    eventProcessor.setRowOffset(startRow);
0568:
0569:                    eventProcessor.setFetchSize(rowsPerPage);
0570:
0571:                    // Retrieve the data for the screen section.
0572:                    Debug
0573:                            .logVerbose(
0574:                                    "About to call GenericWebEventProcessor.processRetrieve.",
0575:                                    module);
0576:
0577:                    StringBuffer queryIdBuffer = new StringBuffer(queryId);
0578:                    int status = this .processRetrieve(userInfo,
0579:                            uiWebScreenSection, retrieveMethod, request,
0580:                            response, delegator, eventProcessor, dataMatrix,
0581:                            queryIdBuffer, action);
0582:                    queryId = queryIdBuffer.toString();
0583:
0584:                    if (eventProcessor.getHasMoreData())
0585:                        uiWebScreenSection.setTotalRows(eventProcessor
0586:                                .getTotalRows() + 1);
0587:                    else
0588:                        uiWebScreenSection.setTotalRows(eventProcessor
0589:                                .getTotalRows());
0590:
0591:                    Debug.logVerbose("queryId after call to processRetrieve: "
0592:                            + queryId, module);
0593:
0594:                    switch (status) {
0595:                    case STATUS_ERROR:
0596:                        return "An error occurred while retrieving the data from the data base.";
0597:
0598:                    case STATUS_CANCEL:
0599:                        return "Retrieve canceled.";
0600:                    }
0601:
0602:                    if (TIMER) {
0603:                        timer
0604:                                .timerString("[GenericWebEventProcessor.processEvents] Finished retrieve");
0605:                    }
0606:                }
0607:
0608:                // --------
0609:                // SHOW_COPY
0610:                // --------
0611:                if (action.equals(uiWebScreenSection.ACTION_SHOW_COPY)) {
0612:                    // Displaying a copy of the retrieved record on the screen.
0613:                    int status = this .processShowCopy(userInfo,
0614:                            uiWebScreenSection, request, response, delegator,
0615:                            eventProcessor, dataMatrix);
0616:
0617:                    if (TIMER) {
0618:                        timer
0619:                                .timerString("[GenericWebEventProcessor.processEvents] Finished showCopy");
0620:                    }
0621:
0622:                    switch (status) {
0623:                    case STATUS_ERROR:
0624:                        return "An error occurred while updating the copied record before displaying it.";
0625:
0626:                    case STATUS_CANCEL:
0627:                        return "Copy canceled.";
0628:                    }
0629:                }
0630:
0631:                // Get values of extra parameters to send to other screen sections when buttons on this screen
0632:                // section are clicked.
0633:                evalSendQueryParameterList(uiWebScreenSection, request,
0634:                        dataMatrix);
0635:
0636:                if (TIMER) {
0637:                    timer
0638:                            .timerString("[GenericWebEventProcessor.processEvents] Evaluated \"send\" query parameter list");
0639:                }
0640:
0641:                // ---------------------------------------------------------------------------------
0642:                // Generate the HTML to display the data on the screen, and return it to the calling method.
0643:                // ---------------------------------------------------------------------------------
0644:                Debug.logVerbose("Data matrix before display: "
0645:                        + dataMatrix.getCurrentBuffer().getContents()
0646:                                .toString(), module);
0647:
0648:                String displayHtml = uiWebScreenSection.display(dataMatrix,
0649:                        action, queryId, isSubsection, tabOffset);
0650:
0651:                if (TIMER) {
0652:                    timer
0653:                            .timerString("[GenericWebEventProcessor.processEvents] End");
0654:                }
0655:
0656:                logUiHistory(action, request, dataMatrix, delegator, userInfo,
0657:                        uiWebScreenSection);
0658:
0659:                return displayHtml;
0660:            }
0661:
0662:            //-------------------------------------------------------------------------
0663:            // RETRIEVE - Retrieves an entity and associated entities from the data base.
0664:            //-------------------------------------------------------------------------
0665:            protected int processRetrieve(UserInfo userInfo,
0666:                    UIWebScreenSection uiWebScreenSection, int retrieveMethod,
0667:                    HttpServletRequest request, HttpServletResponse response,
0668:                    GenericDelegator delegator,
0669:                    GenericEventProcessor eventProcessor,
0670:                    DataMatrix dataMatrix, StringBuffer queryIdBuffer,
0671:                    String action) throws GenericEntityException {
0672:                UtilTimer timer = new UtilTimer();
0673:
0674:                if (TIMER) {
0675:                    timer.timerString(1,
0676:                            "[GenericWebEventProcessor.processRetrieve] Start");
0677:                }
0678:
0679:                int status = STATUS_CONTINUE;
0680:
0681:                String queryId = queryIdBuffer.toString();
0682:
0683:                // Get info about the screen.
0684:                String screenName = uiWebScreenSection.getUiScreen()
0685:                        .getScreenName();
0686:
0687:                // Get info about the screen section.
0688:                String sectionId = uiWebScreenSection.getSectionId();
0689:                String sectionName = uiWebScreenSection.getSectionName();
0690:                int layoutTypeId = uiWebScreenSection.getLayoutTypeId();
0691:
0692:                String primaryEntityName = uiWebScreenSection
0693:                        .getUiScreenSectionEntity(0).getUiEntity()
0694:                        .getEntityName();
0695:
0696:                Debug.logVerbose("Primary entity name: " + primaryEntityName,
0697:                        module);
0698:
0699:                ModelEntity primaryME = uiWebScreenSection
0700:                        .getUiScreenSectionEntity(0).getUiEntity()
0701:                        .getModelEntity();
0702:                List primaryPkFieldNames = uiWebScreenSection
0703:                        .getUiScreenSectionEntity(0).getUiEntity()
0704:                        .getPrimaryKeyFieldNames();
0705:
0706:                // Specify how the primary entity will be retrieved.
0707:                HashMap fields = new HashMap();
0708:                ArrayList orderBy = new ArrayList();
0709:                QueryInfo queryInfo = new QueryInfo(delegator,
0710:                        primaryEntityName);
0711:                Enumeration params = null;
0712:                String searchAttribValue = "";
0713:                String searchEntityName = "";
0714:                String searchAttribName = "";
0715:                String queryName = "";
0716:                String listName = "";
0717:                EntityComparisonOperator entityOperator = null;
0718:                List relatedSearchClauses = new LinkedList();
0719:                List selectFields = new ArrayList();
0720:
0721:                // Note that we only care about primary entity fields in the select at the moment.
0722:                // TODO:  change the queries so that all related data is retrieved as part of the main retrieve
0723:                //        which it is, but the original code was written before dynamicViewEntities were added
0724:                int selectFieldListSize = uiWebScreenSection.getUiFieldList()
0725:                        .size();
0726:                for (int fieldNbr = 0; fieldNbr < selectFieldListSize; fieldNbr++) {
0727:                    UIFieldInfo fieldInfo = uiWebScreenSection
0728:                            .getUiField(fieldNbr);
0729:                    String fieldName = fieldInfo.getUiAttribute()
0730:                            .getAttributeName();
0731:                    String entityName = fieldInfo.getUiAttribute()
0732:                            .getUiEntity().getEntityName();
0733:                    if (entityName.equals(primaryEntityName))
0734:                        selectFields.add(fieldName);
0735:
0736:                    /*			if ( fieldInfo.getIsVisible() )
0737:                     {
0738:                     String fieldName = fieldInfo.getUiAttribute().getAttributeName();
0739:                     String entityName = fieldInfo.getUiAttribute().getUiEntity().getEntityName();
0740:                     String aliasName = fieldName;
0741:                     if ( ! entityName.equals(primaryEntityName))
0742:                     aliasName = entityName + "." + fieldName;
0743:                     selectFields.add(aliasName);
0744:                     }
0745:                     */
0746:                }
0747:                queryInfo.setSelectFields(selectFields);
0748:
0749:                if (request.getParameter("queryName") != null) {
0750:                    queryName = request.getParameter("queryName");
0751:                }
0752:
0753:                if (request.getParameter("listName") != null) {
0754:                    listName = request.getParameter("listName");
0755:                    if (queryName.length() < 1)
0756:                        queryName = listName;
0757:                }
0758:
0759:                //		HashMap querySaveMap = new HashMap();
0760:                UIQuery uiQuery = null;
0761:
0762:                // Specify how associated entities will be retrieved.
0763:                Iterator uiScreenSectionEntityI = uiWebScreenSection
0764:                        .getUiScreenSectionEntityList().iterator();
0765:                uiScreenSectionEntityI.next(); // Pass up the primary entity.
0766:
0767:                while (uiScreenSectionEntityI.hasNext()) {
0768:                    UIScreenSectionEntity uiScreenSectionEntity = (UIScreenSectionEntity) uiScreenSectionEntityI
0769:                            .next();
0770:
0771:                    relatedSearchClauses.add(uiScreenSectionEntity);
0772:                }
0773:
0774:                uiScreenSectionEntityI = null; // Reset the iterator.
0775:
0776:                switch (retrieveMethod) {
0777:                case GenericEventProcessor.RETRIEVE_METHOD_ALL:
0778:
0779:                    // Find all entities of this type.
0780:                    // Don't need to populate the fields map.
0781:                    break;
0782:
0783:                case GenericEventProcessor.RETRIEVE_METHOD_AND:
0784:
0785:                    // Find the main entity(ies) by building a WHERE clause using "=" and AND.
0786:                    throw new GenericEntityException(
0787:                            "RETRIEVE_METHOD_AND not implemented yet.");
0788:
0789:                case GenericEventProcessor.RETRIEVE_METHOD_CLAUSE:
0790:
0791:                    if (TIMER) {
0792:                        timer
0793:                                .timerString(1,
0794:                                        "[GenericWebEventProcessor.processRetrieve] Start RETRIEVE_METHOD_CLAUSE");
0795:                    }
0796:
0797:                    HashMap joinedEntities = new HashMap();
0798:
0799:                    joinedEntities.put(primaryEntityName, "Y");
0800:
0801:                    // Find the main entity(ies) by building a WHERE clause using LIKE and AND, with one or more tables in the FROM clause.
0802:                    // First join all secondary screen section entities in the WHERE and FROM clauses in case
0803:                    // we are going to use query values from them.
0804:                    Iterator relatedClauseI = relatedSearchClauses.iterator();
0805:
0806:                    while (relatedClauseI.hasNext()) {
0807:                        UIScreenSectionEntity uiScreenSectionEntity = (UIScreenSectionEntity) relatedClauseI
0808:                                .next();
0809:                        String relationTitle = uiScreenSectionEntity
0810:                                .getRelationTitle();
0811:                        String relatedEntityName = uiScreenSectionEntity
0812:                                .getUiEntity().getEntityName();
0813:                        boolean isOuterJoin = uiScreenSectionEntity
0814:                                .getIsOuterJoined();
0815:                        String relatedAndFields = uiScreenSectionEntity
0816:                                .getRelationByAndFields();
0817:
0818:                        Debug.logVerbose("Adding relation clauses for "
0819:                                + relationTitle + "/" + relatedEntityName,
0820:                                module);
0821:
0822:                        eventProcessor.addOneRelationClause(delegator,
0823:                                relationTitle, relatedAndFields,
0824:                                relatedEntityName, primaryEntityName,
0825:                                primaryME, isOuterJoin, queryInfo);
0826:
0827:                        joinedEntities.put(relatedEntityName, "Y");
0828:                    }
0829:
0830:                    Debug.logVerbose(
0831:                            "queryId at beginning of RETRIEVE_METHOD_CLAUSE section: "
0832:                                    + queryId, module);
0833:
0834:                    if (queryId.equalsIgnoreCase("NONE")) {
0835:                        // Don't retrieve any data. The calling link specified to use the last query, but there wasn't one.
0836:                        return STATUS_CONTINUE;
0837:                    } else if (!queryId.equals("")) {
0838:                        // User selected a saved query.  Get it from the data base.
0839:                        uiQuery = new UIQuery(queryId, delegator);
0840:
0841:                        if (!uiQuery.getQueryId().equals("")) {
0842:                            // Query was found.
0843:                            uiQuery.appendEntityClauses(delegator, queryInfo);
0844:
0845:                            //						// Store the attribute ID and value in the query save map.
0846:                            //						querySaveMap.put(attributeId, searchAttribValue);
0847:                        }
0848:
0849:                        // add extra clauses from the hidden query parameters in case this is a detail screen
0850:                        addUseQueryParameterClauses(uiWebScreenSection,
0851:                                queryInfo, relatedSearchClauses,
0852:                                primaryEntityName, request);
0853:                    } else {
0854:                        // Brand new query. Process all the parameters coming in through the request object to get the values to search by.
0855:                        uiQuery = new UIQuery();
0856:
0857:                        String queryListMaxRows = request
0858:                                .getParameter("queryListMaxRows");
0859:                        // if queryListMaxRows is set, then we are using advanced query mode
0860:                        if ((queryListMaxRows != null)
0861:                                && (queryListMaxRows.length() > 0)) {
0862:                            int maxRows = Integer.valueOf(queryListMaxRows)
0863:                                    .intValue();
0864:                            for (int i = 1; i <= maxRows; i++) {
0865:                                String qlFieldInfo = request
0866:                                        .getParameter("queryListField" + i);
0867:                                if ((qlFieldInfo != null)
0868:                                        && (qlFieldInfo.length() > 0)) {
0869:                                    StringTokenizer tokSemi = new StringTokenizer(
0870:                                            qlFieldInfo, ";");
0871:                                    String qlFieldName = "";
0872:                                    String qlAttributeId = "";
0873:                                    String qlDisplayObjectId = "";
0874:                                    String qlDisplayTypeId = "";
0875:
0876:                                    if (tokSemi.countTokens() == 4) {
0877:                                        qlFieldName = tokSemi.nextToken();
0878:                                        qlAttributeId = tokSemi.nextToken();
0879:                                        qlDisplayTypeId = tokSemi.nextToken();
0880:                                        qlDisplayObjectId = tokSemi.nextToken();
0881:                                    } else {
0882:                                        qlFieldName = qlFieldInfo;
0883:                                    }
0884:
0885:                                    String qlOperator = request
0886:                                            .getParameter("queryListOperator"
0887:                                                    + i);
0888:                                    String qlValue = request
0889:                                            .getParameter("queryListValue" + i);
0890:
0891:                                    if (qlOperator.equals("like"))
0892:                                        qlValue = "%"
0893:                                                + qlValue.replace('*', '%')
0894:                                                + "%";
0895:                                    else if (qlOperator.equals("startsWith")) {
0896:                                        qlValue = qlValue.replace('*', '%')
0897:                                                + "%";
0898:                                        qlOperator = "like";
0899:                                    } else if (qlOperator.equals("endsWith")) {
0900:                                        qlValue = "%"
0901:                                                + qlValue.replace('*', '%');
0902:                                        qlOperator = "like";
0903:                                    }
0904:
0905:                                    searchEntityName = UIWebUtility
0906:                                            .getEntityFromParamName(qlFieldName);
0907:
0908:                                    String hasJoin = (String) joinedEntities
0909:                                            .get(searchEntityName);
0910:
0911:                                    if ((hasJoin == null)
0912:                                            || (!hasJoin.equals("Y"))) {
0913:                                        eventProcessor.addOneRelationClause(
0914:                                                delegator, "", "",
0915:                                                searchEntityName,
0916:                                                primaryEntityName, primaryME,
0917:                                                false, queryInfo);
0918:
0919:                                        joinedEntities.put(searchEntityName,
0920:                                                "Y");
0921:                                    }
0922:
0923:                                    if ((searchEntityName == null)
0924:                                            || searchEntityName.equals("")) {
0925:                                        searchEntityName = primaryEntityName;
0926:                                    }
0927:
0928:                                    searchAttribName = UIWebUtility
0929:                                            .getAttribFromParamName(qlFieldName);
0930:                                    entityOperator = EntityOperator
0931:                                            .lookupComparison(qlOperator);
0932:                                    Object searchValue = qlValue;
0933:
0934:                                    // If this is a set operator, convert the String param into a comma separated List 
0935:                                    if ((entityOperator
0936:                                            .equals(EntityOperator.IN))
0937:                                            || (entityOperator
0938:                                                    .equals(EntityOperator.NOT_IN))
0939:                                            || (entityOperator
0940:                                                    .equals(EntityOperator.BETWEEN))) {
0941:                                        List valueList = new ArrayList();
0942:                                        StringTokenizer tokComma = new StringTokenizer(
0943:                                                qlValue, ",");
0944:
0945:                                        while (tokComma.hasMoreTokens()) {
0946:                                            String valueItem = tokComma
0947:                                                    .nextToken();
0948:                                            valueList.add(valueItem);
0949:                                        }
0950:                                        searchValue = valueList;
0951:                                    }
0952:
0953:                                    try {
0954:                                        // Figure out the attribute ID for the UiAttribute this parameter corresponds to so we can
0955:                                        // save the query.
0956:                                        String attributeId = UIWebUtility
0957:                                                .getAttributeId(delegator,
0958:                                                        searchAttribName,
0959:                                                        searchEntityName);
0960:
0961:                                        // Generate an entry in the WHERE clause for this attribute.  The entityOperator
0962:                                        // is returned in case appendEntityClause changes it.
0963:                                        // NOTE:  changes here must also be applied to UIQuery.appendEntityClauses() to work with saved queries
0964:                                        //
0965:                                        if (qlDisplayTypeId
0966:                                                .equals(UIDisplayObject.DISPLAY_TYPE_SELECT)
0967:                                                || qlDisplayTypeId
0968:                                                        .equals(UIDisplayObject.DISPLAY_TYPE_SEARCH_TEXT)) {
0969:                                            String aliasName = searchEntityName
0970:                                                    + searchAttribName + "srch";
0971:                                            UIUtility.addSelectSearch(
0972:                                                    queryInfo,
0973:                                                    qlDisplayObjectId,
0974:                                                    searchEntityName,
0975:                                                    searchAttribName,
0976:                                                    aliasName, entityOperator,
0977:                                                    searchValue);
0978:                                        } else {
0979:                                            if (searchValue instanceof  String) {
0980:                                                entityOperator = EventUtility
0981:                                                        .appendEntityClause(
0982:                                                                searchEntityName,
0983:                                                                searchAttribName,
0984:                                                                (String) searchValue,
0985:                                                                entityOperator,
0986:                                                                queryInfo);
0987:                                            } else if (searchValue instanceof  Collection) {
0988:                                                entityOperator = EventUtility
0989:                                                        .appendEntityClause(
0990:                                                                searchEntityName,
0991:                                                                searchAttribName,
0992:                                                                (Collection) searchValue,
0993:                                                                entityOperator,
0994:                                                                queryInfo);
0995:                                            } else
0996:                                                throw new IllegalArgumentException(
0997:                                                        "Query Param must be String or Collection");
0998:                                        }
0999:
1000:                                        // Store the attribute ID and value in the query save map.
1001:                                        //									querySaveMap.put(attributeId, searchAttribValue);
1002:                                        uiQuery.addUiQueryValue(attributeId,
1003:                                                entityOperator, qlValue,
1004:                                                qlDisplayTypeId,
1005:                                                qlDisplayObjectId, delegator);
1006:                                    } catch (GenericEntityException e) {
1007:                                        //this parameter was not associated with a column in a table, so skip it
1008:                                        Debug.logVerbose(
1009:                                                "skipping parameter which is not an entity attribute: "
1010:                                                        + qlFieldName, module);
1011:                                    }
1012:
1013:                                }
1014:                            }
1015:                        } else {
1016:
1017:                            params = request.getParameterNames();
1018:
1019:                            while (params.hasMoreElements()) {
1020:                                String paramName = (String) params
1021:                                        .nextElement();
1022:
1023:                                //						boolean useSentQueryParameter =
1024:                                //							!action.equals(uiWebScreenSection.ACTION_QUERY_UPDATE &&
1025:                                //							!action.equals(uiWebScreenSection.ACTION_QUERY &&
1026:                                //							uiWebScreenSection.getUseQueryParameterMap().containsValue(paramName);
1027:                                Debug.logVerbose("paramName: " + paramName,
1028:                                        module);
1029:                                Debug.logVerbose("action: " + action, module);
1030:                                Debug
1031:                                        .logVerbose(
1032:                                                "uiWebScreenSection.getUseQueryParameterMap().containsValue(paramName): "
1033:                                                        + String
1034:                                                                .valueOf(uiWebScreenSection
1035:                                                                        .getUseQueryParameterMap()
1036:                                                                        .containsValue(
1037:                                                                                paramName)),
1038:                                                module);
1039:
1040:                                if (UIWebUtility
1041:                                        .checkReservedParameterName(paramName)) {
1042:                                    //								(	action.equals(uiWebScreenSection.ACTION_QUERY_UPDATE) || action.equals(uiWebScreenSection.ACTION_QUERY))
1043:                                    //							) {
1044:                                    // This is a value being passed in from the prior screen in query mode.  Use it to search.
1045:                                    if (paramName.equals("nameToSearch")) {
1046:                                        // Alpha search using alphabet buttons.
1047:                                        HashMap alphaSearchValues = EventUtility
1048:                                                .getAlphaSearchValues(
1049:                                                        delegator,
1050:                                                        uiWebScreenSection,
1051:                                                        request
1052:                                                                .getParameter("nameToSearch"));
1053:                                        searchEntityName = (String) alphaSearchValues
1054:                                                .get("searchEntityName");
1055:                                        searchAttribName = (String) alphaSearchValues
1056:                                                .get("searchAttribName");
1057:                                        searchAttribValue = (String) alphaSearchValues
1058:                                                .get("searchAttribValue");
1059:                                        entityOperator = null;
1060:                                    } else {
1061:                                        // Regular search attribute in query mode.
1062:                                        searchEntityName = UIWebUtility
1063:                                                .getEntityFromParamName(paramName);
1064:
1065:                                        if ((searchEntityName == null)
1066:                                                || searchEntityName.equals("")) {
1067:                                            searchEntityName = primaryEntityName;
1068:                                        }
1069:
1070:                                        searchAttribName = UIWebUtility
1071:                                                .getAttribFromParamName(paramName);
1072:
1073:                                        String[] searchAttribValueArray = request
1074:                                                .getParameterValues(paramName);
1075:
1076:                                        Debug
1077:                                                .logVerbose(
1078:                                                        "Number of values for query attribute "
1079:                                                                + paramName
1080:                                                                + ": "
1081:                                                                + String
1082:                                                                        .valueOf(searchAttribValueArray.length),
1083:                                                        module);
1084:
1085:                                        searchAttribValue = getRequestParameterValue(
1086:                                                paramName,
1087:                                                searchAttribValueArray);
1088:
1089:                                        //  Determine the entity search operator to use.  If multiple, use IN
1090:                                        if ((null != searchAttribValue)
1091:                                                && (searchAttribValueArray.length > 1)) {
1092:                                            entityOperator = EntityOperator.IN;
1093:                                        } else {
1094:                                            entityOperator = null;
1095:                                        }
1096:
1097:                                        Debug.logVerbose("searchEntityName: "
1098:                                                + searchEntityName, module);
1099:                                        Debug.logVerbose("searchAttribName: "
1100:                                                + searchAttribName, module);
1101:                                        Debug.logVerbose("searchAttribValue: "
1102:                                                + searchAttribValue, module);
1103:                                    }
1104:
1105:                                    if ((searchAttribValue != null)
1106:                                            && !searchAttribValue.equals("")) {
1107:                                        try {
1108:                                            // Figure out the attribute ID for the UiAttribute this parameter corresponds to so we can
1109:                                            // save the query.
1110:                                            String attributeId = UIWebUtility
1111:                                                    .getAttributeId(delegator,
1112:                                                            searchAttribName,
1113:                                                            searchEntityName);
1114:
1115:                                            // Generate an entry in the WHERE clause for this attribute.  The entityOperator
1116:                                            // is returned in case appendEntityClause changes it.
1117:                                            entityOperator = EventUtility
1118:                                                    .appendEntityClause(
1119:                                                            searchEntityName,
1120:                                                            searchAttribName,
1121:                                                            searchAttribValue,
1122:                                                            entityOperator,
1123:                                                            queryInfo);
1124:
1125:                                            // Store the attribute ID and value in the query save map.
1126:                                            //									querySaveMap.put(attributeId, searchAttribValue);
1127:                                            uiQuery.addUiQueryValue(
1128:                                                    attributeId,
1129:                                                    entityOperator,
1130:                                                    searchAttribValue, "", "",
1131:                                                    delegator);
1132:                                        } catch (GenericEntityException e) {
1133:                                            //this parameter was not associated with a column in a table, so skip it
1134:                                            Debug
1135:                                                    .logVerbose(
1136:                                                            "skipping parameter which is not an entity attribute: "
1137:                                                                    + paramName,
1138:                                                            module);
1139:                                        }
1140:                                    }
1141:                                }
1142:                            }
1143:                        }
1144:                        // add extra clauses from the hidden query parameters in case this is a detail screen
1145:                        addUseQueryParameterClauses(uiWebScreenSection,
1146:                                queryInfo, relatedSearchClauses,
1147:                                primaryEntityName, request);
1148:                    }
1149:
1150:                    // Save the Query
1151:                    if (!queryName.equals("")) {
1152:                        // User entered a name for the query. Save it with the given name.
1153:                        // Change the party ID to the current user's party ID, and the section ID to the current section ID
1154:                        // in case either of these was -1 (wildcard).
1155:                        uiQuery.setSectionId(uiWebScreenSection.getSectionId());
1156:                        uiQuery.setPartyId(userInfo.getPartyId());
1157:                        uiQuery.setQueryName(queryName);
1158:                        queryId = uiQuery.save(delegator);
1159:
1160:                        //			queryId = UIQuery.saveUiQuery(delegator, userInfo.getPartyId(), sectionId, queryName, querySaveMap);
1161:                        Debug.logVerbose("queryId after saving query \""
1162:                                + queryName + "\": " + queryId, module);
1163:
1164:                        if (TIMER) {
1165:                            timer
1166:                                    .timerString(1,
1167:                                            "[GenericWebEventProcessor.processRetrieve] Saved query");
1168:                        }
1169:                    }
1170:
1171:                    if (listName.length() > 0) {
1172:                        // save the UiList info
1173:                        List uiListGVL = delegator.findByAnd("UiList", UtilMisc
1174:                                .toMap("listName", listName, "partyId",
1175:                                        userInfo.getAccountId()), null);
1176:                        GenericValue uiListGV = null;
1177:                        if (uiListGVL.size() > 0) {
1178:                            uiListGV = (GenericValue) uiListGVL.get(0);
1179:                            delegator.removeByAnd("UiListItem", UtilMisc.toMap(
1180:                                    "listId", uiListGV.getString("listId")));
1181:                        } else {
1182:                            uiListGV = new GenericValue(delegator
1183:                                    .getModelEntity("UiList"));
1184:                            String listId = GenericReplicator.getNextSeqId(
1185:                                    "UiList", delegator);
1186:                            uiListGV.set("listId", listId);
1187:                        }
1188:                        String listId = uiListGV.getString("listId");
1189:                        uiListGV.setDelegator(delegator);
1190:
1191:                        uiListGV.set("listName", listName);
1192:                        uiListGV.set("partyId", userInfo.getAccountId());
1193:                        uiListGV.set("queryId", queryId);
1194:                        uiListGV.set("sectionId", sectionId);
1195:                        uiListGV.set("listType", primaryEntityName);
1196:
1197:                        delegator.createOrStore(uiListGV);
1198:
1199:                        queryInfo.setSaveResultListId(listId);
1200:                    }
1201:
1202:                    // Save the query as the last query.  First make a new UIQuery using the same values as the original query.
1203:                    // Change the party ID to the current user's party ID, and the section ID to the current section ID
1204:                    // in case either of these was -1 (wildcard).
1205:                    //		UIQuery.saveUiQuery(delegator, userInfo.getPartyId(), sectionId, UIQuery.LAST_QUERY_NAME, querySaveMap);
1206:                    UIQuery uiQueryLast = new UIQuery("", uiWebScreenSection
1207:                            .getSectionId(), userInfo.getPartyId(),
1208:                            UIQuery.LAST_QUERY_NAME, uiQuery
1209:                                    .getUiQueryValueList());
1210:                    String lastQueryId = uiQueryLast.save(delegator);
1211:
1212:                    // if the query was not saved, set the queryId to be returned to lastQueryId so that the query parameters 
1213:                    // can be used when displaying the page (Primarily to set the params on the next and previous buttons for multi-page datasets
1214:                    if (queryId == null || queryId.equals(""))
1215:                        queryId = lastQueryId;
1216:
1217:                    Debug.logVerbose("Saved query as last query. Id="
1218:                            + lastQueryId + ", returning queryId=" + queryId,
1219:                            module);
1220:
1221:                    if (TIMER) {
1222:                        timer
1223:                                .timerString(1,
1224:                                        "[GenericWebEventProcessor.processRetrieve] End RETRIEVE_METHOD_CLAUSE");
1225:                    }
1226:
1227:                    break;
1228:
1229:                case GenericEventProcessor.RETRIEVE_METHOD_LIKE:
1230:
1231:                    // Find the main entity(ies) using findByLike.
1232:                    // Process all the parameters coming into through the request object to get the values to search by.
1233:                    params = request.getParameterNames();
1234:
1235:                    while (params.hasMoreElements()) {
1236:                        String paramName = (String) params.nextElement();
1237:
1238:                        if (UIWebUtility.checkReservedParameterName(paramName)) {
1239:                            // This is a value being passed in from the prior screen.  Use it to search.
1240:
1241:                            /*                                                if (paramName.equals("nameToSearch")) {
1242:                                                                                    // Alpha search using alphabet buttons.
1243:                                                                                    HashMap alphaSearchValues = EventUtility.getAlphaSearchValues(
1244:                                                                                            delegator,
1245:                                                                                            uiScreenSectionGV,
1246:                                                                                            request.getParameter("nameToSearch"));
1247:                                                                                    searchEntityName = (String)alphaSearchValues.get("searchEntityName");
1248:                                                                                    searchAttribName = (String)alphaSearchValues.get("searchAttribName");
1249:                                                                                    searchAttribValue = (String)alphaSearchValues.get("searchAttribValue");
1250:                                                                            } else { */
1251:
1252:                            // Regular search attribute.
1253:                            searchEntityName = UIWebUtility
1254:                                    .getEntityFromParamName(paramName);
1255:                            searchAttribName = UIWebUtility
1256:                                    .getAttribFromParamName(paramName);
1257:                            searchAttribValue = request.getParameter(paramName)
1258:                                    .replace('*', '%')
1259:                                    + "%";
1260:
1261:                            /*                                                } */
1262:                            if ((searchEntityName != null)
1263:                                    && !searchEntityName.equals("")
1264:                                    && !searchEntityName
1265:                                            .equals(primaryEntityName)) {
1266:                                throw new GenericEntityException(
1267:                                        "Cannot do a LIKE search using a value from a related entity. Values must be from the primary entity.");
1268:                            }
1269:
1270:                            fields.put(searchAttribName, searchAttribValue);
1271:                        }
1272:                    }
1273:
1274:                    break;
1275:
1276:                case GenericEventProcessor.RETRIEVE_METHOD_PK:
1277:
1278:                    if (TIMER) {
1279:                        timer
1280:                                .timerString(1,
1281:                                        "[GenericWebEventProcessor.processRetrieve] Start RETRIEVE_METHOD_PK");
1282:                    }
1283:
1284:                    // Get one main entity using the primary key.
1285:                    Iterator primaryPkFieldNameI = primaryPkFieldNames
1286:                            .iterator();
1287:
1288:                    while (primaryPkFieldNameI.hasNext()) {
1289:                        String primaryPkFieldName = (String) primaryPkFieldNameI
1290:                                .next();
1291:                        String primaryPkFieldValue = "";
1292:
1293:                        if (request.getParameter(primaryPkFieldName) != null) {
1294:                            primaryPkFieldValue = request
1295:                                    .getParameter(primaryPkFieldName);
1296:                        } else if (request.getParameter(primaryEntityName + "_"
1297:                                + primaryPkFieldName) != null) {
1298:                            primaryPkFieldValue = request
1299:                                    .getParameter(primaryEntityName + "_"
1300:                                            + primaryPkFieldName);
1301:                        }
1302:
1303:                        fields.put(primaryPkFieldName, primaryPkFieldValue);
1304:                    }
1305:
1306:                    if (TIMER) {
1307:                        timer
1308:                                .timerString(1,
1309:                                        "[GenericWebEventProcessor.processRetrieve] End RETRIEVE_METHOD_PK");
1310:                    }
1311:
1312:                    break;
1313:
1314:                default:
1315:                    throw new GenericEntityException("Invalid retrieve method.");
1316:
1317:                    //				break;
1318:                }
1319:
1320:                // Specify the sort order.
1321:                orderBy = new DelimitedValueDecoder(uiWebScreenSection
1322:                        .getSortDef()).decode();
1323:
1324:                Debug.logVerbose("orderBy: " + orderBy.toString(), module);
1325:
1326:                if (TIMER) {
1327:                    timer
1328:                            .timerString(1,
1329:                                    "[GenericWebEventProcessor.processRetrieve] Specified retrieve info");
1330:                }
1331:
1332:                // Trigger the pre-retrieve event.
1333:                status = this .preRetrieve(userInfo, uiWebScreenSection,
1334:                        request, response, delegator, eventProcessor,
1335:                        dataMatrix, primaryEntityName, retrieveMethod, fields,
1336:                        orderBy, queryInfo, relatedSearchClauses, queryId);
1337:
1338:                if (status != STATUS_CONTINUE) {
1339:                    return status;
1340:                }
1341:
1342:                // Trigger the retrieve event.
1343:                status = this .retrieve(userInfo, uiWebScreenSection, request,
1344:                        response, delegator, eventProcessor, dataMatrix,
1345:                        primaryEntityName, retrieveMethod, fields, orderBy,
1346:                        queryInfo, relatedSearchClauses, queryId);
1347:
1348:                if (status != STATUS_CONTINUE) {
1349:                    return status;
1350:                }
1351:
1352:                // Trigger the post-retrieve event.
1353:                status = this .postRetrieve(userInfo, uiWebScreenSection,
1354:                        request, response, delegator, eventProcessor,
1355:                        dataMatrix, primaryEntityName, retrieveMethod, fields,
1356:                        orderBy, queryInfo, relatedSearchClauses, queryId);
1357:
1358:                Debug.logVerbose(
1359:                        "queryId before returning from processRetrieve: "
1360:                                + queryId, module);
1361:
1362:                queryIdBuffer.delete(0, queryIdBuffer.length());
1363:                queryIdBuffer.append(queryId);
1364:
1365:                if (TIMER) {
1366:                    timer.timerString(1,
1367:                            "[GenericWebEventProcessor.processRetrieve] End");
1368:                }
1369:
1370:                return status;
1371:            }
1372:
1373:            /**
1374:             * DOCUMENT ME!
1375:             *
1376:             * @param userInfo 
1377:             * @param uiWebScreenSection 
1378:             * @param request 
1379:             * @param response 
1380:             * @param delegator 
1381:             * @param eventProcessor 
1382:             * @param dataMatrix 
1383:             * @param primaryEntityName 
1384:             * @param retrieveMethod 
1385:             * @param fields 
1386:             * @param orderBy 
1387:             * @param queryInfo  criteria to be used in search 
1388:             * @param relatedSearchClauses 
1389:             * @param queryId 
1390:             *
1391:             * @return 
1392:             */
1393:            protected int preRetrieve(UserInfo userInfo,
1394:                    UIWebScreenSection uiWebScreenSection,
1395:                    HttpServletRequest request, HttpServletResponse response,
1396:                    GenericDelegator delegator,
1397:                    GenericEventProcessor eventProcessor,
1398:                    DataMatrix dataMatrix, String primaryEntityName,
1399:                    int retrieveMethod, HashMap fields, ArrayList orderBy,
1400:                    QueryInfo queryInfo, List relatedSearchClauses,
1401:                    String queryId) {
1402:                return STATUS_CONTINUE;
1403:            }
1404:
1405:            /**
1406:             * DOCUMENT ME!
1407:             *
1408:             * @param userInfo 
1409:             * @param uiWebScreenSection 
1410:             * @param request 
1411:             * @param response 
1412:             * @param delegator 
1413:             * @param eventProcessor 
1414:             * @param dataMatrix 
1415:             * @param primaryEntityName 
1416:             * @param retrieveMethod 
1417:             * @param fields 
1418:             * @param orderBy 
1419:             * @param queryInfo  criteria to be used in search 
1420:             * @param relatedSearchClauses 
1421:             * @param queryId 
1422:             *
1423:             * @return 
1424:             *
1425:             * @throws GenericEntityException 
1426:             */
1427:            protected int retrieve(UserInfo userInfo,
1428:                    UIWebScreenSection uiWebScreenSection,
1429:                    HttpServletRequest request, HttpServletResponse response,
1430:                    GenericDelegator delegator,
1431:                    GenericEventProcessor eventProcessor,
1432:                    DataMatrix dataMatrix, String primaryEntityName,
1433:                    int retrieveMethod, HashMap fields, ArrayList orderBy,
1434:                    QueryInfo queryInfo, List relatedSearchClauses,
1435:                    String queryId) throws GenericEntityException {
1436:
1437:                return eventProcessor.processRetrieve(userInfo,
1438:                        primaryEntityName, retrieveMethod, fields, orderBy,
1439:                        queryInfo, relatedSearchClauses, delegator, dataMatrix);
1440:            }
1441:
1442:            /**
1443:             * DOCUMENT ME!
1444:             *
1445:             * @param userInfo 
1446:             * @param uiWebScreenSection 
1447:             * @param request 
1448:             * @param response 
1449:             * @param delegator 
1450:             * @param eventProcessor 
1451:             * @param dataMatrix 
1452:             * @param primaryEntityName 
1453:             * @param retrieveMethod 
1454:             * @param fields 
1455:             * @param orderBy 
1456:             * @param queryInfo  criteria to be used in search 
1457:             * @param relatedSearchClauses 
1458:             * @param queryId 
1459:             *
1460:             * @return 
1461:             */
1462:            protected int postRetrieve(UserInfo userInfo,
1463:                    UIWebScreenSection uiWebScreenSection,
1464:                    HttpServletRequest request, HttpServletResponse response,
1465:                    GenericDelegator delegator,
1466:                    GenericEventProcessor eventProcessor,
1467:                    DataMatrix dataMatrix, String primaryEntityName,
1468:                    int retrieveMethod, HashMap fields, ArrayList orderBy,
1469:                    QueryInfo queryInfo, List relatedSearchClauses,
1470:                    String queryId) {
1471:                return STATUS_CONTINUE;
1472:            }
1473:
1474:            //-------------------------------------------------------------------------
1475:            // UPDATE - Updates a set of entities in the data base.
1476:            //-------------------------------------------------------------------------
1477:            protected int processUpdate(UserInfo userInfo,
1478:                    UIWebScreenSection uiWebScreenSection,
1479:                    HttpServletRequest request, HttpServletResponse response,
1480:                    GenericDelegator delegator,
1481:                    GenericEventProcessor eventProcessor,
1482:                    DataMatrix dataMatrix, UICache uiCache)
1483:                    throws GenericEntityException {
1484:                UtilTimer timer = new UtilTimer();
1485:
1486:                if (TIMER) {
1487:                    timer.timerString(1,
1488:                            "[GenericWebEventProcessor.processUpdate] Start");
1489:                }
1490:
1491:                int status = STATUS_CONTINUE;
1492:
1493:                // Pre fill the data matrix from the info entered on the screen.
1494:                dataMatrix.fillFromHtml(request, uiWebScreenSection);
1495:
1496:                if (TIMER) {
1497:                    timer
1498:                            .timerString(1,
1499:                                    "[GenericWebEventProcessor.processUpdate] Filled data matrix");
1500:                }
1501:
1502:                // Trigger the pre-update event.
1503:                status = this .preUpdate(userInfo, uiWebScreenSection, request,
1504:                        response, delegator, eventProcessor, dataMatrix,
1505:                        uiCache);
1506:
1507:                if (status != STATUS_CONTINUE) {
1508:                    return status;
1509:                }
1510:
1511:                if (TIMER) {
1512:                    timer
1513:                            .timerString(1,
1514:                                    "[GenericWebEventProcessor.processUpdate] Preupdate finished");
1515:                }
1516:
1517:                // Trigger the update event.
1518:                status = this .update(userInfo, uiWebScreenSection, request,
1519:                        response, delegator, eventProcessor, dataMatrix,
1520:                        uiCache);
1521:
1522:                if (status != STATUS_CONTINUE) {
1523:                    return status;
1524:                }
1525:
1526:                if (TIMER) {
1527:                    timer
1528:                            .timerString(1,
1529:                                    "[GenericWebEventProcessor.processUpdate] Update finished");
1530:                }
1531:
1532:                // Trigger the post-update event.
1533:                status = this .postUpdate(userInfo, uiWebScreenSection, request,
1534:                        response, delegator, eventProcessor, dataMatrix,
1535:                        uiCache);
1536:
1537:                if (TIMER) {
1538:                    timer
1539:                            .timerString(1,
1540:                                    "[GenericWebEventProcessor.processUpdate] Postupdate finished");
1541:                }
1542:
1543:                return status;
1544:            }
1545:
1546:            /**
1547:             * DOCUMENT ME!
1548:             *
1549:             * @param userInfo 
1550:             * @param uiWebScreenSection 
1551:             * @param request 
1552:             * @param response 
1553:             * @param delegator 
1554:             * @param eventProcessor 
1555:             * @param dataMatrix 
1556:             * @param uiCache 
1557:             *
1558:             * @return 
1559:             */
1560:            protected int preUpdate(UserInfo userInfo,
1561:                    UIWebScreenSection uiWebScreenSection,
1562:                    HttpServletRequest request, HttpServletResponse response,
1563:                    GenericDelegator delegator,
1564:                    GenericEventProcessor eventProcessor,
1565:                    DataMatrix dataMatrix, UICache uiCache) {
1566:
1567:                return STATUS_CONTINUE;
1568:            }
1569:
1570:            /**
1571:             * DOCUMENT ME!
1572:             *
1573:             * @param userInfo 
1574:             * @param uiWebScreenSection 
1575:             * @param request 
1576:             * @param response 
1577:             * @param delegator 
1578:             * @param eventProcessor 
1579:             * @param dataMatrix 
1580:             * @param uiCache 
1581:             *
1582:             * @return 
1583:             *
1584:             * @throws GenericEntityException 
1585:             */
1586:            protected int update(UserInfo userInfo,
1587:                    UIWebScreenSection uiWebScreenSection,
1588:                    HttpServletRequest request, HttpServletResponse response,
1589:                    GenericDelegator delegator,
1590:                    GenericEventProcessor eventProcessor,
1591:                    DataMatrix dataMatrix, UICache uiCache)
1592:                    throws GenericEntityException {
1593:
1594:                int status = eventProcessor.processUpdate(userInfo, delegator,
1595:                        dataMatrix);
1596:
1597:                return status;
1598:            }
1599:
1600:            /**
1601:             * DOCUMENT ME!
1602:             *
1603:             * @param userInfo 
1604:             * @param uiWebScreenSection 
1605:             * @param request 
1606:             * @param response 
1607:             * @param delegator 
1608:             * @param eventProcessor 
1609:             * @param dataMatrix 
1610:             * @param uiCache 
1611:             *
1612:             * @return 
1613:             */
1614:            protected int postUpdate(UserInfo userInfo,
1615:                    UIWebScreenSection uiWebScreenSection,
1616:                    HttpServletRequest request, HttpServletResponse response,
1617:                    GenericDelegator delegator,
1618:                    GenericEventProcessor eventProcessor,
1619:                    DataMatrix dataMatrix, UICache uiCache) {
1620:
1621:                return STATUS_CONTINUE;
1622:            }
1623:
1624:            //-------------------------------------------------------------------------
1625:            // UPDATE_SELECT - Adds and/or deletes entities in a many-to-many relationship table the data base.
1626:            //-------------------------------------------------------------------------
1627:            protected int processUpdateSelect(UserInfo userInfo,
1628:                    UIWebScreenSection uiWebScreenSection,
1629:                    HttpServletRequest request, HttpServletResponse response,
1630:                    GenericDelegator delegator,
1631:                    GenericEventProcessor eventProcessor)
1632:                    throws GenericEntityException {
1633:
1634:                int status = STATUS_CONTINUE;
1635:
1636:                ModelEntity primaryME = uiWebScreenSection
1637:                        .getUiScreenSectionEntity(0).getUiEntity()
1638:                        .getModelEntity();
1639:
1640:                // Get the items to add and remove from the request object.
1641:                String unassignedItemString = request
1642:                        .getParameter("inpUnassigned");
1643:                String assignedItemString = request.getParameter("inpAssigned");
1644:
1645:                Debug.logVerbose("unassignedItemString: "
1646:                        + unassignedItemString, module);
1647:                Debug.logVerbose("assignedItemString: " + assignedItemString,
1648:                        module);
1649:
1650:                // Convert the strings to array lists of primary keys.
1651:                String entityName = primaryME.getEntityName();
1652:                ModelEntity modelEntity = delegator.getModelEntity(entityName);
1653:                HashMap useQueryParameterValueMap = uiWebScreenSection
1654:                        .getUseQueryParameterValueMap();
1655:                ArrayList removeKeyMapList = EventUtility.decodeSelectItem(
1656:                        useQueryParameterValueMap, unassignedItemString);
1657:                ArrayList createKeyMapList = EventUtility.decodeSelectItem(
1658:                        useQueryParameterValueMap, assignedItemString);
1659:
1660:                // Trigger the pre-update event.
1661:                status = this .preUpdateSelect(userInfo, uiWebScreenSection,
1662:                        request, response, delegator, eventProcessor,
1663:                        primaryME, removeKeyMapList, createKeyMapList);
1664:
1665:                if (status != STATUS_CONTINUE) {
1666:                    return status;
1667:                }
1668:
1669:                // Trigger the update event.
1670:                status = this .updateSelect(userInfo, uiWebScreenSection,
1671:                        request, response, delegator, eventProcessor,
1672:                        primaryME, removeKeyMapList, createKeyMapList);
1673:
1674:                if (status != STATUS_CONTINUE) {
1675:                    return status;
1676:                }
1677:
1678:                // Trigger the post-update event.
1679:                status = this .postUpdateSelect(userInfo, uiWebScreenSection,
1680:                        request, response, delegator, eventProcessor,
1681:                        primaryME, removeKeyMapList, createKeyMapList);
1682:
1683:                return status;
1684:            }
1685:
1686:            /**
1687:             * DOCUMENT ME!
1688:             *
1689:             * @param userInfo 
1690:             * @param uiWebScreenSection 
1691:             * @param request 
1692:             * @param response 
1693:             * @param delegator 
1694:             * @param eventProcessor 
1695:             * @param primaryME 
1696:             * @param removeKeyMapList 
1697:             * @param createKeyMapList 
1698:             *
1699:             * @return 
1700:             */
1701:            protected int preUpdateSelect(UserInfo userInfo,
1702:                    UIWebScreenSection uiWebScreenSection,
1703:                    HttpServletRequest request, HttpServletResponse response,
1704:                    GenericDelegator delegator,
1705:                    GenericEventProcessor eventProcessor,
1706:                    ModelEntity primaryME, ArrayList removeKeyMapList,
1707:                    ArrayList createKeyMapList) {
1708:
1709:                return STATUS_CONTINUE;
1710:            }
1711:
1712:            /**
1713:             * DOCUMENT ME!
1714:             *
1715:             * @param userInfo 
1716:             * @param uiWebScreenSection 
1717:             * @param request 
1718:             * @param response 
1719:             * @param delegator 
1720:             * @param eventProcessor 
1721:             * @param primaryME 
1722:             * @param removeKeyMapList 
1723:             * @param createKeyMapList 
1724:             *
1725:             * @return 
1726:             *
1727:             * @throws GenericEntityException 
1728:             */
1729:            protected int updateSelect(UserInfo userInfo,
1730:                    UIWebScreenSection uiWebScreenSection,
1731:                    HttpServletRequest request, HttpServletResponse response,
1732:                    GenericDelegator delegator,
1733:                    GenericEventProcessor eventProcessor,
1734:                    ModelEntity primaryME, ArrayList removeKeyMapList,
1735:                    ArrayList createKeyMapList) throws GenericEntityException {
1736:
1737:                int status = eventProcessor.processUpdateSelect(userInfo,
1738:                        delegator, primaryME, removeKeyMapList,
1739:                        createKeyMapList);
1740:
1741:                return status;
1742:            }
1743:
1744:            /**
1745:             * DOCUMENT ME!
1746:             *
1747:             * @param userInfo 
1748:             * @param uiWebScreenSection 
1749:             * @param request 
1750:             * @param response 
1751:             * @param delegator 
1752:             * @param eventProcessor 
1753:             * @param primaryME 
1754:             * @param removeKeyMapList 
1755:             * @param createKeyMapList 
1756:             *
1757:             * @return 
1758:             */
1759:            protected int postUpdateSelect(UserInfo userInfo,
1760:                    UIWebScreenSection uiWebScreenSection,
1761:                    HttpServletRequest request, HttpServletResponse response,
1762:                    GenericDelegator delegator,
1763:                    GenericEventProcessor eventProcessor,
1764:                    ModelEntity primaryME, ArrayList removeKeyMapList,
1765:                    ArrayList createKeyMapList) {
1766:
1767:                return STATUS_CONTINUE;
1768:            }
1769:
1770:            //-------------------------------------------------------------------------
1771:            // INSERT - Inserts a new set of entities into the data base.
1772:            //-------------------------------------------------------------------------
1773:            protected int processInsert(UserInfo userInfo,
1774:                    UIWebScreenSection uiWebScreenSection,
1775:                    HttpServletRequest request, HttpServletResponse response,
1776:                    GenericDelegator delegator,
1777:                    GenericEventProcessor eventProcessor,
1778:                    DataMatrix dataMatrix, UICache uiCache)
1779:                    throws GenericEntityException {
1780:
1781:                int status = STATUS_CONTINUE;
1782:
1783:                // Pre fill the data matrix from the info entered on the screen.
1784:                dataMatrix.fillFromHtml(request, uiWebScreenSection);
1785:
1786:                // Trigger the pre-insert event.
1787:                status = this .preInsert(userInfo, uiWebScreenSection, request,
1788:                        response, delegator, eventProcessor, dataMatrix,
1789:                        uiCache);
1790:
1791:                if (status != STATUS_CONTINUE) {
1792:                    return status;
1793:                }
1794:
1795:                // Trigger the insert event.
1796:                status = this .insert(userInfo, uiWebScreenSection, request,
1797:                        response, delegator, eventProcessor, dataMatrix,
1798:                        uiCache);
1799:
1800:                if (status != STATUS_CONTINUE) {
1801:                    return status;
1802:                }
1803:
1804:                // Trigger the post-insert event.
1805:                status = this .postInsert(userInfo, uiWebScreenSection, request,
1806:                        response, delegator, eventProcessor, dataMatrix,
1807:                        uiCache);
1808:
1809:                return status;
1810:            }
1811:
1812:            /**
1813:             * DOCUMENT ME!
1814:             *
1815:             * @param userInfo 
1816:             * @param uiWebScreenSection 
1817:             * @param request 
1818:             * @param response 
1819:             * @param delegator 
1820:             * @param eventProcessor 
1821:             * @param dataMatrix 
1822:             * @param uiCache 
1823:             *
1824:             * @return 
1825:             */
1826:            protected int preInsert(UserInfo userInfo,
1827:                    UIWebScreenSection uiWebScreenSection,
1828:                    HttpServletRequest request, HttpServletResponse response,
1829:                    GenericDelegator delegator,
1830:                    GenericEventProcessor eventProcessor,
1831:                    DataMatrix dataMatrix, UICache uiCache) {
1832:
1833:                return STATUS_CONTINUE;
1834:            }
1835:
1836:            /**
1837:             * DOCUMENT ME!
1838:             *
1839:             * @param userInfo 
1840:             * @param uiWebScreenSection 
1841:             * @param request 
1842:             * @param response 
1843:             * @param delegator 
1844:             * @param eventProcessor 
1845:             * @param dataMatrix 
1846:             * @param uiCache 
1847:             *
1848:             * @return 
1849:             *
1850:             * @throws GenericEntityException 
1851:             */
1852:            protected int insert(UserInfo userInfo,
1853:                    UIWebScreenSection uiWebScreenSection,
1854:                    HttpServletRequest request, HttpServletResponse response,
1855:                    GenericDelegator delegator,
1856:                    GenericEventProcessor eventProcessor,
1857:                    DataMatrix dataMatrix, UICache uiCache)
1858:                    throws GenericEntityException {
1859:
1860:                int status = eventProcessor.processInsert(userInfo, delegator,
1861:                        dataMatrix);
1862:
1863:                Debug.logVerbose("Data matrix after insert: "
1864:                        + dataMatrix.getCurrentBuffer().getContents()
1865:                                .toString(), module);
1866:
1867:                return status;
1868:            }
1869:
1870:            /**
1871:             * DOCUMENT ME!
1872:             *
1873:             * @param userInfo 
1874:             * @param uiWebScreenSection 
1875:             * @param request 
1876:             * @param response 
1877:             * @param delegator 
1878:             * @param eventProcessor 
1879:             * @param dataMatrix 
1880:             * @param uiCache 
1881:             *
1882:             * @return 
1883:             */
1884:            protected int postInsert(UserInfo userInfo,
1885:                    UIWebScreenSection uiWebScreenSection,
1886:                    HttpServletRequest request, HttpServletResponse response,
1887:                    GenericDelegator delegator,
1888:                    GenericEventProcessor eventProcessor,
1889:                    DataMatrix dataMatrix, UICache uiCache) {
1890:
1891:                return STATUS_CONTINUE;
1892:            }
1893:
1894:            //-------------------------------------------------------------------------
1895:            // DELETE - Deletes data for an entity from the data base.
1896:            //-------------------------------------------------------------------------
1897:            protected int processDelete(UserInfo userInfo,
1898:                    UIWebScreenSection uiWebScreenSection,
1899:                    HttpServletRequest request, HttpServletResponse response,
1900:                    GenericDelegator delegator,
1901:                    GenericEventProcessor eventProcessor, UICache uiCache)
1902:                    throws GenericEntityException {
1903:
1904:                int status = STATUS_CONTINUE;
1905:
1906:                UtilTimer timer = new UtilTimer();
1907:
1908:                if (TIMER) {
1909:                    timer.timerString(1,
1910:                            "[GenericWebEventProcessor.processDelete] Start");
1911:                }
1912:
1913:                // Get the main entity using the primary key.
1914:                HashMap fields = new HashMap();
1915:                String primaryEntityName = uiWebScreenSection
1916:                        .getUiScreenSectionEntity(0).getUiEntity()
1917:                        .getEntityName();
1918:
1919:                Debug.logVerbose("Primary entity name: " + primaryEntityName,
1920:                        module);
1921:
1922:                ModelEntity primaryME = uiWebScreenSection
1923:                        .getUiScreenSectionEntity(0).getUiEntity()
1924:                        .getModelEntity();
1925:                List primaryPkFieldNames = uiWebScreenSection
1926:                        .getUiScreenSectionEntity(0).getUiEntity()
1927:                        .getPrimaryKeyFieldNames();
1928:                Iterator primaryPkFieldNameI = primaryPkFieldNames.iterator();
1929:
1930:                while (primaryPkFieldNameI.hasNext()) {
1931:                    String primaryPkFieldName = (String) primaryPkFieldNameI
1932:                            .next();
1933:                    String primaryPkFieldValue = "";
1934:
1935:                    if (request.getParameter(primaryPkFieldName) != null) {
1936:                        primaryPkFieldValue = request
1937:                                .getParameter(primaryPkFieldName);
1938:                    } else if (request.getParameter(primaryEntityName + "_"
1939:                            + primaryPkFieldName) != null) {
1940:                        primaryPkFieldValue = request
1941:                                .getParameter(primaryEntityName + "_"
1942:                                        + primaryPkFieldName);
1943:                    } else {
1944:                        throw new GenericEntityException("Parameter \""
1945:                                + primaryPkFieldName
1946:                                + "\" is required for delete.");
1947:                    }
1948:
1949:                    fields.put(primaryPkFieldName, primaryPkFieldValue);
1950:                }
1951:
1952:                Debug.logVerbose("Primary key fields: " + fields.toString(),
1953:                        module);
1954:
1955:                // Trigger the pre-delete event.
1956:                status = this .preDelete(userInfo, uiWebScreenSection, request,
1957:                        response, delegator, eventProcessor, primaryME, fields,
1958:                        uiCache);
1959:
1960:                if (status != STATUS_CONTINUE) {
1961:                    return status;
1962:                }
1963:
1964:                // Trigger the delete event.
1965:                status = this .delete(userInfo, uiWebScreenSection, request,
1966:                        response, delegator, eventProcessor, primaryME, fields,
1967:                        uiCache);
1968:
1969:                if (status != STATUS_CONTINUE) {
1970:                    return status;
1971:                }
1972:
1973:                // Trigger the post-create event.
1974:                status = this .postDelete(userInfo, uiWebScreenSection, request,
1975:                        response, delegator, eventProcessor, primaryME, fields,
1976:                        uiCache);
1977:
1978:                return status;
1979:            }
1980:
1981:            /**
1982:             * DOCUMENT ME!
1983:             *
1984:             * @param userInfo 
1985:             * @param uiWebScreenSection 
1986:             * @param request 
1987:             * @param response 
1988:             * @param delegator 
1989:             * @param eventProcessor 
1990:             * @param primaryME 
1991:             * @param fields 
1992:             * @param uiCache 
1993:             *
1994:             * @return 
1995:             */
1996:            protected int preDelete(UserInfo userInfo,
1997:                    UIWebScreenSection uiWebScreenSection,
1998:                    HttpServletRequest request, HttpServletResponse response,
1999:                    GenericDelegator delegator,
2000:                    GenericEventProcessor eventProcessor,
2001:                    ModelEntity primaryME, HashMap fields, UICache uiCache) {
2002:
2003:                return STATUS_CONTINUE;
2004:            }
2005:
2006:            /**
2007:             * DOCUMENT ME!
2008:             *
2009:             * @param userInfo 
2010:             * @param uiWebScreenSection 
2011:             * @param request 
2012:             * @param response 
2013:             * @param delegator 
2014:             * @param eventProcessor 
2015:             * @param primaryME 
2016:             * @param fields 
2017:             * @param uiCache 
2018:             *
2019:             * @return 
2020:             *
2021:             * @throws GenericEntityException 
2022:             */
2023:            protected int delete(UserInfo userInfo,
2024:                    UIWebScreenSection uiWebScreenSection,
2025:                    HttpServletRequest request, HttpServletResponse response,
2026:                    GenericDelegator delegator,
2027:                    GenericEventProcessor eventProcessor,
2028:                    ModelEntity primaryME, HashMap fields, UICache uiCache)
2029:                    throws GenericEntityException {
2030:
2031:                int status = eventProcessor.processDelete(userInfo, delegator,
2032:                        primaryME, fields);
2033:
2034:                return status;
2035:            }
2036:
2037:            /**
2038:             * DOCUMENT ME!
2039:             *
2040:             * @param userInfo 
2041:             * @param uiWebScreenSection 
2042:             * @param request 
2043:             * @param response 
2044:             * @param delegator 
2045:             * @param eventProcessor 
2046:             * @param primaryME 
2047:             * @param fields 
2048:             * @param uiCache 
2049:             *
2050:             * @return 
2051:             */
2052:            protected int postDelete(UserInfo userInfo,
2053:                    UIWebScreenSection uiWebScreenSection,
2054:                    HttpServletRequest request, HttpServletResponse response,
2055:                    GenericDelegator delegator,
2056:                    GenericEventProcessor eventProcessor,
2057:                    ModelEntity primaryME, HashMap fields, UICache uiCache) {
2058:
2059:                return STATUS_CONTINUE;
2060:            }
2061:
2062:            //-------------------------------------------------------------------------
2063:            // CREATE - Creates a blank set of entities to prepare for an INSERT.
2064:            //-------------------------------------------------------------------------
2065:            protected int processCreate(UserInfo userInfo,
2066:                    UIWebScreenSection uiWebScreenSection,
2067:                    HttpServletRequest request, HttpServletResponse response,
2068:                    GenericDelegator delegator,
2069:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix)
2070:                    throws GenericEntityException {
2071:
2072:                int status = STATUS_CONTINUE;
2073:
2074:                // Create a List of entity names from which the empty entities will be created.
2075:                //		if (DEBUG) Debug.logVerbose("[create] About to create an empty generic value vector List.");
2076:                List entityNameList = uiWebScreenSection.getEntityNameList();
2077:
2078:                // Trigger the pre-create event.
2079:                status = this .preCreate(userInfo, uiWebScreenSection, request,
2080:                        response, delegator, eventProcessor, dataMatrix,
2081:                        entityNameList);
2082:
2083:                if (status != STATUS_CONTINUE) {
2084:                    return status;
2085:                }
2086:
2087:                // Trigger the create event.
2088:                status = this .create(userInfo, uiWebScreenSection, request,
2089:                        response, delegator, eventProcessor, dataMatrix,
2090:                        entityNameList);
2091:
2092:                if (status != STATUS_CONTINUE) {
2093:                    return status;
2094:                }
2095:
2096:                // Trigger the post-create event.
2097:                status = this .postCreate(userInfo, uiWebScreenSection, request,
2098:                        response, delegator, eventProcessor, dataMatrix,
2099:                        entityNameList);
2100:
2101:                return status;
2102:            }
2103:
2104:            /**
2105:             * DOCUMENT ME!
2106:             *
2107:             * @param userInfo 
2108:             * @param uiWebScreenSection 
2109:             * @param request 
2110:             * @param response 
2111:             * @param delegator 
2112:             * @param eventProcessor 
2113:             * @param dataMatrix 
2114:             * @param entityNameList 
2115:             *
2116:             * @return 
2117:             */
2118:            protected int preCreate(UserInfo userInfo,
2119:                    UIWebScreenSection uiWebScreenSection,
2120:                    HttpServletRequest request, HttpServletResponse response,
2121:                    GenericDelegator delegator,
2122:                    GenericEventProcessor eventProcessor,
2123:                    DataMatrix dataMatrix, List entityNameList) {
2124:
2125:                return STATUS_CONTINUE;
2126:            }
2127:
2128:            /**
2129:             * DOCUMENT ME!
2130:             *
2131:             * @param userInfo 
2132:             * @param uiWebScreenSection 
2133:             * @param request 
2134:             * @param response 
2135:             * @param delegator 
2136:             * @param eventProcessor 
2137:             * @param dataMatrix 
2138:             * @param entityNameList 
2139:             *
2140:             * @return 
2141:             *
2142:             * @throws GenericEntityException 
2143:             */
2144:            protected int create(UserInfo userInfo,
2145:                    UIWebScreenSection uiWebScreenSection,
2146:                    HttpServletRequest request, HttpServletResponse response,
2147:                    GenericDelegator delegator,
2148:                    GenericEventProcessor eventProcessor,
2149:                    DataMatrix dataMatrix, List entityNameList)
2150:                    throws GenericEntityException {
2151:
2152:                int status = eventProcessor.processCreate(userInfo,
2153:                        entityNameList, delegator, dataMatrix);
2154:
2155:                // For each attribute in the data matrix, look for HTML parameters in the
2156:                // request object to set default values.
2157:                Vector genericValueVector = dataMatrix.getCurrentBuffer()
2158:                        .getContentsRow(0);
2159:
2160:                for (int entityNbr = 0; entityNbr < genericValueVector.size(); entityNbr++) {
2161:                    GenericValue gV = (GenericValue) genericValueVector
2162:                            .get(entityNbr);
2163:                    String entityName = gV.getEntityName();
2164:
2165:                    //			List fieldNames = gV.getModelEntity().getNoPkFieldNames();
2166:                    List fieldNames = gV.getModelEntity().getAllFieldNames();
2167:                    Iterator fieldNameI = fieldNames.iterator();
2168:
2169:                    while (fieldNameI.hasNext()) {
2170:                        String fieldName = (String) fieldNameI.next();
2171:
2172:                        if (request.getParameter(fieldName) != null) {
2173:                            // A parameter was passed in to set this value. Store it in the data matrix.
2174:                            String defaultValue = request
2175:                                    .getParameter(fieldName);
2176:                            EventUtility.storeValue(gV, fieldName,
2177:                                    defaultValue, delegator);
2178:                        } else {
2179:                            // Check for a parameter with the entity name as a prefix.
2180:                            String parameterName = entityName + "_" + fieldName;
2181:
2182:                            if (request.getParameter(parameterName) != null) {
2183:                                // A parameter was passed in to set this value. Store it in the data matrix.
2184:                                String defaultValue = request
2185:                                        .getParameter(parameterName);
2186:                                EventUtility.storeValue(gV, fieldName,
2187:                                        defaultValue, delegator);
2188:                            }
2189:                        }
2190:                    }
2191:                }
2192:
2193:                return status;
2194:            }
2195:
2196:            /**
2197:             * DOCUMENT ME!
2198:             *
2199:             * @param userInfo 
2200:             * @param uiWebScreenSection 
2201:             * @param request 
2202:             * @param response 
2203:             * @param delegator 
2204:             * @param eventProcessor 
2205:             * @param dataMatrix 
2206:             * @param entityNameList 
2207:             *
2208:             * @return 
2209:             */
2210:            protected int postCreate(UserInfo userInfo,
2211:                    UIWebScreenSection uiWebScreenSection,
2212:                    HttpServletRequest request, HttpServletResponse response,
2213:                    GenericDelegator delegator,
2214:                    GenericEventProcessor eventProcessor,
2215:                    DataMatrix dataMatrix, List entityNameList) {
2216:
2217:                return STATUS_CONTINUE;
2218:            }
2219:
2220:            //-------------------------------------------------------------------------
2221:            // SHOW_COPY - Creates a copy of the retrieved entity(s) to prepare for an INSERT.
2222:            //-------------------------------------------------------------------------
2223:            protected int processShowCopy(UserInfo userInfo,
2224:                    UIWebScreenSection uiWebScreenSection,
2225:                    HttpServletRequest request, HttpServletResponse response,
2226:                    GenericDelegator delegator,
2227:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix)
2228:                    throws GenericEntityException {
2229:
2230:                int status = STATUS_CONTINUE;
2231:
2232:                // Trigger the pre-showCopy event.
2233:                status = this .preShowCopy(userInfo, uiWebScreenSection,
2234:                        request, response, delegator, eventProcessor,
2235:                        dataMatrix);
2236:
2237:                if (status != STATUS_CONTINUE) {
2238:                    return status;
2239:                }
2240:
2241:                // Trigger the showCopy event.
2242:                status = this .showCopy(userInfo, uiWebScreenSection, request,
2243:                        response, delegator, eventProcessor, dataMatrix);
2244:
2245:                if (status != STATUS_CONTINUE) {
2246:                    return status;
2247:                }
2248:
2249:                // Trigger the post-showCopy event.
2250:                status = this .postShowCopy(userInfo, uiWebScreenSection,
2251:                        request, response, delegator, eventProcessor,
2252:                        dataMatrix);
2253:
2254:                return status;
2255:            }
2256:
2257:            /**
2258:             * DOCUMENT ME!
2259:             *
2260:             * @param userInfo 
2261:             * @param uiWebScreenSection 
2262:             * @param request 
2263:             * @param response 
2264:             * @param delegator 
2265:             * @param eventProcessor 
2266:             * @param dataMatrix 
2267:             *
2268:             * @return 
2269:             */
2270:            protected int preShowCopy(UserInfo userInfo,
2271:                    UIWebScreenSection uiWebScreenSection,
2272:                    HttpServletRequest request, HttpServletResponse response,
2273:                    GenericDelegator delegator,
2274:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix) {
2275:
2276:                return STATUS_CONTINUE;
2277:            }
2278:
2279:            /**
2280:             * DOCUMENT ME!
2281:             *
2282:             * @param userInfo 
2283:             * @param uiWebScreenSection 
2284:             * @param request 
2285:             * @param response 
2286:             * @param delegator 
2287:             * @param eventProcessor 
2288:             * @param dataMatrix 
2289:             *
2290:             * @return 
2291:             *
2292:             * @throws GenericEntityException 
2293:             */
2294:            protected int showCopy(UserInfo userInfo,
2295:                    UIWebScreenSection uiWebScreenSection,
2296:                    HttpServletRequest request, HttpServletResponse response,
2297:                    GenericDelegator delegator,
2298:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix)
2299:                    throws GenericEntityException {
2300:
2301:                int status = eventProcessor.processShowCopy(userInfo,
2302:                        delegator, dataMatrix);
2303:
2304:                return status;
2305:            }
2306:
2307:            /**
2308:             * DOCUMENT ME!
2309:             *
2310:             * @param userInfo 
2311:             * @param uiWebScreenSection 
2312:             * @param request 
2313:             * @param response 
2314:             * @param delegator 
2315:             * @param eventProcessor 
2316:             * @param dataMatrix 
2317:             *
2318:             * @return 
2319:             */
2320:            protected int postShowCopy(UserInfo userInfo,
2321:                    UIWebScreenSection uiWebScreenSection,
2322:                    HttpServletRequest request, HttpServletResponse response,
2323:                    GenericDelegator delegator,
2324:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix) {
2325:
2326:                return STATUS_CONTINUE;
2327:            }
2328:
2329:            //-------------------------------------------------------------------------
2330:            // SHOWQUERY - Creates a blank set of entities to prepare for query mode.
2331:            //-------------------------------------------------------------------------
2332:            protected int processShowQuery(UserInfo userInfo,
2333:                    UIWebScreenSection uiWebScreenSection,
2334:                    HttpServletRequest request, HttpServletResponse response,
2335:                    GenericDelegator delegator,
2336:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix)
2337:                    throws GenericEntityException {
2338:
2339:                int status = STATUS_CONTINUE;
2340:
2341:                // Create a List of entity names from which the empty entities will be created.
2342:                //		if (DEBUG) Debug.logVerbose("[processShowQuery] About to create an empty generic value vector List for query mode.");
2343:                List entityNameList = uiWebScreenSection.getEntityNameList();
2344:
2345:                String queryMode = UtilFormatOut.checkNull(request
2346:                        .getParameter("queryMode"));
2347:                if (queryMode.length() < 1) {
2348:                    Preference pref = Preference.getInstance(delegator);
2349:
2350:                    queryMode = pref.getPreference(userInfo.getPartyId(),
2351:                            userInfo.getAccountId(), "QUERY_MODE", "standard");
2352:
2353:                }
2354:                uiWebScreenSection.setQueryMode(queryMode);
2355:
2356:                //		if (DEBUG) Debug.logVerbose("[processShowQuery] Entity name List: " + entityNameList.toString());
2357:                // Trigger the pre-create event.
2358:                status = this .preShowQuery(userInfo, uiWebScreenSection,
2359:                        request, response, delegator, eventProcessor,
2360:                        dataMatrix, entityNameList);
2361:
2362:                if (status != STATUS_CONTINUE) {
2363:                    return status;
2364:                }
2365:
2366:                // Trigger the create event.
2367:                status = this .showQuery(userInfo, uiWebScreenSection, request,
2368:                        response, delegator, eventProcessor, dataMatrix,
2369:                        entityNameList);
2370:
2371:                if (status != STATUS_CONTINUE) {
2372:                    return status;
2373:                }
2374:
2375:                // Trigger the post-create event.
2376:                status = this .postShowQuery(userInfo, uiWebScreenSection,
2377:                        request, response, delegator, eventProcessor,
2378:                        dataMatrix, entityNameList);
2379:
2380:                return status;
2381:            }
2382:
2383:            /**
2384:             * DOCUMENT ME!
2385:             *
2386:             * @param userInfo 
2387:             * @param uiWebScreenSection 
2388:             * @param request 
2389:             * @param response 
2390:             * @param delegator 
2391:             * @param eventProcessor 
2392:             * @param dataMatrix 
2393:             * @param entityNameList 
2394:             *
2395:             * @return 
2396:             */
2397:            protected int preShowQuery(UserInfo userInfo,
2398:                    UIWebScreenSection uiWebScreenSection,
2399:                    HttpServletRequest request, HttpServletResponse response,
2400:                    GenericDelegator delegator,
2401:                    GenericEventProcessor eventProcessor,
2402:                    DataMatrix dataMatrix, List entityNameList) {
2403:
2404:                return STATUS_CONTINUE;
2405:            }
2406:
2407:            /**
2408:             * DOCUMENT ME!
2409:             *
2410:             * @param userInfo 
2411:             * @param uiWebScreenSection 
2412:             * @param request 
2413:             * @param response 
2414:             * @param delegator 
2415:             * @param eventProcessor 
2416:             * @param dataMatrix 
2417:             * @param entityNameList 
2418:             *
2419:             * @return 
2420:             *
2421:             * @throws GenericEntityException 
2422:             */
2423:            protected int showQuery(UserInfo userInfo,
2424:                    UIWebScreenSection uiWebScreenSection,
2425:                    HttpServletRequest request, HttpServletResponse response,
2426:                    GenericDelegator delegator,
2427:                    GenericEventProcessor eventProcessor,
2428:                    DataMatrix dataMatrix, List entityNameList)
2429:                    throws GenericEntityException {
2430:
2431:                int status = eventProcessor.processShowQuery(userInfo,
2432:                        entityNameList, delegator, dataMatrix);
2433:
2434:                //		if (DEBUG) Debug.logVerbose("[showQuery] Empty generic value vector List: " + genericValueVectorList.toString());
2435:                return status;
2436:            }
2437:
2438:            /**
2439:             * DOCUMENT ME!
2440:             *
2441:             * @param userInfo 
2442:             * @param uiWebScreenSection 
2443:             * @param request 
2444:             * @param response 
2445:             * @param delegator 
2446:             * @param eventProcessor 
2447:             * @param dataMatrix 
2448:             * @param entityNameList 
2449:             *
2450:             * @return 
2451:             */
2452:            protected int postShowQuery(UserInfo userInfo,
2453:                    UIWebScreenSection uiWebScreenSection,
2454:                    HttpServletRequest request, HttpServletResponse response,
2455:                    GenericDelegator delegator,
2456:                    GenericEventProcessor eventProcessor,
2457:                    DataMatrix dataMatrix, List entityNameList) {
2458:
2459:                return STATUS_CONTINUE;
2460:            }
2461:
2462:            /**
2463:             * DOCUMENT ME!
2464:             *
2465:             * @param uiWebScreenSection 
2466:             * @param request 
2467:             *
2468:             * @throws GenericEntityException 
2469:             */
2470:            protected void evalUseQueryParameterList(
2471:                    UIWebScreenSection uiWebScreenSection,
2472:                    HttpServletRequest request) throws GenericEntityException {
2473:                HashMap useQueryParameterMap = uiWebScreenSection
2474:                        .getUseQueryParameterMap();
2475:
2476:                Debug.logVerbose("useQueryParameterMap: \""
2477:                        + useQueryParameterMap.toString() + "\".", module);
2478:
2479:                HashMap useQueryParameterValueMap = new HashMap();
2480:                Iterator useQueryParameterMapIterator = useQueryParameterMap
2481:                        .keySet().iterator();
2482:
2483:                while (useQueryParameterMapIterator.hasNext()) {
2484:                    String key = (String) useQueryParameterMapIterator.next();
2485:                    String valueSource = (String) useQueryParameterMap.get(key);
2486:
2487:                    if (request.getParameter(valueSource) != null) {
2488:                        String value = request.getParameter(valueSource);
2489:
2490:                        Debug.logVerbose(
2491:                                "key-value pair: " + key + ":" + value, module);
2492:
2493:                        useQueryParameterValueMap.put(key, value);
2494:                    }
2495:                }
2496:
2497:                uiWebScreenSection
2498:                        .setUseQueryParameterValueMap(useQueryParameterValueMap);
2499:
2500:                Debug.logVerbose("useQueryParameterValueMap: \""
2501:                        + useQueryParameterValueMap.toString() + "\".", module);
2502:            }
2503:
2504:            /**
2505:             * DOCUMENT ME!
2506:             *
2507:             * @param uiWebScreenSection 
2508:             * @param request 
2509:             * @param dataMatrix 
2510:             *
2511:             * @throws GenericEntityException 
2512:             */
2513:            protected void evalSendQueryParameterList(
2514:                    UIWebScreenSection uiWebScreenSection,
2515:                    HttpServletRequest request, DataMatrix dataMatrix)
2516:                    throws GenericEntityException {
2517:                HashMap sendQueryParameterMap = uiWebScreenSection
2518:                        .getSendQueryParameterMap();
2519:
2520:                Debug.logVerbose("sendQueryParameterMap: \""
2521:                        + sendQueryParameterMap.toString() + "\".", module);
2522:
2523:                HashMap sendQueryParameterValueMap = new HashMap();
2524:                Iterator sendQueryParameterMapIterator = sendQueryParameterMap
2525:                        .keySet().iterator();
2526:
2527:                while (sendQueryParameterMapIterator.hasNext()) {
2528:                    String key = (String) sendQueryParameterMapIterator.next();
2529:
2530:                    Debug.logVerbose(
2531:                            "Setting search key value \"" + key + "\"", module);
2532:
2533:                    String valueSource = (String) sendQueryParameterMap
2534:                            .get(key);
2535:
2536:                    if (request.getParameter(valueSource) == null) {
2537:                        // This parameter was NOT found in the request object.  Get the value from the first row in the
2538:                        // data matrix.
2539:                        Debug
2540:                                .logVerbose(
2541:                                        "Parameter \""
2542:                                                + valueSource
2543:                                                + "\" not found in request object. Looking in current buffer.",
2544:                                        module);
2545:
2546:                        if (dataMatrix.getCurrentBuffer().getContents().size() > 0) {
2547:
2548:                            Debug.logVerbose("Looking for parameter \""
2549:                                    + valueSource + "\" in current buffer.",
2550:                                    module);
2551:
2552:                            Vector entityDetailsVector = dataMatrix
2553:                                    .getCurrentBuffer().getContentsRow(0);
2554:
2555:                            //				String keyParams = UIWebUtility.getHiddenArgs(getButtonKeyMap(), entityDetailsVector, "       ");
2556:                            try {
2557:                                String value = UIUtility.decodeAttributeValue(
2558:                                        valueSource, entityDetailsVector, "");
2559:
2560:                                Debug.logVerbose(
2561:                                        "Search parameter key-value from current buffer: "
2562:                                                + key + ":" + value, module);
2563:
2564:                                sendQueryParameterValueMap.put(key, value);
2565:                            } catch (GenericEntityException e) {
2566:                                Debug.logError("Error looking for value for "
2567:                                        + valueSource + " in data matrix: "
2568:                                        + e.getLocalizedMessage(), module);
2569:                            }
2570:                        }
2571:                    } else {
2572:                        // This parameter was found in the request object.  Use that value.
2573:                        String value = request.getParameter(valueSource);
2574:
2575:                        Debug.logVerbose(
2576:                                "Search parameter key-value from request object: "
2577:                                        + key + ":" + value, module);
2578:
2579:                        sendQueryParameterValueMap.put(key, value);
2580:                    }
2581:                }
2582:
2583:                uiWebScreenSection
2584:                        .setSendQueryParameterValueMap(sendQueryParameterValueMap);
2585:
2586:                Debug
2587:                        .logVerbose(
2588:                                "sendQueryParameterValueMap: \""
2589:                                        + sendQueryParameterValueMap.toString()
2590:                                        + "\".", module);
2591:            }
2592:
2593:            //-------------------------------------------------------------------------
2594:            // SHOWREPORT - Re-displays the query criteria in query mode..
2595:            //-------------------------------------------------------------------------
2596:            protected int processShowReport(UserInfo userInfo,
2597:                    UIWebScreenSection uiWebScreenSection,
2598:                    HttpServletRequest request, HttpServletResponse response,
2599:                    GenericDelegator delegator,
2600:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix)
2601:                    throws GenericEntityException {
2602:
2603:                int status = STATUS_CONTINUE;
2604:
2605:                // Trigger the pre-showReport event.
2606:                status = this .preShowReport(userInfo, uiWebScreenSection,
2607:                        request, response, delegator, eventProcessor,
2608:                        dataMatrix);
2609:
2610:                if (status != STATUS_CONTINUE) {
2611:                    return status;
2612:                }
2613:
2614:                // Trigger the showReport event.
2615:                status = this .showReport(userInfo, uiWebScreenSection, request,
2616:                        response, delegator, eventProcessor, dataMatrix);
2617:
2618:                if (status != STATUS_CONTINUE) {
2619:                    return status;
2620:                }
2621:
2622:                // Trigger the post-showReport event.
2623:                status = this .postShowReport(userInfo, uiWebScreenSection,
2624:                        request, response, delegator, eventProcessor,
2625:                        dataMatrix);
2626:
2627:                return status;
2628:            }
2629:
2630:            /**
2631:             * DOCUMENT ME!
2632:             *
2633:             * @param userInfo 
2634:             * @param uiWebScreenSection 
2635:             * @param request 
2636:             * @param response 
2637:             * @param delegator 
2638:             * @param eventProcessor 
2639:             * @param dataMatrix 
2640:             *
2641:             * @return 
2642:             */
2643:            protected int preShowReport(UserInfo userInfo,
2644:                    UIWebScreenSection uiWebScreenSection,
2645:                    HttpServletRequest request, HttpServletResponse response,
2646:                    GenericDelegator delegator,
2647:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix) {
2648:
2649:                return STATUS_CONTINUE;
2650:            }
2651:
2652:            /**
2653:             * DOCUMENT ME!
2654:             *
2655:             * @param userInfo 
2656:             * @param uiWebScreenSection 
2657:             * @param request 
2658:             * @param response 
2659:             * @param delegator 
2660:             * @param eventProcessor 
2661:             * @param dataMatrix 
2662:             *
2663:             * @return 
2664:             *
2665:             * @throws GenericEntityException 
2666:             */
2667:            protected int showReport(UserInfo userInfo,
2668:                    UIWebScreenSection uiWebScreenSection,
2669:                    HttpServletRequest request, HttpServletResponse response,
2670:                    GenericDelegator delegator,
2671:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix)
2672:                    throws GenericEntityException {
2673:
2674:                // Pre fill the data matrix from the info entered on the screen.
2675:                Debug.logVerbose("Prefilling data matrix from screen data.",
2676:                        module);
2677:
2678:                dataMatrix.fillFromHtml(request, uiWebScreenSection);
2679:
2680:                int status = eventProcessor.processShowReport(userInfo,
2681:                        delegator, dataMatrix);
2682:
2683:                return status;
2684:            }
2685:
2686:            /**
2687:             * DOCUMENT ME!
2688:             *
2689:             * @param userInfo 
2690:             * @param uiWebScreenSection 
2691:             * @param request 
2692:             * @param response 
2693:             * @param delegator 
2694:             * @param eventProcessor 
2695:             * @param dataMatrix 
2696:             *
2697:             * @return 
2698:             */
2699:            protected int postShowReport(UserInfo userInfo,
2700:                    UIWebScreenSection uiWebScreenSection,
2701:                    HttpServletRequest request, HttpServletResponse response,
2702:                    GenericDelegator delegator,
2703:                    GenericEventProcessor eventProcessor, DataMatrix dataMatrix) {
2704:
2705:                return STATUS_CONTINUE;
2706:            }
2707:
2708:            //-------------------------------------------------------------------------
2709:            // CUSTOM - Performs one or more custom events.
2710:            //-------------------------------------------------------------------------
2711:            public int processCustom(UserInfo userInfo,
2712:                    UIWebScreenSection uiWebScreenSection,
2713:                    HttpServletRequest request, HttpServletResponse response,
2714:                    GenericDelegator delegator,
2715:                    GenericEventProcessor eventProcessor,
2716:                    DataMatrix dataMatrix, String action)
2717:                    throws GenericEntityException {
2718:
2719:                int status = eventProcessor.processCustom(userInfo, delegator,
2720:                        dataMatrix, action);
2721:
2722:                return status;
2723:            }
2724:
2725:            /**
2726:             * DOCUMENT ME!
2727:             *
2728:             * @param uiWebScreenSection 
2729:             * @param queryInfo  criteria to be used in search 
2730:             * @param relatedSearchClauses 
2731:             * @param primaryEntityName 
2732:             * @param request 
2733:             */
2734:            protected void addUseQueryParameterClauses(
2735:                    UIWebScreenSection uiWebScreenSection, QueryInfo queryInfo,
2736:                    List relatedSearchClauses, String primaryEntityName,
2737:                    HttpServletRequest request) {
2738:
2739:                EventUtility.appendEntityClauses(primaryEntityName,
2740:                        uiWebScreenSection.getUseQueryParameterValueMap(),
2741:                        queryInfo);
2742:            }
2743:
2744:            /**
2745:             * DOCUMENT ME!
2746:             *
2747:             * @param userInfo 
2748:             * @param screenName 
2749:             * @param sectionName 
2750:             * @param delegator 
2751:             * @param uiCache 
2752:             *
2753:             * @return 
2754:             *
2755:             * @throws GenericEntityException 
2756:             */
2757:            protected UIWebScreenSection getUiWebScreenSection(
2758:                    UserInfo userInfo, String screenName, String sectionName,
2759:                    GenericDelegator delegator, UICache uiCache)
2760:                    throws GenericEntityException {
2761:                // This method is here so a child class can specify a different screen section class.
2762:                Debug
2763:                        .logVerbose("Looking in cache for UIScreenSection",
2764:                                module);
2765:
2766:                UIScreenSection uiScreenSection = uiCache.getUiScreenSection(
2767:                        screenName, sectionName, userInfo.getPartyId());
2768:                UIWebScreenSection uiWebScreenSection = null;
2769:
2770:                if (uiScreenSection == null) {
2771:                    Debug.logVerbose(
2772:                            "Screen section not found in cache. Creating",
2773:                            module);
2774:
2775:                    uiWebScreenSection = new UIWebScreenSection(userInfo,
2776:                            screenName, sectionName, delegator, uiCache);
2777:                    uiCache.putUiScreenSection(screenName, sectionName,
2778:                            userInfo.getPartyId(),
2779:                            (UIScreenSection) uiWebScreenSection);
2780:                } else {
2781:                    Debug.logVerbose("Screen section found in cache", module);
2782:
2783:                    uiWebScreenSection = (UIWebScreenSection) uiScreenSection;
2784:                }
2785:
2786:                return uiWebScreenSection;
2787:            }
2788:
2789:            //  getRequestParameterValue
2790:            //  This method may be overridden in order to massage or remove parameters passed on the request object.
2791:            //  Removing a value of NULL for any parameter passed in will cause the parameter to NOT be used in the query clause.
2792:            //  Massaging the return value will affect the query accordingly.
2793:            //  Note:  If there is more than one item in the searchAttribValue array, you MUST return a comma delimited list of
2794:            //  values for use with an IN query that will be used for the search.
2795:            protected String getRequestParameterValue(String paramName,
2796:                    String[] searchAttribValueArray) {
2797:                String searchAttribValue = "";
2798:
2799:                if (searchAttribValueArray.length > 1) {
2800:                    // This was a multi-select box, and more than value was selected. Make a string
2801:                    // of values with commas in between and use the IN operation in selectByClause
2802:                    for (int valueNbr = 0; valueNbr < searchAttribValueArray.length; valueNbr++) {
2803:                        if (valueNbr > 0) {
2804:                            searchAttribValue += ", ";
2805:                        }
2806:
2807:                        searchAttribValue += ("'"
2808:                                + searchAttribValueArray[valueNbr] + "'");
2809:                    }
2810:                } else {
2811:                    // This was not a multi-select box, or only one value was selected. Just use the first
2812:                    // value in the parameter value list, and use LIKE, or whatever operator is entered by the user.
2813:                    searchAttribValue = searchAttribValueArray[0];
2814:                }
2815:
2816:                return searchAttribValue;
2817:            }
2818:
2819:            /**
2820:             * DOCUMENT ME!
2821:             *
2822:             * @param action 
2823:             * @param request 
2824:             * @param dataMatrix 
2825:             * @param delegator 
2826:             * @param userInfo 
2827:             * @param uiWebScreenSection 
2828:             */
2829:            protected void logUiHistory(String action,
2830:                    HttpServletRequest request, DataMatrix dataMatrix,
2831:                    GenericDelegator delegator, UserInfo userInfo,
2832:                    UIWebScreenSection uiWebScreenSection) {
2833:                String primaryEntityName = uiWebScreenSection
2834:                        .getUiScreenSectionEntity(0).getUiEntity()
2835:                        .getEntityName();
2836:
2837:                //		if (action.equals(uiWebScreenSection.ACTION_SHOW) ||
2838:                //			action.equals(uiWebScreenSection.ACTION_SHOW_QUERY_REPORT)) {
2839:                if (action.equals(uiWebScreenSection.ACTION_SHOW)) {
2840:                    //  Add an entry in the history tables
2841:                    String url = request.getRequestURL().toString();
2842:                    String uri = request.getRequestURI();
2843:
2844:                    String appPath = getUiHistoryAppPath(url);
2845:                    String historyUrl = (request.getScheme() + "://"
2846:                            + request.getServerName() + ":"
2847:                            + request.getServerPort() + "/sfa/control" + appPath);
2848:
2849:                    java.util.Enumeration parmNames = request
2850:                            .getParameterNames();
2851:
2852:                    int i = 0;
2853:
2854:                    while (parmNames.hasMoreElements() == true) {
2855:                        String parmName = (String) parmNames.nextElement();
2856:
2857:                        if (!parmName.equals("historySelect")) {
2858:                            if (i == 0) {
2859:                                historyUrl = historyUrl + "?";
2860:                            } else {
2861:                                historyUrl = historyUrl + "&";
2862:                            }
2863:
2864:                            historyUrl = historyUrl + parmName + "="
2865:                                    + request.getParameter(parmName);
2866:                            i++;
2867:                        }
2868:                    }
2869:
2870:                    Debug.logVerbose("HISTORY URL: " + historyUrl, module);
2871:
2872:                    String historyDescription = getUiHistoryDescription(
2873:                            dataMatrix, delegator, action, uiWebScreenSection);
2874:
2875:                    Debug.logVerbose("HISTORY DESCR: " + historyDescription,
2876:                            module);
2877:
2878:                    UIHistoryManager historyManager = new UIHistoryManager(
2879:                            delegator);
2880:
2881:                    try {
2882:                        String historySeqId = historyManager.saveHistoryEvent(
2883:                                userInfo.getPartyId(), historyUrl,
2884:                                historyDescription);
2885:
2886:                        Debug.logVerbose("HISTORY Saved: " + historySeqId,
2887:                                module);
2888:                    } catch (GenericEntityException e) {
2889:                        Debug.logError("Error Logging History: "
2890:                                + e.getLocalizedMessage(), module);
2891:                    }
2892:                }
2893:            }
2894:
2895:            /**
2896:             * This function gets the application path to be used to reconstruct the URI when a
2897:             * UI History record is logged.  Example: "/accounts"
2898:             * @author  John Nutting
2899:             * @param url The URL used to open the screen section
2900:             * @return String containing the application path
2901:             */
2902:            protected String getUiHistoryAppPath(String url) {
2903:                return "";
2904:            }
2905:
2906:            /**
2907:             * This function gets the description to store in the UI history table.  This description
2908:             * will show up in the UI History drop list.
2909:             * @author  John Nutting
2910:             * @param dataMatrix DataMatrix object containing the data from the screen
2911:             * @param delegator Generic delegator through which the data base is accessed
2912:             * @param action The action being performed on the screen
2913:             * @param uiWebScreenSection The UIWebScreenSection being used to construct the screen section
2914:             * @return String containing the UI History description
2915:             */
2916:            protected String getUiHistoryDescription(DataMatrix dataMatrix,
2917:                    GenericDelegator delegator, String action,
2918:                    UIWebScreenSection uiWebScreenSection) {
2919:                if (action.equals(UIWebScreenSection.ACTION_SHOW_QUERY_REPORT)) {
2920:                    // This is a report.
2921:                    return "Report: "
2922:                            + uiWebScreenSection.getSectionDescription();
2923:                } else {
2924:                    // This is a standard screen section.  Just set the name to the entity name as a default value.
2925:                    // This should be overridden by a child class to set the name for each screen section.
2926:                    return dataMatrix.getCurrentBuffer().getGenericValue(0, 0)
2927:                            .getEntityName();
2928:                }
2929:            }
2930:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.