001    package org.kuali.ole.editor.keyvalue;
002    
003    import org.kuali.ole.catalog.bo.OleFieldEncodingLevel;
004    import org.kuali.rice.core.api.util.ConcreteKeyValue;
005    import org.kuali.rice.core.api.util.KeyValue;
006    import org.kuali.rice.krad.keyvalues.KeyValuesBase;
007    import org.kuali.rice.krad.service.KRADServiceLocator;
008    
009    import java.util.ArrayList;
010    import java.util.Collection;
011    import java.util.List;
012    
013    /**
014     * FieldEncodingLevel used to render the values for FieldEncodingLevel dropdown control.
015     */
016    public class FieldEncodingLevel extends KeyValuesBase {
017        /**
018         * This method returns the List of ConcreteKeyValue,,
019         * ConcreteKeyValue has two arguments fieldEncodingLevelCode and
020         * fieldEncodingLevelName.
021         * @return   List<KeyValue>
022         */
023        @Override
024        public List<KeyValue> getKeyValues() {
025            List<KeyValue> options = new ArrayList<KeyValue>();
026            Collection<OleFieldEncodingLevel> oleFieldEncodingLevels = KRADServiceLocator.getBusinessObjectService().findAll(OleFieldEncodingLevel.class);
027            options.add(new ConcreteKeyValue("", ""));
028            for (OleFieldEncodingLevel type : oleFieldEncodingLevels) {
029                options.add(new ConcreteKeyValue(type.getFieldEncodingLevelCode(), type.getFieldEncodingLevelName()));
030            }
031            return options;
032        }
033    }