Source Code Cross Referenced for LaborLedgerBalanceDaoOjb.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » labor » dao » ojb » 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.dao.ojb 
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.dao.ojb;
017:
018:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.APRIL;
019:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.AUGUST;
020:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.DECEMBER;
021:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.FEBRUARY;
022:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.JANUARY;
023:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.JULY;
024:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.JUNE;
025:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.MARCH;
026:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.MAY;
027:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.NOVEMBER;
028:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.OCTOBER;
029:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.SEPTEMBER;
030:        import static org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties.YEAR_END;
031:        import static org.kuali.module.labor.util.ConsolidationUtil.buildConsolidatedQuery;
032:        import static org.kuali.module.labor.util.ConsolidationUtil.buildGroupByCollection;
033:        import static org.kuali.module.labor.util.ConsolidationUtil.sum;
034:
035:        import java.util.ArrayList;
036:        import java.util.Collection;
037:        import java.util.HashMap;
038:        import java.util.Iterator;
039:        import java.util.List;
040:        import java.util.Map;
041:
042:        import org.apache.ojb.broker.query.Criteria;
043:        import org.apache.ojb.broker.query.Query;
044:        import org.apache.ojb.broker.query.QueryByCriteria;
045:        import org.apache.ojb.broker.query.QueryFactory;
046:        import org.apache.ojb.broker.query.ReportQueryByCriteria;
047:        import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
048:        import org.kuali.core.service.KualiConfigurationService;
049:        import org.kuali.kfs.KFSConstants;
050:        import org.kuali.kfs.KFSPropertyConstants;
051:        import org.kuali.module.chart.service.BalanceTypService;
052:        import org.kuali.module.gl.util.OJBUtility;
053:        import org.kuali.module.labor.LaborConstants;
054:        import org.kuali.module.labor.bo.EmployeeFunding;
055:        import org.kuali.module.labor.bo.LaborBalanceSummary;
056:        import org.kuali.module.labor.bo.LedgerBalance;
057:        import org.kuali.module.labor.bo.LedgerBalanceForYearEndBalanceForward;
058:        import org.kuali.module.labor.dao.LaborLedgerBalanceDao;
059:        import org.kuali.module.labor.util.ConsolidationUtil;
060:        import org.kuali.module.labor.util.ObjectUtil;
061:
062:        /**
063:         * This is the data access object for ledger balance.
064:         * 
065:         * @see org.kuali.module.labor.bo.LedgerBalance
066:         */
067:        public class LaborLedgerBalanceDaoOjb extends PlatformAwareDaoBaseOjb
068:                implements  LaborLedgerBalanceDao {
069:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
070:                    .getLogger(LaborLedgerBalanceDaoOjb.class);
071:            private KualiConfigurationService kualiConfigurationService;
072:
073:            private BalanceTypService balanceTypService;
074:
075:            /**
076:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#findBalancesForFiscalYear(java.lang.Integer)
077:             */
078:            public Iterator<LedgerBalance> findBalancesForFiscalYear(
079:                    Integer year) {
080:                LOG.debug("findBalancesForFiscalYear() started");
081:
082:                Criteria c = new Criteria();
083:                c.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, year);
084:
085:                QueryByCriteria query = QueryFactory.newQuery(
086:                        LedgerBalance.class, c);
087:                query
088:                        .addOrderByAscending(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
089:                query.addOrderByAscending(KFSPropertyConstants.ACCOUNT_NUMBER);
090:                query
091:                        .addOrderByAscending(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
092:                query
093:                        .addOrderByAscending(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
094:                query
095:                        .addOrderByAscending(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
096:                query
097:                        .addOrderByAscending(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE);
098:                query
099:                        .addOrderByAscending(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE);
100:
101:                return getPersistenceBrokerTemplate().getIteratorByQuery(query);
102:            }
103:
104:            /**
105:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#findBalancesForFiscalYear(java.lang.Integer, java.util.Map)
106:             */
107:            public Iterator<LedgerBalance> findBalancesForFiscalYear(
108:                    Integer fiscalYear, Map<String, String> fieldValues) {
109:
110:                Criteria criteria = buildCriteriaFromMap(fieldValues,
111:                        new LedgerBalance());
112:                criteria
113:                        .addEqualTo(
114:                                KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR,
115:                                fiscalYear);
116:
117:                QueryByCriteria query = QueryFactory.newQuery(
118:                        LedgerBalance.class, criteria);
119:
120:                query
121:                        .addOrderByAscending(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
122:                query.addOrderByAscending(KFSPropertyConstants.ACCOUNT_NUMBER);
123:                query
124:                        .addOrderByAscending(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
125:                query
126:                        .addOrderByAscending(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
127:                query
128:                        .addOrderByAscending(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
129:                query
130:                        .addOrderByAscending(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE);
131:                query
132:                        .addOrderByAscending(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE);
133:
134:                return getPersistenceBrokerTemplate().getIteratorByQuery(query);
135:            }
136:
137:            /**
138:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#findBalance(java.util.Map, boolean)
139:             */
140:            public Iterator<LedgerBalance> findBalance(Map fieldValues,
141:                    boolean isConsolidated) {
142:                LOG.debug("findBalance() started");
143:
144:                Query query = this .getBalanceQuery(fieldValues, isConsolidated);
145:                OJBUtility.limitResultSize(query);
146:
147:                if (isConsolidated) {
148:                    return getPersistenceBrokerTemplate()
149:                            .getReportQueryIteratorByQuery(query);
150:                }
151:                return getPersistenceBrokerTemplate().getIteratorByQuery(query);
152:            }
153:
154:            /**
155:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#getConsolidatedBalanceRecordCount(java.util.Map)
156:             */
157:            public Iterator getConsolidatedBalanceRecordCount(Map fieldValues) {
158:                LOG.debug("getBalanceRecordCount() started");
159:
160:                ReportQueryByCriteria query = this 
161:                        .getBalanceCountQuery(fieldValues);
162:                return getPersistenceBrokerTemplate()
163:                        .getReportQueryIteratorByQuery(query);
164:            }
165:
166:            // build the query for balance search
167:            private Query getBalanceQuery(Map fieldValues,
168:                    boolean isConsolidated) {
169:                LOG.debug("getBalanceQuery(Map, boolean) started");
170:                LOG.debug("Building criteria from map fields: "
171:                        + fieldValues.keySet());
172:
173:                Criteria criteria = buildCriteriaFromMap(fieldValues,
174:                        new LedgerBalance());
175:                ReportQueryByCriteria query = QueryFactory.newReportQuery(
176:                        LedgerBalance.class, criteria);
177:
178:                // if consolidated, then ignore subaccount number and balance type code
179:                if (isConsolidated) {
180:                    buildConsolidatedQuery(query, sum(JULY.propertyName),
181:                            sum(AUGUST.propertyName),
182:                            sum(SEPTEMBER.propertyName),
183:                            sum(OCTOBER.propertyName),
184:                            sum(NOVEMBER.propertyName),
185:                            sum(DECEMBER.propertyName),
186:                            sum(JANUARY.propertyName),
187:                            sum(FEBRUARY.propertyName),
188:                            sum(MARCH.propertyName), sum(APRIL.propertyName),
189:                            sum(MAY.propertyName), sum(JUNE.propertyName),
190:                            sum(YEAR_END.propertyName));
191:                }
192:
193:                return query;
194:            }
195:
196:            // build the query for balance search
197:            private ReportQueryByCriteria getBalanceCountQuery(Map fieldValues) {
198:                Criteria criteria = buildCriteriaFromMap(fieldValues,
199:                        new LedgerBalance());
200:                ReportQueryByCriteria query = QueryFactory.newReportQuery(
201:                        LedgerBalance.class, criteria);
202:
203:                // set the selection attributes
204:                query.setAttributes(new String[] { "count(*)" });
205:
206:                Collection<String> groupByList = buildGroupByCollection();
207:                groupByList.remove(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
208:                groupByList
209:                        .remove(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
210:                groupByList
211:                        .remove(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE);
212:
213:                // add the group criteria into the selection statement
214:                String[] groupBy = (String[]) groupByList
215:                        .toArray(new String[groupByList.size()]);
216:                query.addGroupBy(groupBy);
217:                return query;
218:            }
219:
220:            /**
221:             * This method builds the query criteria based on the input field map
222:             * 
223:             * @param fieldValues
224:             * @param balance
225:             * @return a query criteria
226:             */
227:            private Criteria buildCriteriaFromMap(Map fieldValues,
228:                    LedgerBalance balance) {
229:                Map localFieldValues = new HashMap();
230:                localFieldValues.putAll(fieldValues);
231:
232:                Criteria criteria = new Criteria();
233:
234:                // handle encumbrance balance type
235:                String propertyName = KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE;
236:                if (localFieldValues.containsKey(propertyName)) {
237:                    String propertyValue = (String) localFieldValues
238:                            .get(propertyName);
239:                    if (KFSConstants.AGGREGATE_ENCUMBRANCE_BALANCE_TYPE_CODE
240:                            .equals(propertyValue)) {
241:                        localFieldValues
242:                                .remove(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE);
243:
244:                        // parse the university fiscal year since it's a required field from the lookups
245:                        String universityFiscalYearStr = (String) localFieldValues
246:                                .get(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
247:                        Integer universityFiscalYear = new Integer(
248:                                universityFiscalYearStr);
249:
250:                        criteria
251:                                .addIn(
252:                                        KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE,
253:                                        balanceTypService
254:                                                .getEncumbranceBalanceTypes(universityFiscalYear));
255:                    }
256:                }
257:
258:                criteria.addAndCriteria(OJBUtility.buildCriteriaFromMap(
259:                        localFieldValues, new LedgerBalance()));
260:                return criteria;
261:            }
262:
263:            /**
264:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#findCurrentFunds(java.util.Map)
265:             */
266:            public List<LedgerBalance> findCurrentFunds(Map fieldValues) {
267:                LOG.debug("Start findCurrentFunds()");
268:
269:                Iterator<Object[]> queryResults = this 
270:                        .findCurrentFundsRawData(fieldValues);
271:                List<LedgerBalance> currentFundsCollection = new ArrayList<LedgerBalance>();
272:                while (queryResults != null && queryResults.hasNext()) {
273:                    currentFundsCollection.add(this 
274:                            .marshalFundsAsLedgerBalance(queryResults.next()));
275:                }
276:                return currentFundsCollection;
277:            }
278:
279:            /**
280:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#findEncumbranceFunds(java.util.Map)
281:             */
282:            public List<LedgerBalance> findEncumbranceFunds(Map fieldValues) {
283:                LOG.debug("Start findEncumbranceFunds()");
284:
285:                Iterator<Object[]> queryResults = this 
286:                        .findEncumbranceFundsRawData(fieldValues);
287:                List<LedgerBalance> currentFundsCollection = new ArrayList<LedgerBalance>();
288:                while (queryResults != null && queryResults.hasNext()) {
289:                    currentFundsCollection.add(this 
290:                            .marshalFundsAsLedgerBalance(queryResults.next()));
291:                }
292:                return currentFundsCollection;
293:            }
294:
295:            /**
296:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#findCurrentEmployeeFunds(java.util.Map)
297:             */
298:            public List<EmployeeFunding> findCurrentEmployeeFunds(
299:                    Map fieldValues) {
300:                LOG.debug("Start findCurrentEmployeeFunds()");
301:
302:                Iterator<Object[]> queryResults = this 
303:                        .findCurrentFundsRawData(fieldValues);
304:                List<EmployeeFunding> currentFundsCollection = new ArrayList<EmployeeFunding>();
305:                while (queryResults != null && queryResults.hasNext()) {
306:                    currentFundsCollection
307:                            .add(this 
308:                                    .marshalFundsAsEmployeeFunding(queryResults
309:                                            .next()));
310:                }
311:                return currentFundsCollection;
312:            }
313:
314:            /**
315:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#findEncumbranceEmployeeFunds(java.util.Map)
316:             */
317:            public List<EmployeeFunding> findEncumbranceEmployeeFunds(
318:                    Map fieldValues) {
319:                LOG.debug("Start findCurrentEmployeeFunds()");
320:
321:                Iterator<Object[]> queryResults = this 
322:                        .findEncumbranceFundsRawData(fieldValues);
323:                List<EmployeeFunding> currentFundsCollection = new ArrayList<EmployeeFunding>();
324:                while (queryResults != null && queryResults.hasNext()) {
325:                    currentFundsCollection
326:                            .add(this 
327:                                    .marshalFundsAsEmployeeFunding(queryResults
328:                                            .next()));
329:                }
330:                return currentFundsCollection;
331:            }
332:
333:            /**
334:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#findBalanceSummary(java.lang.Integer, java.util.Collection)
335:             */
336:            public List<LaborBalanceSummary> findBalanceSummary(
337:                    Integer fiscalYear, Collection<String> balanceTypes) {
338:                LOG.debug("Start findBalanceSummary()");
339:
340:                Criteria criteria = new Criteria();
341:                criteria
342:                        .addEqualTo(
343:                                KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR,
344:                                fiscalYear);
345:                criteria.addIn(
346:                        KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE,
347:                        balanceTypes);
348:
349:                Iterator<Object[]> queryResults = this 
350:                        .findBalanceSummaryRawData(criteria);
351:                List<LaborBalanceSummary> balanceSummaryCollection = new ArrayList<LaborBalanceSummary>();
352:                while (queryResults != null && queryResults.hasNext()) {
353:                    balanceSummaryCollection.add(this 
354:                            .marshalFundsAsLaborBalanceSummary(queryResults
355:                                    .next()));
356:                }
357:                return balanceSummaryCollection;
358:            }
359:
360:            /**
361:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#save(org.kuali.module.labor.bo.LedgerBalance)
362:             */
363:            public void save(LedgerBalance ledgerBalance) {
364:                getPersistenceBrokerTemplate().store(ledgerBalance);
365:            }
366:
367:            // get the current funds according to the given criteria
368:            private Iterator<Object[]> findCurrentFundsRawData(Map fieldValues) {
369:                Criteria criteria = OJBUtility.buildCriteriaFromMap(
370:                        fieldValues, new LedgerBalance());
371:                criteria.addEqualTo(
372:                        KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE,
373:                        KFSConstants.BALANCE_TYPE_ACTUAL);
374:
375:                List<String> objectTypeCodes = new ArrayList<String>();
376:                objectTypeCodes
377:                        .add(LaborConstants.BalanceInquiries.EMPLOYEE_FUNDING_EXPENSE_OBJECT_TYPE_CODE);
378:                objectTypeCodes
379:                        .add(LaborConstants.BalanceInquiries.EMPLOYEE_FUNDING_NORMAL_OP_EXPENSE_OBJECT_TYPE_CODE);
380:                criteria.addIn(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE,
381:                        objectTypeCodes);
382:
383:                return this .findFundsRawData(criteria);
384:            }
385:
386:            // get the encumbrance funds according to the given criteria
387:            private Iterator<Object[]> findEncumbranceFundsRawData(
388:                    Map fieldValues) {
389:                Criteria criteria = OJBUtility.buildCriteriaFromMap(
390:                        fieldValues, new LedgerBalance());
391:                criteria.addEqualTo(
392:                        KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE,
393:                        KFSConstants.BALANCE_TYPE_INTERNAL_ENCUMBRANCE);
394:
395:                return this .findFundsRawData(criteria);
396:            }
397:
398:            // get the funds based on the given criteria
399:            private Iterator<Object[]> findFundsRawData(Criteria criteria) {
400:                ReportQueryByCriteria query = QueryFactory.newReportQuery(
401:                        LedgerBalance.class, criteria);
402:
403:                List<String> groupByList = this 
404:                        .getGroupByListForFundingInquiry();
405:                String[] groupBy = (String[]) groupByList
406:                        .toArray(new String[groupByList.size()]);
407:                query.addGroupBy(groupBy);
408:
409:                List<String> getAttributeList = getAttributeListForFundingInquiry(false);
410:                String[] attributes = (String[]) getAttributeList
411:                        .toArray(new String[getAttributeList.size()]);
412:                query.setAttributes(attributes);
413:
414:                OJBUtility.limitResultSize(query);
415:                return getPersistenceBrokerTemplate()
416:                        .getReportQueryIteratorByQuery(query);
417:            }
418:
419:            // get the balance summary based on the given criteria
420:            private Iterator<Object[]> findBalanceSummaryRawData(
421:                    Criteria criteria) {
422:                ReportQueryByCriteria query = QueryFactory.newReportQuery(
423:                        LedgerBalance.class, criteria);
424:
425:                List<String> groupByList = this 
426:                        .getGroupByListForBalanceSummary();
427:                String[] groupBy = (String[]) groupByList
428:                        .toArray(new String[groupByList.size()]);
429:                query.addGroupBy(groupBy);
430:
431:                List<String> getAttributeList = this 
432:                        .getAttributeListForBalanceSummary(false);
433:                String[] attributes = (String[]) getAttributeList
434:                        .toArray(new String[getAttributeList.size()]);
435:                query.setAttributes(attributes);
436:
437:                query.addOrderByAscending(groupByList.get(0));
438:                return getPersistenceBrokerTemplate()
439:                        .getReportQueryIteratorByQuery(query);
440:            }
441:
442:            // marshal into AccountStatusBaseFunds from the query result
443:            private LedgerBalance marshalFundsAsLedgerBalance(
444:                    Object[] queryResult) {
445:                LedgerBalance ledgerBalance = new LedgerBalance();
446:                List<String> keyFields = this 
447:                        .getAttributeListForFundingInquiry(true);
448:
449:                ObjectUtil.buildObject(ledgerBalance, queryResult, keyFields);
450:                return ledgerBalance;
451:            }
452:
453:            // marshal into AccountStatusBaseFunds from the query result
454:            private EmployeeFunding marshalFundsAsEmployeeFunding(
455:                    Object[] queryResult) {
456:                EmployeeFunding employeeFunding = new EmployeeFunding();
457:                List<String> keyFields = this 
458:                        .getAttributeListForFundingInquiry(true);
459:
460:                ObjectUtil.buildObject(employeeFunding, queryResult, keyFields);
461:                return employeeFunding;
462:            }
463:
464:            // marshal into AccountStatusBaseFunds from the query result
465:            private LaborBalanceSummary marshalFundsAsLaborBalanceSummary(
466:                    Object[] queryResult) {
467:                return new LaborBalanceSummary(queryResult);
468:            }
469:
470:            // define the attribute list that can be used to group the search results
471:            private List<String> getGroupByListForFundingInquiry() {
472:                List<String> groupByList = new ArrayList<String>();
473:                groupByList.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
474:                groupByList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
475:                groupByList.add(KFSPropertyConstants.ACCOUNT_NUMBER);
476:                groupByList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
477:                groupByList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
478:                groupByList.add(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
479:                groupByList
480:                        .add(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE);
481:                groupByList.add(KFSPropertyConstants.POSITION_NUMBER);
482:                groupByList.add(KFSPropertyConstants.EMPLID);
483:                return groupByList;
484:            }
485:
486:            // define the return attribute list for funding query
487:            private List<String> getAttributeListForFundingInquiry(
488:                    boolean isAttributeNameNeeded) {
489:                List<String> attributeList = getGroupByListForFundingInquiry();
490:                attributeList
491:                        .add(ConsolidationUtil
492:                                .wrapAttributeName(
493:                                        KFSPropertyConstants.ACCOUNTING_LINE_ANNUAL_BALANCE_AMOUNT,
494:                                        isAttributeNameNeeded));
495:                attributeList
496:                        .add(ConsolidationUtil
497:                                .wrapAttributeName(
498:                                        KFSPropertyConstants.FINANCIAL_BEGINNING_BALANCE_LINE_AMOUNT,
499:                                        isAttributeNameNeeded));
500:                attributeList
501:                        .add(ConsolidationUtil
502:                                .wrapAttributeName(
503:                                        KFSPropertyConstants.CONTRACTS_GRANTS_BEGINNING_BALANCE_AMOUNT,
504:                                        isAttributeNameNeeded));
505:                return attributeList;
506:            }
507:
508:            // define the attribute list that can be used to group the search results
509:            private List<String> getGroupByListForBalanceSummary() {
510:                List<String> groupByList = new ArrayList<String>();
511:                groupByList.add("account.subFundGroup.fundGroupCode");
512:                return groupByList;
513:            }
514:
515:            // define the return attribute list for balance summary
516:            private List<String> getAttributeListForBalanceSummary(
517:                    boolean isAttributeNameNeeded) {
518:                List<String> attributeList = getGroupByListForBalanceSummary();
519:                attributeList
520:                        .add(ConsolidationUtil
521:                                .wrapAttributeName(
522:                                        KFSPropertyConstants.ACCOUNTING_LINE_ANNUAL_BALANCE_AMOUNT,
523:                                        isAttributeNameNeeded));
524:                attributeList
525:                        .add(ConsolidationUtil
526:                                .wrapAttributeName(
527:                                        KFSPropertyConstants.FINANCIAL_BEGINNING_BALANCE_LINE_AMOUNT,
528:                                        isAttributeNameNeeded));
529:                attributeList
530:                        .add(ConsolidationUtil
531:                                .wrapAttributeName(
532:                                        KFSPropertyConstants.CONTRACTS_GRANTS_BEGINNING_BALANCE_AMOUNT,
533:                                        isAttributeNameNeeded));
534:                attributeList.add(ConsolidationUtil.wrapAttributeName(
535:                        KFSPropertyConstants.MONTH1_AMOUNT,
536:                        isAttributeNameNeeded));
537:                attributeList.add(ConsolidationUtil.wrapAttributeName(
538:                        KFSPropertyConstants.MONTH2_AMOUNT,
539:                        isAttributeNameNeeded));
540:                attributeList.add(ConsolidationUtil.wrapAttributeName(
541:                        KFSPropertyConstants.MONTH3_AMOUNT,
542:                        isAttributeNameNeeded));
543:                attributeList.add(ConsolidationUtil.wrapAttributeName(
544:                        KFSPropertyConstants.MONTH4_AMOUNT,
545:                        isAttributeNameNeeded));
546:                attributeList.add(ConsolidationUtil.wrapAttributeName(
547:                        KFSPropertyConstants.MONTH5_AMOUNT,
548:                        isAttributeNameNeeded));
549:                attributeList.add(ConsolidationUtil.wrapAttributeName(
550:                        KFSPropertyConstants.MONTH6_AMOUNT,
551:                        isAttributeNameNeeded));
552:                attributeList.add(ConsolidationUtil.wrapAttributeName(
553:                        KFSPropertyConstants.MONTH7_AMOUNT,
554:                        isAttributeNameNeeded));
555:                attributeList.add(ConsolidationUtil.wrapAttributeName(
556:                        KFSPropertyConstants.MONTH8_AMOUNT,
557:                        isAttributeNameNeeded));
558:                attributeList.add(ConsolidationUtil.wrapAttributeName(
559:                        KFSPropertyConstants.MONTH9_AMOUNT,
560:                        isAttributeNameNeeded));
561:                attributeList.add(ConsolidationUtil.wrapAttributeName(
562:                        KFSPropertyConstants.MONTH10_AMOUNT,
563:                        isAttributeNameNeeded));
564:                attributeList.add(ConsolidationUtil.wrapAttributeName(
565:                        KFSPropertyConstants.MONTH11_AMOUNT,
566:                        isAttributeNameNeeded));
567:                attributeList.add(ConsolidationUtil.wrapAttributeName(
568:                        KFSPropertyConstants.MONTH12_AMOUNT,
569:                        isAttributeNameNeeded));
570:                attributeList.add(ConsolidationUtil.wrapAttributeName(
571:                        KFSPropertyConstants.MONTH13_AMOUNT,
572:                        isAttributeNameNeeded));
573:                return attributeList;
574:            }
575:
576:            /**
577:             * Sets the kualiConfigurationService attribute value.
578:             * 
579:             * @param kualiConfigurationService The kualiConfigurationService to set.
580:             */
581:            public void setKualiConfigurationService(
582:                    KualiConfigurationService kualiConfigurationService) {
583:                this .kualiConfigurationService = kualiConfigurationService;
584:            }
585:
586:            public void setBalanceTypService(BalanceTypService balanceTypService) {
587:                this .balanceTypService = balanceTypService;
588:            }
589:
590:            /**
591:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#findBalancesForFiscalYear(java.lang.Integer, java.util.Map,
592:             *      java.util.List, java.util.List)
593:             */
594:            public Iterator<LedgerBalanceForYearEndBalanceForward> findBalancesForFiscalYear(
595:                    Integer fiscalYear, Map<String, String> fieldValues,
596:                    List<String> subFundGroupCodes, List<String> fundGroupCodes) {
597:                Criteria criteria = OJBUtility.buildCriteriaFromMap(
598:                        fieldValues,
599:                        new LedgerBalanceForYearEndBalanceForward());
600:                criteria
601:                        .addEqualTo(
602:                                KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR,
603:                                fiscalYear);
604:
605:                if (subFundGroupCodes != null && !subFundGroupCodes.isEmpty()) {
606:                    Criteria criteriaForSubFundGroup = new Criteria();
607:                    String subFundGroupFieldName = KFSPropertyConstants.ACCOUNT
608:                            + "." + KFSPropertyConstants.SUB_FUND_GROUP_CODE;
609:                    criteriaForSubFundGroup.addIn(subFundGroupFieldName,
610:                            subFundGroupCodes);
611:
612:                    if (fundGroupCodes != null && !fundGroupCodes.isEmpty()) {
613:
614:                        Criteria criteriaForFundGroup = new Criteria();
615:                        String fundGroupFieldName = KFSPropertyConstants.ACCOUNT
616:                                + "."
617:                                + KFSPropertyConstants.SUB_FUND_GROUP
618:                                + "." + KFSPropertyConstants.FUND_GROUP_CODE;
619:                        criteriaForFundGroup.addIn(fundGroupFieldName,
620:                                fundGroupCodes);
621:
622:                        criteriaForSubFundGroup
623:                                .addOrCriteria(criteriaForFundGroup);
624:                    }
625:                    criteria.addAndCriteria(criteriaForSubFundGroup);
626:                }
627:
628:                QueryByCriteria query = QueryFactory.newQuery(
629:                        LedgerBalanceForYearEndBalanceForward.class, criteria);
630:                return getPersistenceBrokerTemplate().getIteratorByQuery(query);
631:            }
632:
633:            /**
634:             * @see org.kuali.module.labor.dao.LaborLedgerBalanceDao#findAccountsInFundGroups(java.lang.Integer, java.util.Map,
635:             *      java.util.List, java.util.List)
636:             */
637:            public List<List<String>> findAccountsInFundGroups(
638:                    Integer fiscalYear, Map<String, String> fieldValues,
639:                    List<String> subFundGroupCodes, List<String> fundGroupCodes) {
640:                Criteria criteria = OJBUtility.buildCriteriaFromMap(
641:                        fieldValues,
642:                        new LedgerBalanceForYearEndBalanceForward());
643:                criteria
644:                        .addEqualTo(
645:                                KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR,
646:                                fiscalYear);
647:
648:                if (subFundGroupCodes != null && !subFundGroupCodes.isEmpty()) {
649:                    Criteria criteriaForSubFundGroup = new Criteria();
650:                    String subFundGroupFieldName = KFSPropertyConstants.ACCOUNT
651:                            + "." + KFSPropertyConstants.SUB_FUND_GROUP_CODE;
652:                    criteriaForSubFundGroup.addIn(subFundGroupFieldName,
653:                            subFundGroupCodes);
654:
655:                    if (fundGroupCodes != null && !fundGroupCodes.isEmpty()) {
656:
657:                        Criteria criteriaForFundGroup = new Criteria();
658:                        String fundGroupFieldName = KFSPropertyConstants.ACCOUNT
659:                                + "."
660:                                + KFSPropertyConstants.SUB_FUND_GROUP
661:                                + "." + KFSPropertyConstants.FUND_GROUP_CODE;
662:                        criteriaForFundGroup.addIn(fundGroupFieldName,
663:                                fundGroupCodes);
664:
665:                        criteriaForSubFundGroup
666:                                .addOrCriteria(criteriaForFundGroup);
667:                    }
668:                    criteria.addAndCriteria(criteriaForSubFundGroup);
669:                }
670:
671:                ReportQueryByCriteria query = QueryFactory.newReportQuery(
672:                        LedgerBalanceForYearEndBalanceForward.class, criteria);
673:
674:                query.setAttributes(LaborConstants.ACCOUNT_FIELDS);
675:                query.setDistinct(true);
676:
677:                Iterator<Object[]> accountIterator = getPersistenceBrokerTemplate()
678:                        .getReportQueryIteratorByQuery(query);
679:
680:                List<List<String>> accounts = new ArrayList<List<String>>();
681:                while (accountIterator != null && accountIterator.hasNext()) {
682:                    Object[] accountObject = accountIterator.next();
683:
684:                    List<String> account = new ArrayList<String>();
685:                    account.add(accountObject[0].toString());
686:                    account.add(accountObject[1].toString());
687:
688:                    accounts.add(account);
689:                }
690:                return accounts;
691:            }
692:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.