View Javadoc
1   /*
2    * Copyright 2009 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  package org.kuali.ole.sec.service.impl;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.ole.coa.service.ChartService;
22  import org.kuali.ole.sys.context.SpringContext;
23  
24  /**
25   * Custom access permission evaluator that looks at the chart hierarchy when matching values
26   */
27  public class DescendChartAccessPermissionEvaluatorImpl extends AccessPermissionEvaluatorImpl {
28  
29      /**
30       * Sets the match values to the chart code and its child charts (if any)
31       * 
32       * @see org.kuali.ole.sec.service.impl.AccessPermissionEvaluatorImpl#setMatchValues()
33       */
34      @Override
35      protected void setMatchValues() {
36          ChartService chartService = SpringContext.getBean(ChartService.class);
37  
38          List<String> matchChartCodes = new ArrayList<String>();
39          matchChartCodes.add(propertyValue);
40  
41          List<String> allChartCodes = chartService.getAllChartCodes();
42          for (String chart : allChartCodes) {
43              if (chartService.isParentChart(chart, propertyValue)) {
44                  matchChartCodes.add(chart);
45              }
46          }
47  
48          matchValues = new String[matchChartCodes.size()];
49          matchValues = (String[]) matchChartCodes.toArray(matchValues);
50      }
51  
52  }