Source Code Cross Referenced for PaymentSearchAction.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » pdp » action » paymentsearch » 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 » Kuali Financial System » org.kuali.module.pdp.action.paymentsearch 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         * http://www.opensource.org/licenses/ecl1.php
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        /*
017:         * Created on Aug 2, 2004
018:         *
019:         */
020:        package org.kuali.module.pdp.action.paymentsearch;
021:
022:        import java.sql.Timestamp;
023:        import java.util.Iterator;
024:        import java.util.List;
025:
026:        import javax.servlet.http.HttpServletRequest;
027:        import javax.servlet.http.HttpServletResponse;
028:        import javax.servlet.http.HttpSession;
029:
030:        import org.apache.struts.action.ActionForm;
031:        import org.apache.struts.action.ActionForward;
032:        import org.apache.struts.action.ActionMapping;
033:        import org.apache.struts.action.ActionMessage;
034:        import org.apache.struts.action.ActionMessages;
035:        import org.kuali.kfs.context.SpringContext;
036:        import org.kuali.kfs.service.ParameterService;
037:        import org.kuali.kfs.service.impl.ParameterConstants;
038:        import org.kuali.module.pdp.PdpConstants;
039:        import org.kuali.module.pdp.action.BaseAction;
040:        import org.kuali.module.pdp.bo.PaymentDetailSearch;
041:        import org.kuali.module.pdp.exception.ConfigurationError;
042:        import org.kuali.module.pdp.form.paymentsearch.PaymentDetailSearchForm;
043:        import org.kuali.module.pdp.service.PaymentDetailSearchService;
044:        import org.kuali.module.pdp.service.SecurityRecord;
045:        import org.kuali.module.pdp.utilities.GeneralUtilities;
046:
047:        /**
048:         * @author delyea
049:         */
050:        public class PaymentSearchAction extends BaseAction {
051:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
052:                    .getLogger(PaymentSearchAction.class);
053:
054:            private PaymentDetailSearchService paymentDetailSearchService;
055:
056:            public PaymentSearchAction() {
057:                setPaymentDetailSearchService(SpringContext
058:                        .getBean(PaymentDetailSearchService.class));
059:            }
060:
061:            protected boolean isAuthorized(ActionMapping mapping,
062:                    ActionForm form, HttpServletRequest request,
063:                    HttpServletResponse response) {
064:                SecurityRecord sr = getSecurityRecord(request);
065:                return sr.isLimitedViewRole() || sr.isViewAllRole()
066:                        || sr.isViewIdRole() || sr.isViewBankRole();
067:            }
068:
069:            private int getSearchResultsPerPage() {
070:                return getParameterInteger(
071:                        ParameterConstants.PRE_DISBURSEMENT_LOOKUP.class,
072:                        PdpConstants.ApplicationParameterKeys.SEARCH_RESULTS_PER_PAGE);
073:            }
074:
075:            private int getMaxSearchTotal() {
076:                return getParameterInteger(
077:                        ParameterConstants.PRE_DISBURSEMENT_LOOKUP.class,
078:                        PdpConstants.ApplicationParameterKeys.SEARCH_RESULTS_TOTAL);
079:            }
080:
081:            private int getParameterInteger(Class componentClass, String parm) {
082:                String srpp = SpringContext.getBean(ParameterService.class)
083:                        .getParameterValue(componentClass, parm);
084:                if (srpp != null) {
085:                    try {
086:                        return Integer.parseInt(srpp);
087:                    } catch (NumberFormatException e) {
088:                        throw new ConfigurationError(parm + " is not a number");
089:                    }
090:                } else {
091:                    throw new ConfigurationError("Unable to find " + parm);
092:                }
093:            }
094:
095:            protected ActionForward executeLogic(ActionMapping mapping,
096:                    ActionForm form, HttpServletRequest request,
097:                    HttpServletResponse response) throws Exception {
098:                LOG.info("executeLogic() starting");
099:
100:                String forward = "search";
101:                HttpSession session = request.getSession();
102:                LOG
103:                        .debug("executeLogic() ************* SESSION ID = "
104:                                + session.getId()
105:                                + "  and created "
106:                                + (new Timestamp(session.getCreationTime()))
107:                                        .toString());
108:                // before we attempt to do a search first validate the form fields.
109:                PaymentDetailSearchForm searchForm = (PaymentDetailSearchForm) form;
110:                ActionMessages errors = searchForm.validate(mapping, request);
111:                if (errors != null && errors.size() > 0) {
112:                    request.setAttribute("PaymentDetailSearchForm", searchForm);
113:                    return null;
114:                }
115:                List searchResults = null;
116:                Object perPage = session.getAttribute("perPage");
117:                if ((perPage == null) || (perPage.toString() == "")) {
118:                    session.setAttribute("perPage", getSearchResultsPerPage());
119:                }
120:
121:                ActionMessages actionErrors = new ActionMessages();
122:                String buttonPressed = GeneralUtilities
123:                        .whichButtonWasPressed(request);
124:
125:                PaymentDetailSearchForm pdsf = (PaymentDetailSearchForm) form;
126:                LOG.debug("executeLogic() pdsf is " + pdsf);
127:                LOG.debug("executeLogic() buttonPressed is " + buttonPressed);
128:
129:                if (buttonPressed.startsWith("btnSearch")) {
130:                    // Code for Searching for Individual Payments
131:                    clearObjects(session, actionErrors);
132:                    PaymentDetailSearch pds = pdsf.getPaymentDetailSearch();
133:                    searchResults = paymentDetailSearchService
134:                            .getAllPaymentsForSearchCriteria(pds);
135:
136:                    searchResults = checkList(searchResults, session,
137:                            actionErrors);
138:                    if (GeneralUtilities.isStringEmpty(pdsf
139:                            .getDisbursementNbr())) {
140:                        pdsf.setOldDisbursementNbr("");
141:                    }
142:                    session
143:                            .setAttribute("PaymentDetailSearchFormSession",
144:                                    pdsf);
145:                } else if (buttonPressed.startsWith("btnClear")) {
146:                    // Code to clear the form
147:                    session.removeAttribute("PaymentDetailSearchFormSession");
148:                    Boolean b = pdsf.getAdvancedSearch();
149:                    String oldDisbursementNbr = pdsf.getOldDisbursementNbr();
150:                    pdsf.clearForm();
151:                    pdsf.setOldDisbursementNbr(oldDisbursementNbr);
152:                    pdsf.setAdvancedSearch(b);
153:                } else if (buttonPressed.startsWith("btnBack")) {
154:                    pdsf = (PaymentDetailSearchForm) session
155:                            .getAttribute("PaymentDetailSearchFormSession");
156:                    if (pdsf != null) {
157:                        // Code to use BreadCrumb Links
158:                        PaymentDetailSearch pds = pdsf.getPaymentDetailSearch();
159:                        searchResults = paymentDetailSearchService
160:                                .getAllPaymentsForSearchCriteria(pds);
161:                        searchResults = checkList(searchResults, session,
162:                                actionErrors);
163:                    } else {
164:                        LOG
165:                                .info("executeLogic() PaymentDetailSearchForm 'pdsf' from session is null");
166:                        return mapping.findForward("pdp_session_timeout");
167:                    }
168:                } else if (buttonPressed.startsWith("btnUpdate")) {
169:                    pdsf = (PaymentDetailSearchForm) session
170:                            .getAttribute("PaymentDetailSearchFormSession");
171:                    session.removeAttribute("indivSearchResults");
172:                } else {
173:                    clearObjects(session, actionErrors);
174:                }
175:
176:                // If we had errors, save them.
177:                if (!actionErrors.isEmpty()) {
178:                    saveErrors(request, actionErrors);
179:                    for (Iterator iter = actionErrors.get(); iter.hasNext();) {
180:                        ActionMessage element = (ActionMessage) iter.next();
181:                        LOG.debug("executeLogic() ActionErrors Element = "
182:                                + element.getKey());
183:                    }
184:                }
185:
186:                request.setAttribute("PaymentDetailSearchForm", pdsf);
187:                return mapping.findForward(forward);
188:            }
189:
190:            /**
191:             * Clear stored session objects as well as actionErrors.
192:             * 
193:             * @param request
194:             * @return
195:             */
196:            protected void clearObjects(HttpSession session,
197:                    ActionMessages actionErrors) {
198:
199:                // Individual Search Variables in Session
200:                session.removeAttribute("indivSearchResults");
201:                session.removeAttribute("PaymentDetailSearchFormSession");
202:
203:                // Batch Search Variables in Session
204:                session.removeAttribute("batchSearchResults");
205:                session.removeAttribute("batchIndivSearchResults");
206:                session.removeAttribute("BatchDetail");
207:                session.removeAttribute("BatchSearchFormSession");
208:
209:                actionErrors.clear();
210:            }
211:
212:            /**
213:             * Takes in the list from Search & the Search Type and updates appropriate variables and the list itself.
214:             * 
215:             * @param request
216:             * @param searchResults
217:             * @param searchType
218:             * @return searchResults
219:             */
220:            protected List checkList(List searchResults, HttpSession session,
221:                    ActionMessages actionErrors) {
222:                session.removeAttribute("indivSearchResults");
223:                Integer searchSize = getMaxSearchTotal();
224:                int maxSize = searchSize.intValue() + 1;
225:                int returnSize = searchSize.intValue() - 1;
226:
227:                if (searchResults != null) {
228:                    LOG.debug("executeLogic() Search returned having found "
229:                            + searchResults.size() + " results");
230:                    if (searchResults.size() == 0) {
231:                        actionErrors.add("errors", new ActionMessage(
232:                                "PaymentSearchAction.emptyresults.invalid"));
233:                    } else if (searchResults.size() < maxSize) {
234:                        session.setAttribute("indivSearchResults",
235:                                searchResults);
236:                    } else {
237:                        actionErrors.add("errors", new ActionMessage(
238:                                "PaymentSearchAction.listover.invalid"));
239:                        session.setAttribute("indivSearchResults",
240:                                searchResults.subList(0, returnSize));
241:                    }
242:                } else {
243:                    actionErrors.add("errors", new ActionMessage(
244:                            "PaymentSearchAction.emptyresults.invalid"));
245:                }
246:                return searchResults;
247:            }
248:
249:            public void setPaymentDetailSearchService(
250:                    PaymentDetailSearchService p) {
251:                paymentDetailSearchService = p;
252:            }
253:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.