001package org.kuali.ole.deliver.keyvalue; 002 003import org.kuali.ole.deliver.bo.OleSourceBo; 004import org.kuali.rice.core.api.util.ConcreteKeyValue; 005import org.kuali.rice.core.api.util.KeyValue; 006import org.kuali.rice.krad.keyvalues.KeyValuesBase; 007import org.kuali.rice.krad.service.KRADServiceLocator; 008 009import java.util.ArrayList; 010import java.util.Collection; 011import java.util.List; 012 013/** 014 * OleSourceKeyValue returns OleSourceId and OleSourceName for OleSourceBo. 015 */ 016public class OleSourceKeyValue extends KeyValuesBase { 017 /** 018 * This method will populate the code as a key and name as a value and return it as list 019 * 020 * @return keyValues(list) 021 */ 022 @Override 023 public List getKeyValues() { 024 List<KeyValue> keyValues = new ArrayList<KeyValue>(); 025 Collection<OleSourceBo> oleSourceBos = KRADServiceLocator.getBusinessObjectService().findAll(OleSourceBo.class); 026 keyValues.add(new ConcreteKeyValue("", "")); 027 for (OleSourceBo oleSourceType : oleSourceBos) { 028 if (oleSourceType.isActive()) { 029 keyValues.add(new ConcreteKeyValue(oleSourceType.getOleSourceId(), oleSourceType.getOleSourceName())); 030 } 031 } 032 return keyValues; 033 } 034}