View Javadoc

1   /**
2    * Copyright 2005-2014 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.account.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  public class ComponentViewHelperServiceImpl extends ViewHelperServiceImpl {
29      public List<TravelAccount> retrieveTravelAccounts(String term) {
30          List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
31  
32          Map<String, String> lookupCriteria = new HashMap<String, String>();
33          lookupCriteria.put("number", term + SearchOperator.LIKE_MANY.op());
34  
35          matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
36                  TravelAccount.class, lookupCriteria);
37  
38          return matchingAccounts;
39      }
40  
41      public List<TravelAccount> retrieveTravelAccountsBySubAcctAndTerm(String subAccount, String term) {
42          List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
43  
44          Map<String, String> lookupCriteria = new HashMap<String, String>();
45          lookupCriteria.put("subAccount", subAccount);
46          lookupCriteria.put("number", term + SearchOperator.LIKE_MANY.op());
47  
48          matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
49                  TravelAccount.class, lookupCriteria);
50  
51          return matchingAccounts;
52      }
53  
54      public List<TravelAccount> retrieveTravelAccountsBySubAcct(String subAccount) {
55          List<TravelAccount> matchingAccounts = new ArrayList<TravelAccount>();
56  
57          Map<String, String> lookupCriteria = new HashMap<String, String>();
58          lookupCriteria.put("subAccountName", subAccount + SearchOperator.LIKE_MANY.op());
59  
60          matchingAccounts = (List<TravelAccount>) KRADServiceLocatorWeb.getLookupService().findCollectionBySearch(
61                  TravelAccount.class, lookupCriteria);
62  
63          return matchingAccounts;
64      }
65  }