View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.demo.uif.components;
17  
18  import org.kuali.rice.core.api.search.SearchOperator;
19  import org.kuali.rice.krad.demo.travel.dataobject.TravelAccount;
20  import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
21  import org.kuali.rice.krad.uif.service.impl.ViewHelperServiceImpl;
22  
23  import java.util.ArrayList;
24  import java.util.HashMap;
25  import java.util.List;
26  import java.util.Map;
27  
28  /**
29   * Implementation of {@link ComponentViewHelperService}.
30   *
31   * @author Kuali Rice Team (rice.collab@kuali.org)
32   */
33  public class ComponentViewHelperServiceImpl extends ViewHelperServiceImpl implements ComponentViewHelperService {
34  
35      private static final long serialVersionUID = -3952713360851782891L;
36  
37      /**
38       * {@inheritDoc}
39       */
40      @Override
41      public List<TravelAccount> retrieveTravelAccounts(String term) {
42          List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
43  
44          Map<String, String> lookupCriteria = new HashMap<String, String>();
45          lookupCriteria.put("number", term + SearchOperator.LIKE_MANY.op());
46  
47          matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
48                  TravelAccount.class, lookupCriteria);
49  
50          return matchingAccounts;
51      }
52  
53      /**
54       * {@inheritDoc}
55       */
56      @Override
57      public List<TravelAccount> retrieveTravelAccountsBySubAcctAndTerm(String subAccount, String term) {
58          List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
59  
60          Map<String, String> lookupCriteria = new HashMap<String, String>();
61          lookupCriteria.put("subAccounts.subAccount", subAccount);
62          lookupCriteria.put("number", term + SearchOperator.LIKE_MANY.op());
63  
64          matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
65                  TravelAccount.class, lookupCriteria);
66  
67          return matchingAccounts;
68      }
69  
70      /**
71       * {@inheritDoc}
72       */
73      @Override
74      public List<TravelAccount> retrieveTravelAccountsByName(String name) {
75          List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
76  
77          Map<String, String> lookupCriteria = new HashMap<String, String>();
78          lookupCriteria.put("name", name + SearchOperator.LIKE_MANY.op());
79  
80          matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
81                  TravelAccount.class, lookupCriteria);
82  
83          return matchingAccounts;
84      }
85  
86  }