Source Code Cross Referenced for ServiceBillingDocumentAuthorizer.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » financial » document » authorization » 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.document.authorization 
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.financial.document.authorization;
017:
018:        import java.util.HashMap;
019:        import java.util.List;
020:        import java.util.Map;
021:
022:        import org.apache.commons.logging.Log;
023:        import org.apache.commons.logging.LogFactory;
024:        import org.kuali.core.bo.user.UniversalUser;
025:        import org.kuali.core.document.Document;
026:        import org.kuali.core.document.TransactionalDocument;
027:        import org.kuali.core.document.authorization.DocumentActionFlags;
028:        import org.kuali.core.document.authorization.TransactionalDocumentActionFlags;
029:        import org.kuali.core.exceptions.DocumentTypeAuthorizationException;
030:        import org.kuali.kfs.bo.AccountingLine;
031:        import org.kuali.kfs.bo.SourceAccountingLine;
032:        import org.kuali.kfs.context.SpringContext;
033:        import org.kuali.kfs.document.authorization.AccountingDocumentAuthorizerBase;
034:        import org.kuali.module.chart.bo.ChartUser;
035:        import org.kuali.module.financial.bo.ServiceBillingControl;
036:        import org.kuali.module.financial.document.ServiceBillingDocument;
037:        import org.kuali.module.financial.rules.ServiceBillingDocumentRuleUtil;
038:        import org.kuali.module.financial.service.ServiceBillingControlService;
039:
040:        /**
041:         * Authorization permissions specific to the Service Billing document.
042:         */
043:        public class ServiceBillingDocumentAuthorizer extends
044:                AccountingDocumentAuthorizerBase {
045:            private static Log LOG = LogFactory
046:                    .getLog(ServiceBillingDocumentAuthorizer.class);
047:
048:            /**
049:             * Overrides to always return false because there is never FO routing or FO approval for SB docs.
050:             * 
051:             * @see FinancialDocumentAuthorizer#userOwnsAnyAccountingLine(KualiUser, List)
052:             */
053:            protected boolean userOwnsAnyAccountingLine(UniversalUser user,
054:                    List accountingLines) {
055:                return false;
056:            }
057:
058:            /**
059:             * Overrides parent to return an empty Map since FO routing doesn't apply to the SB doc.
060:             * 
061:             * @see org.kuali.core.authorization.TransactionalDocumentAuthorizer#getEditableAccounts(org.kuali.core.document.TransactionalDocument,
062:             *      KualiUser)
063:             */
064:            public Map getEditableAccounts(TransactionalDocument document,
065:                    ChartUser user) {
066:                return new HashMap();
067:            }
068:
069:            /**
070:             * Overrides parent to return an empty Map since FO routing doesn't apply to the SB doc.
071:             * 
072:             * @see org.kuali.kfs.document.authorization.AccountingDocumentAuthorizerBase#getEditableAccounts(java.util.List,
073:             *      org.kuali.module.chart.bo.ChartUser)
074:             */
075:            @Override
076:            public Map getEditableAccounts(List<AccountingLine> lines,
077:                    ChartUser user) {
078:                return new HashMap();
079:            }
080:
081:            /**
082:             * SB docs use FP_SB_CTRL_T to limit income account users by workgroup. Thus a user who is not in any of the workgroups in that
083:             * table will not be able to add any income accounting lines. This method uses those groups directly for initiation authority,
084:             * instead of another group, so the administrator does not need to add users to multiple SB groups.
085:             * 
086:             * @see org.kuali.core.authorization.DocumentAuthorizer#canInitiate(java.lang.String, org.kuali.core.bo.user.KualiUser)
087:             */
088:            public void canInitiate(String documentTypeName, UniversalUser user) {
089:                boolean canInitiate = false;
090:                ServiceBillingControl[] controls = SpringContext.getBean(
091:                        ServiceBillingControlService.class).getAll();
092:                for (int i = 0; i < controls.length; i++) {
093:                    if (user.isMember(controls[i].getWorkgroupName())) {
094:                        canInitiate = true;
095:                    }
096:                }
097:                if (!canInitiate) {
098:                    // TODO: Give better message listing the required control workgroup names using DocumentInitiationAuthorizationException
099:                    throw new DocumentTypeAuthorizationException(user
100:                            .getPersonUserIdentifier(), "initiate",
101:                            documentTypeName);
102:                }
103:            }
104:
105:            /**
106:             * Overrides the error-correct flag for SB income account control. Unlike a copy, an SB error correction's income accounts
107:             * cannot be changed, so if this user isn't authorized for all those income accounts then he won't be able to save or submit the
108:             * error correction. We avoid this frustration by hiding that button in the first place.
109:             * 
110:             * @see org.kuali.kfs.document.authorization.AccountingDocumentAuthorizerBase#getDocumentActionFlags(org.kuali.core.document.Document,
111:             *      org.kuali.core.bo.user.KualiUser)
112:             */
113:            @Override
114:            public DocumentActionFlags getDocumentActionFlags(
115:                    Document document, UniversalUser user) {
116:                TransactionalDocumentActionFlags flags = (TransactionalDocumentActionFlags) super 
117:                        .getDocumentActionFlags(document, user);
118:                boolean canUseAllIncomeSectionAccountsBool = false;
119:                if (flags.getCanErrorCorrect() || flags.getCanCopy()) {
120:                    // canUseAllIncomeSectionAccounts may be an expensive operation, so we only invoke it exactly once only if it's
121:                    // absolutely necessary
122:                    // (i.e. can error correct or copy flags are true)
123:                    // if any of these flags are false, we rely on short circuiting to ignore the value of this variable when
124:                    // any of the flags are false
125:                    canUseAllIncomeSectionAccountsBool = canUseAllIncomeSectionAccounts(
126:                            (ServiceBillingDocument) document, user);
127:                }
128:                flags.setCanErrorCorrect(flags.getCanErrorCorrect()
129:                        && canUseAllIncomeSectionAccountsBool);
130:                flags.setCanCopy(flags.getCanCopy()
131:                        && canUseAllIncomeSectionAccountsBool);
132:                return flags;
133:            }
134:
135:            /**
136:             * @param serviceBillingDocument
137:             * @param user
138:             * @return whether the given user is allowed to use all of the accounts in the given SB doc's income accounting lines section
139:             */
140:            private static boolean canUseAllIncomeSectionAccounts(
141:                    ServiceBillingDocument serviceBillingDocument,
142:                    UniversalUser user) {
143:                for (SourceAccountingLine sourceAccountingLine : ((List<SourceAccountingLine>) serviceBillingDocument
144:                        .getSourceAccountingLines())) {
145:                    if (!ServiceBillingDocumentRuleUtil
146:                            .serviceBillingIncomeAccountIsAccessible(
147:                                    sourceAccountingLine, null, user)) {
148:                        return false;
149:                    }
150:                }
151:                return true;
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.