Source Code Cross Referenced for BankAccountRule.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » rules » 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.financial.rules 
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.financial.rules;
017:
018:        import java.util.HashMap;
019:        import java.util.Map;
020:
021:        import org.apache.commons.lang.StringUtils;
022:        import org.kuali.core.document.MaintenanceDocument;
023:        import org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase;
024:        import org.kuali.core.util.ObjectUtils;
025:        import org.kuali.kfs.KFSKeyConstants;
026:        import org.kuali.kfs.context.SpringContext;
027:        import org.kuali.module.chart.bo.SubAccount;
028:        import org.kuali.module.chart.bo.SubObjCd;
029:        import org.kuali.module.financial.bo.BankAccount;
030:        import org.kuali.module.financial.service.UniversityDateService;
031:
032:        /**
033:         * This is the rules class that is used for the default implementation of the Bank Account maintenance document.
034:         */
035:        public class BankAccountRule extends MaintenanceDocumentRuleBase {
036:
037:            BankAccount oldBankAccount;
038:            BankAccount newBankAccount;
039:
040:            /**
041:             * Validates a bank account maintenance document when it is approved. Method returns true if objects are completely filled out,
042:             * sub account number exists, and sub object code exists
043:             * 
044:             * @param document submitted document
045:             * @return true if objects are completed filled out, sub account number exists, and sub object code exists
046:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomApproveDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
047:             */
048:            protected boolean processCustomApproveDocumentBusinessRules(
049:                    MaintenanceDocument document) {
050:                // default to success
051:                boolean success = true;
052:
053:                success &= checkPartiallyFilledOutReferences();
054:                success &= checkSubAccountNumberExistence();
055:                success &= checkSubObjectCodeExistence();
056:
057:                return success;
058:            }
059:
060:            /**
061:             * Validates a bank account maintenance document when it is routed. Method returns true if objects are completely filled out,
062:             * sub account number exists, and sub object code exists
063:             * 
064:             * @param document submitted document
065:             * @return true if objects are completed filled out, sub account number exists, and sub object code exists
066:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
067:             */
068:            protected boolean processCustomRouteDocumentBusinessRules(
069:                    MaintenanceDocument document) {
070:                // default to success
071:                boolean success = true;
072:
073:                success &= checkPartiallyFilledOutReferences();
074:                success &= checkSubAccountNumberExistence();
075:                success &= checkSubObjectCodeExistence();
076:
077:                return success;
078:            }
079:
080:            /**
081:             * Validates a bank account maintenance document when it is save. Although method checks if objects are completely filled out,
082:             * sub account number exists, and sub object code exists, this method always returns TRUE.
083:             * 
084:             * @param document submitted document
085:             * @return true always
086:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomSaveDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
087:             */
088:            protected boolean processCustomSaveDocumentBusinessRules(
089:                    MaintenanceDocument document) {
090:                checkPartiallyFilledOutReferences();
091:                checkSubAccountNumberExistence();
092:                checkSubObjectCodeExistence();
093:
094:                return true;
095:            }
096:
097:            /**
098:             * This method sets the convenience objects like newAccount and oldAccount, so you have short and easy handles to the new and
099:             * old objects contained in the maintenance document. It also calls the BusinessObjectBase.refresh(), which will attempt to load
100:             * all sub-objects from the DB by their primary keys, if available.
101:             * 
102:             * @param document the maintenanceDocument being evaluated
103:             */
104:            public void setupConvenienceObjects() {
105:                // setup oldAccount convenience objects, make sure all possible sub-objects are populated
106:                oldBankAccount = (BankAccount) super .getOldBo();
107:
108:                // setup newAccount convenience objects, make sure all possible sub-objects are populated
109:                newBankAccount = (BankAccount) super .getNewBo();
110:            }
111:
112:            /**
113:             * This method checks for partially filled out objects.
114:             * 
115:             * @param document maintenance document being evaluated
116:             * @return true if there are no partially filled out references
117:             */
118:            private boolean checkPartiallyFilledOutReferences() {
119:
120:                boolean success = true;
121:
122:                success &= checkForPartiallyFilledOutReferenceForeignKeys("cashOffsetAccount");
123:                return success;
124:            }
125:
126:            /**
127:             * This method validates that the Cash Offset subAccountNumber exists, if it is entered
128:             * 
129:             * @param document maintenance document being evaluated
130:             * @return true if sub account number exists
131:             */
132:            private boolean checkSubAccountNumberExistence() {
133:
134:                boolean success = true;
135:
136:                // if all of the relevant values arent entered, don't bother
137:                if (StringUtils.isBlank(newBankAccount
138:                        .getCashOffsetFinancialChartOfAccountCode())) {
139:                    return success;
140:                }
141:                if (StringUtils.isBlank(newBankAccount
142:                        .getCashOffsetAccountNumber())) {
143:                    return success;
144:                }
145:                if (StringUtils.isBlank(newBankAccount
146:                        .getCashOffsetSubAccountNumber())) {
147:                    return success;
148:                }
149:
150:                // setup the map to search on
151:                Map pkMap = new HashMap();
152:                pkMap.put("chartOfAccountsCode", newBankAccount
153:                        .getCashOffsetFinancialChartOfAccountCode());
154:                pkMap.put("accountNumber", newBankAccount
155:                        .getCashOffsetAccountNumber());
156:                pkMap.put("subAccountNumber", newBankAccount
157:                        .getCashOffsetSubAccountNumber());
158:
159:                // do the search
160:                SubAccount testSubAccount = (SubAccount) getBoService()
161:                        .findByPrimaryKey(SubAccount.class, pkMap);
162:
163:                // fail if the subAccount isnt found
164:                if (testSubAccount == null) {
165:                    putFieldError("cashOffsetSubAccountNumber",
166:                            KFSKeyConstants.ERROR_EXISTENCE, getDdService()
167:                                    .getAttributeLabel(BankAccount.class,
168:                                            "cashOffsetSubAccountNumber"));
169:                    success &= false;
170:                }
171:
172:                return success;
173:            }
174:
175:            /**
176:             * This method validates that the Cash Offset subObjectCode exists, if it is entered
177:             * 
178:             * @param document maintenance document being evaluated
179:             * @return true if sub object code exists
180:             */
181:            private boolean checkSubObjectCodeExistence() {
182:
183:                boolean success = true;
184:
185:                // if all of the relevant values arent entered, dont bother
186:                if (StringUtils.isBlank(newBankAccount
187:                        .getCashOffsetFinancialChartOfAccountCode())) {
188:                    return success;
189:                }
190:                if (StringUtils.isBlank(newBankAccount
191:                        .getCashOffsetAccountNumber())) {
192:                    return success;
193:                }
194:                if (StringUtils.isBlank(newBankAccount
195:                        .getCashOffsetObjectCode())) {
196:                    return success;
197:                }
198:                if (StringUtils.isBlank(newBankAccount
199:                        .getCashOffsetSubObjectCode())) {
200:                    return success;
201:                }
202:
203:                // setup the map to search on
204:                Map pkMap = new HashMap();
205:                pkMap.put("universityFiscalYear", SpringContext.getBean(
206:                        UniversityDateService.class).getCurrentFiscalYear());
207:                pkMap.put("chartOfAccountsCode", newBankAccount
208:                        .getCashOffsetFinancialChartOfAccountCode());
209:                pkMap.put("accountNumber", newBankAccount
210:                        .getCashOffsetAccountNumber());
211:                pkMap.put("financialObjectCode", newBankAccount
212:                        .getCashOffsetObjectCode());
213:                pkMap.put("financialSubObjectCode", newBankAccount
214:                        .getCashOffsetSubObjectCode());
215:
216:                // do the search
217:                SubObjCd testSubObjCd = (SubObjCd) getBoService()
218:                        .findByPrimaryKey(SubObjCd.class, pkMap);
219:
220:                // fail if the subObjectCode isnt found
221:                if (testSubObjCd == null) {
222:                    putFieldError("cashOffsetSubObjectCode",
223:                            KFSKeyConstants.ERROR_EXISTENCE, getDdService()
224:                                    .getAttributeLabel(BankAccount.class,
225:                                            "cashOffsetSubObjectCode"));
226:                    success &= false;
227:                }
228:
229:                return success;
230:            }
231:
232:            /**
233:             * This method has been taken out of service to be replaced by the defaultExistenceChecks happening through the
234:             * BankAccountMaintenanceDocument.xml
235:             * 
236:             * @param document maintenance document being evaluated
237:             * @return true if sub object code exists
238:             */
239:            private boolean checkSubObjectExistence(MaintenanceDocument document) {
240:                // default to success
241:                boolean success = true;
242:                BankAccount newBankAcct = (BankAccount) document
243:                        .getNewMaintainableObject().getBusinessObject();
244:                newBankAcct.refresh();
245:
246:                // existence check on bank code
247:
248:                if (StringUtils.isNotEmpty(newBankAcct
249:                        .getFinancialDocumentBankCode())) {
250:                    if (ObjectUtils.isNull(newBankAcct.getBank())) {
251:                        success &= false;
252:                        putFieldError(
253:                                "financialDocumentBankCode",
254:                                KFSKeyConstants.ERROR_DOCUMENT_BANKACCMAINT_INVALID_BANK);
255:                    }
256:                }
257:
258:                return success;
259:            }
260:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.