001    /*
002     * Copyright 2011 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.kfs.sec.businessobject.lookup;
017    
018    import java.util.List;
019    import java.util.Map;
020    
021    import org.kuali.kfs.coa.businessobject.lookup.OrganizationRoutingModelNameLookupableHelperServiceImpl;
022    import org.kuali.kfs.sec.SecKeyConstants;
023    import org.kuali.kfs.sec.service.AccessSecurityService;
024    import org.kuali.kfs.sec.util.SecUtil;
025    import org.kuali.rice.kns.util.GlobalVariables;
026    
027    public class AccessSecurityAccountDelegateModelLookupableHelperServiceImpl extends OrganizationRoutingModelNameLookupableHelperServiceImpl {
028    
029        protected AccessSecurityService accessSecurityService;
030    
031        /**
032         * Gets search results and passes to access security service to apply access restrictions
033         * 
034         * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResults(java.util.Map)
035         */
036        public List getSearchResults(Map<String, String> fieldValues) {
037            List results = super.getSearchResults(fieldValues);
038    
039            int resultSizeBeforeRestrictions = results.size();
040            accessSecurityService.applySecurityRestrictionsForLookup(results, GlobalVariables.getUserSession().getPerson());
041    
042            SecUtil.compareListSizeAndAddMessageIfChanged(resultSizeBeforeRestrictions, results, SecKeyConstants.MESSAGE_LOOKUP_RESULTS_RESTRICTED);
043    
044            return results;
045        }
046    
047        /**
048         * Gets search results and passes to access security service to apply access restrictions
049         * 
050         * @see org.kuali.rice.kns.lookup.LookupableHelperService#getSearchResultsUnbounded(java.util.Map)
051         */
052        public List getSearchResultsUnbounded(Map<String, String> fieldValues) {
053            List results = super.getSearchResultsUnbounded(fieldValues);
054    
055            int resultSizeBeforeRestrictions = results.size();
056            accessSecurityService.applySecurityRestrictionsForLookup(results, GlobalVariables.getUserSession().getPerson());
057    
058            SecUtil.compareListSizeAndAddMessageIfChanged(resultSizeBeforeRestrictions, results, SecKeyConstants.MESSAGE_LOOKUP_RESULTS_RESTRICTED);
059    
060            return results;
061        }
062    
063        /**
064         * Sets the accessSecurityService attribute value.
065         * 
066         * @param accessSecurityService The accessSecurityService to set.
067         */
068        public void setAccessSecurityService(AccessSecurityService accessSecurityService) {
069            this.accessSecurityService = accessSecurityService;
070        }
071    
072    }