001/** 002 * Copyright 2005-2018 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.demo.uif.options; 017 018import org.kuali.rice.core.api.util.ConcreteKeyValue; 019import org.kuali.rice.core.api.util.KeyValue; 020import org.kuali.rice.krad.keyvalues.KeyValuesBase; 021import org.kuali.rice.krad.uif.util.UifKeyValue; 022import org.kuali.rice.krad.uif.util.UifOptionGroupLabel; 023 024import java.util.ArrayList; 025import java.util.HashMap; 026import java.util.List; 027import java.util.Vector; 028 029/** 030 * @author Kuali Rice Team (rice.collab@kuali.org) 031 */ 032public class SimpleTestKeyValuesLong extends KeyValuesBase { 033 034 private boolean blankOption; 035 036 /** 037 * This is a fake implementation of a key value finder, normally this would make a request to 038 * a database to obtain the necessary values. Used only for testing. 039 * 040 * @see org.kuali.rice.krad.keyvalues.KeyValuesFinder#getKeyValues() 041 */ 042 @Override 043 public List<KeyValue> getKeyValues() { 044 List<KeyValue> keyValues = new ArrayList<KeyValue>(); 045 String groupName; 046 String optionName; 047 Integer randomOption; 048 Integer minimum=2; 049 Integer maximum=25; 050 051 if (blankOption) { 052 keyValues.add(new UifKeyValue("", "")); 053 } 054 HashMap<String, Vector<String>> data = new HashMap(); 055 for(int x = 1; x <= 20; x++) { 056 randomOption = minimum + (int)(Math.random()*maximum); 057 groupName = (String) "group " + x; 058 keyValues.add(new UifOptionGroupLabel(groupName)); 059 for(int y = 1; y <= randomOption; y++) { 060 optionName = (String) "sub" + x + "_" + y; 061 keyValues.add(new UifKeyValue(optionName, optionName)); 062 } 063 } 064 return keyValues; 065 } 066 067 /** 068 * @return the blankOption 069 */ 070 public boolean isBlankOption() { 071 return this.blankOption; 072 } 073 074 /** 075 * @param blankOption the blankOption to set 076 */ 077 public void setBlankOption(boolean blankOption) { 078 this.blankOption = blankOption; 079 } 080 081}