Source Code Cross Referenced for CollectorServiceImpl.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » gl » 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.gl.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.gl.service.impl;
017:
018:        import java.io.File;
019:        import java.sql.Date;
020:        import java.util.ArrayList;
021:        import java.util.Collection;
022:        import java.util.List;
023:
024:        import org.apache.commons.lang.StringUtils;
025:        import org.apache.log4j.Logger;
026:        import org.kuali.core.service.DateTimeService;
027:        import org.kuali.kfs.batch.BatchInputFileType;
028:        import org.kuali.kfs.service.BatchInputFileService;
029:        import org.kuali.module.gl.bo.OriginEntryGroup;
030:        import org.kuali.module.gl.bo.OriginEntrySource;
031:        import org.kuali.module.gl.service.CollectorHelperService;
032:        import org.kuali.module.gl.service.CollectorScrubberService;
033:        import org.kuali.module.gl.service.CollectorService;
034:        import org.kuali.module.gl.service.OriginEntryGroupService;
035:        import org.kuali.module.gl.service.OriginEntryService;
036:        import org.kuali.module.gl.service.RunDateService;
037:        import org.kuali.module.gl.util.CollectorReportData;
038:        import org.kuali.module.gl.util.CollectorScrubberStatus;
039:        import org.kuali.module.gl.util.LedgerEntryHolder;
040:        import org.springframework.transaction.annotation.Transactional;
041:
042:        /**
043:         * The base implementation of the Collector service
044:         */
045:        @Transactional
046:        public class CollectorServiceImpl implements  CollectorService {
047:            private static Logger LOG = Logger
048:                    .getLogger(CollectorServiceImpl.class);
049:
050:            private CollectorHelperService collectorHelperService;
051:            private BatchInputFileService batchInputFileService;
052:            private BatchInputFileType collectorInputFileType;
053:            private OriginEntryGroupService originEntryGroupService;
054:            private DateTimeService dateTimeService;
055:            private CollectorScrubberService collectorScrubberService;
056:            private RunDateService runDateService;
057:
058:            /**
059:             * performs collection
060:             * 
061:             * @return status information related to the collection execution
062:             */
063:            public CollectorReportData performCollection() {
064:                List<String> fileNamesToLoad = batchInputFileService
065:                        .listInputFileNamesWithDoneFile(collectorInputFileType);
066:                List<String> processedFiles = new ArrayList();
067:
068:                Date executionDate = dateTimeService.getCurrentSqlDate();
069:
070:                Date runDate = new Date(runDateService.calculateRunDate(
071:                        executionDate).getTime());
072:                OriginEntryGroup group = originEntryGroupService
073:                        .createGroup(runDate, OriginEntrySource.COLLECTOR,
074:                                true, false, true);
075:                CollectorReportData collectorReportData = new CollectorReportData();
076:                List<CollectorScrubberStatus> collectorScrubberStatuses = new ArrayList<CollectorScrubberStatus>();
077:
078:                try {
079:                    for (String inputFileName : fileNamesToLoad) {
080:                        boolean processSuccess = false;
081:                        try {
082:                            LOG.info("Collecting file: " + inputFileName);
083:                            processSuccess = collectorHelperService
084:                                    .loadCollectorFile(inputFileName, group,
085:                                            collectorReportData,
086:                                            collectorScrubberStatuses);
087:                        } catch (RuntimeException e) {
088:                            LOG.error(
089:                                    "Caught exception trying to load collector file: "
090:                                            + inputFileName, e);
091:                        }
092:                        processedFiles.add(inputFileName);
093:                    }
094:                    updateCollectorReportDataWithExecutionStatistics(
095:                            collectorReportData, collectorScrubberStatuses);
096:                } finally {
097:                    collectorScrubberService
098:                            .removeTempGroups(collectorScrubberStatuses);
099:                    group.setProcess(true);
100:                    originEntryGroupService.save(group);
101:                    removeDoneFiles(processedFiles);
102:                }
103:                return collectorReportData;
104:            }
105:
106:            /**
107:             * Clears out associated .done files for the processed data files.
108:             * @param dataFileNames the name of files with done files to remove
109:             */
110:            private void removeDoneFiles(List<String> dataFileNames) {
111:                for (String dataFileName : dataFileNames) {
112:                    File doneFile = new File(StringUtils.substringBeforeLast(
113:                            dataFileName, ".")
114:                            + ".done");
115:                    if (doneFile.exists()) {
116:                        doneFile.delete();
117:                    }
118:                }
119:            }
120:
121:            public void setCollectorHelperService(
122:                    CollectorHelperService collectorHelperService) {
123:                this .collectorHelperService = collectorHelperService;
124:            }
125:
126:            public void setBatchInputFileService(
127:                    BatchInputFileService batchInputFileService) {
128:                this .batchInputFileService = batchInputFileService;
129:            }
130:
131:            public void setCollectorInputFileType(
132:                    BatchInputFileType collectorInputFileType) {
133:                this .collectorInputFileType = collectorInputFileType;
134:            }
135:
136:            /**
137:             * Gets the originEntryGroupService attribute.
138:             * 
139:             * @return Returns the originEntryGroupService.
140:             */
141:            public OriginEntryGroupService getOriginEntryGroupService() {
142:                return originEntryGroupService;
143:            }
144:
145:            /**
146:             * Sets the originEntryGroupService attribute value.
147:             * 
148:             * @param originEntryGroupService The originEntryGroupService to set.
149:             */
150:            public void setOriginEntryGroupService(
151:                    OriginEntryGroupService originEntryGroupService) {
152:                this .originEntryGroupService = originEntryGroupService;
153:            }
154:
155:            /**
156:             * Gets the dateTimeService attribute.
157:             * 
158:             * @return Returns the dateTimeService.
159:             */
160:            public DateTimeService getDateTimeService() {
161:                return dateTimeService;
162:            }
163:
164:            /**
165:             * Sets the dateTimeService attribute value.
166:             * 
167:             * @param dateTimeService The dateTimeService to set.
168:             */
169:            public void setDateTimeService(DateTimeService dateTimeService) {
170:                this .dateTimeService = dateTimeService;
171:            }
172:
173:            /**
174:             * Gets the collectorScrubberService attribute.
175:             * 
176:             * @return Returns the collectorScrubberService.
177:             */
178:            public CollectorScrubberService getCollectorScrubberService() {
179:                return collectorScrubberService;
180:            }
181:
182:            /**
183:             * Sets the collectorScrubberService attribute value.
184:             * 
185:             * @param collectorScrubberService The collectorScrubberService to set.
186:             */
187:            public void setCollectorScrubberService(
188:                    CollectorScrubberService collectorScrubberService) {
189:                this .collectorScrubberService = collectorScrubberService;
190:            }
191:
192:            /**
193:             * Adds execution statistics to the Collector run
194:             * 
195:             * @param collectorReportData data gathered from the run of the Collector
196:             * @param collectorScrubberStatuses a List of CollectorScrubberStatus records
197:             */
198:            protected void updateCollectorReportDataWithExecutionStatistics(
199:                    CollectorReportData collectorReportData,
200:                    List<CollectorScrubberStatus> collectorScrubberStatuses) {
201:                Collection<OriginEntryGroup> inputGroups = new ArrayList<OriginEntryGroup>();
202:
203:                // NOTE: this implementation does not support the use of multiple origin entry group service/origin entry services
204:                for (CollectorScrubberStatus collectorScrubberStatus : collectorScrubberStatuses) {
205:                    inputGroups.add(collectorScrubberStatus.getValidGroup());
206:                }
207:
208:                if (inputGroups.size() > 0
209:                        && collectorScrubberStatuses.size() > 0) {
210:                    OriginEntryService collectorScrubberOriginEntryService = collectorScrubberStatuses
211:                            .get(0).getOriginEntryService();
212:                    LedgerEntryHolder ledgerEntryHolder = collectorScrubberOriginEntryService
213:                            .getSummaryByGroupId(inputGroups);
214:                    collectorReportData.setLedgerEntryHolder(ledgerEntryHolder);
215:                }
216:            }
217:
218:            public RunDateService getRunDateService() {
219:                return runDateService;
220:            }
221:
222:            public void setRunDateService(RunDateService runDateService) {
223:                this.runDateService = runDateService;
224:            }
225:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.