Source Code Cross Referenced for ServiceBillingDocumentRuleUtil.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 static org.kuali.core.util.AssertionUtils.assertThat;
019:
020:        import org.apache.commons.lang.StringUtils;
021:        import org.kuali.core.bo.user.UniversalUser;
022:        import org.kuali.core.util.GlobalVariables;
023:        import org.kuali.core.util.ObjectUtils;
024:        import org.kuali.kfs.KFSKeyConstants;
025:        import org.kuali.kfs.KFSPropertyConstants;
026:        import org.kuali.kfs.bo.AccountingLine;
027:        import org.kuali.kfs.context.SpringContext;
028:        import org.kuali.kfs.rules.AccountingDocumentRuleBase;
029:        import org.kuali.module.financial.bo.ServiceBillingControl;
030:        import org.kuali.module.financial.service.ServiceBillingControlService;
031:
032:        /**
033:         * This class contains static helper methods for ServiceBillingDocumentRule and ServiceBillingDocumentAuthorizer.
034:         */
035:        public class ServiceBillingDocumentRuleUtil {
036:
037:            /**
038:             * Checks the account and current user against the service billing control table.
039:             * 
040:             * @param accountingLine The accounting line from the income section of the service billing document.
041:             * @param action The type of error messages to generate, if not null.
042:             * @return Whether the current user is authorized to use the given account in the service billing income section.
043:             */
044:            public static boolean serviceBillingIncomeAccountIsAccessible(
045:                    AccountingLine accountingLine,
046:                    AccountingDocumentRuleBase.AccountingLineAction action) {
047:                return serviceBillingIncomeAccountIsAccessible(accountingLine,
048:                        action, GlobalVariables.getUserSession()
049:                                .getUniversalUser());
050:            }
051:
052:            /**
053:             * Checks the account and user against the service billing control table.
054:             * 
055:             * @param accountingLine The accounting line from the income section of the service billing document.
056:             * @param action The type of error messages to generate, if not null.
057:             * @param user The user for whom to check accessibility.
058:             * @return Whether the given user is authorized to use the given account in the service billing income section.
059:             */
060:            public static boolean serviceBillingIncomeAccountIsAccessible(
061:                    AccountingLine accountingLine,
062:                    AccountingDocumentRuleBase.AccountingLineAction action,
063:                    UniversalUser user) {
064:                assertThat(accountingLine.isSourceAccountingLine(),
065:                        accountingLine);
066:                String chartOfAccountsCode = accountingLine
067:                        .getChartOfAccountsCode();
068:                String accountNumber = accountingLine.getAccountNumber();
069:                if (StringUtils.isEmpty(chartOfAccountsCode)
070:                        || StringUtils.isEmpty(accountNumber)) {
071:                    // Ignore empty key because hasAccessibleAccountingLines() may not validate beforehand.
072:                    return false;
073:                }
074:                ServiceBillingControl control = SpringContext.getBean(
075:                        ServiceBillingControlService.class).getByPrimaryId(
076:                        chartOfAccountsCode, accountNumber);
077:                if (ObjectUtils.isNull(control)) {
078:                    if (action != null) {
079:                        GlobalVariables.getErrorMap().putError(
080:                                KFSPropertyConstants.ACCOUNT_NUMBER,
081:                                noServiceBillingControlErrorKey(action),
082:                                accountingLine.getAccountNumber());
083:                    }
084:                    return false;
085:                }
086:
087:                if (user.isMember(control.getWorkgroupName())) {
088:                    return true;
089:                } else {
090:                    if (action != null) {
091:                        GlobalVariables.getErrorMap().putError(
092:                                KFSPropertyConstants.ACCOUNT_NUMBER,
093:                                notControlGroupMemberErrorKey(action),
094:                                accountingLine.getAccountNumber(),
095:                                user.getPersonUserIdentifier(),
096:                                control.getWorkgroupName());
097:                    }
098:                    return false;
099:                }
100:            }
101:
102:            /**
103:             * This method determines what error key to use when posting the associated error.  The error key is determined 
104:             * based on the constants passed in, which are values defined in the AccountingDocumentRuleBase.AccountingLineAction.
105:             * 
106:             * @param action The constant used to identify which error key to return.
107:             * @return The error key for not having a service billing control.
108:             * 
109:             * @see AccountingDocumentRuleBase.AccountingLineAction
110:             */
111:            private static String noServiceBillingControlErrorKey(
112:                    AccountingDocumentRuleBase.AccountingLineAction action) {
113:                switch (action) {
114:                case ADD:
115:                    return KFSKeyConstants.ERROR_ACCOUNTINGLINE_INACCESSIBLE_ADD_NO_SB_CTRL;
116:                case UPDATE:
117:                    return KFSKeyConstants.ERROR_ACCOUNTINGLINE_INACCESSIBLE_UPDATE_NO_SB_CTRL;
118:                case DELETE:
119:                    return KFSKeyConstants.ERROR_ACCOUNTINGLINE_INACCESSIBLE_DELETE_NO_SB_CTRL;
120:                default:
121:                    throw new AssertionError(action);
122:                }
123:            }
124:
125:            /**
126:             * This method determines what error key to use when posting the associated error.  The error key is determined 
127:             * based on the constants passed in, which are values defined in the AccountingDocumentRuleBase.AccountingLineAction.
128:             * 
129:             * @param action The constant used to identify which error key to return.
130:             * @return The error key for not being a member of the workgroup of the necessary service billing control.
131:             * 
132:             * @see AccountingDocumentRuleBase.AccountingLineAction
133:             */
134:            private static String notControlGroupMemberErrorKey(
135:                    AccountingDocumentRuleBase.AccountingLineAction action) {
136:                switch (action) {
137:                case ADD:
138:                    return KFSKeyConstants.ERROR_ACCOUNTINGLINE_INACCESSIBLE_ADD_NOT_IN_SB_CTRL_GRP;
139:                case UPDATE:
140:                    return KFSKeyConstants.ERROR_ACCOUNTINGLINE_INACCESSIBLE_UPDATE_NOT_IN_SB_CTRL_GRP;
141:                case DELETE:
142:                    return KFSKeyConstants.ERROR_ACCOUNTINGLINE_INACCESSIBLE_DELETE_NOT_IN_SB_CTRL_GRP;
143:                default:
144:                    throw new AssertionError(action);
145:                }
146:            }
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.