Source Code Cross Referenced for ReversalDaoOjb.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » gl » 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.gl.dao.ojb 
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:        /*
017:         * Created on Jan 11, 2006
018:         *
019:         */
020:        package org.kuali.module.gl.dao.ojb;
021:
022:        import java.math.BigDecimal;
023:        import java.util.Date;
024:        import java.util.Iterator;
025:
026:        import org.apache.ojb.broker.query.Criteria;
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.kuali.core.dao.ojb.PlatformAwareDaoBaseOjb;
031:        import org.kuali.core.util.TransactionalServiceUtils;
032:        import org.kuali.kfs.KFSPropertyConstants;
033:        import org.kuali.module.gl.bo.Entry;
034:        import org.kuali.module.gl.bo.Reversal;
035:        import org.kuali.module.gl.bo.Transaction;
036:        import org.kuali.module.gl.dao.ReversalDao;
037:
038:        /**
039:         * An OJB implementation of the Reversal DAO
040:         */
041:        public class ReversalDaoOjb extends PlatformAwareDaoBaseOjb implements 
042:                ReversalDao {
043:            private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
044:                    .getLogger(ReversalDaoOjb.class);
045:
046:            private final static String UNIVERISITY_FISCAL_YEAR = "universityFiscalYear";
047:            private final static String CHART_OF_ACCOUNTS_CODE = "chartOfAccountsCode";
048:            private final static String ACCOUNT_NUMBER = "accountNumber";
049:            private final static String SUB_ACCOUNT_NUMBER = "subAccountNumber";
050:            private final static String FINANCIAL_OBJECT_CODE = "financialObjectCode";
051:            private final static String FINANCIAL_SUB_OBJECT_CODE = "financialSubObjectCode";
052:            private final static String FINANCIAL_BALANCE_TYPE_CODE = "financialBalanceTypeCode";
053:            private final static String FINANCIAL_OBJECT_TYPE_CODE = "financialObjectTypeCode";
054:            private final static String UNIVERISTY_FISCAL_PERIOD_CODE = "universityFiscalPeriodCode";
055:            private final static String FINANCIAL_DOCUMENT_TYPE_CODE = "financialDocumentTypeCode";
056:            private final static String FINANCIAL_SYSTEM_ORIGINATION_CODE = "financialSystemOriginationCode";
057:            private final static String MAX_CONSTANT = "max(documentNumber)";
058:
059:            /**
060:             * Constructs a ReversalDaoOjb instance
061:             */
062:            public ReversalDaoOjb() {
063:                super ();
064:            }
065:
066:            /**
067:             * Find the maximum transactionLedgerEntrySequenceNumber in the entry table for a specific transaction. This is used to make
068:             * sure that rows added have a unique primary key.
069:             * 
070:             * @param t a transaction to find the maximum sequence number for
071:             * @return the max sequence number for the given transaction
072:             */
073:            public int getMaxSequenceNumber(Transaction t) {
074:                LOG.debug("getSequenceNumber() ");
075:
076:                Criteria crit = new Criteria();
077:                crit.addEqualTo(UNIVERISITY_FISCAL_YEAR, t
078:                        .getUniversityFiscalYear());
079:                crit.addEqualTo(CHART_OF_ACCOUNTS_CODE, t
080:                        .getChartOfAccountsCode());
081:                crit.addEqualTo(ACCOUNT_NUMBER, t.getAccountNumber());
082:                crit.addEqualTo(SUB_ACCOUNT_NUMBER, t.getSubAccountNumber());
083:                crit.addEqualTo(FINANCIAL_OBJECT_CODE, t
084:                        .getFinancialObjectCode());
085:                crit.addEqualTo(FINANCIAL_SUB_OBJECT_CODE, t
086:                        .getFinancialSubObjectCode());
087:                crit.addEqualTo(FINANCIAL_BALANCE_TYPE_CODE, t
088:                        .getFinancialBalanceTypeCode());
089:                crit.addEqualTo(FINANCIAL_OBJECT_TYPE_CODE, t
090:                        .getFinancialObjectTypeCode());
091:                crit.addEqualTo(UNIVERISTY_FISCAL_PERIOD_CODE, t
092:                        .getUniversityFiscalPeriodCode());
093:                crit.addEqualTo(FINANCIAL_DOCUMENT_TYPE_CODE, t
094:                        .getFinancialDocumentTypeCode());
095:                crit.addEqualTo(FINANCIAL_SYSTEM_ORIGINATION_CODE, t
096:                        .getFinancialSystemOriginationCode());
097:                crit.addEqualTo(KFSPropertyConstants.DOCUMENT_NUMBER, t
098:                        .getDocumentNumber());
099:
100:                ReportQueryByCriteria q = QueryFactory.newReportQuery(
101:                        Entry.class, crit);
102:                q
103:                        .setAttributes(new String[] { "max(transactionLedgerEntrySequenceNumber)" });
104:
105:                Iterator iter = getPersistenceBrokerTemplate()
106:                        .getReportQueryIteratorByQuery(q);
107:                if (iter.hasNext()) {
108:                    Object[] data = (Object[]) TransactionalServiceUtils
109:                            .retrieveFirstAndExhaustIterator(iter);
110:                    BigDecimal max = (BigDecimal) data[0]; // Don't know why OJB returns a BigDecimal, but it does
111:
112:                    if (max == null) {
113:                        return 0;
114:                    } else {
115:                        return max.intValue();
116:                    }
117:                } else {
118:                    return 0;
119:                }
120:            }
121:
122:            /**
123:             * Fetches the reversal record that would affected by the posting of the given transaction
124:             * 
125:             * @param t the transaction to find the related reversal for
126:             * @return the reversal affected by the given transaction
127:             * @see org.kuali.module.gl.dao.ReversalDao#getByTransaction(org.kuali.module.gl.bo.Transaction)
128:             */
129:            public Reversal getByTransaction(Transaction t) {
130:                LOG.debug("getByTransaction() started");
131:
132:                Criteria crit = new Criteria();
133:                crit.addEqualTo(
134:                        KFSPropertyConstants.FINANCIAL_DOCUMENT_REVERSAL_DATE,
135:                        t.getFinancialDocumentReversalDate());
136:                crit.addEqualTo(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, t
137:                        .getUniversityFiscalYear());
138:                crit.addEqualTo(KFSPropertyConstants.CHART_OF_ACCOUNTS_CODE, t
139:                        .getChartOfAccountsCode());
140:                crit.addEqualTo(KFSPropertyConstants.ACCOUNT_NUMBER, t
141:                        .getAccountNumber());
142:                crit.addEqualTo(KFSPropertyConstants.SUB_ACCOUNT_NUMBER, t
143:                        .getSubAccountNumber());
144:                crit.addEqualTo(KFSPropertyConstants.FINANCIAL_OBJECT_CODE, t
145:                        .getFinancialObjectCode());
146:                crit.addEqualTo(KFSPropertyConstants.FINANCIAL_SUB_OBJECT_CODE,
147:                        t.getFinancialSubObjectCode());
148:                crit.addEqualTo(
149:                        KFSPropertyConstants.FINANCIAL_BALANCE_TYPE_CODE, t
150:                                .getFinancialBalanceTypeCode());
151:                crit.addEqualTo(
152:                        KFSPropertyConstants.FINANCIAL_OBJECT_TYPE_CODE, t
153:                                .getFinancialObjectTypeCode());
154:                crit.addEqualTo(
155:                        KFSPropertyConstants.UNIVERSITY_FISCAL_PERIOD_CODE, t
156:                                .getUniversityFiscalPeriodCode());
157:                crit.addEqualTo(
158:                        KFSPropertyConstants.FINANCIAL_DOCUMENT_TYPE_CODE, t
159:                                .getFinancialDocumentTypeCode());
160:                crit.addEqualTo(
161:                        KFSPropertyConstants.FINANCIAL_SYSTEM_ORIGINATION_CODE,
162:                        t.getFinancialSystemOriginationCode());
163:                crit.addEqualTo(KFSPropertyConstants.DOCUMENT_NUMBER, t
164:                        .getDocumentNumber());
165:                crit.addEqualTo(
166:                        KFSPropertyConstants.TRANSACTION_ENTRY_SEQUENCE_NUMBER,
167:                        t.getTransactionLedgerEntrySequenceNumber());
168:
169:                QueryByCriteria qbc = QueryFactory.newQuery(Reversal.class,
170:                        crit);
171:                return (Reversal) getPersistenceBrokerTemplate()
172:                        .getObjectByQuery(qbc);
173:            }
174:
175:            /**
176:             * Saves a reversal record
177:             * 
178:             * @param re a reversal record to save
179:             * @see org.kuali.module.gl.dao.ReversalDao#save(org.kuali.module.gl.bo.Reversal)
180:             */
181:            public void save(Reversal re) {
182:                LOG.debug("save() started");
183:
184:                getPersistenceBrokerTemplate().store(re);
185:            }
186:
187:            /**
188:             * Fetches all reversals that have been set to reverse on or before the given date - that is to say,
189:             * returns all the reversal records ready to be reversed!
190:             * 
191:             * @param before the date that reversals must reverse on or before
192:             * @return an Iterator of reversal records to reverse
193:             * @see org.kuali.module.gl.dao.ReversalDao#getByDate(java.util.Date)
194:             */
195:            public Iterator getByDate(Date before) {
196:                LOG.debug("getByDate() started");
197:
198:                Criteria crit = new Criteria();
199:                crit.addLessOrEqualThan(
200:                        KFSPropertyConstants.FINANCIAL_DOCUMENT_REVERSAL_DATE,
201:                        new java.sql.Date(before.getTime()));
202:
203:                QueryByCriteria qbc = QueryFactory.newQuery(Reversal.class,
204:                        crit);
205:                return getPersistenceBrokerTemplate().getIteratorByQuery(qbc);
206:            }
207:
208:            /**
209:             * Deletes a reversal record
210:             * 
211:             * @param re reversal to delete
212:             * @see org.kuali.module.gl.dao.ReversalDao#delete(org.kuali.module.gl.bo.Reversal)
213:             */
214:            public void delete(Reversal re) {
215:                LOG.debug("delete() started");
216:
217:                getPersistenceBrokerTemplate().delete(re);
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.