Source Code Cross Referenced for DisbursementVoucherDocumentAuthorizer.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.ArrayList;
019:        import java.util.HashMap;
020:        import java.util.List;
021:        import java.util.Map;
022:
023:        import org.apache.commons.collections.CollectionUtils;
024:        import org.kuali.core.authorization.AuthorizationConstants;
025:        import org.kuali.core.bo.user.UniversalUser;
026:        import org.kuali.core.document.Document;
027:        import org.kuali.core.document.authorization.DocumentActionFlags;
028:        import org.kuali.core.document.authorization.TransactionalDocumentActionFlags;
029:        import org.kuali.core.workflow.service.KualiWorkflowDocument;
030:        import org.kuali.kfs.KFSConstants;
031:        import org.kuali.kfs.KFSPropertyConstants;
032:        import org.kuali.kfs.context.SpringContext;
033:        import org.kuali.kfs.document.authorization.AccountingDocumentAuthorizerBase;
034:        import org.kuali.kfs.service.ParameterService;
035:        import org.kuali.module.financial.document.DisbursementVoucherDocument;
036:        import org.kuali.module.financial.rules.DisbursementVoucherRuleConstants;
037:        import org.kuali.workflow.KualiWorkflowUtils.RouteLevelNames;
038:
039:        /**
040:         * Document Authorizer for the Disbursement Voucher document.
041:         */
042:        public class DisbursementVoucherDocumentAuthorizer extends
043:                AccountingDocumentAuthorizerBase {
044:
045:            private static String taxGroupName;
046:            private static String travelGroupName;
047:            private static String wireTransferGroupName;
048:            private static String frnGroupName;
049:            private static String adminGroupName;
050:
051:            /**
052:             * Overrides to call super and then blanketly set the canBlanketApprove flag to false, since this is never allowed on a DV.
053:             * 
054:             * @see org.kuali.core.authorization.DocumentAuthorizer#getDocumentActionFlags(org.kuali.core.document.Document,
055:             *      org.kuali.core.bo.user.KualiUser)
056:             */
057:            public DocumentActionFlags getDocumentActionFlags(
058:                    Document document, UniversalUser user) {
059:                TransactionalDocumentActionFlags flags = new TransactionalDocumentActionFlags(
060:                        super .getDocumentActionFlags(document, user));
061:
062:                flags.setCanBlanketApprove(false); // this is never allowed on a DV document
063:
064:                flags.setCanErrorCorrect(false); // CR, DV, andd PCDO don't allow error correction
065:
066:                return flags;
067:            }
068:
069:            /**
070:             * @see org.kuali.core.authorization.DocumentAuthorizer#getEditMode(org.kuali.core.document.Document,
071:             *      org.kuali.core.bo.user.KualiUser)
072:             */
073:            public Map getEditMode(Document document, UniversalUser user,
074:                    List sourceLines, List targetLines) {
075:                KualiWorkflowDocument workflowDocument = document
076:                        .getDocumentHeader().getWorkflowDocument();
077:
078:                Map editModeMap = super .getEditMode(document, user,
079:                        sourceLines, targetLines);
080:                if (((workflowDocument.stateIsInitiated() || workflowDocument
081:                        .stateIsSaved()) && workflowDocument
082:                        .userIsInitiator(user))
083:                        || (workflowDocument.stateIsEnroute()
084:                                && workflowDocument.isApprovalRequested() && isSpecialRouting(
085:                                document, user))) {
086:                    setDVWorkgroupEditModes(editModeMap, document, user);
087:                }
088:
089:                return editModeMap;
090:            }
091:
092:            /**
093:             * Sets additional edit modes based on the user's workgroups.
094:             * 
095:             * @param editModeMap
096:             * @param document
097:             * @param user
098:             */
099:            private void setDVWorkgroupEditModes(Map editModeMap,
100:                    Document document, UniversalUser user) {
101:                if (isUserInTaxGroup(user)) {
102:                    editModeMap
103:                            .put(
104:                                    AuthorizationConstants.DisbursementVoucherEditMode.TAX_ENTRY,
105:                                    "TRUE");
106:                    editModeMap
107:                            .put(
108:                                    AuthorizationConstants.DisbursementVoucherEditMode.EXPENSE_SPECIAL_ENTRY,
109:                                    "TRUE");
110:                }
111:                if (isUserInFRNGroup(user)) {
112:                    editModeMap
113:                            .put(
114:                                    AuthorizationConstants.DisbursementVoucherEditMode.FRN_ENTRY,
115:                                    "TRUE");
116:                    editModeMap
117:                            .put(
118:                                    AuthorizationConstants.DisbursementVoucherEditMode.EXPENSE_SPECIAL_ENTRY,
119:                                    "TRUE");
120:                }
121:                if (isUserInTravelGroup(user)) {
122:                    editModeMap
123:                            .put(
124:                                    AuthorizationConstants.DisbursementVoucherEditMode.TRAVEL_ENTRY,
125:                                    "TRUE");
126:                    editModeMap
127:                            .put(
128:                                    AuthorizationConstants.DisbursementVoucherEditMode.EXPENSE_SPECIAL_ENTRY,
129:                                    "TRUE");
130:                }
131:                if (isUserInWireGroup(user)) {
132:                    editModeMap
133:                            .put(
134:                                    AuthorizationConstants.DisbursementVoucherEditMode.WIRE_ENTRY,
135:                                    "TRUE");
136:                    editModeMap
137:                            .put(
138:                                    AuthorizationConstants.DisbursementVoucherEditMode.EXPENSE_SPECIAL_ENTRY,
139:                                    "TRUE");
140:                }
141:                if (isUserInDvAdminGroup(user)) {
142:                    editModeMap
143:                            .put(
144:                                    AuthorizationConstants.DisbursementVoucherEditMode.ADMIN_ENTRY,
145:                                    "TRUE");
146:                    editModeMap
147:                            .put(
148:                                    AuthorizationConstants.DisbursementVoucherEditMode.EXPENSE_SPECIAL_ENTRY,
149:                                    "TRUE");
150:                }
151:            }
152:
153:            /**
154:             * Checks if the current user is a member of the dv tax workgroup.
155:             * 
156:             * @return true if user is in group
157:             */
158:            private boolean isUserInTaxGroup(UniversalUser user) {
159:                if (taxGroupName == null) {
160:                    taxGroupName = SpringContext
161:                            .getBean(ParameterService.class)
162:                            .getParameterValue(
163:                                    DisbursementVoucherDocument.class,
164:                                    KFSConstants.FinancialApcParms.DV_TAX_WORKGROUP);
165:                }
166:                return user.isMember(taxGroupName);
167:            }
168:
169:            /**
170:             * Checks if the current user is a member of the dv travel workgroup.
171:             * 
172:             * @return true if user is in group
173:             */
174:            private boolean isUserInTravelGroup(UniversalUser user) {
175:                if (travelGroupName == null) {
176:                    travelGroupName = SpringContext.getBean(
177:                            ParameterService.class).getParameterValue(
178:                            DisbursementVoucherDocument.class,
179:                            KFSConstants.FinancialApcParms.DV_TRAVEL_WORKGROUP);
180:                }
181:                return user.isMember(travelGroupName);
182:            }
183:
184:            /**
185:             * Checks if the current user is a member of the dv frn workgroup.
186:             * 
187:             * @return true if user is in group
188:             */
189:            private boolean isUserInFRNGroup(UniversalUser user) {
190:                if (frnGroupName == null) {
191:                    frnGroupName = SpringContext
192:                            .getBean(ParameterService.class)
193:                            .getParameterValue(
194:                                    DisbursementVoucherDocument.class,
195:                                    KFSConstants.FinancialApcParms.DV_FOREIGNDRAFT_WORKGROUP);
196:                }
197:                return user.isMember(frnGroupName);
198:            }
199:
200:            /**
201:             * Checks if the current user is a member of the dv wire workgroup.
202:             * 
203:             * @return true if user is in group
204:             */
205:            private boolean isUserInWireGroup(UniversalUser user) {
206:                if (wireTransferGroupName == null) {
207:                    wireTransferGroupName = SpringContext
208:                            .getBean(ParameterService.class)
209:                            .getParameterValue(
210:                                    DisbursementVoucherDocument.class,
211:                                    KFSConstants.FinancialApcParms.DV_WIRETRANSFER_WORKGROUP);
212:                }
213:                return user.isMember(wireTransferGroupName);
214:            }
215:
216:            /**
217:             * This method checks to see whether the user is in the dv admin group or not.
218:             * 
219:             * @return true if user is in group, false otherwise
220:             */
221:            private boolean isUserInDvAdminGroup(UniversalUser user) {
222:                if (adminGroupName == null) {
223:                    adminGroupName = SpringContext.getBean(
224:                            ParameterService.class).getParameterValue(
225:                            DisbursementVoucherDocument.class,
226:                            KFSConstants.FinancialApcParms.DV_ADMIN_WORKGROUP);
227:                }
228:                return user.isMember(adminGroupName);
229:            }
230:
231:            /**
232:             * @see org.kuali.core.authorization.DocumentAuthorizer#getAccountingLineEditableFields(org.kuali.core.document.Document,
233:             *      org.kuali.core.bo.user.KualiUser)
234:             */
235:            public Map getAccountingLineEditableFields(Document document,
236:                    UniversalUser user) {
237:                Map editableFields = new HashMap();
238:                KualiWorkflowDocument workflowDocument = document
239:                        .getDocumentHeader().getWorkflowDocument();
240:
241:                // only check special expense edits if we are in special routing
242:                if (!workflowDocument.stateIsEnroute()
243:                        || !workflowDocument.isApprovalRequested()
244:                        || !isSpecialRouting(document, user)) {
245:                    return editableFields;
246:                }
247:
248:                if (isUserInDvAdminGroup(user) || isUserInTravelGroup(user)) {
249:                    // retrieve allow object code edit indicator
250:                    boolean allowObjectEdits = SpringContext
251:                            .getBean(ParameterService.class)
252:                            .getIndicatorParameter(
253:                                    DisbursementVoucherDocument.class,
254:                                    DisbursementVoucherRuleConstants.ALLOW_OBJECT_CODE_EDITS);
255:                    if (allowObjectEdits) {
256:                        editableFields.put(
257:                                KFSPropertyConstants.FINANCIAL_OBJECT_CODE,
258:                                "TRUE");
259:                    }
260:                }
261:
262:                if (isUserInTaxGroup(user) || isUserInFRNGroup(user)
263:                        || isUserInWireGroup(user) || isUserInTravelGroup(user)) {
264:                    editableFields.put(KFSPropertyConstants.AMOUNT, "TRUE");
265:                }
266:
267:                return editableFields;
268:            }
269:
270:            /**
271:             * Determines if the current active routing nodes are one of the disbursement voucher special routing nodes.
272:             * 
273:             * @param document
274:             * @param user
275:             * @return boolean
276:             */
277:            public boolean isSpecialRouting(Document document,
278:                    UniversalUser user) {
279:                boolean isSpecialRouteNode = false;
280:
281:                KualiWorkflowDocument workflowDocument = document
282:                        .getDocumentHeader().getWorkflowDocument();
283:                List activeNodes = getCurrentRouteLevels(workflowDocument);
284:
285:                List dvSpecialNodes = new ArrayList();
286:                dvSpecialNodes.add(RouteLevelNames.ALIEN_INDICATOR);
287:                dvSpecialNodes
288:                        .add(RouteLevelNames.ALIEN_INDICATOR_PAYMENT_REASON);
289:                dvSpecialNodes.add(RouteLevelNames.CAMPUS_CODE);
290:                dvSpecialNodes.add(RouteLevelNames.EMPLOYEE_INDICATOR);
291:                dvSpecialNodes.add(RouteLevelNames.PAYMENT_METHOD);
292:                dvSpecialNodes.add(RouteLevelNames.PAYMENT_REASON);
293:                dvSpecialNodes.add(RouteLevelNames.PAYMENT_REASON_CAMPUS);
294:                dvSpecialNodes.add(RouteLevelNames.TAX_CONTROL_CODE);
295:
296:                if (CollectionUtils.containsAny(activeNodes, dvSpecialNodes)) {
297:                    isSpecialRouteNode = true;
298:                }
299:
300:                return isSpecialRouteNode;
301:            }
302:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.