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


001:        /*
002:         * Copyright 2006-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:        package org.kuali.module.gl.web.lookupable;
017:
018:        import java.sql.Date;
019:        import java.util.Collection;
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import org.apache.commons.lang.StringUtils;
025:        import org.kuali.core.bo.BusinessObject;
026:        import org.kuali.core.exceptions.ValidationException;
027:        import org.kuali.core.service.DateTimeService;
028:        import org.kuali.core.util.GlobalVariables;
029:        import org.kuali.kfs.KFSConstants;
030:        import org.kuali.kfs.KFSKeyConstants;
031:        import org.kuali.kfs.KFSPropertyConstants;
032:        import org.kuali.kfs.bo.GeneralLedgerPendingEntry;
033:        import org.kuali.kfs.context.SpringContext;
034:        import org.kuali.module.financial.service.UniversityDateService;
035:        import org.kuali.module.gl.bo.Entry;
036:        import org.kuali.module.gl.bo.UniversityDate;
037:        import org.kuali.module.gl.service.EntryService;
038:        import org.kuali.module.gl.service.ScrubberValidator;
039:        import org.kuali.module.gl.util.BusinessObjectFieldConverter;
040:        import org.kuali.module.gl.web.Constant;
041:        import org.kuali.module.gl.web.inquirable.EntryInquirableImpl;
042:        import org.kuali.module.gl.web.inquirable.InquirableFinancialDocument;
043:        import org.springframework.transaction.annotation.Transactional;
044:
045:        /**
046:         * An extension of KualiLookupableImpl to support entry lookups
047:         */
048:        @Transactional
049:        public class EntryLookupableHelperServiceImpl extends
050:                AbstractGLLookupableHelperServiceImpl {
051:            private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
052:                    .getLogger(EntryLookupableHelperServiceImpl.class);
053:
054:            private ScrubberValidator scrubberValidator;
055:            private EntryService entryService;
056:
057:            /**
058:             * Validate the university fiscal year that has been queried on
059:             * 
060:             * @param fieldValues the queried fields
061:             * @see org.kuali.core.lookup.AbstractLookupableHelperServiceImpl#validateSearchParameters(java.util.Map)
062:             */
063:            @Override
064:            public void validateSearchParameters(Map fieldValues) {
065:                super .validateSearchParameters(fieldValues);
066:
067:                String valueFiscalYear = (String) fieldValues
068:                        .get("universityFiscalYear");
069:                if (!StringUtils.isEmpty(valueFiscalYear)) {
070:                    try {
071:                        int year = Integer.parseInt(valueFiscalYear);
072:                    } catch (NumberFormatException e) {
073:                        GlobalVariables
074:                                .getErrorMap()
075:                                .putError(
076:                                        "universityFiscalYear",
077:                                        KFSKeyConstants.ERROR_CUSTOM,
078:                                        new String[] { "Fiscal Year must be a four-digit number" });
079:                        throw new ValidationException(
080:                                "errors in search criteria");
081:                    }
082:                }
083:            }
084:
085:            /**
086:             * Returns the url for any drill down links within the lookup
087:             * @param bo the business object with a property being drilled down on
088:             * @param propertyName the name of the property being drilled down on
089:             * @return a String with the URL of the property
090:             * @see org.kuali.core.lookup.Lookupable#getInquiryUrl(org.kuali.core.bo.BusinessObject, java.lang.String)
091:             */
092:            @Override
093:            public String getInquiryUrl(BusinessObject businessObject,
094:                    String propertyName) {
095:                if (KFSPropertyConstants.DOCUMENT_NUMBER.equals(propertyName)) {
096:                    if (businessObject instanceof  Entry) {
097:                        Entry entry = (Entry) businessObject;
098:                        return new InquirableFinancialDocument()
099:                                .getInquirableDocumentUrl(entry);
100:                    }
101:                }
102:                return (new EntryInquirableImpl()).getInquiryUrl(
103:                        businessObject, propertyName);
104:            }
105:
106:            /**
107:             * Generates the list of search results for this inquiry
108:             * @param fieldValues the field values of the query to carry out
109:             * @return List the search results returned by the lookup
110:             * @see org.kuali.core.lookup.Lookupable#getSearchResults(java.util.Map)
111:             */
112:            @Override
113:            public List getSearchResults(Map fieldValues) {
114:                setBackLocation((String) fieldValues
115:                        .get(KFSConstants.BACK_LOCATION));
116:                setDocFormKey((String) fieldValues
117:                        .get(KFSConstants.DOC_FORM_KEY));
118:
119:                // get the pending entry option. This method must be prior to the get search results
120:                String pendingEntryOption = this 
121:                        .getSelectedPendingEntryOption(fieldValues);
122:
123:                // get the search result collection
124:                Collection searchResultsCollection = getLookupService()
125:                        .findCollectionBySearch(getBusinessObjectClass(),
126:                                fieldValues);
127:
128:                // update search results according to the selected pending entry option
129:                updateByPendingLedgerEntry(searchResultsCollection,
130:                        fieldValues, pendingEntryOption, false, false);
131:
132:                // get the actual size of all qualified search results
133:                Long actualSize = new Long(entryService
134:                        .getEntryRecordCount(fieldValues));
135:
136:                return this .buildSearchResultList(searchResultsCollection,
137:                        actualSize);
138:            }
139:
140:            /**
141:             * Updates pending entries before their results are included in the lookup results
142:             * 
143:             * @param entryCollection a collection of balance entries
144:             * @param fieldValues the map containing the search fields and values
145:             * @param isApproved flag whether the approved entries or all entries will be processed
146:             * @param isConsolidated flag whether the results are consolidated or not
147:             * @param isCostShareExcluded flag whether the user selects to see the results with cost share subaccount
148:             * @see org.kuali.module.gl.web.lookupable.AbstractGLLookupableImpl#updateEntryCollection(java.util.Collection, java.util.Map,
149:             *      boolean, boolean, boolean)
150:             */
151:            @Override
152:            protected void updateEntryCollection(Collection entryCollection,
153:                    Map fieldValues, boolean isApproved,
154:                    boolean isConsolidated, boolean isCostShareInclusive) {
155:                LOG.debug("updateEntryCollection started");
156:
157:                // convert the field names of balance object into corresponding ones of pending entry object
158:                Map pendingEntryFieldValues = BusinessObjectFieldConverter
159:                        .convertToTransactionFieldValues(fieldValues);
160:
161:                // go through the pending entries to update the balance collection
162:                Iterator pendingEntryIterator = getGeneralLedgerPendingEntryService()
163:                        .findPendingLedgerEntriesForEntry(
164:                                pendingEntryFieldValues, isApproved);
165:
166:                String pendingOption = isApproved ? Constant.APPROVED_PENDING_ENTRY
167:                        : Constant.ALL_PENDING_ENTRY;
168:                UniversityDate today = SpringContext.getBean(
169:                        UniversityDateService.class).getCurrentUniversityDate();
170:                String currentFiscalPeriodCode = today
171:                        .getUniversityFiscalAccountingPeriod();
172:                Integer currentFiscalYear = today.getUniversityFiscalYear();
173:                Date postDate = SpringContext.getBean(DateTimeService.class)
174:                        .getCurrentSqlDate();
175:
176:                while (pendingEntryIterator.hasNext()) {
177:                    GeneralLedgerPendingEntry pendingEntry = (GeneralLedgerPendingEntry) pendingEntryIterator
178:                            .next();
179:
180:                    // Gotta circumvent date checks in the scrubberValidator. They totally kill performance.
181:                    if (pendingEntry.getUniversityFiscalYear() == null) {
182:                        pendingEntry.setUniversityFiscalYear(currentFiscalYear);
183:                    }
184:
185:                    if (pendingEntry.getUniversityFiscalPeriodCode() == null) {
186:                        pendingEntry
187:                                .setUniversityFiscalPeriodCode(currentFiscalPeriodCode);
188:                    }
189:
190:                    scrubberValidator.validateForInquiry(pendingEntry);
191:                    entryCollection.add(new Entry(pendingEntry, postDate));
192:                }
193:            }
194:
195:            /**
196:             * Sets the scrubberValidator attribute value.
197:             * 
198:             * @param scrubberValidator The scrubberValidator to set.
199:             */
200:            public void setScrubberValidator(ScrubberValidator scrubberValidator) {
201:                this .scrubberValidator = scrubberValidator;
202:            }
203:
204:            /**
205:             * Sets the entryService attribute value.
206:             * 
207:             * @param entryService The entryService to set.
208:             */
209:            public void setEntryService(EntryService entryService) {
210:                this.entryService = entryService;
211:            }
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.