Source Code Cross Referenced for LaborLedgerPendingEntryServiceImpl.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 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.labor.service.impl;
017:
018:        import java.util.Collection;
019:        import java.util.HashMap;
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import org.kuali.core.service.BusinessObjectService;
025:        import org.kuali.core.service.KualiRuleService;
026:        import org.kuali.core.service.LookupService;
027:        import org.kuali.core.util.GeneralLedgerPendingEntrySequenceHelper;
028:        import org.kuali.kfs.KFSConstants;
029:        import org.kuali.kfs.bo.AccountingLine;
030:        import org.kuali.kfs.context.SpringContext;
031:        import org.kuali.module.chart.bo.Account;
032:        import org.kuali.module.labor.bo.LaborLedgerPendingEntry;
033:        import org.kuali.module.labor.dao.LaborLedgerPendingEntryDao;
034:        import org.kuali.module.labor.document.LaborLedgerPostingDocument;
035:        import org.kuali.module.labor.rule.event.GenerateLaborLedgerBenefitClearingPendingEntriesEvent;
036:        import org.kuali.module.labor.rule.event.GenerateLaborLedgerPendingEntriesEvent;
037:        import org.kuali.module.labor.service.LaborLedgerPendingEntryService;
038:        import org.springframework.transaction.annotation.Transactional;
039:
040:        /**
041:         * Service implementation of LaborLedgerPendingEntryService.
042:         */
043:        @Transactional
044:        public class LaborLedgerPendingEntryServiceImpl implements 
045:                LaborLedgerPendingEntryService {
046:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
047:                    .getLogger(LaborLedgerPendingEntryServiceImpl.class);
048:
049:            private LaborLedgerPendingEntryDao laborLedgerPendingEntryDao;
050:            private KualiRuleService kualiRuleService;
051:            private BusinessObjectService businessObjectService;
052:
053:            /**
054:             * @see org.kuali.module.labor.service.LaborLedgerPendingEntryService#hasPendingLaborLedgerEntry(org.kuali.module.chart.bo.Account)
055:             */
056:            public boolean hasPendingLaborLedgerEntry(Account account) {
057:                Map fieldValues = new HashMap();
058:                fieldValues.put("chartOfAccountsCode", account
059:                        .getChartOfAccountsCode());
060:                fieldValues.put("accountNumber", account.getAccountNumber());
061:
062:                return businessObjectService.countMatching(
063:                        LaborLedgerPendingEntry.class, fieldValues) > 0;
064:            }
065:
066:            /**
067:             * @see org.kuali.module.labor.service.LaborLedgerPendingEntryService#hasPendingLaborLedgerEntry(java.util.Map)
068:             */
069:            public boolean hasPendingLaborLedgerEntry(Map fieldValues) {
070:                LOG.info("hasPendingLaborLedgerEntry(Map fieldValues) started");
071:
072:                Collection<LaborLedgerPendingEntry> pendingEntries = SpringContext
073:                        .getBean(LookupService.class).findCollectionBySearch(
074:                                LaborLedgerPendingEntry.class, fieldValues);
075:
076:                // exclude the pending labor ledger transaction has been processed
077:                for (LaborLedgerPendingEntry pendingLedgerEntry : pendingEntries) {
078:                    String approvedCode = pendingLedgerEntry
079:                            .getFinancialDocumentApprovedCode();
080:                    if (!KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.PROCESSED
081:                            .equals(approvedCode)) {
082:                        return true;
083:                    }
084:                }
085:                return false;
086:            }
087:
088:            /**
089:             * Invokes generateEntries method on the salary expense transfer document.
090:             * 
091:             * @param document - document whose pending entries need generated
092:             * @return whether the business rules succeeded
093:             */
094:            public boolean generateLaborLedgerPendingEntries(
095:                    LaborLedgerPostingDocument document) {
096:                LOG.info("generateLaborLedgerPendingEntries() started");
097:                boolean success = true;
098:
099:                // we must clear them first before creating new ones
100:                document.getLaborLedgerPendingEntries().clear();
101:
102:                LOG
103:                        .info("deleting existing labor ledger pending ledger entries for document "
104:                                + document.getDocumentNumber());
105:                delete(document.getDocumentNumber());
106:
107:                LOG
108:                        .info("generating labor ledger pending ledger entries for document "
109:                                + document.getDocumentNumber());
110:                GeneralLedgerPendingEntrySequenceHelper sequenceHelper = new GeneralLedgerPendingEntrySequenceHelper();
111:
112:                // process accounting lines, generate labor ledger pending entries
113:                List<AccountingLine> sourceAccountingLines = getSourceLines(document);
114:                if (sourceAccountingLines != null) {
115:                    for (AccountingLine line : sourceAccountingLines) {
116:                        success &= processLaborLedgerPendingEntryForAccountingLine(
117:                                document, sequenceHelper, line);
118:                    }
119:                }
120:
121:                List<AccountingLine> targetAccountingLines = getTargetLines(document);
122:                if (targetAccountingLines != null) {
123:                    for (AccountingLine line : targetAccountingLines) {
124:                        success &= processLaborLedgerPendingEntryForAccountingLine(
125:                                document, sequenceHelper, line);
126:                    }
127:                }
128:
129:                // compare source and target accounting lines, and generate benefit clearing lines as needed
130:                success &= processGenerateLaborLedgerBenefitClearingEntries(
131:                        document, sequenceHelper);
132:
133:                return success;
134:            }
135:
136:            private List<AccountingLine> getSourceLines(
137:                    LaborLedgerPostingDocument document) {
138:                return (List<AccountingLine>) document
139:                        .getSourceAccountingLines();
140:            }
141:
142:            private List<AccountingLine> getTargetLines(
143:                    LaborLedgerPostingDocument document) {
144:                return (List<AccountingLine>) document
145:                        .getTargetAccountingLines();
146:            }
147:
148:            /**
149:             * This method handles generically taking an accounting line, doing a deep copy on it so that we have a new instance without
150:             * reference to the original (won't affect the tran doc's acct lines), performing a retrieveNonKeyFields on the line to make
151:             * sure it's populated properly, and then calling the rule framework driven GLPE generation code.
152:             * 
153:             * @param document
154:             * @param sequenceHelper
155:             * @param iter
156:             * @return whether the business rules succeeded
157:             */
158:            private boolean processLaborLedgerPendingEntryForAccountingLine(
159:                    LaborLedgerPostingDocument document,
160:                    GeneralLedgerPendingEntrySequenceHelper sequenceHelper,
161:                    AccountingLine line) {
162:                LOG
163:                        .debug("processLaborLedgerPendingEntryForAccountingLine() started");
164:                boolean success = true;
165:
166:                GenerateLaborLedgerPendingEntriesEvent event = new GenerateLaborLedgerPendingEntriesEvent(
167:                        document, line, sequenceHelper);
168:                success &= kualiRuleService.applyRules(event);
169:
170:                return success;
171:            }
172:
173:            private boolean processGenerateLaborLedgerBenefitClearingEntries(
174:                    LaborLedgerPostingDocument document,
175:                    GeneralLedgerPendingEntrySequenceHelper sequenceHelper) {
176:                LOG
177:                        .debug("processLaborLedgerPendingEntryForAccountingLine() started");
178:                boolean success = true;
179:
180:                GenerateLaborLedgerBenefitClearingPendingEntriesEvent event = new GenerateLaborLedgerBenefitClearingPendingEntriesEvent(
181:                        document, sequenceHelper);
182:                success &= kualiRuleService.applyRules(event);
183:
184:                return success;
185:            }
186:
187:            public void delete(String documentHeaderId) {
188:                LOG.debug("delete() started");
189:
190:                laborLedgerPendingEntryDao.delete(documentHeaderId);
191:            }
192:
193:            public Collection findPendingEntries(Map fieldValues,
194:                    boolean isApproved) {
195:                LOG.debug("findPendingEntries() started");
196:
197:                return laborLedgerPendingEntryDao.findPendingEntries(
198:                        fieldValues, isApproved);
199:            }
200:
201:            /**
202:             * @see org.kuali.module.gl.service.GeneralLedgerPendingEntryService#findPendingLedgerEntriesForAccountBalance(java.util.Map,
203:             *      boolean, boolean)
204:             */
205:            public Iterator findPendingLedgerEntriesForLedgerBalance(
206:                    Map fieldValues, boolean isApproved) {
207:                LOG
208:                        .debug("findPendingLedgerEntriesForAccountBalance() started");
209:                return laborLedgerPendingEntryDao
210:                        .findPendingLedgerEntriesForLedgerBalance(fieldValues,
211:                                isApproved);
212:            }
213:
214:            /**
215:             * @see org.kuali.module.labor.service.LaborLedgerPendingEntryService#findApprovedPendingLedgerEntries()
216:             */
217:            public Iterator<LaborLedgerPendingEntry> findApprovedPendingLedgerEntries() {
218:                return laborLedgerPendingEntryDao
219:                        .findApprovedPendingLedgerEntries();
220:            }
221:
222:            /**
223:             * @see org.kuali.module.labor.service.LaborLedgerPendingEntryService#deleteByFinancialDocumentApprovedCode(java.lang.String)
224:             */
225:            public void deleteByFinancialDocumentApprovedCode(
226:                    String financialDocumentApprovedCode) {
227:                laborLedgerPendingEntryDao
228:                        .deleteByFinancialDocumentApprovedCode(financialDocumentApprovedCode);
229:            }
230:
231:            public void setLaborLedgerPendingEntryDao(
232:                    LaborLedgerPendingEntryDao laborLedgerPendingEntryDao) {
233:                this .laborLedgerPendingEntryDao = laborLedgerPendingEntryDao;
234:            }
235:
236:            public void setKualiRuleService(KualiRuleService kualiRuleService) {
237:                this .kualiRuleService = kualiRuleService;
238:            }
239:
240:            public void setBusinessObjectService(
241:                    BusinessObjectService businessObjectService) {
242:                this.businessObjectService = businessObjectService;
243:            }
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.