001/* 002 * Copyright 2008 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.fp.document.authorization; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.ole.fp.document.BudgetAdjustmentDocument; 020import org.kuali.ole.fp.service.FiscalYearFunctionControlService; 021import org.kuali.ole.sys.businessobject.AccountingLine; 022import org.kuali.ole.sys.context.SpringContext; 023import org.kuali.ole.sys.document.AccountingDocument; 024import org.kuali.ole.sys.document.authorization.AccountingLineAuthorizerBase; 025 026/** 027 * The line authorizer for Budget Adjustment documents, which makes the base amount read only if it can't be edited for the given 028 * fiscal year 029 */ 030public class BudgetAdjustmentAccountingLineAuthorizer extends AccountingLineAuthorizerBase { 031 032 /** 033 * Overridden to make base amount read only if it is not available to be edited for the given fiscal year 034 * 035 * @see org.kuali.ole.sys.document.authorization.AccountingLineAuthorizerBase#determineFieldModifyability(org.kuali.ole.sys.document.AccountingDocument, 036 * org.kuali.ole.sys.businessobject.AccountingLine, org.kuali.ole.sys.document.web.AccountingLineViewField, java.util.Map) 037 */ 038 @Override 039 public boolean determineEditPermissionOnField(AccountingDocument accountingDocument, AccountingLine accountingLine, String accountingLineCollectionProperty, String fieldName, boolean editablePage) { 040 final boolean canModify = super.determineEditPermissionOnField(accountingDocument, accountingLine, accountingLineCollectionProperty, fieldName, editablePage); 041 042 if (StringUtils.equals(fieldName, getBaseAmountPropertyName())) { 043 return SpringContext.getBean(FiscalYearFunctionControlService.class).isBaseAmountChangeAllowed(((BudgetAdjustmentDocument) accountingDocument).getPostingYear()); 044 } 045 046 return canModify; 047 } 048 049 /** 050 * @return the property name of the base amount field, which will be set to read only under certain conditions 051 */ 052 protected String getBaseAmountPropertyName() { 053 return "baseBudgetAdjustmentAmount"; 054 } 055}