View Javadoc
1   /**
2    * Copyright 2005-2016 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.demo.uif.options;
17  
18  import org.kuali.rice.core.api.util.ConcreteKeyValue;
19  import org.kuali.rice.core.api.util.KeyValue;
20  import org.kuali.rice.krad.keyvalues.KeyValuesBase;
21  import org.kuali.rice.krad.uif.util.UifKeyValue;
22  import org.kuali.rice.krad.uif.util.UifOptionGroupLabel;
23  
24  import java.util.ArrayList;
25  import java.util.HashMap;
26  import java.util.List;
27  import java.util.Vector;
28  
29  /**
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class SimpleTestKeyValuesLong extends KeyValuesBase {
33  
34      private boolean blankOption;
35  
36      /**
37       * This is a fake implementation of a key value finder, normally this would make a request to
38       * a database to obtain the necessary values.  Used only for testing.
39       *
40       * @see org.kuali.rice.krad.keyvalues.KeyValuesFinder#getKeyValues()
41       */
42      @Override
43      public List<KeyValue> getKeyValues() {
44          List<KeyValue> keyValues = new ArrayList<KeyValue>();
45          String groupName;
46          String optionName;
47          Integer randomOption;
48          Integer minimum=2;
49          Integer maximum=25;
50  
51          if (blankOption) {
52              keyValues.add(new UifKeyValue("", ""));
53          }
54          HashMap<String, Vector<String>> data = new HashMap();
55          for(int x = 1; x <= 20; x++) {
56              randomOption = minimum + (int)(Math.random()*maximum);
57              groupName = (String) "group " + x;
58              keyValues.add(new UifOptionGroupLabel(groupName));
59              for(int y = 1; y <= randomOption; y++) {
60                  optionName = (String) "sub" + x + "_" + y;
61                  keyValues.add(new UifKeyValue(optionName, optionName));
62              }
63          }
64          return keyValues;
65      }
66  
67      /**
68       * @return the blankOption
69       */
70      public boolean isBlankOption() {
71          return this.blankOption;
72      }
73  
74      /**
75       * @param blankOption the blankOption to set
76       */
77      public void setBlankOption(boolean blankOption) {
78          this.blankOption = blankOption;
79      }
80  
81  }