001package org.kuali.ole.deliver.keyvalue;
002
003import org.kuali.ole.OLEConstants;
004import org.kuali.ole.deliver.bo.OlePaymentStatus;
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.krad.service.KRADServiceLocator;
009
010import java.util.ArrayList;
011import java.util.Collection;
012import java.util.List;
013
014/**
015 * Created with IntelliJ IDEA.
016 * User: ?
017 * Date: 10/11/12
018 * Time: 3:32 PM
019 * To change this template use File | Settings | File Templates.
020 */
021public class OlePaymentStatusKeyValues extends KeyValuesBase {
022
023    @Override
024    public List getKeyValues() {
025        List<KeyValue> keyValues = new ArrayList<KeyValue>();
026        Collection<OlePaymentStatus> olePaymentStatus = KRADServiceLocator.getBusinessObjectService().findAll(OlePaymentStatus.class);
027        for (OlePaymentStatus paymentStatus : olePaymentStatus) {
028            if (paymentStatus.getPaymentStatusName().equals(OLEConstants.OlePatron.BILL_PAYMENT_STATUS_OUTSTANDING)) {
029                keyValues.add(new ConcreteKeyValue(paymentStatus.getPaymentStatusId(), paymentStatus.getPaymentStatusName()));
030                break;
031            }
032        }
033        for (OlePaymentStatus paymentStatus : olePaymentStatus) {
034            if (!paymentStatus.getPaymentStatusName().equals(OLEConstants.OlePatron.BILL_PAYMENT_STATUS_OUTSTANDING)) {
035                keyValues.add(new ConcreteKeyValue(paymentStatus.getPaymentStatusId(), paymentStatus.getPaymentStatusName()));
036            }
037        }
038        return keyValues;
039    }
040}