View Javadoc
1   /**
2    * Copyright 2005-2016 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 edu.sampleu.travel.options;
17  
18  import edu.sampleu.travel.dataobject.TravelDestination;
19  import org.kuali.rice.core.api.criteria.QueryByCriteria;
20  import org.kuali.rice.core.api.criteria.QueryResults;
21  import org.kuali.rice.core.api.util.ConcreteKeyValue;
22  import org.kuali.rice.core.api.util.KeyValue;
23  import org.kuali.rice.krad.keyvalues.KeyValuesBase;
24  import org.kuali.rice.krad.service.KRADServiceLocator;
25  
26  import java.util.ArrayList;
27  import java.util.List;
28  
29  /**
30   * This class provides a simple key values for travel destinations
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class TravelDestinationKeyValues extends KeyValuesBase {
35  
36      private static final long serialVersionUID = 1L;
37  
38      @Override
39      public List<KeyValue> getKeyValues() {
40          List<KeyValue> keyValues = new ArrayList<KeyValue>();
41  
42          QueryResults<TravelDestination> bos = KRADServiceLocator.getDataObjectService().findMatching(
43                  TravelDestination.class, QueryByCriteria.Builder.create().build());
44  
45          keyValues.add(new ConcreteKeyValue("", ""));
46          for (TravelDestination typ : bos.getResults()) {
47              keyValues.add(new ConcreteKeyValue(typ.getTravelDestinationId(), typ.getTravelDestinationName()));
48          }
49  
50          return keyValues;
51      }
52  
53  }