View Javadoc
1   /**
2    * Copyright 2005-2014 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.form;
17  
18  import org.kuali.rice.krad.web.form.UifFormBase;
19  
20  import java.math.BigDecimal;
21  import java.math.BigInteger;
22  import java.util.ArrayList;
23  import java.util.List;
24  import java.util.Random;
25  
26  /**
27   * form for the server paging component library page
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class ServerPagingTestForm extends UifFormBase {
32  
33      private static final long serialVersionUID = -8790636700086973158L;
34  
35      // Fields needed on component library forms
36      private String themeName;
37      private String exampleShown;
38      private String currentExampleIndex;
39  
40      List<ServerPagingTestObject> collection1;
41      private List<UITestObject> collection2 = new ArrayList<UITestObject>();
42      List<ServerPagingTestObject> collection3;
43  
44      public ServerPagingTestForm() {
45          int collection1Size = 1000;
46          this.collection1 = new ArrayList<ServerPagingTestObject>(collection1Size);
47          Random random = new Random(2);
48  
49          for (int i = 1; i < collection1Size; i++) {
50              ServerPagingTestObject listItem = new ServerPagingTestObject();
51  
52              listItem.setIntegerField(i);
53  
54              // random rating between 8 and 10
55              BigDecimal rating = new BigDecimal(BigInteger.valueOf(random.nextInt(200) + 800), 2);
56              listItem.setDoubleField(rating);
57  
58              String standardDesc = ", I give XKCD " + i + " a rating of " + listItem.getDoubleField();
59  
60              if (rating.doubleValue() < 8.3) {
61                  listItem.setStringField("Funny" + standardDesc);
62              } else if (rating.doubleValue() < 8.6) {
63                  listItem.setStringField("Good one" + standardDesc);
64              } else if (rating.doubleValue() < 8.9) {
65                  listItem.setStringField("Really liked it" + standardDesc);
66              } else if (rating.doubleValue() < 9.2) {
67                  listItem.setStringField("Clever" + standardDesc);
68              } else if (rating.doubleValue() < 9.5) {
69                  listItem.setStringField("Brilliant" + standardDesc);
70              } else if (rating.doubleValue() < 9.8) {
71                  listItem.setStringField("Stupendous" + standardDesc);
72              } else {
73                  listItem.setStringField("Celestial" + standardDesc);
74              }
75  
76              collection1.add(listItem);
77          }
78  
79          collection2.add(new UITestObject("A", "100", "200", "300"));
80          collection2.add(new UITestObject("A", "101", "200", "300"));
81          collection2.add(new UITestObject("A", "102", "200", "300"));
82          collection2.add(new UITestObject("A", "103", "200", "300"));
83          collection2.add(new UITestObject("A", "104", "200", "300"));
84  
85          collection2.add(new UITestObject("B", "100", "200", "300"));
86          collection2.add(new UITestObject("B", "101", "200", "300"));
87          collection2.add(new UITestObject("B", "102", "200", "300"));
88  
89          collection2.add(new UITestObject("C", "100", "200", "300"));
90          collection2.add(new UITestObject("C", "101", "200", "300"));
91          collection2.add(new UITestObject("C", "102", "200", "300"));
92          collection2.add(new UITestObject("C", "103", "200", "300"));
93  
94          collection2.add(new UITestObject("D", "100", "200", "300"));
95          collection2.add(new UITestObject("D", "101", "200", "300"));
96          collection2.add(new UITestObject("D", "102", "200", "300"));
97  
98          collection2.add(new UITestObject("E", "100", "200", "300"));
99          collection2.add(new UITestObject("E", "101", "200", "300"));
100         collection2.add(new UITestObject("E", "102", "200", "300"));
101 
102         collection2.add(new UITestObject("F", "100", "200", "300"));
103         collection2.add(new UITestObject("F", "101", "200", "300"));
104         collection2.add(new UITestObject("F", "102", "200", "300"));
105 
106         collection2.add(new UITestObject("G", "100", "200", "300"));
107         collection2.add(new UITestObject("G", "101", "200", "300"));
108         collection2.add(new UITestObject("G", "102", "200", "300"));
109 
110         collection2.add(new UITestObject("H", "100", "200", "300"));
111         collection2.add(new UITestObject("H", "101", "200", "300"));
112         collection2.add(new UITestObject("H", "102", "200", "300"));
113         collection2.add(new UITestObject("H", "103", "200", "300"));
114         collection2.add(new UITestObject("H", "104", "200", "300"));
115 
116         collection2.add(new UITestObject("I", "100", "200", "300"));
117         collection2.add(new UITestObject("I", "101", "200", "300"));
118         collection2.add(new UITestObject("I", "102", "200", "300"));
119         collection2.add(new UITestObject("I", "103", "200", "300"));
120         collection2.add(new UITestObject("I", "104", "200", "300"));
121 
122         this.collection3 = new ArrayList<ServerPagingTestObject>(collection1);
123     }
124 
125     public String getThemeName() {
126         return themeName;
127     }
128 
129     public void setThemeName(String themeName) {
130         this.themeName = themeName;
131     }
132 
133     public String getExampleShown() {
134         return exampleShown;
135     }
136 
137     public void setExampleShown(String exampleShown) {
138         this.exampleShown = exampleShown;
139     }
140 
141     public String getCurrentExampleIndex() {
142         return currentExampleIndex;
143     }
144 
145     public void setCurrentExampleIndex(String currentExampleIndex) {
146         this.currentExampleIndex = currentExampleIndex;
147     }
148 
149     public List<ServerPagingTestObject> getCollection1() {
150         return collection1;
151     }
152 
153     public void setCollection1(List<ServerPagingTestObject> collection1) {
154         this.collection1 = collection1;
155     }
156 
157     public List<UITestObject> getCollection2() {
158         return collection2;
159     }
160 
161     public void setCollection2(List<UITestObject> collection2) {
162         this.collection2 = collection2;
163     }
164 
165     public List<ServerPagingTestObject> getCollection3() {
166         return collection3;
167     }
168 
169     public void setCollection3(List<ServerPagingTestObject> collection3) {
170         this.collection3 = collection3;
171     }
172 }