Source Code Cross Referenced for LaborDaoOjb.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 java.util.ArrayList;
019:        import java.util.Collection;
020:        import java.util.HashMap;
021:        import java.util.Iterator;
022:        import java.util.List;
023:        import java.util.Map;
024:
025:        import org.apache.ojb.broker.query.Criteria;
026:        import org.apache.ojb.broker.query.Query;
027:        import org.apache.ojb.broker.query.QueryByCriteria;
028:        import org.apache.ojb.broker.query.QueryFactory;
029:        import org.apache.ojb.broker.query.ReportQueryByCriteria;
030:        import org.apache.ojb.broker.util.ObjectModification;
031:        import org.kuali.core.bo.BusinessObject;
032:        import org.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
033:        import org.kuali.core.util.KualiDecimal;
034:        import org.kuali.kfs.KFSConstants;
035:        import org.kuali.kfs.KFSPropertyConstants;
036:        import org.kuali.module.gl.util.OJBUtility;
037:        import org.kuali.module.labor.LaborConstants;
038:        import org.kuali.module.labor.LaborPropertyConstants;
039:        import org.kuali.module.labor.LaborPropertyConstants.AccountingPeriodProperties;
040:        import org.kuali.module.labor.bo.AccountStatusBaseFunds;
041:        import org.kuali.module.labor.bo.AccountStatusCurrentFunds;
042:        import org.kuali.module.labor.bo.CalculatedSalaryFoundationTracker;
043:        import org.kuali.module.labor.bo.EmployeeFunding;
044:        import org.kuali.module.labor.bo.July1PositionFunding;
045:        import org.kuali.module.labor.bo.LaborObject;
046:        import org.kuali.module.labor.dao.LaborDao;
047:        import org.kuali.module.labor.util.ConsolidationUtil;
048:
049:        /**
050:         * OJB Implementation of Labor Distribution DAO database queries.
051:         */
052:        public class LaborDaoOjb extends PlatformAwareDaoBaseOjb implements 
053:                LaborDao {
054:            private static final org.apache.commons.logging.Log LOG = org.apache.commons.logging.LogFactory
055:                    .getLog(LaborDaoOjb.class);
056:
057:            /**
058:             * @see org.kuali.module.labor.dao.LaborDao#getCSFTrackerData(java.util.Map)
059:             */
060:            @Deprecated
061:            public Object getCSFTrackerTotal(Map fieldValues) {
062:
063:                Criteria criteria = new Criteria();
064:                criteria.addAndCriteria(OJBUtility.buildCriteriaFromMap(
065:                        fieldValues, new CalculatedSalaryFoundationTracker()));
066:
067:                ReportQueryByCriteria query = QueryFactory.newReportQuery(
068:                        CalculatedSalaryFoundationTracker.class, criteria);
069:
070:                List<String> groupByList = new ArrayList<String>();
071:                groupByList.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
072:                groupByList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
073:                groupByList.add(KFSPropertyConstants.ACCOUNT_NUMBER);
074:                groupByList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
075:                groupByList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
076:                groupByList.add(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
077:                String[] groupBy = (String[]) groupByList
078:                        .toArray(new String[groupByList.size()]);
079:
080:                query.setAttributes(new String[] { ConsolidationUtil
081:                        .sum(KFSPropertyConstants.CSF_AMOUNT) });
082:                query.addGroupBy(groupBy);
083:
084:                Object[] csf = null;
085:
086:                Iterator<Object[]> calculatedSalaryFoundationTracker = getPersistenceBrokerTemplate()
087:                        .getReportQueryIteratorByQuery(query);
088:                while (calculatedSalaryFoundationTracker != null
089:                        && calculatedSalaryFoundationTracker.hasNext()) {
090:                    csf = calculatedSalaryFoundationTracker.next();
091:                }
092:                KualiDecimal csfAmount = KualiDecimal.ZERO;
093:                if (csf != null) {
094:                    csfAmount = new KualiDecimal(csf[0].toString());
095:                }
096:                return csfAmount;
097:            }
098:
099:            /**
100:             * @see org.kuali.module.labor.dao.LaborDao#getEncumbranceTotal(java.util.Map)
101:             */
102:            public Object getEncumbranceTotal(Map fieldValues) {
103:
104:                Criteria criteria = new Criteria();
105:                criteria.addAndCriteria(OJBUtility.buildCriteriaFromMap(
106:                        fieldValues, new AccountStatusCurrentFunds()));
107:
108:                ReportQueryByCriteria query = QueryFactory.newReportQuery(
109:                        AccountStatusCurrentFunds.class, criteria);
110:
111:                List<String> groupByList = new ArrayList<String>();
112:                groupByList.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
113:                groupByList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
114:                groupByList.add(KFSPropertyConstants.ACCOUNT_NUMBER);
115:                groupByList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
116:                groupByList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
117:                groupByList.add(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
118:
119:                String[] groupBy = (String[]) groupByList
120:                        .toArray(new String[groupByList.size()]);
121:
122:                query
123:                        .setAttributes(new String[] { ConsolidationUtil
124:                                .sum(LaborConstants.BalanceInquiries.ANNUAL_BALANCE)
125:                                + " + "
126:                                + ConsolidationUtil
127:                                        .sum(LaborConstants.BalanceInquiries.CONTRACT_GRANT_BB_AMOUNT) });
128:                query.addGroupBy(groupBy);
129:
130:                Object[] encumbrances = null;
131:
132:                Iterator<Object[]> accountStatusCurrentFunds = getPersistenceBrokerTemplate()
133:                        .getReportQueryIteratorByQuery(query);
134:                while (accountStatusCurrentFunds != null
135:                        && accountStatusCurrentFunds.hasNext()) {
136:                    encumbrances = accountStatusCurrentFunds.next();
137:                }
138:                KualiDecimal encumbranceTotal = KualiDecimal.ZERO;
139:                if (encumbrances != null)
140:                    encumbranceTotal = new KualiDecimal(encumbrances[0]
141:                            .toString());
142:                return encumbranceTotal;
143:            }
144:
145:            /**
146:             * @see org.kuali.module.labor.dao.LaborDao#getJuly1(java.util.Map)
147:             */
148:            public Collection getJuly1(Map fieldValues) {
149:                Map fieldCriteria = new HashMap();
150:                fieldCriteria.putAll(fieldValues);
151:                fieldCriteria
152:                        .remove(KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE);
153:
154:                ArrayList objectTypeCodes = new ArrayList();
155:                Criteria criteria = new Criteria();
156:                criteria.addAndCriteria(OJBUtility.buildCriteriaFromMap(
157:                        fieldCriteria, new July1PositionFunding()));
158:                QueryByCriteria query = QueryFactory.newQuery(
159:                        July1PositionFunding.class, criteria);
160:
161:                Collection<July1PositionFunding> july1PositionFundings = getPersistenceBrokerTemplate()
162:                        .getCollectionByQuery(query);
163:                return july1PositionFundings;
164:            }
165:
166:            /**
167:             * @see org.kuali.module.labor.dao.LaborDao#getBaseFunds(java.util.Map)
168:             */
169:            @Deprecated
170:            public Iterator getBaseFunds(Map fieldValues, boolean isConsolidated) {
171:                fieldValues.put(
172:                        KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE,
173:                        KFSConstants.BALANCE_TYPE_BASE_BUDGET);
174:                return getAccountStatus(AccountStatusBaseFunds.class,
175:                        fieldValues, isConsolidated);
176:            }
177:
178:            /**
179:             * @see org.kuali.module.labor.dao.LaborDao#getCurrentFunds(java.util.Map)
180:             */
181:            public Iterator getCurrentFunds(Map fieldValues,
182:                    boolean isConsolidated) {
183:                fieldValues.put(
184:                        KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE,
185:                        KFSConstants.BALANCE_TYPE_ACTUAL);
186:                return getAccountStatus(AccountStatusCurrentFunds.class,
187:                        fieldValues, isConsolidated);
188:            }
189:
190:            private <T> Iterator getAccountStatus(Class<T> clazz,
191:                    Map fieldValues, boolean isConsolidated) {
192:                Query query = getAccountStatusQuery(clazz, fieldValues,
193:                        isConsolidated);
194:                OJBUtility.limitResultSize(query);
195:
196:                if (isConsolidated) {
197:                    return getPersistenceBrokerTemplate()
198:                            .getReportQueryIteratorByQuery(query);
199:                }
200:                return getPersistenceBrokerTemplate().getIteratorByQuery(query);
201:            }
202:
203:            // build the query for balance search
204:            private <T> Query getAccountStatusQuery(Class<T> clazz,
205:                    Map fieldValues, boolean isConsolidated) {
206:                LOG
207:                        .debug("getAccountStatusQuery(Class<T>, Map, boolean) started");
208:                LOG.debug("Building criteria from map fields: "
209:                        + fieldValues.entrySet());
210:
211:                Criteria criteria = new Criteria();
212:                try {
213:                    criteria.addAndCriteria(OJBUtility.buildCriteriaFromMap(
214:                            fieldValues, clazz.newInstance()));
215:                } catch (Exception e) {
216:                    LOG.error("Could not add and criteria properly for "
217:                            + clazz);
218:                    throw new RuntimeException(e);
219:                }
220:
221:                ReportQueryByCriteria query = QueryFactory.newReportQuery(
222:                        clazz, criteria);
223:                LOG.debug("Built query: " + query);
224:
225:                // if consolidated, then ignore subaccount number and balance type code
226:                if (isConsolidated) {
227:                    ConsolidationUtil
228:                            .buildConsolidatedQuery(
229:                                    query,
230:                                    ConsolidationUtil
231:                                            .sum(AccountingPeriodProperties.JULY.propertyName));
232:                }
233:
234:                return query;
235:            }
236:
237:            /**
238:             * @see org.kuali.module.labor.dao.LaborDao#getEmployeeFunding(java.util.Map)
239:             */
240:            @Deprecated
241:            public Iterator getEmployeeFunding(Map fieldValues) {
242:
243:                ArrayList objectTypeCodes = new ArrayList();
244:                objectTypeCodes
245:                        .add(LaborConstants.BalanceInquiries.EMPLOYEE_FUNDING_EXPENSE_OBJECT_TYPE_CODE);
246:                objectTypeCodes
247:                        .add(LaborConstants.BalanceInquiries.EMPLOYEE_FUNDING_NORMAL_OP_EXPENSE_OBJECT_TYPE_CODE);
248:
249:                Criteria criteria = new Criteria();
250:                criteria.addEqualToField(
251:                        KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE, "'"
252:                                + KFSConstants.BALANCE_TYPE_ACTUAL + "'");
253:                criteria.addIn(KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE,
254:                        objectTypeCodes);
255:                criteria.addAndCriteria(OJBUtility.buildCriteriaFromMap(
256:                        fieldValues, new EmployeeFunding()));
257:                ReportQueryByCriteria query = QueryFactory.newReportQuery(
258:                        EmployeeFunding.class, criteria);
259:
260:                List<String> groupByList = new ArrayList<String>();
261:                groupByList.add(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
262:                groupByList.add(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
263:                groupByList.add(KFSPropertyConstants.ACCOUNT_NUMBER);
264:                groupByList.add(KFSPropertyConstants.SUB_ACCOUNT_NUMBER);
265:                groupByList.add(KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
266:                groupByList.add(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE);
267:                groupByList.add(KFSPropertyConstants.POSITION_NUMBER);
268:                groupByList.add(KFSPropertyConstants.EMPLID);
269:
270:                String[] groupBy = (String[]) groupByList
271:                        .toArray(new String[groupByList.size()]);
272:                List<String> attributeList = new ArrayList<String>(groupByList);
273:                attributeList
274:                        .add(
275:                                0,
276:                                ConsolidationUtil
277:                                        .sum(KFSPropertyConstants.ACCOUNTING_LINE_ANNUAL_BALANCE_AMOUNT));
278:                query.setAttributes((String[]) attributeList
279:                        .toArray(new String[attributeList.size()]));
280:
281:                query.addGroupBy(groupBy);
282:                OJBUtility.limitResultSize(query);
283:                return getPersistenceBrokerTemplate()
284:                        .getReportQueryIteratorByQuery(query);
285:            }
286:
287:            /**
288:             * @see org.kuali.module.labor.dao.LaborDao#getJuly1PositionFunding(java.util.Map)
289:             */
290:            public Collection<July1PositionFunding> getJuly1PositionFunding(
291:                    Map<String, String> fieldValues) {
292:                Criteria criteria = OJBUtility.buildCriteriaFromMap(
293:                        fieldValues, new July1PositionFunding());
294:
295:                criteria.addEqualToField(LaborPropertyConstants.LABOR_OBJECT
296:                        + "." + KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR,
297:                        KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR);
298:                criteria.addEqualToField(LaborPropertyConstants.LABOR_OBJECT
299:                        + "." + KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE,
300:                        KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE);
301:                criteria.addEqualToField(LaborPropertyConstants.LABOR_OBJECT
302:                        + "." + KFSPropertyConstants.FINANCIAL_OBJECT_CODE,
303:                        KFSPropertyConstants.FINANCIAL_OBJECT_CODE);
304:                criteria
305:                        .addNotNull(LaborPropertyConstants.LABOR_OBJECT
306:                                + "."
307:                                + LaborPropertyConstants.FINANCIAL_OBJECT_FRINGE_OR_SALARY_CODE);
308:
309:                QueryByCriteria query = QueryFactory.newQuery(
310:                        July1PositionFunding.class, criteria);
311:                OJBUtility.limitResultSize(query);
312:
313:                return getPersistenceBrokerTemplate().getCollectionByQuery(
314:                        query);
315:            }
316:
317:            /**
318:             * @see org.kuali.module.labor.dao.LaborDao#insert(org.kuali.core.bo.BusinessObject)
319:             */
320:            public void insert(BusinessObject businessObject) {
321:                getPersistenceBroker(true).store(businessObject,
322:                        ObjectModification.INSERT);
323:            }
324:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.