001package org.kuali.ole.deliver.keyvalue;
002
003import org.kuali.ole.select.service.impl.OleExposedWebServiceImpl;
004import org.kuali.ole.sys.context.SpringContext;
005import org.kuali.rice.core.api.config.property.ConfigContext;
006import org.kuali.rice.core.api.util.ConcreteKeyValue;
007import org.kuali.rice.core.api.util.KeyValue;
008import org.kuali.rice.krad.keyvalues.KeyValuesBase;
009
010import java.util.ArrayList;
011import java.util.List;
012
013/**
014 * OlePaymentMethodKeyValue returns PaymentMethodId and PaymentMethodName
015 */
016public class OlePaymentMethodKeyValue extends KeyValuesBase {
017    /**
018     * This method will retrieve Payment method maintenance document from rice 1
019     *
020     * @return keyValues(list)
021     */
022    @Override
023    public List getKeyValues() {
024        List<KeyValue> keyValues = new ArrayList<KeyValue>();
025        OleExposedWebServiceImpl oleExposedWebService = (OleExposedWebServiceImpl) SpringContext.getBean("oleExposedWebService");
026
027        String paymentMethod = oleExposedWebService.getPaymentMethod();
028        String methods = paymentMethod.substring(0, paymentMethod.length() - 1);
029        String[] method = methods.split(",");
030        keyValues.add(new ConcreteKeyValue("", ""));
031        for (int i = 0; i < method.length; i++) {
032            keyValues.add(new ConcreteKeyValue(method[i], method[i]));
033        }
034        return keyValues;
035    }
036
037    /**
038     * Gets the webservice URL using PropertyUtil.
039     *
040     * @return String
041     */
042    public String getURL() {
043        String url = ConfigContext.getCurrentContextConfig().getProperty("oleExposedWebService.url");
044        return url;
045    }
046}