001/**
002 * Copyright 2005-2016 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.impl;
017
018import org.kuali.rice.core.api.config.property.ConfigurationService;
019import org.kuali.rice.krad.service.LegacyDataAdapter;
020import org.kuali.rice.krad.service.LookupService;
021
022import java.util.Collection;
023import java.util.List;
024import java.util.Map;
025
026/**
027 * Service implementation for the Lookup structure. It Provides a generic search
028 * mechanism against Business Objects. This is the default implementation, that
029 * is delivered with Kuali.
030 * 
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 */
033public class LookupServiceImpl implements LookupService {
034    private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(LookupServiceImpl.class);
035
036    private ConfigurationService kualiConfigurationService;
037    private LegacyDataAdapter legacyDataAdapter;
038
039    @Override
040    @Deprecated
041    public <T> Collection<T> findCollectionBySearchUnbounded(Class<T> example,
042            Map<String, String> formProps) {
043        return findCollectionBySearchHelper(example, formProps, true);
044    }
045
046    @Override
047    @Deprecated
048    public <T> Collection<T> findCollectionBySearch(Class<T> type, Map<String, String> formProps) {
049        return findCollectionBySearchHelper(type, formProps, false);
050    }
051
052    @Override
053    @Deprecated
054    public <T> Collection<T> findCollectionBySearchHelper(Class<T> type,
055            Map<String, String> formProps, boolean unbounded) {
056        return findCollectionBySearchHelper(type, formProps, unbounded, null);
057    }
058
059    @Override
060    @Deprecated
061    public <T> Collection<T> findCollectionBySearchHelper(Class<T> type,
062            Map<String, String> formProps, boolean unbounded, Integer searchResultsLimit) {
063        return getLegacyDataAdapter().findCollectionBySearchHelper(type, formProps, unbounded,
064                allPrimaryKeyValuesPresentAndNotWildcard(type, formProps), searchResultsLimit);
065    }
066
067    @Override
068    public <T> Collection<T> findCollectionBySearchHelper(Class<T> type,Map<String, String> formProps,
069           List<String> wildcardAsLiteralPropertyNames, boolean unbounded, Integer searchResultsLimit) {
070        return getLegacyDataAdapter().findCollectionBySearchHelper(type, formProps, wildcardAsLiteralPropertyNames,
071                unbounded, allPrimaryKeyValuesPresentAndNotWildcard(type, formProps), searchResultsLimit);
072    }
073
074    @Override
075    public <T> T findObjectBySearch(Class<T> type, Map<String, String> formProps) {
076        if (type == null || formProps == null) {
077            throw new IllegalArgumentException("Object and Map must not be null");
078        }
079        return getLegacyDataAdapter().findObjectBySearch(type, formProps);
080    }
081
082    @Override
083    public boolean allPrimaryKeyValuesPresentAndNotWildcard(Class<?> boClass, Map<String, String> formProps) {
084        return getLegacyDataAdapter().allPrimaryKeyValuesPresentAndNotWildcard(boClass, formProps);
085    }
086
087    public ConfigurationService getKualiConfigurationService() {
088        return kualiConfigurationService;
089    }
090
091    public void setKualiConfigurationService(ConfigurationService kualiConfigurationService) {
092        this.kualiConfigurationService = kualiConfigurationService;
093    }
094
095    public LegacyDataAdapter getLegacyDataAdapter() {
096        return legacyDataAdapter;
097    }
098
099    public void setLegacyDataAdapter(LegacyDataAdapter legacyDataAdapter) {
100        this.legacyDataAdapter = legacyDataAdapter;
101    }
102
103}