View Javadoc

1   package org.kuali.ole.patron.keyvalue;
2   
3   import org.kuali.rice.core.api.util.ConcreteKeyValue;
4   import org.kuali.rice.core.api.util.KeyValue;
5   import org.kuali.rice.krad.keyvalues.KeyValuesBase;
6   import org.kuali.rice.krad.service.KRADServiceLocator;
7   import org.kuali.ole.patron.bo.OleBorrowerType;
8   import org.kuali.rice.krms.impl.repository.AgendaBo;
9   
10  import java.util.ArrayList;
11  import java.util.Collection;
12  import java.util.List;
13  /**
14   *  OleBorrowerKeyValue returns BorrowerTypeId and BorrowerTypeName for OleBorrowerType.
15   */
16  public class OleBorrowerKeyValue 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<OleBorrowerType> oleBorrowerTypes = KRADServiceLocator.getBusinessObjectService().findAll(OleBorrowerType.class);
25          keyValues.add(new ConcreteKeyValue("", ""));
26          for (OleBorrowerType oleBorrowerType : oleBorrowerTypes) {
27              if(oleBorrowerType.isActive()) {
28                  keyValues.add(new ConcreteKeyValue(oleBorrowerType.getBorrowerTypeId(),oleBorrowerType.getBorrowerTypeName()));
29              }
30          }
31          return keyValues;
32      }
33  }