View Javadoc

1   /**
2    * Copyright 2004-2012 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.hr.time.authorization;
17  
18  
19  import java.util.LinkedList;
20  import java.util.List;
21  import java.util.Map;
22  
23  import org.kuali.hr.time.HrEffectiveDateActiveLookupableHelper;
24  import org.kuali.rice.krad.bo.BusinessObject;
25  
26  public abstract class TkAuthorizedLookupableHelperBase extends HrEffectiveDateActiveLookupableHelper {
27  
28      @Override
29      /**
30       * Overridden single point where the Lookup methods call to obtain Business
31       * Objects. We scan this list and remove anything that the user does not
32       * have access to.
33       */
34      protected List<? extends BusinessObject> getSearchResultsHelper(Map<String, String> fieldValues, boolean unbounded) {
35          List<? extends BusinessObject> list = super.getSearchResultsHelper(fieldValues, unbounded);
36          List<BusinessObject> reduced = new LinkedList<BusinessObject>();
37  
38          for (BusinessObject bo : list) {
39              if (shouldShowBusinessObject(bo)) {
40                  reduced.add(bo);
41              }
42          }
43  
44          return reduced;
45      }
46  
47      /**
48       * Subclasses implement this method to restrict the business objects
49       * that will be shown on the lookup/inquiry pages. Maintenance Authorization
50       * classes will handle the determination of whether or not this object can
51       * be edited.
52       *
53       * @param bo The business object to examine.
54       * @return true if the current user can see this business object.
55       */
56      abstract public boolean shouldShowBusinessObject(BusinessObject bo);
57  }