001/**
002 * Copyright 2005-2017 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.demo.uif.components;
017
018import org.kuali.rice.core.api.search.SearchOperator;
019import org.kuali.rice.krad.demo.travel.dataobject.TravelAccount;
020import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
021import org.kuali.rice.krad.uif.service.impl.ViewHelperServiceImpl;
022
023import java.util.ArrayList;
024import java.util.HashMap;
025import java.util.List;
026import java.util.Map;
027
028/**
029 * Implementation of {@link ComponentViewHelperService}.
030 *
031 * @author Kuali Rice Team (rice.collab@kuali.org)
032 */
033public class ComponentViewHelperServiceImpl extends ViewHelperServiceImpl implements ComponentViewHelperService {
034
035    private static final long serialVersionUID = -3952713360851782891L;
036
037    /**
038     * {@inheritDoc}
039     */
040    @Override
041    public List<TravelAccount> retrieveTravelAccounts(String term) {
042        List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
043
044        Map<String, String> lookupCriteria = new HashMap<String, String>();
045        lookupCriteria.put("number", term + SearchOperator.LIKE_MANY.op());
046
047        matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
048                TravelAccount.class, lookupCriteria);
049
050        return matchingAccounts;
051    }
052
053    /**
054     * {@inheritDoc}
055     */
056    @Override
057    public List<TravelAccount> retrieveTravelAccountsBySubAcctAndTerm(String subAccount, String term) {
058        List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
059
060        Map<String, String> lookupCriteria = new HashMap<String, String>();
061        lookupCriteria.put("subAccounts.subAccount", subAccount);
062        lookupCriteria.put("number", term + SearchOperator.LIKE_MANY.op());
063
064        matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
065                TravelAccount.class, lookupCriteria);
066
067        return matchingAccounts;
068    }
069
070    /**
071     * {@inheritDoc}
072     */
073    @Override
074    public List<TravelAccount> retrieveTravelAccountsByName(String name) {
075        List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
076
077        Map<String, String> lookupCriteria = new HashMap<String, String>();
078        lookupCriteria.put("name", name + SearchOperator.LIKE_MANY.op());
079
080        matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
081                TravelAccount.class, lookupCriteria);
082
083        return matchingAccounts;
084    }
085
086}