Source Code Cross Referenced for OrgPreRules.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » chart » 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.chart.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.chart.rules;
017:
018:        import java.util.HashMap;
019:
020:        import org.apache.commons.lang.StringUtils;
021:        import org.kuali.core.document.MaintenanceDocument;
022:        import org.kuali.core.service.BusinessObjectService;
023:        import org.kuali.core.service.DateTimeService;
024:        import org.kuali.core.util.ObjectUtils;
025:        import org.kuali.kfs.bo.PostalZipCode;
026:        import org.kuali.kfs.context.SpringContext;
027:        import org.kuali.module.chart.bo.Account;
028:        import org.kuali.module.chart.bo.Org;
029:        import org.kuali.module.chart.bo.OrganizationExtension;
030:
031:        /**
032:         * PreRules checks for the {@link Org} that needs to occur while still in the Struts processing. This includes defaults, confirmations,
033:         * etc.
034:         */
035:        public class OrgPreRules extends MaintenancePreRulesBase {
036:            private Org newOrg;
037:            private Org copyOrg;
038:
039:            public OrgPreRules() {
040:
041:            }
042:
043:            /**
044:             * This checks to see if a continuation account is necessary and if the HRMS data has changed
045:             * 
046:             * @see org.kuali.module.chart.rules.MaintenancePreRulesBase#doCustomPreRules(org.kuali.core.document.MaintenanceDocument)
047:             */
048:            @Override
049:            protected boolean doCustomPreRules(MaintenanceDocument document) {
050:                setupConvenienceObjects(document);
051:                checkForContinuationAccounts(); // run this first to avoid side effects
052:
053:                LOG
054:                        .debug("done with continuation account, proceeeding with remaining pre rules");
055:
056:                updateHRMSUpdateDate((Org) document.getOldMaintainableObject()
057:                        .getBusinessObject(), (Org) document
058:                        .getNewMaintainableObject().getBusinessObject());
059:
060:                return true;
061:            }
062:
063:            /**
064:             * 
065:             * This looks for the org default account number and then sets the values to the continuation account value if it exists
066:             */
067:            private void checkForContinuationAccounts() {
068:                LOG.debug("entering checkForContinuationAccounts()");
069:
070:                if (StringUtils.isNotBlank(newOrg
071:                        .getOrganizationDefaultAccountNumber())) {
072:                    Account account = checkForContinuationAccount(
073:                            "Account Number", newOrg.getChartOfAccountsCode(),
074:                            newOrg.getOrganizationDefaultAccountNumber(), "");
075:                    if (ObjectUtils.isNotNull(account)) { // override old user inputs
076:                        newOrg.setOrganizationDefaultAccountNumber(account
077:                                .getAccountNumber());
078:                        newOrg.setChartOfAccountsCode(account
079:                                .getChartOfAccountsCode());
080:                    }
081:                }
082:            }
083:
084:            /**
085:             * 
086:             * This method sets the convenience objects like newOrg and copyOrg, so you have short and easy handles to the new and
087:             * old objects contained in the maintenance document. It also calls the BusinessObjectBase.refresh(), which will attempt to load
088:             * all sub-objects from the DB by their primary keys, if available.
089:             * @param document
090:             */
091:            private void setupConvenienceObjects(MaintenanceDocument document) {
092:
093:                // setup newOrg convenience objects, make sure all possible sub-objects are populated
094:                newOrg = (Org) document.getNewMaintainableObject()
095:                        .getBusinessObject();
096:                copyOrg = (Org) ObjectUtils.deepCopy(newOrg);
097:                copyOrg.refresh();
098:            }
099:
100:            /**
101:             * Check if the HRMS data has changed on this document. If so, update the last update date.
102:             * 
103:             * @param oldData
104:             * @param newData
105:             */
106:            private void updateHRMSUpdateDate(Org oldData, Org newData) {
107:                if (oldData != null) {
108:                    OrganizationExtension oldExt = oldData
109:                            .getOrganizationExtension();
110:                    OrganizationExtension newExt = newData
111:                            .getOrganizationExtension();
112:                    if (oldExt != null) {
113:                        if (!ObjectUtils.nullSafeEquals(
114:                                oldExt.getHrmsCompany(), newExt
115:                                        .getHrmsCompany())
116:                                || !ObjectUtils.nullSafeEquals(oldExt
117:                                        .getHrmsIuOrganizationAddress2(),
118:                                        newExt.getHrmsIuOrganizationAddress2())
119:                                || !ObjectUtils.nullSafeEquals(oldExt
120:                                        .getHrmsIuOrganizationAddress3(),
121:                                        newExt.getHrmsIuOrganizationAddress3())
122:                                || !ObjectUtils.nullSafeEquals(oldExt
123:                                        .getHrmsIuCampusCode(), newExt
124:                                        .getHrmsIuCampusCode())
125:                                || !ObjectUtils.nullSafeEquals(oldExt
126:                                        .getHrmsIuCampusBuilding(), newExt
127:                                        .getHrmsIuCampusBuilding())
128:                                || !ObjectUtils.nullSafeEquals(oldExt
129:                                        .getHrmsIuCampusRoom(), newExt
130:                                        .getHrmsIuCampusRoom())
131:                                || oldExt.isHrmsIuPositionAllowedFlag() != newExt
132:                                        .isHrmsIuPositionAllowedFlag()
133:                                || oldExt.isHrmsIuTenureAllowedFlag() != newExt
134:                                        .isHrmsIuTenureAllowedFlag()
135:                                || oldExt.isHrmsIuTitleAllowedFlag() != newExt
136:                                        .isHrmsIuTitleAllowedFlag()
137:                                || oldExt.isHrmsIuOccupationalUnitAllowedFlag() != newExt
138:                                        .isHrmsIuOccupationalUnitAllowedFlag()
139:                                || !ObjectUtils
140:                                        .nullSafeEquals(
141:                                                oldExt
142:                                                        .getHrmsPersonnelApproverUniversalId(),
143:                                                newExt
144:                                                        .getHrmsPersonnelApproverUniversalId())
145:                                || !ObjectUtils.nullSafeEquals(oldExt
146:                                        .getFiscalApproverUniversalId(), newExt
147:                                        .getFiscalApproverUniversalId())) {
148:                            newExt.setHrmsLastUpdateDate(SpringContext.getBean(
149:                                    DateTimeService.class)
150:                                    .getCurrentTimestamp());
151:                        }
152:                    } else {
153:                        newExt.setHrmsLastUpdateDate(SpringContext.getBean(
154:                                DateTimeService.class).getCurrentTimestamp());
155:                    }
156:                } else {
157:                    newData.getOrganizationExtension().setHrmsLastUpdateDate(
158:                            SpringContext.getBean(DateTimeService.class)
159:                                    .getCurrentTimestamp());
160:                }
161:            }
162:
163:            /**
164:             * 
165:             * This takes the org zip code and fills in state, city and country code based off of it
166:             * @param maintenanceDocument
167:             */
168:            private void setLocationFromZip(
169:                    MaintenanceDocument maintenanceDocument) {
170:
171:                // organizationStateCode , organizationCityName are populated by looking up
172:                // the zip code and getting the state and city from that
173:                if (!StringUtils.isBlank(copyOrg.getOrganizationZipCode())) {
174:
175:                    HashMap primaryKeys = new HashMap();
176:                    primaryKeys.put("postalZipCode", copyOrg
177:                            .getOrganizationZipCode());
178:                    PostalZipCode zip = (PostalZipCode) SpringContext.getBean(
179:                            BusinessObjectService.class).findByPrimaryKey(
180:                            PostalZipCode.class, primaryKeys);
181:
182:                    // If user enters a valid zip code, override city name and state code entered by user
183:                    if (ObjectUtils.isNotNull(zip)) { // override old user inputs
184:                        newOrg.setOrganizationCityName(zip.getPostalCityName());
185:                        newOrg.setOrganizationStateCode(zip
186:                                .getPostalStateCode());
187:                        newOrg.setOrganizationCountryCode("US");// no way to look up
188:                    }
189:                }
190:            }
191:
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.