1 /*
2 * Copyright 2010 The Kuali Foundation.
3 *
4 * Licensed under the Educational Community License, Version 1.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/ecl1.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
17 package org.kuali.ole.coa.document.authorization;
18
19 import java.util.Set;
20
21 import org.kuali.ole.coa.service.AccountService;
22 import org.kuali.ole.sys.OLEPropertyConstants;
23 import org.kuali.ole.sys.context.SpringContext;
24 import org.kuali.ole.sys.document.authorization.FinancialSystemMaintenanceDocumentPresentationControllerBase;
25 import org.kuali.rice.kns.document.MaintenanceDocument;
26
27
28 /**
29 * This class can be shared by all account-involved maintenance documents which have special nested reference accounts.
30 */
31 public class SubAccountMaintenanceDocumentPresentationController extends FinancialSystemMaintenanceDocumentPresentationControllerBase {
32
33 // COA code fields that are PKs of nested reference accounts but don't exist in the Sub-Account BO as FKs.
34 public static final String[] COA_CODE_NAMES = {
35 OLEPropertyConstants.A21_SUB_ACCOUNT + "." + OLEPropertyConstants.COST_SHARE_SOURCE_CHART_OF_ACCOUNTS_CODE,
36 };
37
38 /**
39 * @see org.kuali.rice.krad.document.authorization.MaintenanceDocumentPresentationControllerBase#getConditionallyReadOnlyPropertyNames(org.kuali.rice.kns.document.MaintenanceDocument)
40 *
41 * This methods adds the extra COA code fields that are PKs of nested reference accounts but don't exist in the BO as FKs
42 * to the readOnlyPropertyNames set when accounts can't cross charts.
43 * Since these fields aren't included in AccountPersistenceStructureService.listChartOfAccountsCodeNames as
44 * in super.getConditionallyReadOnlyPropertyNames, they need to be added individually for such special cases.
45 */
46 @Override
47 public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) {
48 Set<String> readOnlyPropertyNames = super.getConditionallyReadOnlyPropertyNames(document);
49
50 // if accounts can't cross charts, then add the extra chartOfAccountsCode fields to be displayed readOnly
51 if (!SpringContext.getBean(AccountService.class).accountsCanCrossCharts()) {
52 for (int i=0; i<COA_CODE_NAMES.length; i++) {
53 readOnlyPropertyNames.add(COA_CODE_NAMES[i]);
54 }
55 }
56
57 return readOnlyPropertyNames;
58 }
59
60 }