Source Code Cross Referenced for PayeeAchAccountRule.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » pdp » 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.pdp.rules 
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.pdp.rules;
017:
018:        import java.util.HashMap;
019:        import java.util.List;
020:        import java.util.Map;
021:
022:        import org.kuali.core.document.MaintenanceDocument;
023:        import org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase;
024:        import org.kuali.core.service.BusinessObjectService;
025:        import org.kuali.kfs.KFSKeyConstants;
026:        import org.kuali.kfs.context.SpringContext;
027:        import org.kuali.module.pdp.bo.PayeeAchAccount;
028:
029:        /*
030:         * import java.util.Iterator; import java.util.List; import org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase; import
031:         * org.kuali.core.service.KeyValuesService; import org.kuali.kfs.bo.Options; import org.kuali.kfs.context.SpringContext; import
032:         * org.kuali.module.chart.rules.AccountingPeriodRule;
033:         */
034:
035:        public class PayeeAchAccountRule extends MaintenanceDocumentRuleBase {
036:
037:            protected static org.apache.log4j.Logger LOG = org.apache.log4j.Logger
038:                    .getLogger(PayeeAchAccount.class);
039:
040:            private PayeeAchAccount oldPayeeAchAccount;
041:            private PayeeAchAccount newPayeeAchAccount;
042:
043:            /**
044:             * This method sets the convenience objects like newAccount and oldAccount, so you have short and easy handles to the new and
045:             * old objects contained in the maintenance document. It also calls the BusinessObjectBase.refresh(), which will attempt to load
046:             * all sub-objects from the DB by their primary keys, if available.
047:             * 
048:             * @param document - the maintenanceDocument being evaluated
049:             */
050:            public void setupConvenienceObjects() {
051:
052:                LOG.info("setupConvenienceObjects called");
053:
054:                // setup oldPayeeAchAccount convenience objects, make sure all possible sub-objects are populated
055:                oldPayeeAchAccount = (PayeeAchAccount) super .getOldBo();
056:
057:                // setup newPayeeAchAccount convenience objects, make sure all possible sub-objects are populated
058:                newPayeeAchAccount = (PayeeAchAccount) super .getNewBo();
059:            }
060:
061:            protected boolean processCustomSaveDocumentBusinessRules(
062:                    MaintenanceDocument document) {
063:
064:                LOG.info("processCustomSaveDocumentBusinessRules called");
065:
066:                // call the route rules to report all of the messages, but ignore the result
067:                processCustomRouteDocumentBusinessRules(document);
068:
069:                // Save always succeeds, even if there are business rule failures
070:                return true;
071:            }
072:
073:            protected boolean processCustomRouteDocumentBusinessRules(
074:                    MaintenanceDocument document) {
075:
076:                boolean validEntry = true;
077:                String payeeIdTypeCd, payeeUserId, feinNumber, dvPayeeId, ssn;
078:                Integer vendorGnrtdId, vendorAsndId;
079:
080:                LOG.info("processCustomRouteDocumentBusinessRules called");
081:                setupConvenienceObjects();
082:
083:                payeeIdTypeCd = newPayeeAchAccount.getPayeeIdentifierTypeCode();
084:
085:                if (payeeIdTypeCd == null)
086:                    return validEntry;
087:
088:                // Create a query to do a lookup on.
089:                Map<String, Object> criteria = new HashMap<String, Object>();
090:                String identifierField = "";
091:
092:                if (payeeIdTypeCd.equals("E")) {
093:                    identifierField = "personUniversalIdentifier";
094:                    payeeUserId = newPayeeAchAccount
095:                            .getPersonUniversalIdentifier();
096:                    if (payeeUserId == null) {
097:                        putFieldError("personUniversalIdentifier",
098:                                KFSKeyConstants.ERROR_REQUIRED,
099:                                getFieldLabel("personUniversalIdentifier"));
100:                        validEntry = false;
101:                    } else
102:                        criteria.put("personUniversalIdentifier", payeeUserId);
103:                } else if (payeeIdTypeCd.equals("V")) {
104:                    identifierField = "vendorHeaderGeneratedIdentifier";
105:                    vendorGnrtdId = newPayeeAchAccount
106:                            .getVendorHeaderGeneratedIdentifier();
107:                    vendorAsndId = newPayeeAchAccount
108:                            .getVendorDetailAssignedIdentifier();
109:                    if ((vendorGnrtdId == null) || (vendorAsndId == null)) {
110:                        putFieldError(
111:                                "vendorHeaderGeneratedIdentifier",
112:                                KFSKeyConstants.ERROR_REQUIRED,
113:                                getFieldLabel("vendorHeaderGeneratedIdentifier"));
114:                        validEntry = false;
115:                    }
116:                    if (validEntry) {
117:                        criteria.put("vendorHeaderGeneratedIdentifier",
118:                                vendorGnrtdId);
119:                        criteria.put("vendorDetailAssignedIdentifier",
120:                                vendorAsndId);
121:                    }
122:                } else if (payeeIdTypeCd.equals("F")) {
123:                    identifierField = "payeeFederalEmployerIdentificationNumber";
124:                    feinNumber = newPayeeAchAccount
125:                            .getPayeeFederalEmployerIdentificationNumber();
126:                    if (feinNumber == null) {
127:                        putFieldError(
128:                                "payeeFederalEmployerIdentificationNumber",
129:                                KFSKeyConstants.ERROR_REQUIRED,
130:                                getFieldLabel("payeeFederalEmployerIdentificationNumber"));
131:                        validEntry = false;
132:                    } else
133:                        criteria.put(
134:                                "payeeFederalEmployerIdentificationNumber",
135:                                feinNumber);
136:                } else if (payeeIdTypeCd.equals("S")) {
137:                    identifierField = "payeeSocialSecurityNumber";
138:                    ssn = newPayeeAchAccount.getPayeeSocialSecurityNumber();
139:                    if (ssn == null) {
140:                        putFieldError("payeeSocialSecurityNumber",
141:                                KFSKeyConstants.ERROR_REQUIRED,
142:                                getFieldLabel("payeeSocialSecurityNumber"));
143:                        validEntry = false;
144:                    } else
145:                        criteria.put("payeeSocialSecurityNumber", ssn);
146:                } else if (payeeIdTypeCd.equals("P")) {
147:                    identifierField = "disbVchrPayeeIdNumber";
148:                    dvPayeeId = newPayeeAchAccount.getDisbVchrPayeeIdNumber();
149:                    if (dvPayeeId == null) {
150:                        putFieldError("disbVchrPayeeIdNumber",
151:                                KFSKeyConstants.ERROR_REQUIRED,
152:                                getFieldLabel("disbVchrPayeeIdNumber"));
153:                        validEntry = false;
154:                    } else
155:                        criteria.put("disbVchrPayeeIdNumber", dvPayeeId);
156:                }
157:                if (validEntry)
158:                    validEntry &= checkForDuplicateRecord(criteria,
159:                            identifierField);
160:
161:                return validEntry;
162:            }
163:
164:            private boolean checkForDuplicateRecord(
165:                    Map<String, Object> criteria, String identifierField) {
166:
167:                String newPayeeIdTypeCd = newPayeeAchAccount
168:                        .getPayeeIdentifierTypeCode();
169:                String newPsdTransactionCd = newPayeeAchAccount
170:                        .getPsdTransactionCode();
171:                boolean valid = true;
172:
173:                // Do not check for a duplicate record if the following conditions are true
174:                // 1. editing an existing record (old primary key = new primary key)
175:                // 2. new PSD code = old PSD code
176:                // 3. new payee type code = old payee type code
177:                // 4. depending of the value of payee type code, new correspoding PayeeId = old corresponding PayeeId
178:
179:                if (newPayeeAchAccount.getAchAccountGeneratedIdentifier() != null
180:                        && oldPayeeAchAccount
181:                                .getAchAccountGeneratedIdentifier() != null
182:                        && newPayeeAchAccount
183:                                .getAchAccountGeneratedIdentifier()
184:                                .equals(
185:                                        oldPayeeAchAccount
186:                                                .getAchAccountGeneratedIdentifier())) {
187:                    if (newPayeeIdTypeCd.equals(oldPayeeAchAccount
188:                            .getPayeeIdentifierTypeCode())
189:                            && newPsdTransactionCd.equals(oldPayeeAchAccount
190:                                    .getPsdTransactionCode())) {
191:                        if (newPayeeIdTypeCd.equals("E")) {
192:                            if (newPayeeAchAccount
193:                                    .getPersonUniversalIdentifier()
194:                                    .equals(
195:                                            oldPayeeAchAccount
196:                                                    .getPersonUniversalIdentifier()))
197:                                return valid;
198:                        } else if (newPayeeIdTypeCd.equals("V")) {
199:                            if (newPayeeAchAccount
200:                                    .getVendorHeaderGeneratedIdentifier()
201:                                    .equals(
202:                                            oldPayeeAchAccount
203:                                                    .getVendorHeaderGeneratedIdentifier())
204:                                    && newPayeeAchAccount
205:                                            .getVendorDetailAssignedIdentifier()
206:                                            .equals(
207:                                                    oldPayeeAchAccount
208:                                                            .getVendorDetailAssignedIdentifier()))
209:                                return valid;
210:                        } else if (newPayeeIdTypeCd.equals("F")) {
211:                            if (newPayeeAchAccount
212:                                    .getPayeeFederalEmployerIdentificationNumber()
213:                                    .equals(
214:                                            oldPayeeAchAccount
215:                                                    .getPayeeFederalEmployerIdentificationNumber()))
216:                                return valid;
217:                        } else if (newPayeeIdTypeCd.equals("S")) {
218:                            if (newPayeeAchAccount
219:                                    .getPayeeSocialSecurityNumber()
220:                                    .equals(
221:                                            oldPayeeAchAccount
222:                                                    .getPayeeSocialSecurityNumber()))
223:                                return valid;
224:                        } else if (newPayeeIdTypeCd.equals("P")) {
225:                            if (newPayeeAchAccount
226:                                    .getDisbVchrPayeeIdNumber()
227:                                    .equals(
228:                                            oldPayeeAchAccount
229:                                                    .getDisbVchrPayeeIdNumber()))
230:                                return valid;
231:                        }
232:                    }
233:                }
234:
235:                // check for a duplicate record if creating a new record or editing an old one and above mentioned conditions are not true
236:                criteria.put("psdTransactionCode", newPsdTransactionCd);
237:                criteria.put("payeeIdentifierTypeCode", newPayeeIdTypeCd);
238:
239:                int matches = SpringContext
240:                        .getBean(BusinessObjectService.class).countMatching(
241:                                PayeeAchAccount.class, criteria);
242:                if (matches > 0) {
243:                    putFieldError(
244:                            identifierField,
245:                            KFSKeyConstants.ERROR_DOCUMENT_PAYEEACHACCOUNTMAINT_DUPLICATE_RECORD);
246:                    valid = false;
247:                }
248:                return valid;
249:            }
250:
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.