View Javadoc

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