Source Code Cross Referenced for EmployeeFundingLookupableHelperServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » 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.labor.web.lookupable 
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:        package org.kuali.module.labor.web.lookupable;
017:
018:        import static org.kuali.module.labor.LaborConstants.BalanceInquiries.EMPLOYEE_FUNDING_EXPENSE_OBJECT_TYPE_CODE;
019:        import static org.kuali.module.labor.LaborConstants.BalanceInquiries.EMPLOYEE_FUNDING_NORMAL_OP_EXPENSE_OBJECT_TYPE_CODE;
020:
021:        import java.util.ArrayList;
022:        import java.util.Collection;
023:        import java.util.Collections;
024:        import java.util.Iterator;
025:        import java.util.List;
026:        import java.util.Map;
027:
028:        import org.apache.commons.lang.ArrayUtils;
029:        import org.apache.commons.lang.StringUtils;
030:        import org.kuali.core.bo.BusinessObject;
031:        import org.kuali.core.lookup.AbstractLookupableHelperServiceImpl;
032:        import org.kuali.core.lookup.CollectionIncomplete;
033:        import org.kuali.core.util.BeanPropertyComparator;
034:        import org.kuali.core.util.KualiDecimal;
035:        import org.kuali.kfs.KFSConstants;
036:        import org.kuali.kfs.KFSPropertyConstants;
037:        import org.kuali.module.gl.web.Constant;
038:        import org.kuali.module.labor.bo.EmployeeFunding;
039:        import org.kuali.module.labor.bo.LaborLedgerPendingEntry;
040:        import org.kuali.module.labor.service.LaborInquiryOptionsService;
041:        import org.kuali.module.labor.service.LaborLedgerBalanceService;
042:        import org.kuali.module.labor.service.LaborLedgerPendingEntryService;
043:        import org.kuali.module.labor.util.DebitCreditUtil;
044:        import org.kuali.module.labor.util.ObjectUtil;
045:        import org.kuali.module.labor.web.inquirable.EmployeeFundingInquirableImpl;
046:        import org.springframework.transaction.annotation.Transactional;
047:
048:        /**
049:         * The EmployeeFundingLookupableHelperServiceImpl class is the front-end for all Employee Funding balance inquiry processing.
050:         */
051:        @Transactional
052:        public class EmployeeFundingLookupableHelperServiceImpl extends
053:                AbstractLookupableHelperServiceImpl {
054:            private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
055:                    .getLog(EmployeeFundingLookupableHelperServiceImpl.class);
056:
057:            private LaborLedgerBalanceService laborLedgerBalanceService;
058:            private LaborInquiryOptionsService laborInquiryOptionsService;
059:            private LaborLedgerPendingEntryService laborLedgerPendingEntryService;
060:
061:            /**
062:             * @see org.kuali.core.lookup.Lookupable#getInquiryUrl(org.kuali.core.bo.BusinessObject, java.lang.String)
063:             */
064:            @Override
065:            public String getInquiryUrl(BusinessObject bo, String propertyName) {
066:                return (new EmployeeFundingInquirableImpl()).getInquiryUrl(bo,
067:                        propertyName);
068:            }
069:
070:            /**
071:             * @see org.kuali.core.lookup.Lookupable#gfetSearchResults(java.util.Map)
072:             */
073:            @Override
074:            public List getSearchResults(Map fieldValues) {
075:                setBackLocation((String) fieldValues
076:                        .get(KFSConstants.BACK_LOCATION));
077:                setDocFormKey((String) fieldValues
078:                        .get(KFSConstants.DOC_FORM_KEY));
079:
080:                // get the pending entry option. This method must be prior to the get search results
081:                String pendingEntryOption = laborInquiryOptionsService
082:                        .getSelectedPendingEntryOption(fieldValues);
083:
084:                // test if the consolidation option is selected or not
085:                boolean isConsolidated = false;
086:
087:                Collection<EmployeeFunding> searchResultsCollection = laborLedgerBalanceService
088:                        .findEmployeeFundingWithCSFTracker(fieldValues,
089:                                isConsolidated);
090:
091:                // update search results according to the selected pending entry option
092:                updateByPendingLedgerEntry(searchResultsCollection,
093:                        fieldValues, pendingEntryOption, isConsolidated);
094:
095:                // get the actual size of all qualified search results
096:                Long actualSize = new Long(searchResultsCollection.size());
097:
098:                return this .buildSearchResultList(searchResultsCollection,
099:                        actualSize);
100:            }
101:
102:            /**
103:             * build the serach result list from the given collection and the number of all qualified search results
104:             * 
105:             * @param searchResultsCollection the given search results, which may be a subset of the qualified search results
106:             * @param actualSize the number of all qualified search results
107:             * @return the serach result list with the given results and actual size
108:             */
109:            protected List buildSearchResultList(
110:                    Collection searchResultsCollection, Long actualSize) {
111:                CollectionIncomplete results = new CollectionIncomplete(
112:                        searchResultsCollection, actualSize);
113:
114:                // sort list if default sort column given
115:                List searchResults = (List) results;
116:                List defaultSortColumns = getDefaultSortColumns();
117:                if (defaultSortColumns.size() > 0) {
118:                    Collections.sort(results, new BeanPropertyComparator(
119:                            defaultSortColumns, true));
120:                }
121:                return searchResults;
122:            }
123:
124:            /**
125:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#updateByPendingLedgerEntry(java.util.Collection,
126:             *      java.util.Map, java.lang.String, boolean)
127:             */
128:            public void updateByPendingLedgerEntry(Collection entryCollection,
129:                    Map fieldValues, String pendingEntryOption,
130:                    boolean isConsolidated) {
131:
132:                // determine if search results need to be updated by pending ledger entries
133:                if (Constant.ALL_PENDING_ENTRY.equals(pendingEntryOption)) {
134:                    updateEntryCollection(entryCollection, fieldValues, false,
135:                            isConsolidated);
136:                } else if (Constant.APPROVED_PENDING_ENTRY
137:                        .equals(pendingEntryOption)) {
138:                    updateEntryCollection(entryCollection, fieldValues, true,
139:                            isConsolidated);
140:                }
141:            }
142:
143:            /**
144:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#updateEntryCollection(java.util.Collection, java.util.Map,
145:             *      boolean, boolean)
146:             */
147:            public void updateEntryCollection(Collection entryCollection,
148:                    Map fieldValues, boolean isApproved, boolean isConsolidated) {
149:                // go through the pending entries to update the balance collection
150:                Iterator<LaborLedgerPendingEntry> pendingEntryIterator = laborLedgerPendingEntryService
151:                        .findPendingLedgerEntriesForLedgerBalance(fieldValues,
152:                                isApproved);
153:
154:                while (pendingEntryIterator.hasNext()) {
155:                    LaborLedgerPendingEntry pendingEntry = pendingEntryIterator
156:                            .next();
157:
158:                    if (!isEmployeeFunding(pendingEntry)) {
159:                        continue;
160:                    }
161:
162:                    // if consolidated, change the following fields into the default values for consolidation
163:                    if (isConsolidated) {
164:                        pendingEntry
165:                                .setSubAccountNumber(Constant.CONSOLIDATED_SUB_ACCOUNT_NUMBER);
166:                        pendingEntry
167:                                .setFinancialSubObjectCode(Constant.CONSOLIDATED_SUB_OBJECT_CODE);
168:                        pendingEntry
169:                                .setFinancialObjectTypeCode(Constant.CONSOLIDATED_OBJECT_TYPE_CODE);
170:                    }
171:
172:                    EmployeeFunding ledgerBalance = (EmployeeFunding) laborLedgerBalanceService
173:                            .findLedgerBalance(entryCollection, pendingEntry,
174:                                    getKeyList());
175:                    if (ledgerBalance == null) {
176:                        ledgerBalance = new EmployeeFunding();
177:                        ObjectUtil.buildObject(ledgerBalance, pendingEntry);
178:                        entryCollection.add(ledgerBalance);
179:                    } else {
180:                        laborLedgerBalanceService.updateLedgerBalance(
181:                                ledgerBalance, pendingEntry);
182:                    }
183:                    updateAmount(ledgerBalance, pendingEntry);
184:                }
185:            }
186:
187:            /**
188:             * update the amount of the given employee funding with the given pending entry
189:             * 
190:             * @param employeeFunding the given employee funding
191:             * @param pendingEntry the given pending entry
192:             */
193:            private void updateAmount(EmployeeFunding employeeFunding,
194:                    LaborLedgerPendingEntry pendingEntry) {
195:                String balanceTypeCode = pendingEntry
196:                        .getFinancialBalanceTypeCode();
197:                String debitCreditCode = pendingEntry
198:                        .getTransactionDebitCreditCode();
199:                KualiDecimal amount = DebitCreditUtil.getNumericAmount(
200:                        pendingEntry.getTransactionLedgerEntryAmount(),
201:                        pendingEntry.getTransactionDebitCreditCode());
202:
203:                if (StringUtils.equals(balanceTypeCode,
204:                        KFSConstants.BALANCE_TYPE_ACTUAL)) {
205:                    employeeFunding.setCurrentAmount(amount.add(employeeFunding
206:                            .getCurrentAmount()));
207:                } else if (StringUtils.equals(balanceTypeCode,
208:                        KFSConstants.BALANCE_TYPE_INTERNAL_ENCUMBRANCE)) {
209:                    employeeFunding.setOutstandingEncumbrance(amount
210:                            .add(employeeFunding.getOutstandingEncumbrance()));
211:                }
212:            }
213:
214:            /**
215:             * determine whether the given pending entry is qualified to be processed as an employee funding
216:             * 
217:             * @param pendingEntry the given pending entry
218:             * @return true if the given pending entry is qualified to be processed as an employee funding; otherwise, false
219:             */
220:            private boolean isEmployeeFunding(
221:                    LaborLedgerPendingEntry pendingEntry) {
222:                String balanceTypeCode = pendingEntry
223:                        .getFinancialBalanceTypeCode();
224:
225:                if (StringUtils.equals(balanceTypeCode,
226:                        KFSConstants.BALANCE_TYPE_ACTUAL)) {
227:                    String objectTypeCode = pendingEntry
228:                            .getFinancialObjectTypeCode();
229:                    String[] objectTypeCodes = {
230:                            EMPLOYEE_FUNDING_EXPENSE_OBJECT_TYPE_CODE,
231:                            EMPLOYEE_FUNDING_NORMAL_OP_EXPENSE_OBJECT_TYPE_CODE };
232:
233:                    return ArrayUtils.contains(objectTypeCodes, objectTypeCode) ? true
234:                            : false;
235:                }
236:
237:                if (StringUtils.equals(balanceTypeCode,
238:                        KFSConstants.BALANCE_TYPE_INTERNAL_ENCUMBRANCE)) {
239:                    return true;
240:                }
241:
242:                return false;
243:            }
244:
245:            /**
246:             * construct the primary key list of the business object
247:             * 
248:             * @return the primary key list of the business object
249:             */
250:            private List<String> getKeyList() {
251:                List<String> keyList = new ArrayList<String>();
252:                keyList.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
253:                keyList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
254:                keyList.add(KFSPropertyConstants.ACCOUNT_NUMBER);
255:                keyList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
256:                keyList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
257:                keyList.add(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
258:                keyList.add(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE);
259:                keyList.add(KFSPropertyConstants.POSITION_NUMBER);
260:                keyList.add(KFSPropertyConstants.EMPLID);
261:                return keyList;
262:            }
263:
264:            /**
265:             * Sets the laborLedgerBalanceService attribute value.
266:             * 
267:             * @param laborLedgerBalanceService The laborLedgerBalanceService to set.
268:             */
269:            public void setLaborLedgerBalanceService(
270:                    LaborLedgerBalanceService laborLedgerBalanceService) {
271:                this .laborLedgerBalanceService = laborLedgerBalanceService;
272:            }
273:
274:            /**
275:             * Sets the laborInquiryOptionsService attribute value.
276:             * 
277:             * @param laborInquiryOptionsService The laborInquiryOptionsService to set.
278:             */
279:            public void setLaborInquiryOptionsService(
280:                    LaborInquiryOptionsService laborInquiryOptionsService) {
281:                this .laborInquiryOptionsService = laborInquiryOptionsService;
282:            }
283:
284:            /**
285:             * Sets the laborLedgerPendingEntryService attribute value.
286:             * 
287:             * @param laborLedgerPendingEntryService The laborLedgerPendingEntryService to set.
288:             */
289:            public void setLaborLedgerPendingEntryService(
290:                    LaborLedgerPendingEntryService laborLedgerPendingEntryService) {
291:                this.laborLedgerPendingEntryService = laborLedgerPendingEntryService;
292:            }
293:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.