View Javadoc
1   /*
2    * Copyright 2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.coa.document.authorization;
17  
18  import java.util.Set;
19  
20  import org.kuali.ole.coa.businessobject.Account;
21  import org.kuali.ole.sys.OLEConstants;
22  import org.kuali.ole.sys.document.authorization.FinancialSystemMaintenanceDocumentPresentationControllerBase;
23  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
24  import org.kuali.rice.kns.document.MaintenanceDocument;
25  import org.kuali.rice.krad.util.GlobalVariables;
26  
27  public class AccountDocumentPresentationController extends FinancialSystemMaintenanceDocumentPresentationControllerBase {
28  
29  
30      @Override
31      public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) {
32          Set<String> conditionallyReadonlyPropertyNames = super.getConditionallyReadOnlyPropertyNames(document);
33          Account vendor = (Account) document.getNewMaintainableObject().getBusinessObject();
34  
35          String nameSpaceCode = OLEConstants.Account.ACCOUNT_NAMESPACE;
36  
37          boolean hasPermission = KimApiServiceLocator.getPermissionService().hasPermission(
38                  GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
39                  OLEConstants.Account.ACCOUNT_RESTRICTIONS);
40          boolean hasPermissionVendorFlag = KimApiServiceLocator.getPermissionService().hasPermission(
41                  GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode,
42                  OLEConstants.Account.ACCOUNT_SUFFICIENT_FUND);
43  
44              if (!hasPermission) {
45                  conditionallyReadonlyPropertyNames.add(OLEConstants.Account.ACCOUNT_RESTRICTED_STATUS_CD);
46              }
47              if (!hasPermissionVendorFlag) {
48                  conditionallyReadonlyPropertyNames.add(OLEConstants.Account.ACCOUNT_SUFFICIENT_FUND_CODE);
49              }
50              return conditionallyReadonlyPropertyNames;
51      }
52  
53  
54  }