View Javadoc

1   package org.kuali.ole.patron.keyvalue;
2   
3   import org.kuali.ole.patron.bo.OleStatisticalCategoryBo;
4   import org.kuali.rice.core.api.util.ConcreteKeyValue;
5   import org.kuali.rice.core.api.util.KeyValue;
6   import org.kuali.rice.krad.keyvalues.KeyValuesBase;
7   import org.kuali.rice.krad.service.KRADServiceLocator;
8   
9   import java.util.ArrayList;
10  import java.util.Collection;
11  import java.util.List;
12  
13  /**
14   *  OleStatisticalCategoryKeyValue returns OleStatisticalCategoryId and OleStatisticalCategoryName for OleStatisticalCategoryBo.
15   */
16  public class OleStatisticalCategoryKeyValue extends KeyValuesBase {
17      /**
18       * This method will populate the code as a key and name as a value and return it as list
19       * @return keyValues(list)
20       */
21      @Override
22      public List getKeyValues() {
23          List<KeyValue> keyValues = new ArrayList<KeyValue>();
24          Collection<OleStatisticalCategoryBo> oleStatisticalCategoryBos = KRADServiceLocator.getBusinessObjectService().findAll(OleStatisticalCategoryBo.class);
25          keyValues.add(new ConcreteKeyValue("", ""));
26          for (OleStatisticalCategoryBo oleStatisticalCategoryType : oleStatisticalCategoryBos) {
27              if(oleStatisticalCategoryType.isActive()) {
28                  keyValues.add(new ConcreteKeyValue(oleStatisticalCategoryType.getOleStatisticalCategoryId(),oleStatisticalCategoryType.getOleStatisticalCategoryName()));
29              }
30          }
31          return keyValues;
32      }
33  }