Source Code Cross Referenced for ChartUserRule.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 org.apache.commons.lang.StringUtils;
019:        import org.kuali.core.bo.user.UniversalUser;
020:        import org.kuali.core.document.MaintenanceDocument;
021:        import org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase;
022:        import org.kuali.core.util.GlobalVariables;
023:        import org.kuali.core.util.ObjectUtils;
024:        import org.kuali.kfs.KFSConstants;
025:        import org.kuali.kfs.KFSKeyConstants;
026:        import org.kuali.kfs.context.SpringContext;
027:        import org.kuali.kfs.service.ParameterService;
028:        import org.kuali.module.chart.bo.ChartUser;
029:
030:        /**
031:         * Business rule(s) applicable to {@link ChartUserMaintenance} documents.
032:         */
033:        public class ChartUserRule extends MaintenanceDocumentRuleBase {
034:
035:            private ChartUser oldUser;
036:            private ChartUser newUser;
037:
038:            /**
039:             * This provides the basic rule checking on document routing Specifically it calls the following: checkGeneralRules
040:             * checkUserGroups
041:             * 
042:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomRouteDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
043:             */
044:            protected boolean processCustomRouteDocumentBusinessRules(
045:                    MaintenanceDocument document) {
046:                boolean success = true;
047:                setupConvenienceObjects(document);
048:                GlobalVariables.getErrorMap().addToErrorPath(
049:                        "document.newMaintainableObject");
050:                GlobalVariables.getErrorMap().addToErrorPath(
051:                        "moduleUsers(chart)");
052:                success &= checkGeneralRules(document);
053:                if (document.isEdit() && !newUser.isActive()) {
054:                    success &= checkUserGroups(document);
055:                }
056:                GlobalVariables.getErrorMap().removeFromErrorPath(
057:                        "moduleUsers(chart)");
058:                GlobalVariables.getErrorMap().removeFromErrorPath(
059:                        "document.newMaintainableObject");
060:                return success;
061:            }
062:
063:            /**
064:             * This provides the basic rule checking on document routing Specifically it calls the following: checkGeneralRules
065:             * checkUserGroups
066:             * 
067:             * @see org.kuali.core.maintenance.rules.MaintenanceDocumentRuleBase#processCustomSaveDocumentBusinessRules(org.kuali.core.document.MaintenanceDocument)
068:             */
069:            protected boolean processCustomSaveDocumentBusinessRules(
070:                    MaintenanceDocument document) {
071:                boolean success = true;
072:                setupConvenienceObjects(document);
073:                GlobalVariables.getErrorMap().addToErrorPath(
074:                        "document.newMaintainableObject");
075:                GlobalVariables.getErrorMap().addToErrorPath(
076:                        "moduleUsers(chart)");
077:                success &= checkGeneralRules(document);
078:                if (document.isEdit() && !newUser.isActive()) {
079:                    success &= checkUserGroups(document);
080:                }
081:                GlobalVariables.getErrorMap().removeFromErrorPath(
082:                        "moduleUsers(chart)");
083:                GlobalVariables.getErrorMap().removeFromErrorPath(
084:                        "document.newMaintainableObject");
085:                // save always succeeds even if there are rule violations
086:                return true;
087:            }
088:
089:            /**
090:             * This method sets the convenience objects like newAccount and oldAccount, so you have short and easy handles to the new and
091:             * old objects contained in the maintenance document. It also calls the BusinessObjectBase.refresh(), which will attempt to load
092:             * all sub-objects from the DB by their primary keys, if available.
093:             * 
094:             * @param document - the maintenanceDocument being evaluated
095:             */
096:            private void setupConvenienceObjects(MaintenanceDocument document) {
097:
098:                // setup oldAccount convenience objects, make sure all possible sub-objects are populated
099:                oldUser = (ChartUser) ((UniversalUser) document
100:                        .getOldMaintainableObject().getBusinessObject())
101:                        .getModuleUser(ChartUser.MODULE_ID);
102:                // ensure that the chartUser object is pointing to the main UU BO
103:                oldUser.setUniversalUser((UniversalUser) document
104:                        .getOldMaintainableObject().getBusinessObject());
105:                oldUser.refresh();
106:
107:                // setup newAccount convenience objects, make sure all possible sub-objects are populated
108:                newUser = (ChartUser) ((UniversalUser) document
109:                        .getNewMaintainableObject().getBusinessObject())
110:                        .getModuleUser(ChartUser.MODULE_ID);
111:                // ensure that the chartUser object is pointing to the main UU BO
112:                newUser.setUniversalUser((UniversalUser) document
113:                        .getNewMaintainableObject().getBusinessObject());
114:                newUser.refresh();
115:            }
116:
117:            /**
118:             * This checks the following conditions: If the user is going to be active then - they must be a valid employee - they must have
119:             * a valid chart of accounts - they must have a valid organization
120:             * 
121:             * @param document
122:             * @return false if any combination of the above conditions fails
123:             */
124:            private boolean checkGeneralRules(MaintenanceDocument document) {
125:                boolean success = true;
126:
127:                // only run these rules if the new user will be active
128:                if (newUser.isActive()) {
129:                    if (newUser.getUniversalUser() != null) {
130:                        // user must not have an employee status in the invalid list in the business rules (KULRNE-10)
131:                        if (!SpringContext
132:                                .getBean(ParameterService.class)
133:                                .getParameterEvaluator(
134:                                        ChartUser.class,
135:                                        KFSConstants.CoreApcParms.USER_INVALID_EMPLOYEE_STATUSES,
136:                                        newUser.getUniversalUser()
137:                                                .getEmployeeStatusCode())
138:                                .evaluationSucceeds()) {
139:                            success = false;
140:                            GlobalVariables
141:                                    .getErrorMap()
142:                                    .putError(
143:                                            "active",
144:                                            KFSKeyConstants.ERROR_DOCUMENT_KUALIUSERMAINT_INVALID_EMP_STATUS);
145:                        }
146:                    }
147:
148:                    // chart code (fin_coa_cd) must be entered and valid (nf_duser-350)
149:                    if (StringUtils.isNotEmpty(newUser
150:                            .getUserChartOfAccountsCode())) {
151:                        if (ObjectUtils
152:                                .isNull(newUser.getUserChartOfAccounts())) {
153:                            success = false;
154:                            GlobalVariables
155:                                    .getErrorMap()
156:                                    .putError(
157:                                            "userChartOfAccountsCode",
158:                                            KFSKeyConstants.ERROR_DOCUMENT_KUALIUSERMAINT_INVALID_CODE,
159:                                            new String[] { ddService
160:                                                    .getAttributeErrorLabel(
161:                                                            newUser.getClass(),
162:                                                            "userChartOfAccountsCode") });
163:                        }
164:                    }
165:
166:                    // (90-113) organization must be entered and valid (nf_duser-376)
167:                    if (StringUtils.isNotEmpty(newUser
168:                            .getUserOrganizationCode())) {
169:                        if (ObjectUtils.isNull(newUser.getUserOrganization())) {
170:                            success = false;
171:                            GlobalVariables
172:                                    .getErrorMap()
173:                                    .putError(
174:                                            "userOrganizationCode",
175:                                            KFSKeyConstants.ERROR_DOCUMENT_KUALIUSERMAINT_INVALID_CODE,
176:                                            new String[] { ddService
177:                                                    .getAttributeErrorLabel(
178:                                                            newUser.getClass(),
179:                                                            "userOrganizationCode") });
180:                        }
181:                    }
182:                }
183:
184:                return success;
185:            }
186:
187:            /**
188:             * This checks to make sure if a user is getting marked as inactive then they're responsibilities and groups need to be removed
189:             * first
190:             * 
191:             * @param document
192:             * @return false if user is still part of groups and has responsibilities and is being marked inactive
193:             */
194:            private boolean checkUserGroups(MaintenanceDocument document) {
195:                boolean success = true;
196:                // cannot mark a user inactive if they're a member of a workgroup, a review hierarchy, or account delegate. (nf_duser-254)
197:                // message to the user to tell them to remove the user from these groups before marking inactive
198:                // test is against 1 since all users belong to kualiUniversalGroup
199:                if (newUser.getUniversalUser().getGroups().size() > 1) {
200:                    success = false;
201:                }
202:                // this retrieves fiscal officer and account delegate responsibilities through
203:                // AccountDaoOjb.getAccountsThatUserIsResponsibleFor(KualiUser kualiUser)
204:                if (newUser.getAccountResponsibilities().size() > 0) {
205:                    success = false;
206:                }
207:                if (!success) {
208:                    GlobalVariables
209:                            .getErrorMap()
210:                            .putError(
211:                                    "active",
212:                                    KFSKeyConstants.ERROR_DOCUMENT_KUALIUSERMAINT_CANNOT_MARK_INACTIVE);
213:                }
214:
215:                return success;
216:            }
217:
218:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.