001/** 002 * Copyright 2005-2014 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 */ 016package org.kuali.rice.kew.lookup.valuefinder; 017 018import org.apache.commons.lang.StringUtils; 019import org.kuali.rice.core.api.util.ConcreteKeyValue; 020import org.kuali.rice.core.api.util.KeyValue; 021import org.kuali.rice.kew.service.KEWServiceLocator; 022import org.kuali.rice.krad.keyvalues.KeyValuesBase; 023import org.kuali.rice.krad.util.GlobalVariables; 024 025import java.util.ArrayList; 026import java.util.List; 027 028/** 029 * This is a description of what this class does - chris don't forget to fill this in. 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 * 033 */ 034public class SavedSearchValuesFinder extends KeyValuesBase { 035 036 /** 037 * @see org.kuali.rice.krad.keyvalues.KeyValuesFinder#getKeyValues() 038 */ 039 @Override 040 public List<KeyValue> getKeyValues() { 041 List<KeyValue> savedSearchValues = new ArrayList<KeyValue>(); 042 savedSearchValues.add(new ConcreteKeyValue("", "Searches")); 043 savedSearchValues.add(new ConcreteKeyValue("*ignore*", "-----")); 044 savedSearchValues.add(new ConcreteKeyValue("*ignore*", "-Named Searches")); 045 List<KeyValue> namedSearches = KEWServiceLocator.getDocumentSearchService().getNamedSearches(GlobalVariables.getUserSession().getPrincipalId()); 046 for (KeyValue keyValue : namedSearches) { 047 String label = StringUtils.abbreviate(keyValue.getValue(), 75); 048 KeyValue keyLabel = new ConcreteKeyValue(keyValue.getKey(),label); 049 savedSearchValues.add(keyLabel); 050 } 051 savedSearchValues.add(new ConcreteKeyValue("*ignore*", "-----")); 052 savedSearchValues.add(new ConcreteKeyValue("*ignore*", "-Recent Searches")); 053 List<KeyValue> mostRecentSearches = KEWServiceLocator.getDocumentSearchService().getMostRecentSearches(GlobalVariables.getUserSession().getPrincipalId()); 054 for (KeyValue keyValue : mostRecentSearches) { 055 String label = StringUtils.abbreviate(keyValue.getValue(), 75); 056 KeyValue keyLabel = new ConcreteKeyValue(keyValue.getKey(),label); 057 savedSearchValues.add(keyLabel); 058 } 059 return savedSearchValues; 060 } 061 062}