Source Code Cross Referenced for PurchaseOrderDocumentAuthorizer.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » module » purap » 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.purap.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.purap.document.authorization;
017:
018:        import java.util.HashMap;
019:        import java.util.List;
020:        import java.util.Map;
021:
022:        import org.apache.commons.lang.StringUtils;
023:        import org.kuali.core.authorization.AuthorizationConstants;
024:        import org.kuali.core.bo.user.UniversalUser;
025:        import org.kuali.core.document.Document;
026:        import org.kuali.core.document.authorization.DocumentActionFlags;
027:        import org.kuali.core.exceptions.GroupNotFoundException;
028:        import org.kuali.core.service.KualiGroupService;
029:        import org.kuali.core.util.GlobalVariables;
030:        import org.kuali.core.util.ObjectUtils;
031:        import org.kuali.core.workflow.service.KualiWorkflowDocument;
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.purap.PurapAuthorizationConstants;
036:        import org.kuali.module.purap.PurapParameterConstants;
037:        import org.kuali.module.purap.PurapWorkflowConstants;
038:        import org.kuali.module.purap.PurapConstants.PurchaseOrderStatuses;
039:        import org.kuali.module.purap.PurapWorkflowConstants.PurchaseOrderDocument.NodeDetailEnum;
040:        import org.kuali.module.purap.document.PurchaseOrderDocument;
041:        import org.kuali.module.purap.service.PurApWorkflowIntegrationService;
042:
043:        /**
044:         * Document Authorizer for the PO document.
045:         */
046:        public class PurchaseOrderDocumentAuthorizer extends
047:                AccountingDocumentAuthorizerBase {
048:
049:            /**
050:             * @see org.kuali.core.document.authorization.DocumentAuthorizerBase#hasInitiateAuthorization(org.kuali.core.document.Document,
051:             *      org.kuali.core.bo.user.UniversalUser)
052:             */
053:            @Override
054:            public boolean hasInitiateAuthorization(Document document,
055:                    UniversalUser user) {
056:                String authorizedWorkgroup = SpringContext
057:                        .getBean(ParameterService.class)
058:                        .getParameterValue(
059:                                PurchaseOrderDocument.class,
060:                                PurapParameterConstants.Workgroups.PURAP_DOCUMENT_PO_INITIATE_ACTION);
061:                try {
062:                    return SpringContext.getBean(KualiGroupService.class)
063:                            .getByGroupName(authorizedWorkgroup)
064:                            .hasMember(user);
065:                } catch (GroupNotFoundException e) {
066:                    throw new RuntimeException("Workgroup "
067:                            + authorizedWorkgroup + " not found", e);
068:                }
069:            }
070:
071:            /**
072:             * This is essentially the same getEditMode as in DocumentAuthorizerBase.java. In AccountingDocumentAuthorizerBase.java, which
073:             * is currently the superclass of this class, this method is being overriden. Unfortunately it will return view only edit mode
074:             * if the initiator of the document is different than the current user. Currently the initiators of Purchase Order Document are
075:             * all "Kuali System User" which is different than the users that we use to log in. Therefore here we have to re-override the
076:             * getEditMode to prevent the problem where the fields appear as read-only. There has been an addition to this method, which at
077:             * this point I'm not sure whether there would be any cases where the Purchase Order Document would have status "RETR". If so,
078:             * then when the status code is "RETR" (retransmit), the edit mode should be set to displayRetransmitTab because we want to hide
079:             * the other tabs and display the retransmit tab when the user clicks on the Retransmit button (is that what we want ?)
080:             * 
081:             * @see org.kuali.core.document.authorization.DocumentAuthorizer#getEditMode(org.kuali.core.document.Document,
082:             *      org.kuali.core.bo.user.UniversalUser)
083:             */
084:            @Override
085:            public Map getEditMode(Document d, UniversalUser user,
086:                    List sourceAccountingLines, List targetAccountingLines) {
087:                Map editModeMap = new HashMap();
088:                String editMode = AuthorizationConstants.EditMode.VIEW_ONLY;
089:
090:                KualiWorkflowDocument workflowDocument = d.getDocumentHeader()
091:                        .getWorkflowDocument();
092:
093:                PurchaseOrderDocument poDocument = (PurchaseOrderDocument) d;
094:                if (workflowDocument.stateIsInitiated()
095:                        || workflowDocument.stateIsSaved()
096:                        || workflowDocument.stateIsEnroute()) {
097:                    if (ObjectUtils.isNotNull(poDocument
098:                            .getVendorHeaderGeneratedIdentifier())) {
099:                        editModeMap
100:                                .put(
101:                                        PurapAuthorizationConstants.PurchaseOrderEditMode.LOCK_VENDOR_ENTRY,
102:                                        "TRUE");
103:                    }
104:                }
105:
106:                if (workflowDocument.stateIsInitiated()
107:                        || workflowDocument.stateIsSaved()) {
108:                    if (hasInitiateAuthorization(d, user)) {
109:                        editMode = AuthorizationConstants.EditMode.FULL_ENTRY;
110:
111:                        // PRE_ROUTE_CHANGEABLE mode is used for fields that are editable only before PO is routed
112:                        // for ex, contract manager, manual status change, and quote etc
113:                        editModeMap
114:                                .put(
115:                                        PurapAuthorizationConstants.PurchaseOrderEditMode.PRE_ROUTE_CHANGEABLE,
116:                                        "TRUE");
117:                    }
118:                } else if (workflowDocument.stateIsEnroute()
119:                        && workflowDocument.isApprovalRequested()) {
120:                    List currentRouteLevels = getCurrentRouteLevels(workflowDocument);
121:
122:                    /**
123:                     * INTERNAL PURCHASING ROUTE LEVEL - Approvers can edit full detail on Purchase Order except they cannot change the
124:                     * CHART/ORG.
125:                     */
126:                    if (((PurchaseOrderDocument) d)
127:                            .isDocumentStoppedInRouteNode(PurapWorkflowConstants.PurchaseOrderDocument.NodeDetailEnum.INTERNAL_PURCHASING_REVIEW)) {
128:                        // FULL_ENTRY allowed; also set internal purchasing lock
129:                        editMode = AuthorizationConstants.EditMode.FULL_ENTRY;
130:                        editModeMap
131:                                .put(
132:                                        PurapAuthorizationConstants.PurchaseOrderEditMode.LOCK_INTERNAL_PURCHASING_ENTRY,
133:                                        "TRUE");
134:                    }
135:
136:                    /**
137:                     * CONTRACTS & GRANTS ROUTE LEVEL - Approvers cannot edit any detail on PO. BUDGET OFFICE ROUTE LEVEL - Approvers cannot
138:                     * edit any detail on PO. VENDOR TAX ROUTE LEVEL - Approvers cannot edit any detail on PO. DOCUMENT TRANSMISSION ROUTE
139:                     * LEVEL - Approvers cannot edit any detail on PO.
140:                     */
141:                    else {
142:                        // VIEW_ENTRY that is already being set is sufficient.
143:                    }
144:                }
145:                editModeMap.put(editMode, "TRUE");
146:
147:                return editModeMap;
148:            }
149:
150:            @Override
151:            public DocumentActionFlags getDocumentActionFlags(
152:                    Document document, UniversalUser user) {
153:                DocumentActionFlags flags = super .getDocumentActionFlags(
154:                        document, user);
155:                PurchaseOrderDocument po = (PurchaseOrderDocument) document;
156:                String statusCode = po.getStatusCode();
157:
158:                if ((StringUtils.equals(statusCode,
159:                        PurchaseOrderStatuses.WAITING_FOR_DEPARTMENT))
160:                        || (StringUtils.equals(statusCode,
161:                                PurchaseOrderStatuses.WAITING_FOR_VENDOR))) {
162:                    flags.setCanRoute(false);
163:                } else if (PurchaseOrderStatuses.STATUSES_BY_TRANSMISSION_TYPE
164:                        .values().contains(statusCode)) {
165:                    if (SpringContext.getBean(
166:                            PurApWorkflowIntegrationService.class)
167:                            .isActionRequestedOfUserAtNodeName(
168:                                    po.getDocumentNumber(),
169:                                    NodeDetailEnum.DOCUMENT_TRANSMISSION
170:                                            .getName(),
171:                                    GlobalVariables.getUserSession()
172:                                            .getUniversalUser())) {
173:                        /*
174:                         * code below for overriding workflow buttons has to do with hiding the workflow buttons but still allowing the
175:                         * actions... this is needed because document service calls this method (getDocumentActionFlags) before it will
176:                         * allow a workflow action to be performed
177:                         */
178:                        if (ObjectUtils.isNotNull(po
179:                                .getOverrideWorkflowButtons())
180:                                && (po.getOverrideWorkflowButtons())) {
181:                            /*
182:                             * if document is in pending transmission status and current user has document transmission action request then
183:                             * assume that the transmit button/action whatever it might be will take associated workflow action for user
184:                             * automatically
185:                             */
186:                            flags.setCanApprove(false);
187:                            flags.setCanDisapprove(false);
188:                            flags.setCanAcknowledge(false);
189:                            flags.setCanFYI(false);
190:                        }
191:                    }
192:                }
193:                if (po
194:                        .isDocumentStoppedInRouteNode(NodeDetailEnum.INTERNAL_PURCHASING_REVIEW)) {
195:                    flags.setCanSave(true);
196:                    // NEED TO REDO ANNOTATE CHECK SINCE CHANGED THE VALUE OF FLAGS
197:                    this.setAnnotateFlag(flags);
198:                }
199:
200:                return flags;
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.