001/* 002 * Copyright 2009 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.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/ecl2.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 */ 016package org.kuali.ole.coa.document.authorization; 017 018import java.util.Set; 019 020import org.kuali.ole.coa.businessobject.Account; 021import org.kuali.ole.sys.OLEConstants; 022import org.kuali.ole.sys.document.authorization.FinancialSystemMaintenanceDocumentPresentationControllerBase; 023import org.kuali.rice.kim.api.services.KimApiServiceLocator; 024import org.kuali.rice.kns.document.MaintenanceDocument; 025import org.kuali.rice.krad.util.GlobalVariables; 026 027public class AccountDocumentPresentationController extends FinancialSystemMaintenanceDocumentPresentationControllerBase { 028 029 030 @Override 031 public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) { 032 Set<String> conditionallyReadonlyPropertyNames = super.getConditionallyReadOnlyPropertyNames(document); 033 Account vendor = (Account) document.getNewMaintainableObject().getBusinessObject(); 034 035 String nameSpaceCode = OLEConstants.Account.ACCOUNT_NAMESPACE; 036 037 boolean hasPermission = KimApiServiceLocator.getPermissionService().hasPermission( 038 GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode, 039 OLEConstants.Account.ACCOUNT_RESTRICTIONS); 040 boolean hasPermissionVendorFlag = KimApiServiceLocator.getPermissionService().hasPermission( 041 GlobalVariables.getUserSession().getPerson().getPrincipalId(), nameSpaceCode, 042 OLEConstants.Account.ACCOUNT_SUFFICIENT_FUND); 043 044 if (!hasPermission) { 045 conditionallyReadonlyPropertyNames.add(OLEConstants.Account.ACCOUNT_RESTRICTED_STATUS_CD); 046 } 047 if (!hasPermissionVendorFlag) { 048 conditionallyReadonlyPropertyNames.add(OLEConstants.Account.ACCOUNT_SUFFICIENT_FUND_CODE); 049 } 050 return conditionallyReadonlyPropertyNames; 051 } 052 053 054}