Source Code Cross Referenced for BatchSearchAction.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.util.Iterator;
023:        import java.util.List;
024:
025:        import javax.servlet.http.HttpServletRequest;
026:        import javax.servlet.http.HttpServletResponse;
027:        import javax.servlet.http.HttpSession;
028:
029:        import org.apache.struts.action.ActionErrors;
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.kuali.kfs.context.SpringContext;
035:        import org.kuali.kfs.service.ParameterService;
036:        import org.kuali.kfs.service.impl.ParameterConstants;
037:        import org.kuali.module.pdp.PdpConstants;
038:        import org.kuali.module.pdp.action.BaseAction;
039:        import org.kuali.module.pdp.bo.Batch;
040:        import org.kuali.module.pdp.bo.BatchSearch;
041:        import org.kuali.module.pdp.form.paymentsearch.BatchSearchForm;
042:        import org.kuali.module.pdp.service.BatchMaintenanceService;
043:        import org.kuali.module.pdp.service.BatchSearchService;
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 BatchSearchAction extends BaseAction {
051:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
052:                    .getLogger(BatchSearchAction.class);
053:
054:            private BatchSearchService batchSearchService;
055:            private BatchMaintenanceService batchMaintenanceService;
056:
057:            public BatchSearchAction() {
058:                setBatchSearchService(SpringContext
059:                        .getBean(BatchSearchService.class));
060:                setBatchMaintenanceService(SpringContext
061:                        .getBean(BatchMaintenanceService.class));
062:            }
063:
064:            protected boolean isAuthorized(ActionMapping mapping,
065:                    ActionForm form, HttpServletRequest request,
066:                    HttpServletResponse response) {
067:                SecurityRecord sr = getSecurityRecord(request);
068:                return sr.isLimitedViewRole() || sr.isViewAllRole()
069:                        || sr.isViewIdRole() || sr.isViewBankRole();
070:            }
071:
072:            protected ActionForward executeLogic(ActionMapping mapping,
073:                    ActionForm form, HttpServletRequest request,
074:                    HttpServletResponse response) throws Exception {
075:                LOG.info("executeLogic() starting");
076:                String forward = "search";
077:                HttpSession session = request.getSession();
078:                List searchResults = null;
079:                Object perPage = session.getAttribute("perPage");
080:                if ((perPage == null) || (perPage.toString() == "")) {
081:                    session.setAttribute("perPage", getSearchResultsPerPage());
082:                }
083:
084:                ActionErrors actionErrors = new ActionErrors();
085:                String buttonPressed = GeneralUtilities
086:                        .whichButtonWasPressed(request);
087:
088:                BatchSearchForm bsf = (BatchSearchForm) form;
089:                LOG.debug("executeLogic() bsf is " + bsf);
090:                LOG.debug("executeLogic() Type of search is Batch");
091:                LOG.debug("executeLogic() buttonPressed is " + buttonPressed);
092:
093:                if ((buttonPressed.endsWith("Hold"))
094:                        || (buttonPressed.endsWith("Cancel"))) {
095:                    // Code to display updated individual search results
096:                    LOG
097:                            .debug("executeLogic() Returned to Search from Update Screen");
098:                    session.removeAttribute("batchIndivSearchResults");
099:                    bsf = (BatchSearchForm) session
100:                            .getAttribute("BatchSearchFormSession");
101:                    if (bsf == null) {
102:                        LOG
103:                                .info("executeLogic() BatchSearchForm 'bsf' from session is null");
104:                        return mapping.findForward("pdp_session_timeout");
105:                    } else {
106:                        Batch btch = (Batch) session
107:                                .getAttribute("BatchDetail");
108:                        Integer bId = null;
109:                        if (btch != null) {
110:                            // If we still have the batch then get the payments in it again to update statuses
111:                            bId = btch.getId();
112:                            LOG
113:                                    .debug("executeLogic() Batch ID being tested is "
114:                                            + bId);
115:                            searchResults = batchSearchService
116:                                    .getAllSingleBatchPayments(bId);
117:                            searchResults = checkList(searchResults, session,
118:                                    "Indiv", actionErrors);
119:                            if (batchMaintenanceService
120:                                    .doBatchPaymentsHaveHeldStatus(bId)) {
121:                                request.setAttribute("allAreHeld", "true");
122:                            }
123:                            return mapping.findForward("batchdetail");
124:                        } else {
125:                            BatchSearch bs = bsf.getBatchSearch();
126:                            searchResults = batchSearchService
127:                                    .getAllBatchesForSearchCriteria(bs);
128:                            searchResults = checkList(searchResults, session,
129:                                    "", actionErrors);
130:                        }
131:                    }
132:                } else if (buttonPressed.startsWith("btnUpdate")) {
133:                    // Code to display updated individual search results
134:                    LOG
135:                            .debug("executeLogic() Returned to Search from Update Screen");
136:                    session.removeAttribute("batchIndivSearchResults");
137:                    bsf = (BatchSearchForm) session
138:                            .getAttribute("BatchSearchFormSession");
139:                    if (bsf.equals(null)) {
140:                        LOG
141:                                .info("executeLogic() BatchSearchForm 'bsf' from session is null");
142:                        return mapping.findForward("pdp_session_timeout");
143:                    } else {
144:                        Batch btch = (Batch) session
145:                                .getAttribute("BatchDetail");
146:                        Integer bId = null;
147:                        if (btch != null) {
148:                            // If we still have the batch then get the payments in it again to update statuses
149:                            bId = btch.getId();
150:                            LOG
151:                                    .debug("executeLogic() Batch ID being tested is "
152:                                            + bId);
153:                            searchResults = batchSearchService
154:                                    .getAllSingleBatchPayments(bId);
155:                            searchResults = checkList(searchResults, session,
156:                                    "Indiv", actionErrors);
157:                            if (batchMaintenanceService
158:                                    .doBatchPaymentsHaveHeldStatus(bId)) {
159:                                request.setAttribute("allAreHeld", "true");
160:                            }
161:                            return mapping.findForward("batchdetail");
162:                        } else {
163:                            BatchSearch bs = bsf.getBatchSearch();
164:                            searchResults = batchSearchService
165:                                    .getAllBatchesForSearchCriteria(bs);
166:                            searchResults = checkList(searchResults, session,
167:                                    "", actionErrors);
168:                        }
169:                    }
170:                } else {
171:                    if (buttonPressed.startsWith("btnSearch")) {
172:                        // Code for Searching for Batches
173:                        clearObjects(session, actionErrors);
174:                        BatchSearch bs = bsf.getBatchSearch();
175:                        searchResults = batchSearchService
176:                                .getAllBatchesForSearchCriteria(bs);
177:
178:                        searchResults = checkList(searchResults, session, "",
179:                                actionErrors);
180:                        session.setAttribute("BatchSearchFormSession", bsf);
181:                    } else if (buttonPressed.startsWith("btnBatchDetail")) {
182:                        session.removeAttribute("batchIndivSearchResults");
183:                        Integer bId = GeneralUtilities
184:                                .convertStringToInteger(request
185:                                        .getParameter("BatchId"));
186:                        List l = (List) session
187:                                .getAttribute("batchSearchResults");
188:
189:                        if (l == null) {
190:                            LOG
191:                                    .info("executeLogic() Batch Search Results variable 'l' from session is null");
192:                            return mapping.findForward("pdp_session_timeout");
193:                        } else {
194:                            if (bId == null) {
195:                                return mapping.findForward("pdp_system_error");
196:                            } else {
197:                                for (Iterator iter = l.iterator(); iter
198:                                        .hasNext();) {
199:                                    Batch element = (Batch) iter.next();
200:                                    if (element.getId().equals(bId)) {
201:                                        LOG
202:                                                .debug("executeLogic() Found Batch relating to batchId "
203:                                                        + bId);
204:                                        session.setAttribute("BatchDetail",
205:                                                element);
206:                                        LOG
207:                                                .debug("executeLogic() Batch contains "
208:                                                        + element
209:                                                                .getPaymentCount()
210:                                                        + " payment(s)");
211:                                    }
212:                                }
213:                                searchResults = batchSearchService
214:                                        .getAllSingleBatchPayments(bId);
215:                                searchResults = checkList(searchResults,
216:                                        session, "Indiv", actionErrors);
217:                                if (batchMaintenanceService
218:                                        .doBatchPaymentsHaveHeldStatus(bId)) {
219:                                    request.setAttribute("allAreHeld", "true");
220:                                }
221:                            }
222:                        }
223:                        return mapping.findForward("batchdetail");
224:                    } else if (buttonPressed.startsWith("btnBack")) {
225:                        bsf = (BatchSearchForm) session
226:                                .getAttribute("BatchSearchFormSession");
227:                        if (bsf != null) {
228:                            // Code to use BreadCrumb Links
229:                            if (buttonPressed.endsWith("Indiv")) {
230:                                return mapping.findForward("batchdetail");
231:                            }
232:                        } else {
233:                            LOG
234:                                    .info("executeLogic() BatchSearchForm 'bsf' from session is null");
235:                            return mapping.findForward("pdp_session_timeout");
236:                        }
237:                    } else if (buttonPressed.startsWith("btnClear")) {
238:                        // Code to clear the form
239:                        bsf.clearForm();
240:                        session.removeAttribute("BatchSearchFormSession");
241:                    } else {
242:                        clearObjects(session, actionErrors);
243:                    }
244:                }
245:
246:                // If we had errors, save them.
247:                if (!actionErrors.isEmpty()) {
248:                    saveErrors(request, actionErrors);
249:                    for (Iterator iter = actionErrors.get(); iter.hasNext();) {
250:                        ActionMessage element = (ActionMessage) iter.next();
251:                        LOG.debug("executeLogic() ActionErrors Element = "
252:                                + element.getKey());
253:                    }
254:                }
255:
256:                request.setAttribute("BatchSearchForm", bsf);
257:                return mapping.findForward(forward);
258:            }
259:
260:            /**
261:             * Clear stored session objects as well as actionErrors.
262:             * 
263:             * @param request
264:             * @return
265:             */
266:            protected void clearObjects(HttpSession session,
267:                    ActionErrors actionErrors) {
268:                // Individual Search Variables in Session
269:                session.removeAttribute("indivSearchResults");
270:                session.removeAttribute("PaymentDetailSearchFormSession");
271:
272:                // Batch Search Variables in Session
273:                session.removeAttribute("batchSearchResults");
274:                session.removeAttribute("batchIndivSearchResults");
275:                session.removeAttribute("BatchDetail");
276:                session.removeAttribute("BatchSearchFormSession");
277:
278:                actionErrors.clear();
279:            }
280:
281:            /**
282:             * Takes in the list from Search & the Search Type and updates appropriate variables and the list itself.
283:             * 
284:             * @param request
285:             * @param searchResults
286:             * @param searchType
287:             * @return searchResults
288:             */
289:            protected List checkList(List searchResults, HttpSession session,
290:                    String resultListType, ActionErrors actionErrors) {
291:                session.removeAttribute("batch" + resultListType
292:                        + "SearchResults");
293:                int searchSize = getMaxSearchTotal();
294:                int maxSize = searchSize + 1;
295:                int returnSize = searchSize - 1;
296:
297:                if (searchResults != null) {
298:                    LOG.debug("executeLogic() Search returned having found "
299:                            + searchResults.size() + " results");
300:                    if (searchResults.size() == 0) {
301:                        actionErrors.add("errors", new ActionMessage(
302:                                "BatchSearchAction.emptyresults.invalid"));
303:                    } else if (searchResults.size() < maxSize) {
304:                        session.setAttribute("batch" + resultListType
305:                                + "SearchResults", searchResults);
306:                    } else {
307:                        if (resultListType != "") {
308:                            session.setAttribute("batch" + resultListType
309:                                    + "SearchResults", searchResults);
310:                        } else {
311:                            actionErrors.add("errors", new ActionMessage(
312:                                    "BatchSearchAction.listover.invalid"));
313:                            session.setAttribute("batch" + resultListType
314:                                    + "SearchResults", searchResults.subList(0,
315:                                    returnSize));
316:                        }
317:                    }
318:                } else {
319:                    actionErrors.add("errors", new ActionMessage(
320:                            "BatchSearchAction.emptyresults.invalid"));
321:                }
322:                return searchResults;
323:            }
324:
325:            private int getSearchResultsPerPage() {
326:                return GeneralUtilities
327:                        .getParameterInteger(
328:                                SpringContext.getBean(ParameterService.class),
329:                                ParameterConstants.PRE_DISBURSEMENT_LOOKUP.class,
330:                                PdpConstants.ApplicationParameterKeys.SEARCH_RESULTS_PER_PAGE);
331:            }
332:
333:            private int getMaxSearchTotal() {
334:                return GeneralUtilities
335:                        .getParameterInteger(
336:                                SpringContext.getBean(ParameterService.class),
337:                                ParameterConstants.PRE_DISBURSEMENT_LOOKUP.class,
338:                                PdpConstants.ApplicationParameterKeys.SEARCH_RESULTS_TOTAL);
339:            }
340:
341:            public void setBatchSearchService(BatchSearchService b) {
342:                batchSearchService = b;
343:            }
344:
345:            /**
346:             * @param batchMaintenanceService The batchMaintenanceService to set.
347:             */
348:            public void setBatchMaintenanceService(
349:                    BatchMaintenanceService batchMaintenanceService) {
350:                this.batchMaintenanceService = batchMaintenanceService;
351:            }
352:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.