001/**
002 * Copyright 2005-2015 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.krad.service;
017
018import java.util.Collection;
019import java.util.List;
020import java.util.Map;
021
022/**
023 * Provides search capabilities for the lookup framework. This service is primarily intended for internal use by the
024 * lookup framework. Client code should preferably invoke {@link org.kuali.rice.krad.data.DataObjectService#findMatching(Class, org.kuali.rice.core.api.criteria.QueryByCriteria)}
025 * passing the appropriate criteria.
026 *
027 * @author Kuali Rice Team (rice.collab@kuali.org)
028 */
029public interface LookupService {
030
031    /**
032     * Returns a collection of objects based on the given search parameters.
033     * Will not limit results, so the returned Collection could be huge.
034     *
035     * @param type the type of the object for which to search
036     * @param formProps a map of attributes against which to query
037     *
038     * @return an unbounded collection of results from the search
039     * @deprecated please use {@link #findCollectionBySearchHelper(Class, java.util.Map, java.util.List, boolean, Integer)} instead
040     */
041    @Deprecated
042    <T> Collection<T> findCollectionBySearchUnbounded(Class<T> type, Map<String, String> formProps);
043
044    /**
045     * Returns a collection of objects based on the given search parameters.
046     *
047     * @return Collection returned from the search
048     * @deprecated please use {@link #findCollectionBySearchHelper(Class, java.util.Map, java.util.List, boolean, Integer)} instead
049     */
050    @Deprecated
051    <T> Collection<T> findCollectionBySearch(Class<T> type, Map<String, String> formProps);
052
053    /**
054     * This version of findCollectionBySearchHelper is needed for version compatibility.   It allows executeSearch
055     * to behave the same way as it did prior to 2.3. In the LookupDao, the value for searchResultsLimit will be
056     * retrieved from the KNS version of LookupUtils in the LookupDao.
057     *
058     * @since 2.3
059     * @deprecated please use {@link #findCollectionBySearchHelper(Class, java.util.Map, java.util.List, boolean, Integer)} instead
060     */
061    @Deprecated
062    <T> Collection<T> findCollectionBySearchHelper(Class<T> type, Map<String, String> formProperties,
063            boolean unbounded);
064
065    /**
066     *
067     * @param type class name of the data object on which the lookup is performed
068     * @param formProperties Map of search criteria properties obtained from the lookup form
069     * @param unbounded determines if search limit used
070     * @param searchResultsLimit search limit value
071     * @return Collection of items found
072     * @deprecated please use {@link #findCollectionBySearchHelper(Class, java.util.Map, java.util.List, boolean, Integer)} instead
073     */
074    @Deprecated
075    <T> Collection<T> findCollectionBySearchHelper(Class<T> type, Map<String, String> formProperties,
076            boolean unbounded, Integer searchResultsLimit);
077
078    /**
079     * Returns a collection of objects based on the given search parameters.
080     *
081     * <p>
082     * This version of findCollectionBySearchHelper further isolates the UIFramework from the LookupService and
083     * should be used instead of the deprecated version.
084     * </p>
085     *
086     * @param type class name of the data object on which the lookup is performed
087     * @param formProperties Map of search criteria properties obtained from the lookup form
088     * @param wildcardAsLiteralPropertyNames List of property names with wildcards disabled
089     * @param unbounded determines if search limit used
090     * @param searchResultsLimit search limit value
091     * @return Collection of items found
092     */
093    <T> Collection<T> findCollectionBySearchHelper(Class<T> type, Map<String, String> formProperties,
094            List<String> wildcardAsLiteralPropertyNames, boolean unbounded, Integer searchResultsLimit);
095
096    /**
097     * Retrieves an Object based on the search criteria, which should uniquely
098     * identify a record.
099     *
100     * @return Object returned from the search
101     */
102    <T> T findObjectBySearch(Class<T> type, Map<String, String> formProps);
103
104     boolean allPrimaryKeyValuesPresentAndNotWildcard(Class<?> boClass, Map<String, String> formProps);
105}