Source Code Cross Referenced for LaborBalanceSummaryReportServiceImpl.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 static org.kuali.module.gl.GLConstants.GlSummaryReport.CURRENT_AND_LAST_YEAR;
019:        import static org.kuali.module.gl.GLConstants.GlSummaryReport.CURRENT_YEAR_LOWER;
020:        import static org.kuali.module.gl.GLConstants.GlSummaryReport.CURRENT_YEAR_UPPER;
021:
022:        import java.sql.Date;
023:        import java.text.SimpleDateFormat;
024:        import java.util.ArrayList;
025:        import java.util.Calendar;
026:        import java.util.List;
027:
028:        import org.apache.commons.lang.StringUtils;
029:        import org.kuali.core.service.DateTimeService;
030:        import org.kuali.kfs.bo.Options;
031:        import org.kuali.kfs.service.OptionsService;
032:        import org.kuali.kfs.service.ParameterService;
033:        import org.kuali.module.gl.batch.PosterSummaryReportStep;
034:        import org.kuali.module.labor.service.LaborBalanceSummaryReportService;
035:        import org.kuali.module.labor.service.LaborReportService;
036:        import org.kuali.module.labor.util.ReportRegistry;
037:        import org.springframework.transaction.annotation.Transactional;
038:
039:        /**
040:         * Implements a set of methods that can generate labor balance summary reports
041:         */
042:        @Transactional
043:        public class LaborBalanceSummaryReportServiceImpl implements 
044:                LaborBalanceSummaryReportService {
045:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
046:                    .getLogger(LaborBalanceSummaryReportServiceImpl.class);
047:
048:            private LaborReportService laborReportService;
049:            private DateTimeService dateTimeService;
050:            private OptionsService optionsService;
051:            private ParameterService parameterService;
052:
053:            /**
054:             * @see org.kuali.module.labor.service.LaborBalanceSummaryReportService#generateBalanceSummaryReports()
055:             */
056:            public void generateBalanceSummaryReports() {
057:                LOG.info("generateBalanceSummaryReports() started");
058:
059:                Date runDate = dateTimeService.getCurrentSqlDate();
060:                this .generateBalanceSummaryReports(runDate);
061:            }
062:
063:            /**
064:             * @see org.kuali.module.labor.service.LaborBalanceSummaryReportService#generateBalanceSummaryReports(java.sql.Date)
065:             */
066:            public void generateBalanceSummaryReports(Date runDate) {
067:                LOG.info("generateBalanceSummaryReports(Date) started");
068:
069:                String yearEndPeriodLowerBound = parameterService
070:                        .getParameterValue(PosterSummaryReportStep.class,
071:                                CURRENT_YEAR_LOWER);
072:                String lastDayOfFiscalYear = parameterService
073:                        .getParameterValue(PosterSummaryReportStep.class,
074:                                CURRENT_AND_LAST_YEAR);
075:                String yearEndPeriodUpperBound = parameterService
076:                        .getParameterValue(PosterSummaryReportStep.class,
077:                                CURRENT_YEAR_UPPER);
078:
079:                Integer currentYear = optionsService.getCurrentYearOptions()
080:                        .getUniversityFiscalYear();
081:                this .generateBalanceSummaryReports(currentYear, runDate);
082:
083:                // if today is within the lower bound of the year end period, then generate reports for the next fiscal year
084:                if (this .isInYearEndLowerBound(runDate,
085:                        yearEndPeriodLowerBound, lastDayOfFiscalYear)) {
086:                    this 
087:                            .generateBalanceSummaryReports(currentYear + 1,
088:                                    runDate);
089:                }
090:
091:                // if today is within the upper bound of the year end period, then generate reports for the last fiscal year
092:                if (this .isInYearEndUpperBound(runDate,
093:                        yearEndPeriodUpperBound, lastDayOfFiscalYear)) {
094:                    this 
095:                            .generateBalanceSummaryReports(currentYear - 1,
096:                                    runDate);
097:                }
098:            }
099:
100:            // generate a set of balance summary reports for actual, budget and encumbrance balances
101:            private void generateBalanceSummaryReports(Integer fiscalYear,
102:                    Date runDate) {
103:                String reportsDirectory = ReportRegistry.getReportsDirectory();
104:                Options options = optionsService.getOptions(fiscalYear);
105:
106:                List<String> actualsBalanceTypes = this 
107:                        .getActualBalanceTypes(fiscalYear);
108:                laborReportService.generateMonthlyBalanceSummaryReport(
109:                        fiscalYear, actualsBalanceTypes,
110:                        ReportRegistry.LABOR_ACTUAL_BALANCE_SUMMARY,
111:                        reportsDirectory, runDate);
112:
113:                List<String> budgetBalanceTypes = this 
114:                        .getBudgetBalanceTypes(fiscalYear);
115:                laborReportService.generateMonthlyBalanceSummaryReport(
116:                        fiscalYear, budgetBalanceTypes,
117:                        ReportRegistry.LABOR_BUDGET_BALANCE_SUMMARY,
118:                        reportsDirectory, runDate);
119:
120:                List<String> encumbranceBalanceTypes = this 
121:                        .getEncumbranceBalanceTypes(fiscalYear);
122:                laborReportService.generateBalanceSummaryReport(fiscalYear,
123:                        encumbranceBalanceTypes,
124:                        ReportRegistry.LABOR_ENCUMBRANCE_SUMMARY,
125:                        reportsDirectory, runDate);
126:            }
127:
128:            /**
129:             * get the encumbrance balance type codes for the given fiscal year
130:             * 
131:             * @param fiscalYear the given fiscal year
132:             * @return the encumbrance balance type codes for the given fiscal year
133:             */
134:            private List<String> getEncumbranceBalanceTypes(Integer fiscalYear) {
135:                Options options = optionsService.getOptions(fiscalYear);
136:
137:                List<String> balanceTypes = new ArrayList<String>();
138:                balanceTypes.add(options.getExtrnlEncumFinBalanceTypCd());
139:                balanceTypes.add(options.getIntrnlEncumFinBalanceTypCd());
140:                balanceTypes.add(options.getPreencumbranceFinBalTypeCd());
141:                balanceTypes
142:                        .add(options.getCostShareEncumbranceBalanceTypeCd());
143:                return balanceTypes;
144:            }
145:
146:            /**
147:             * get the actual balance type codes for the given fiscal year
148:             * 
149:             * @param fiscalYear the given fiscal year
150:             * @return the actual balance type codes for the given fiscal year
151:             */
152:            private List<String> getActualBalanceTypes(Integer fiscalYear) {
153:                Options options = optionsService.getOptions(fiscalYear);
154:
155:                List<String> balanceTypes = new ArrayList<String>();
156:                balanceTypes.add(options.getActualFinancialBalanceTypeCd());
157:                return balanceTypes;
158:            }
159:
160:            /**
161:             * get the budget balance type codes for the given fiscal year
162:             * 
163:             * @param fiscalYear the given fiscal year
164:             * @return the budget balance type codes for the given fiscal year
165:             */
166:            private List<String> getBudgetBalanceTypes(Integer fiscalYear) {
167:                Options options = optionsService.getOptions(fiscalYear);
168:
169:                List<String> balanceTypes = new ArrayList<String>();
170:                balanceTypes.add(options.getBudgetCheckingBalanceTypeCd());
171:                balanceTypes.add(options.getBaseBudgetFinancialBalanceTypeCd());
172:                balanceTypes.add(options
173:                        .getMonthlyBudgetFinancialBalanceTypeCd());
174:                return balanceTypes;
175:            }
176:
177:            /**
178:             * determine if the given date is within the year end period
179:             * 
180:             * @param runDate the given date
181:             * @param yearEndPeriodLowerBound the lower bound date of year end period
182:             * @param yearEndPeriodUpperBound the upper bound date of year end period
183:             * @param lastDayOfFiscalYear the last day of the current fiscal year
184:             * @return true if the given date is within the lower bound of year end period; otherwise, false
185:             */
186:            private boolean isInYearEndPeriod(Date runDate,
187:                    String yearEndPeriodLowerBound,
188:                    String yearEndPeriodUpperBound, String lastDayOfFiscalYear) {
189:                return isInYearEndLowerBound(runDate, yearEndPeriodLowerBound,
190:                        lastDayOfFiscalYear)
191:                        || isInYearEndUpperBound(runDate,
192:                                yearEndPeriodUpperBound, lastDayOfFiscalYear);
193:            }
194:
195:            /**
196:             * determine if the given date is within the lower bound of year end period
197:             * 
198:             * @param runDate the given date
199:             * @param yearEndPeriodLowerBound the lower bound date of year end period
200:             * @param lastDayOfFiscalYear the last day of the current fiscal year
201:             * @return true if the given date is within the lower bound of year end period; otherwise, false
202:             */
203:            private boolean isInYearEndLowerBound(Date runDate,
204:                    String yearEndPeriodLowerBound, String lastDayOfFiscalYear) {
205:                SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
206:                String today = sdf.format(runDate);
207:                return today.compareTo(yearEndPeriodLowerBound) >= 0
208:                        && today.compareTo(lastDayOfFiscalYear) <= 0;
209:            }
210:
211:            /**
212:             * determine if the given date is within the upper bound of year end period
213:             * 
214:             * @param runDate the given date
215:             * @param yearEndPeriodUpperBound the upper bound date of year end period
216:             * @param lastDayOfFiscalYear the last day of the current fiscal year
217:             * @return true if the given date is within the upper bound of year end period; otherwise, false
218:             */
219:            private boolean isInYearEndUpperBound(Date runDate,
220:                    String yearEndPeriodUpperBound, String lastDayOfFiscalYear) {
221:                SimpleDateFormat sdf = new SimpleDateFormat("MMdd");
222:                String today = sdf.format(runDate);
223:
224:                String month = StringUtils.mid(lastDayOfFiscalYear, 0, 2);
225:                String date = StringUtils.mid(lastDayOfFiscalYear, 2, 2);
226:
227:                Calendar calendar = Calendar.getInstance();
228:                calendar.set(Calendar.MONTH, Integer.parseInt(month) - 1);
229:                calendar.set(Calendar.DATE, Integer.parseInt(date));
230:                calendar.add(Calendar.DATE, 1);
231:                String firstDayOfNewFiscalYear = sdf.format(calendar.getTime());
232:
233:                return today.compareTo(yearEndPeriodUpperBound) <= 0
234:                        && today.compareTo(firstDayOfNewFiscalYear) >= 0;
235:            }
236:
237:            /**
238:             * Sets the dateTimeService attribute value.
239:             * 
240:             * @param dateTimeService The dateTimeService to set.
241:             */
242:            public void setDateTimeService(DateTimeService dateTimeService) {
243:                this .dateTimeService = dateTimeService;
244:            }
245:
246:            /**
247:             * Sets the laborReportService attribute value.
248:             * 
249:             * @param laborReportService The laborReportService to set.
250:             */
251:            public void setLaborReportService(
252:                    LaborReportService laborReportService) {
253:                this .laborReportService = laborReportService;
254:            }
255:
256:            /**
257:             * Sets the optionsService attribute value.
258:             * 
259:             * @param optionsService The optionsService to set.
260:             */
261:            public void setOptionsService(OptionsService optionsService) {
262:                this .optionsService = optionsService;
263:            }
264:
265:            public void setParameterService(ParameterService parameterService) {
266:                this.parameterService = parameterService;
267:            }
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.