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.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      private List<UITestObject> collection4 = new ArrayList<UITestObject>();
44  
45      public ServerPagingTestForm() {
46          int collection1Size = 1000;
47          this.collection1 = new ArrayList<ServerPagingTestObject>(collection1Size);
48          Random random = new Random(2);
49  
50          for (int i = 1; i < collection1Size; i++) {
51              ServerPagingTestObject listItem = new ServerPagingTestObject();
52  
53              listItem.setIntegerField(i);
54  
55              // random rating between 8 and 10
56              BigDecimal rating = new BigDecimal(BigInteger.valueOf(random.nextInt(200) + 800), 2);
57              listItem.setDoubleField(rating);
58  
59              String standardDesc = ", I give XKCD " + i + " a rating of " + listItem.getDoubleField();
60  
61              if (rating.doubleValue() < 8.3) {
62                  listItem.setStringField("Funny" + standardDesc);
63              } else if (rating.doubleValue() < 8.6) {
64                  listItem.setStringField("Good one" + standardDesc);
65              } else if (rating.doubleValue() < 8.9) {
66                  listItem.setStringField("Really liked it" + standardDesc);
67              } else if (rating.doubleValue() < 9.2) {
68                  listItem.setStringField("Clever" + standardDesc);
69              } else if (rating.doubleValue() < 9.5) {
70                  listItem.setStringField("Brilliant" + standardDesc);
71              } else if (rating.doubleValue() < 9.8) {
72                  listItem.setStringField("Stupendous" + standardDesc);
73              } else {
74                  listItem.setStringField("Celestial" + standardDesc);
75              }
76  
77              collection1.add(listItem);
78          }
79  
80          collection2.add(new UITestObject("A", "100", "200", "300"));
81          collection2.add(new UITestObject("A", "101", "200", "300"));
82          collection2.add(new UITestObject("A", "102", "200", "300"));
83          collection2.add(new UITestObject("A", "103", "200", "300"));
84          collection2.add(new UITestObject("A", "104", "200", "300"));
85  
86          collection2.add(new UITestObject("B", "100", "200", "300"));
87          collection2.add(new UITestObject("B", "101", "200", "300"));
88          collection2.add(new UITestObject("B", "102", "200", "300"));
89  
90          collection2.add(new UITestObject("C", "100", "200", "300"));
91          collection2.add(new UITestObject("C", "101", "200", "300"));
92          collection2.add(new UITestObject("C", "102", "200", "300"));
93          collection2.add(new UITestObject("C", "103", "200", "300"));
94  
95          collection2.add(new UITestObject("D", "100", "200", "300"));
96          collection2.add(new UITestObject("D", "101", "200", "300"));
97          collection2.add(new UITestObject("D", "102", "200", "300"));
98  
99          collection2.add(new UITestObject("E", "100", "200", "300"));
100         collection2.add(new UITestObject("E", "101", "200", "300"));
101         collection2.add(new UITestObject("E", "102", "200", "300"));
102 
103         collection2.add(new UITestObject("F", "100", "200", "300"));
104         collection2.add(new UITestObject("F", "101", "200", "300"));
105         collection2.add(new UITestObject("F", "102", "200", "300"));
106 
107         collection2.add(new UITestObject("G", "100", "200", "300"));
108         collection2.add(new UITestObject("G", "101", "200", "300"));
109         collection2.add(new UITestObject("G", "102", "200", "300"));
110 
111         collection2.add(new UITestObject("H", "100", "200", "300"));
112         collection2.add(new UITestObject("H", "101", "200", "300"));
113         collection2.add(new UITestObject("H", "102", "200", "300"));
114         collection2.add(new UITestObject("H", "103", "200", "300"));
115         collection2.add(new UITestObject("H", "104", "200", "300"));
116 
117         collection2.add(new UITestObject("I", "100", "200", "300"));
118         collection2.add(new UITestObject("I", "101", "200", "300"));
119         collection2.add(new UITestObject("I", "102", "200", "300"));
120         collection2.add(new UITestObject("I", "103", "200", "300"));
121         collection2.add(new UITestObject("I", "104", "200", "300"));
122 
123         this.collection3 = new ArrayList<ServerPagingTestObject>(collection1);
124         this.collection4 = new ArrayList<UITestObject>(collection2);
125     }
126 
127     public String getThemeName() {
128         return themeName;
129     }
130 
131     public void setThemeName(String themeName) {
132         this.themeName = themeName;
133     }
134 
135     public String getExampleShown() {
136         return exampleShown;
137     }
138 
139     public void setExampleShown(String exampleShown) {
140         this.exampleShown = exampleShown;
141     }
142 
143     public String getCurrentExampleIndex() {
144         return currentExampleIndex;
145     }
146 
147     public void setCurrentExampleIndex(String currentExampleIndex) {
148         this.currentExampleIndex = currentExampleIndex;
149     }
150 
151     public List<ServerPagingTestObject> getCollection1() {
152         return collection1;
153     }
154 
155     public void setCollection1(List<ServerPagingTestObject> collection1) {
156         this.collection1 = collection1;
157     }
158 
159     public List<UITestObject> getCollection2() {
160         return collection2;
161     }
162 
163     public void setCollection2(List<UITestObject> collection2) {
164         this.collection2 = collection2;
165     }
166 
167     public List<ServerPagingTestObject> getCollection3() {
168         return collection3;
169     }
170 
171     public void setCollection3(List<ServerPagingTestObject> collection3) {
172         this.collection3 = collection3;
173     }
174 
175     public List<UITestObject> getCollection4() {
176         return collection4;
177     }
178 
179     public void setCollection4(List<UITestObject> collection4) {
180         this.collection4 = collection4;
181     }
182 }