Source Code Cross Referenced for LaborInquiryOptionsServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » service » impl » 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.service.impl 
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.service.impl;
017:
018:        import java.util.Collection;
019:        import java.util.Iterator;
020:        import java.util.Map;
021:
022:        import org.apache.commons.lang.StringUtils;
023:        import org.kuali.core.web.ui.Field;
024:        import org.kuali.core.web.ui.Row;
025:        import org.kuali.kfs.KFSPropertyConstants;
026:        import org.kuali.module.gl.web.Constant;
027:        import org.kuali.module.labor.bo.AccountStatusCurrentFunds;
028:        import org.kuali.module.labor.bo.LaborLedgerPendingEntry;
029:        import org.kuali.module.labor.bo.LedgerBalance;
030:        import org.kuali.module.labor.bo.LedgerEntry;
031:        import org.kuali.module.labor.service.LaborInquiryOptionsService;
032:        import org.kuali.module.labor.service.LaborLedgerBalanceService;
033:        import org.kuali.module.labor.service.LaborLedgerPendingEntryService;
034:        import org.kuali.module.labor.util.ObjectUtil;
035:        import org.springframework.transaction.annotation.Transactional;
036:
037:        /**
038:         * The LaborInquiryOptionsService class is a service that will generate Pending Ledger and Consilidation options for balance
039:         * inquiries.
040:         */
041:        @Transactional
042:        public class LaborInquiryOptionsServiceImpl implements 
043:                LaborInquiryOptionsService {
044:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
045:                    .getLogger(LaborInquiryOptionsServiceImpl.class);
046:
047:            private LaborLedgerPendingEntryService laborLedgerPendingEntryService;
048:            private LaborLedgerBalanceService laborLedgerBalanceService;
049:
050:            /**
051:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#getConsolidationFieldName()
052:             */
053:            public String getConsolidationFieldName() {
054:                return Constant.CONSOLIDATION_OPTION;
055:            }
056:
057:            /**
058:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#getConsolidationField(java.util.Collection)
059:             */
060:            public Field getConsolidationField(Collection<Row> rows) {
061:                for (Row row : rows) {
062:                    for (Field field : ((Collection<Field>) row.getFields())) {
063:                        if (field.getPropertyName().equals(
064:                                getConsolidationFieldName())) {
065:                            return field;
066:                        }
067:                    }
068:                }
069:                return null;
070:            }
071:
072:            /**
073:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#getSelectedPendingEntryOption(java.util.Map)
074:             */
075:            public String getSelectedPendingEntryOption(Map fieldValues) {
076:                // truncate the non-property filed
077:                String pendingEntryOption = (String) fieldValues
078:                        .get(Constant.PENDING_ENTRY_OPTION);
079:                fieldValues.remove(Constant.PENDING_ENTRY_OPTION);
080:
081:                return pendingEntryOption;
082:            }
083:
084:            /**
085:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#getConsolidationOption(java.util.Map)
086:             */
087:            public String getConsolidationOption(Map fieldValues) {
088:                String consolidationOption = (String) fieldValues
089:                        .get(getConsolidationFieldName());
090:                // truncate the non-property filed
091:                fieldValues.remove(getConsolidationFieldName());
092:                return consolidationOption;
093:            }
094:
095:            /**
096:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#isConsolidationSelected(java.util.Map, java.util.Collection)
097:             */
098:            public boolean isConsolidationSelected(Map fieldValues,
099:                    Collection<Row> rows) {
100:                boolean isConsolidationSelected = isConsolidationSelected(fieldValues);
101:
102:                if (!isConsolidationSelected) {
103:                    Field consolidationField = getConsolidationField(rows);
104:                    consolidationField.setPropertyValue(Constant.DETAIL);
105:                }
106:                return isConsolidationSelected;
107:            }
108:
109:            /**
110:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#isConsolidationSelected(java.util.Map)
111:             */
112:            public boolean isConsolidationSelected(Map fieldValues) {
113:                String consolidationOption = getConsolidationOption(fieldValues);
114:
115:                // detail option would be used
116:                if (Constant.DETAIL.equals(consolidationOption)) {
117:                    return false;
118:                }
119:
120:                // if the subAccountNumber is specified, detail option could be used
121:                // if the subObjectCode is specified, detail option could be used
122:                // if the objectTypeCode is specified, detail option could be used
123:                if (isDetailDefaultFieldUsed(fieldValues,
124:                        KFSPropertyConstants.SUB_ACCOUNT_NUMBER)
125:                        || isDetailDefaultFieldUsed(fieldValues,
126:                                KFSPropertyConstants.SUB_OBJECT_CODE)
127:                        || isDetailDefaultFieldUsed(fieldValues,
128:                                KFSPropertyConstants.OBJECT_TYPE_CODE)) {
129:                    return false;
130:                }
131:                return true;
132:            }
133:
134:            /**
135:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#updateLedgerBalanceByPendingLedgerEntry(java.util.Collection,
136:             *      java.util.Map, java.lang.String, boolean)
137:             */
138:            public void updateLedgerBalanceByPendingLedgerEntry(
139:                    Collection<LedgerBalance> balanceCollection,
140:                    Map fieldValues, String pendingEntryOption,
141:                    boolean isConsolidated) {
142:                // determine if search results need to be updated by pending ledger entries
143:                if (Constant.ALL_PENDING_ENTRY.equals(pendingEntryOption)) {
144:                    updateCollection(balanceCollection, fieldValues, false,
145:                            isConsolidated, LedgerBalance.class);
146:                } else if (Constant.APPROVED_PENDING_ENTRY
147:                        .equals(pendingEntryOption)) {
148:                    updateCollection(balanceCollection, fieldValues, true,
149:                            isConsolidated, LedgerBalance.class);
150:                }
151:            }
152:
153:            /**
154:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#updateCurrentFundsByPendingLedgerEntry(java.util.Collection,
155:             *      java.util.Map, java.lang.String, boolean)
156:             */
157:            public void updateCurrentFundsByPendingLedgerEntry(
158:                    Collection<AccountStatusCurrentFunds> balanceCollection,
159:                    Map fieldValues, String pendingEntryOption,
160:                    boolean isConsolidated) {
161:                // determine if search results need to be updated by pending ledger entries
162:                if (Constant.ALL_PENDING_ENTRY.equals(pendingEntryOption)) {
163:                    updateCollection(balanceCollection, fieldValues, false,
164:                            isConsolidated, AccountStatusCurrentFunds.class);
165:                } else if (Constant.APPROVED_PENDING_ENTRY
166:                        .equals(pendingEntryOption)) {
167:                    updateCollection(balanceCollection, fieldValues, true,
168:                            isConsolidated, AccountStatusCurrentFunds.class);
169:                }
170:            }
171:
172:            /**
173:             * @see org.kuali.module.labor.service.LaborInquiryOptionsService#updateByPendingLedgerEntry(java.util.Collection,
174:             *      java.util.Map, java.lang.String, boolean)
175:             */
176:            public void updateLedgerEntryByPendingLedgerEntry(
177:                    Collection<LedgerEntry> entryCollection, Map fieldValues,
178:                    String pendingEntryOption) {
179:                // determine if search results need to be updated by pending ledger entries
180:                if (Constant.ALL_PENDING_ENTRY.equals(pendingEntryOption)) {
181:                    updateCollection(entryCollection, fieldValues, false,
182:                            false, LedgerEntry.class);
183:                } else if (Constant.APPROVED_PENDING_ENTRY
184:                        .equals(pendingEntryOption)) {
185:                    updateCollection(entryCollection, fieldValues, true, false,
186:                            LedgerEntry.class);
187:                }
188:            }
189:
190:            /**
191:             * update a given collection entry with the pending entry obtained from the given field values and isApproved
192:             * 
193:             * @param entryCollection the given entry collection
194:             * @param fieldValues the given field values
195:             * @param isApproved indicate if the resulting pending entry has been approved
196:             * @param isConsolidated indicate if the collection entries have been consolidated
197:             */
198:            private void updateCollection(Collection entryCollection,
199:                    Map fieldValues, boolean isApproved,
200:                    boolean isConsolidated, Class clazz) {
201:                // go through the pending entries to update the balance collection
202:                Iterator<LaborLedgerPendingEntry> pendingEntryIterator = laborLedgerPendingEntryService
203:                        .findPendingLedgerEntriesForLedgerBalance(fieldValues,
204:                                isApproved);
205:
206:                while (pendingEntryIterator.hasNext()) {
207:                    LaborLedgerPendingEntry pendingEntry = pendingEntryIterator
208:                            .next();
209:
210:                    // if consolidated, change the following fields into the default values for consolidation
211:                    if (isConsolidated) {
212:                        pendingEntry
213:                                .setSubAccountNumber(Constant.CONSOLIDATED_SUB_ACCOUNT_NUMBER);
214:                        pendingEntry
215:                                .setFinancialSubObjectCode(Constant.CONSOLIDATED_SUB_OBJECT_CODE);
216:                        pendingEntry
217:                                .setFinancialObjectTypeCode(Constant.CONSOLIDATED_OBJECT_TYPE_CODE);
218:                    }
219:
220:                    if (LedgerBalance.class.isAssignableFrom(clazz)) {
221:                        try {
222:                            LedgerBalance ledgerBalance = laborLedgerBalanceService
223:                                    .findLedgerBalance(entryCollection,
224:                                            pendingEntry);
225:                            if (ledgerBalance == null) {
226:
227:                                Object newLedgerBalance = clazz.newInstance();
228:                                ObjectUtil.buildObject(newLedgerBalance,
229:                                        pendingEntry);
230:
231:                                ledgerBalance = (LedgerBalance) newLedgerBalance;
232:                                entryCollection.add(ledgerBalance);
233:                            }
234:                            laborLedgerBalanceService.updateLedgerBalance(
235:                                    ledgerBalance, pendingEntry);
236:                            ledgerBalance
237:                                    .getDummyBusinessObject()
238:                                    .setConsolidationOption(
239:                                            isConsolidated ? Constant.CONSOLIDATION
240:                                                    : Constant.DETAIL);
241:                            ledgerBalance
242:                                    .getDummyBusinessObject()
243:                                    .setPendingEntryOption(
244:                                            isApproved ? Constant.APPROVED_PENDING_ENTRY
245:                                                    : Constant.ALL_PENDING_ENTRY);
246:                        } catch (Exception e) {
247:                            LOG.error("cannot create a new object of type: "
248:                                    + clazz.getName() + "/n" + e);
249:                        }
250:                    } else if (LedgerEntry.class.isAssignableFrom(clazz)) {
251:                        LedgerEntry ledgerEntry = new LedgerEntry();
252:                        ObjectUtil.buildObject(ledgerEntry, pendingEntry);
253:
254:                        ledgerEntry.getDummyBusinessObject()
255:                                .setConsolidationOption(
256:                                        isConsolidated ? Constant.CONSOLIDATION
257:                                                : Constant.DETAIL);
258:                        ledgerEntry
259:                                .getDummyBusinessObject()
260:                                .setPendingEntryOption(
261:                                        isApproved ? Constant.APPROVED_PENDING_ENTRY
262:                                                : Constant.ALL_PENDING_ENTRY);
263:
264:                        entryCollection.add(ledgerEntry);
265:                    } else {
266:                        LOG.warn("The class, " + clazz.getName()
267:                                + ", is unregistered with the method.");
268:                        return;
269:                    }
270:                }
271:            }
272:
273:            /**
274:             * Determines if any of the fields that require a detail view are used
275:             * 
276:             * @param fieldValues
277:             * @param fieldName
278:             */
279:            private boolean isDetailDefaultFieldUsed(Map fieldValues,
280:                    String fieldName) {
281:                return StringUtils.isNotBlank((String) fieldValues
282:                        .get(fieldName));
283:            }
284:
285:            /**
286:             * Sets the laborLedgerBalanceService attribute value.
287:             * 
288:             * @param laborLedgerBalanceService The laborLedgerBalanceService to set.
289:             */
290:            public void setLaborLedgerBalanceService(
291:                    LaborLedgerBalanceService laborLedgerBalanceService) {
292:                this .laborLedgerBalanceService = laborLedgerBalanceService;
293:            }
294:
295:            /**
296:             * Sets the laborLedgerPendingEntryService attribute value.
297:             * 
298:             * @param laborLedgerPendingEntryService The laborLedgerPendingEntryService to set.
299:             */
300:            public void setLaborLedgerPendingEntryService(
301:                    LaborLedgerPendingEntryService laborLedgerPendingEntryService) {
302:                this.laborLedgerPendingEntryService = laborLedgerPendingEntryService;
303:            }
304:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.