View Javadoc
1   /*
2    * Copyright 2008-2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.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/ecl2.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  package org.kuali.ole.sys.document.authorization;
17  
18  import java.util.Set;
19  
20  import org.kuali.ole.coa.service.AccountPersistenceStructureService;
21  import org.kuali.ole.coa.service.AccountService;
22  import org.kuali.ole.sys.context.SpringContext;
23  import org.kuali.rice.core.api.parameter.ParameterEvaluatorService;
24  import org.kuali.rice.kns.document.MaintenanceDocument;
25  import org.kuali.rice.kns.document.authorization.MaintenanceDocumentPresentationControllerBase;
26  import org.kuali.rice.krad.bo.PersistableBusinessObject;
27  
28  public class FinancialSystemMaintenanceDocumentPresentationControllerBase extends MaintenanceDocumentPresentationControllerBase {
29  
30      private static ParameterEvaluatorService parameterEvaluatorService;
31  
32      /**
33       * the following three methods still accept the deprecated class as argument in order to bridge the gap between old and new maintenance API
34       *
35       * This is just workaround solution. The better solution would be to replace old API with new one.
36       */
37      public Set<String> getConditionallyReadOnlyPropertyNames(MaintenanceDocument document) {
38          Set<String> readOnlyPropertyNames = super.getConditionallyReadOnlyPropertyNames(document);
39  
40          // if accounts can't cross charts, then all chartOfAccountsCode fields shall be displayed readOnly
41          if (!SpringContext.getBean(AccountService.class).accountsCanCrossCharts()) {
42              AccountPersistenceStructureService apsService = SpringContext.getBean(AccountPersistenceStructureService.class);
43              PersistableBusinessObject bo = document.getNewMaintainableObject().getBusinessObject();
44  
45              // non-collection reference accounts
46              Set<String> coaCodeNames = apsService.listChartOfAccountsCodeNames(bo);
47              readOnlyPropertyNames.addAll(coaCodeNames);
48  
49              // collection reference accounts
50              coaCodeNames = apsService.listCollectionChartOfAccountsCodeNames(bo);
51              readOnlyPropertyNames.addAll(coaCodeNames);
52          }
53  
54          return readOnlyPropertyNames;
55      }
56  
57      protected ParameterEvaluatorService getParameterEvaluatorService() {
58          if (parameterEvaluatorService == null) {
59              parameterEvaluatorService = SpringContext.getBean(ParameterEvaluatorService.class);
60          }
61          return parameterEvaluatorService;
62      }
63  }