001package org.kuali.ole.describe.keyvalue; 002 003import org.kuali.ole.describe.bo.OleReceiptStatus; 004import org.kuali.rice.core.api.criteria.QueryByCriteria; 005import org.kuali.rice.core.api.util.ConcreteKeyValue; 006import org.kuali.rice.core.api.util.KeyValue; 007import org.kuali.rice.krad.keyvalues.KeyValuesBase; 008import org.kuali.rice.kns.service.KNSServiceLocator; 009import org.kuali.rice.krad.service.KRADServiceLocator; 010 011import java.util.ArrayList; 012import java.util.Collection; 013import java.util.List; 014 015/** 016 * ReceiptStatus used to render the values for ReceiptStatus dropdown control. 017 */ 018public class ReceiptStatus extends KeyValuesBase { 019 /** 020 * This method returns the List of ConcreteKeyValues, 021 * ConcreteKeyValue has two arguments receiptStatusCode and 022 * receiptStatusName. 023 * 024 * @return List<KeyValue> 025 */ 026 @Override 027 public List<KeyValue> getKeyValues() { 028 List<KeyValue> options = new ArrayList<KeyValue>(); 029 Collection<OleReceiptStatus> oleReceiptStatuses = KRADServiceLocator.getDataObjectService().findMatching(OleReceiptStatus.class, QueryByCriteria.Builder.create().build()).getResults(); 030 options.add(new ConcreteKeyValue("", "")); 031 for (OleReceiptStatus type : oleReceiptStatuses) { 032 if(type.isActive()){ 033 options.add(new ConcreteKeyValue(type.getReceiptStatusCode(), type.getReceiptStatusName())); 034 } 035 } 036 return options; 037 } 038}