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 edu.sampleu.travel.options;
17  
18  import edu.sampleu.travel.dataobject.TravelMileageRate;
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 mileage rate (needed for lookup screens on Travel Per Diem Expense)
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class MileageRateKeyValues  extends KeyValuesBase {
35      private static final long serialVersionUID = 1L;
36  
37      @Override
38      public List<KeyValue> getKeyValues() {
39          List<KeyValue> keyValues = new ArrayList<KeyValue>();
40  
41          QueryResults<TravelMileageRate> bos = KRADServiceLocator.getDataObjectService().findMatching( TravelMileageRate.class, QueryByCriteria
42                  .Builder.create().build() );
43  
44          keyValues.add(new ConcreteKeyValue("", ""));
45          for ( TravelMileageRate typ : bos.getResults() ) {
46              keyValues.add(new ConcreteKeyValue(typ.getMileageRateId(), typ.getMileageRateCd()));
47          }
48  
49          return keyValues;
50      }
51  
52  }