1 /*
2 * The Kuali Financial System, a comprehensive financial management system for higher education.
3 *
4 * Copyright 2005-2014 The Kuali Foundation
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 package org.kuali.kfs.coa.document.authorization;
21
22 import java.util.Set;
23
24 import org.kuali.kfs.coa.service.AccountService;
25 import org.kuali.kfs.sys.KFSPropertyConstants;
26 import org.kuali.kfs.sys.context.SpringContext;
27 import org.kuali.kfs.sys.document.authorization.FinancialSystemMaintenanceDocumentPresentationControllerBase;
28 import org.kuali.rice.kns.document.MaintenanceDocument;
29
30
31 /**
32 * This class can be shared by all account-involved maintenance documents which have special nested reference accounts.
33 */
34 public class SubAccountMaintenanceDocumentPresentationController extends FinancialSystemMaintenanceDocumentPresentationControllerBase {
35
36 // COA code fields that are PKs of nested reference accounts but don't exist in the Sub-Account BO as FKs.
37 public static final String[] COA_CODE_NAMES = {
38 KFSPropertyConstants.A21_SUB_ACCOUNT + "." + KFSPropertyConstants.COST_SHARE_SOURCE_CHART_OF_ACCOUNTS_CODE,
39 };
40
41 /**
42 * @see org.kuali.rice.krad.document.authorization.MaintenanceDocumentPresentationControllerBase#getConditionallyReadOnlyPropertyNames(org.kuali.rice.kns.document.MaintenanceDocument)
43 *
44 * This methods adds the extra COA code fields that are PKs of nested reference accounts but don't exist in the BO as FKs
45 * to the readOnlyPropertyNames set when accounts can't cross charts.
46 * Since these fields aren't included in AccountPersistenceStructureService.listChartOfAccountsCodeNames as
47 * in super.getConditionallyReadOnlyPropertyNames, they need to be added individually for such special cases.
48 */
49 @Override
50 public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) {
51 Set<String> readOnlyPropertyNames = super.getConditionallyReadOnlyPropertyNames(document);
52
53 // if accounts can't cross charts, then add the extra chartOfAccountsCode fields to be displayed readOnly
54 if (!SpringContext.getBean(AccountService.class).accountsCanCrossCharts()) {
55 for (int i=0; i<COA_CODE_NAMES.length; i++) {
56 readOnlyPropertyNames.add(COA_CODE_NAMES[i]);
57 }
58 }
59
60 return readOnlyPropertyNames;
61 }
62
63 }