001 /* 002 * Copyright 2011 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 */ 016 017 package org.kuali.kfs.coa.document.authorization; 018 019 import java.util.Set; 020 021 import org.kuali.kfs.coa.service.AccountService; 022 import org.kuali.kfs.sys.KFSPropertyConstants; 023 import org.kuali.kfs.sys.context.SpringContext; 024 import org.kuali.kfs.sys.document.authorization.FinancialSystemMaintenanceDocumentPresentationControllerBase; 025 import org.kuali.rice.kns.document.MaintenanceDocument; 026 027 028 /** 029 * This class can be shared by all account-involved maintenance documents which have special nested reference accounts. 030 */ 031 public class SubAccountMaintenanceDocumentPresentationController extends FinancialSystemMaintenanceDocumentPresentationControllerBase { 032 033 // COA code fields that are PKs of nested reference accounts but don't exist in the Sub-Account BO as FKs. 034 public static final String[] COA_CODE_NAMES = { 035 KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.COST_SHARE_SOURCE_CHART_OF_ACCOUNTS_CODE, 036 KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.INDIRECT_COST_RECOVERY_CHART_OF_ACCOUNTS_CODE, 037 }; 038 039 /** 040 * @see org.kuali.rice.kns.document.authorization.MaintenanceDocumentPresentationControllerBase#getConditionallyReadOnlyPropertyNames(org.kuali.rice.kns.document.MaintenanceDocument) 041 * 042 * This methods adds the extra COA code fields that are PKs of nested reference accounts but don't exist in the BO as FKs 043 * to the readOnlyPropertyNames set when accounts can't cross charts. 044 * Since these fields aren't included in AccountPersistenceStructureService.listChartOfAccountsCodeNames as 045 * in super.getConditionallyReadOnlyPropertyNames, they need to be added individually for such special cases. 046 */ 047 @Override 048 public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) { 049 Set<String> readOnlyPropertyNames = super.getConditionallyReadOnlyPropertyNames(document); 050 051 // if accounts can't cross charts, then add the extra chartOfAccountsCode fields to be displayed readOnly 052 if (!SpringContext.getBean(AccountService.class).accountsCanCrossCharts()) { 053 for (int i=0; i<COA_CODE_NAMES.length; i++) { 054 readOnlyPropertyNames.add(COA_CODE_NAMES[i]); 055 } 056 } 057 058 return readOnlyPropertyNames; 059 } 060 061 }