1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.vnd.document.authorization;
17
18 import java.util.Collections;
19 import java.util.HashMap;
20 import java.util.Map;
21 import java.util.Set;
22
23 import org.kuali.ole.sys.OLEConstants;
24 import org.kuali.ole.sys.context.SpringContext;
25 import org.kuali.ole.sys.document.authorization.FinancialSystemMaintenanceDocumentPresentationControllerBase;
26 import org.kuali.ole.vnd.VendorPropertyConstants;
27 import org.kuali.ole.vnd.businessobject.VendorDetail;
28 import org.kuali.rice.kim.api.KimConstants;
29 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
30 import org.kuali.rice.kns.document.MaintenanceDocument;
31 import org.kuali.rice.kns.service.DocumentHelperService;
32 import org.kuali.rice.krad.bo.BusinessObject;
33 import org.kuali.rice.krad.document.Document;
34 import org.kuali.rice.krad.util.GlobalVariables;
35 import org.kuali.rice.krad.util.ObjectUtils;
36
37 public class VendorDocumentPresentationController extends FinancialSystemMaintenanceDocumentPresentationControllerBase {
38
39 @Override
40 public Set<String> getConditionallyReadOnlySectionIds(MaintenanceDocument document) {
41 Set<String> conditionallyReadOnlySectionIds = super.getConditionallyReadOnlySectionIds(document);
42 VendorDetail vendor = (VendorDetail)document.getNewMaintainableObject().getDataObject();
43
44 if (!vendor.isVendorParentIndicator()) {
45
46 conditionallyReadOnlySectionIds.add(VendorPropertyConstants.VENDOR_SUPPLIER_DIVERSITIES);
47 }
48
49 return conditionallyReadOnlySectionIds;
50 }
51
52 @Override
53 public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) {
54 Set<String> conditionallyReadonlyPropertyNames = super.getConditionallyReadOnlyPropertyNames(document);
55 VendorDetail vendor = (VendorDetail)document.getNewMaintainableObject().getDataObject();
56 VendorDocumentAuthorizer documentAuthorizer = (VendorDocumentAuthorizer) SpringContext.getBean(DocumentHelperService.class).getDocumentAuthorizer(document);
57 boolean isAuthorized = documentAuthorizer.isAuthorized(document, VendorPropertyConstants.OLE_VND, VendorPropertyConstants.PERMISSION_NAME_INACTIVATE_VENDOR, GlobalVariables.getUserSession().getPerson().getPrincipalId());
58
59 String nameSpaceCode = OLEConstants.Vendor.VENDOR_NAMESPACE;
60
61 boolean hasPermission = KimApiServiceLocator.getPermissionService().hasPermission(
62 GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
63 OLEConstants.Vendor.DEACTIVATE_VENDOR);
64 boolean hasPermissionVendorFlag = KimApiServiceLocator.getPermissionService().hasPermission(
65 GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
66 OLEConstants.Vendor.EDIT_VENDOR_LINKING_NUM);
67
68 if (!isAuthorized) {
69 if (!hasPermission) {
70 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_ACTIVE_INDICATOR);
71 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_INACTIVE_REASON);
72 }
73 if (!hasPermissionVendorFlag) {
74 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_LINKING_NUMBER);
75 }
76 }
77 if (vendor.isVendorParentIndicator()) {
78
79 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_PARENT_INDICATOR);
80
81
82 if (ObjectUtils.isNotNull(vendor.getVendorHeaderGeneratedIdentifier()) && !vendor.getVendorHeader().getVendorType().isVendorTypeChangeAllowedIndicator()) {
83 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_TYPE_CODE);
84 }
85 }
86
87
88 else {
89
90 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_TYPE_CODE);
91 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_TAX_NUMBER);
92 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_TAX_TYPE_CODE);
93 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_OWNERSHIP_CODE);
94 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_OWNERSHIP_CATEGORY_CODE);
95 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_FEDERAL_WITHOLDING_TAX_BEGINNING_DATE);
96 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_FEDERAL_WITHOLDING_TAX_END_DATE);
97 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_W9_RECEIVED_INDICATOR);
98 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_W8_BEN_RECEIVED_INDICATOR);
99 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_DEBARRED_INDICATOR);
100 conditionallyReadonlyPropertyNames.add(VendorPropertyConstants.VENDOR_FOREIGN_INDICATOR);
101 }
102
103 return conditionallyReadonlyPropertyNames;
104 }
105
106 @Override
107 public Set<String> getConditionallyHiddenPropertyNames(BusinessObject businessObject) {
108 Set<String> conditionallyHiddenPropertyNames = super.getConditionallyHiddenPropertyNames(businessObject);
109 MaintenanceDocument document = (MaintenanceDocument) businessObject;
110 VendorDetail vendor = (VendorDetail)document.getNewMaintainableObject().getDataObject();
111
112 if (vendor.isVendorParentIndicator()) {
113 conditionallyHiddenPropertyNames.add(VendorPropertyConstants.VENDOR_PARENT_NAME);
114 }
115
116 return conditionallyHiddenPropertyNames;
117 }
118
119 @Override
120 public boolean canBlanketApprove(Document document) {
121
122 String documentTypeName = OLEConstants.Vendor.DOCUMENT_TYPE;
123 String nameSpaceCode = OLEConstants.Vendor.VENDOR_NAMESPACE;
124 Map<String,String> permissionDetails = new HashMap<String, String>();
125 permissionDetails.put(KimConstants.AttributeConstants.DOCUMENT_TYPE_NAME,documentTypeName);
126 boolean hasPermission = false;
127
128
129
130 if (!document.getDocumentHeader().getWorkflowDocument().getStatus().getCode().equalsIgnoreCase(OLEConstants.FINAL_STATUS)) {
131 hasPermission = KimApiServiceLocator.getPermissionService().hasPermission(
132 GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
133 OLEConstants.Vendor.BLANKET_APPROVE_VENDOR_DOCUMENT);
134 }
135
136 Map<String,String> roleQualifiers = new HashMap<String,String>();
137
138
139
140
141
142 if(!hasPermission) {
143 permissionDetails.put(KimConstants.AttributeConstants.REQUIRED,"FALSE");
144 permissionDetails.put(KimConstants.AttributeConstants.ACTION_DETAILS_AT_ROLE_MEMBER_LEVEL,"FALSE");
145 permissionDetails.put(KimConstants.AttributeConstants.ROUTE_NODE_NAME,OLEConstants.Vendor.VENDOR_MANAGEMENT);
146
147
148
149
150
151
152 hasPermission = KimApiServiceLocator.getResponsibilityService().hasResponsibility(GlobalVariables.getUserSession().getPerson().getPrincipalId(),OLEConstants.CoreModuleNamespaces.VENDOR, OLEConstants.Vendor.VENDOR_REVIEW_DOCUMENT, Collections.<String, String>emptyMap());
153
154
155 }
156
157 return hasPermission;
158 }
159
160 }