001 /**
002 * Copyright 2004-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.hr.time.authorization;
017
018
019 import java.util.LinkedList;
020 import java.util.List;
021 import java.util.Map;
022
023 import org.kuali.hr.time.HrEffectiveDateActiveLookupableHelper;
024 import org.kuali.rice.krad.bo.BusinessObject;
025
026 public abstract class TkAuthorizedLookupableHelperBase extends HrEffectiveDateActiveLookupableHelper {
027
028 @Override
029 /**
030 * Overridden single point where the Lookup methods call to obtain Business
031 * Objects. We scan this list and remove anything that the user does not
032 * have access to.
033 */
034 protected List<? extends BusinessObject> getSearchResultsHelper(Map<String, String> fieldValues, boolean unbounded) {
035 List<? extends BusinessObject> list = super.getSearchResultsHelper(fieldValues, unbounded);
036 List<BusinessObject> reduced = new LinkedList<BusinessObject>();
037
038 for (BusinessObject bo : list) {
039 if (shouldShowBusinessObject(bo)) {
040 reduced.add(bo);
041 }
042 }
043
044 return reduced;
045 }
046
047 /**
048 * Subclasses implement this method to restrict the business objects
049 * that will be shown on the lookup/inquiry pages. Maintenance Authorization
050 * classes will handle the determination of whether or not this object can
051 * be edited.
052 *
053 * @param bo The business object to examine.
054 * @return true if the current user can see this business object.
055 */
056 abstract public boolean shouldShowBusinessObject(BusinessObject bo);
057 }