001/** 002 * Copyright 2005-2015 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.form; 017 018import org.kuali.rice.krad.web.form.UifFormBase; 019 020import java.math.BigDecimal; 021import java.math.BigInteger; 022import java.util.ArrayList; 023import java.util.List; 024import java.util.Random; 025 026/** 027 * form for the server paging component library page 028 * 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 */ 031public class ServerPagingTestForm extends UifFormBase { 032 033 private static final long serialVersionUID = -8790636700086973158L; 034 035 // Fields needed on component library forms 036 private String themeName; 037 private String exampleShown; 038 private String currentExampleIndex; 039 040 List<ServerPagingTestObject> collection1; 041 private List<UITestObject> collection2 = new ArrayList<UITestObject>(); 042 List<ServerPagingTestObject> collection3; 043 private List<UITestObject> collection4 = new ArrayList<UITestObject>(); 044 045 public ServerPagingTestForm() { 046 int collection1Size = 1000; 047 this.collection1 = new ArrayList<ServerPagingTestObject>(collection1Size); 048 Random random = new Random(2); 049 050 for (int i = 1; i < collection1Size; i++) { 051 ServerPagingTestObject listItem = new ServerPagingTestObject(); 052 053 listItem.setIntegerField(i); 054 055 // random rating between 8 and 10 056 BigDecimal rating = new BigDecimal(BigInteger.valueOf(random.nextInt(200) + 800), 2); 057 listItem.setDoubleField(rating); 058 059 String standardDesc = ", I give XKCD " + i + " a rating of " + listItem.getDoubleField(); 060 061 if (rating.doubleValue() < 8.3) { 062 listItem.setStringField("Funny" + standardDesc); 063 } else if (rating.doubleValue() < 8.6) { 064 listItem.setStringField("Good one" + standardDesc); 065 } else if (rating.doubleValue() < 8.9) { 066 listItem.setStringField("Really liked it" + standardDesc); 067 } else if (rating.doubleValue() < 9.2) { 068 listItem.setStringField("Clever" + standardDesc); 069 } else if (rating.doubleValue() < 9.5) { 070 listItem.setStringField("Brilliant" + standardDesc); 071 } else if (rating.doubleValue() < 9.8) { 072 listItem.setStringField("Stupendous" + standardDesc); 073 } else { 074 listItem.setStringField("Celestial" + standardDesc); 075 } 076 077 collection1.add(listItem); 078 } 079 080 collection2.add(new UITestObject("A", "100", "200", "300")); 081 collection2.add(new UITestObject("A", "101", "200", "300")); 082 collection2.add(new UITestObject("A", "102", "200", "300")); 083 collection2.add(new UITestObject("A", "103", "200", "300")); 084 collection2.add(new UITestObject("A", "104", "200", "300")); 085 086 collection2.add(new UITestObject("B", "100", "200", "300")); 087 collection2.add(new UITestObject("B", "101", "200", "300")); 088 collection2.add(new UITestObject("B", "102", "200", "300")); 089 090 collection2.add(new UITestObject("C", "100", "200", "300")); 091 collection2.add(new UITestObject("C", "101", "200", "300")); 092 collection2.add(new UITestObject("C", "102", "200", "300")); 093 collection2.add(new UITestObject("C", "103", "200", "300")); 094 095 collection2.add(new UITestObject("D", "100", "200", "300")); 096 collection2.add(new UITestObject("D", "101", "200", "300")); 097 collection2.add(new UITestObject("D", "102", "200", "300")); 098 099 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}