001/**
002 * Copyright 2005-2016 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.labs.coursesearch;
017
018import org.kuali.rice.krad.web.controller.UifControllerBase;
019import org.kuali.rice.krad.web.form.UifFormBase;
020import org.springframework.stereotype.Controller;
021import org.springframework.validation.BindingResult;
022import org.springframework.web.bind.annotation.ModelAttribute;
023import org.springframework.web.bind.annotation.RequestMapping;
024import org.springframework.web.servlet.ModelAndView;
025
026import java.io.*;
027import java.net.*;
028
029import javax.json.*;
030
031import javax.servlet.http.HttpServletRequest;
032import javax.servlet.http.HttpServletResponse;
033import java.util.ArrayList;
034import java.util.List;
035
036/**
037 * This class is the controller class for course search performance labs.
038 *
039 * @author Kuali Rice Team (rice.collab@kuali.org)
040 */
041@Controller
042@RequestMapping(value = "/coursesearchperformance")
043public class CourseSearchController extends UifControllerBase {
044
045    public static final String KUALI_ATP_2012_FALL = "kuali.atp.2012Fall";
046
047    /**
048     * @see org.kuali.rice.krad.web.controller.UifControllerBase#createInitialForm(javax.servlet.http.HttpServletRequest)
049     */
050    @Override
051    protected CourseSearchForm createInitialForm() {
052        return new CourseSearchForm();
053    }
054
055    /**
056     *
057     * @param form
058     * @return
059     */
060    @Override
061    @RequestMapping(params = "methodToCall=start")
062    public ModelAndView start(UifFormBase form) {
063        CourseSearchForm perfForm = (CourseSearchForm) form;
064
065        return getModelAndView(perfForm);
066    }
067
068    /**
069     *  This method takes the user input (int) and generates a collection with that many rows. That collection is saved
070     *  to the form object so it can be displayed on the page.
071     * @param form    CourseSearchForm
072     * @param result
073     * @param request
074     * @param response
075     * @return    ModelAndView
076     */
077    @RequestMapping(params = "methodToCall=buildcollection")
078    public ModelAndView buildCollection(@ModelAttribute("KualiForm") CourseSearchForm form, BindingResult result,
079            HttpServletRequest request, HttpServletResponse response) {
080
081        String courseCode = form.getInputOne(); // get input from page
082        String termId = KUALI_ATP_2012_FALL;
083        String termCode = "201208";
084        String temp = "[\n"
085                + "   {\n"
086                + "      \"courseOfferingId\":\"9e89ed85-66ba-4a9c-9765-c36e78929051\",\n"
087                + "      \"courseOfferingCode\":\"CHEM105\",\n"
088                + "      \"courseOfferingDesc\":\"Fundamental of Organic and Biochemistry\",\n"
089                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
090                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
091                + "      \"studentSelectablePassFail\":true,\n"
092                + "      \"auditCourse\":true,\n"
093                + "      \"honorsCourse\":false\n"
094                + "   },\n"
095                + "   {\n"
096                + "      \"courseOfferingId\":\"25a7e006-e71a-4d5d-806c-04675f365222\",\n"
097                + "      \"courseOfferingCode\":\"CHEM131\",\n"
098                + "      \"courseOfferingDesc\":\"Chemistry I - Fundamentals of General Chemistry\",\n"
099                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
100                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
101                + "      \"studentSelectablePassFail\":true,\n"
102                + "      \"auditCourse\":true,\n"
103                + "      \"honorsCourse\":false\n"
104                + "   },\n"
105                + "   {\n"
106                + "      \"courseOfferingId\":\"ea618cb3-8583-4833-bbe3-43c7961f70fb\",\n"
107                + "      \"courseOfferingCode\":\"CHEM131S\",\n"
108                + "      \"courseOfferingDesc\":\"Chemistry I - Fundamentals of General Chemistry\",\n"
109                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
110                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
111                + "      \"studentSelectablePassFail\":true,\n"
112                + "      \"auditCourse\":true,\n"
113                + "      \"honorsCourse\":false\n"
114                + "   },\n"
115                + "   {\n"
116                + "      \"courseOfferingId\":\"ee786c4b-57c9-4237-9519-4bdb961ca5d4\",\n"
117                + "      \"courseOfferingCode\":\"CHEM132\",\n"
118                + "      \"courseOfferingDesc\":\"General Chemistry I Laboratory\",\n"
119                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
120                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
121                + "      \"studentSelectablePassFail\":true,\n"
122                + "      \"auditCourse\":false,\n"
123                + "      \"honorsCourse\":false\n"
124                + "   },\n"
125                + "   {\n"
126                + "      \"courseOfferingId\":\"56802cf2-5577-4163-9fa7-a356396e8d45\",\n"
127                + "      \"courseOfferingCode\":\"CHEM132C\",\n"
128                + "      \"courseOfferingDesc\":\"General Chemistry I Laboratory\",\n"
129                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
130                + "      \"courseOfferingGradingOptionDisplay\":\"Pass/Fail Grading\",\n"
131                + "      \"studentSelectablePassFail\":true,\n"
132                + "      \"auditCourse\":false,\n"
133                + "      \"honorsCourse\":false\n"
134                + "   },\n"
135                + "   {\n"
136                + "      \"courseOfferingId\":\"5fc5ff07-eb70-4c0a-b549-124eb879c8cb\",\n"
137                + "      \"courseOfferingCode\":\"CHEM132S\",\n"
138                + "      \"courseOfferingDesc\":\"General Chemistry I Laboratory\",\n"
139                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
140                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
141                + "      \"studentSelectablePassFail\":true,\n"
142                + "      \"auditCourse\":false,\n"
143                + "      \"honorsCourse\":false\n"
144                + "   },\n"
145                + "   {\n"
146                + "      \"courseOfferingId\":\"ced6bd11-bcd2-445f-be16-3a46d8231323\",\n"
147                + "      \"courseOfferingCode\":\"CHEM135\",\n"
148                + "      \"courseOfferingDesc\":\"General Chemistry for Engineers\",\n"
149                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
150                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
151                + "      \"studentSelectablePassFail\":false,\n"
152                + "      \"auditCourse\":false,\n"
153                + "      \"honorsCourse\":false\n"
154                + "   },\n"
155                + "   {\n"
156                + "      \"courseOfferingId\":\"27f703ed-d24c-4580-a401-105b3b1e5825\",\n"
157                + "      \"courseOfferingCode\":\"CHEM135U\",\n"
158                + "      \"courseOfferingDesc\":\"General Chemistry for Engineers\",\n"
159                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
160                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
161                + "      \"studentSelectablePassFail\":false,\n"
162                + "      \"auditCourse\":false,\n"
163                + "      \"honorsCourse\":false\n"
164                + "   },\n"
165                + "   {\n"
166                + "      \"courseOfferingId\":\"e960defa-3c0c-4bf6-bb2f-0ec13d80096d\",\n"
167                + "      \"courseOfferingCode\":\"CHEM136\",\n"
168                + "      \"courseOfferingDesc\":\"General Chemistry Laboratory for Engineers\",\n"
169                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
170                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
171                + "      \"studentSelectablePassFail\":false,\n"
172                + "      \"auditCourse\":false,\n"
173                + "      \"honorsCourse\":false\n"
174                + "   },\n"
175                + "   {\n"
176                + "      \"courseOfferingId\":\"2403ccea-0951-4730-b481-445631cc14a9\",\n"
177                + "      \"courseOfferingCode\":\"CHEM146\",\n"
178                + "      \"courseOfferingDesc\":\"Principles of General Chemistry\",\n"
179                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
180                + "      \"courseOfferingGradingOptionDisplay\":\"Pass/Fail Grading\",\n"
181                + "      \"studentSelectablePassFail\":true,\n"
182                + "      \"auditCourse\":true,\n"
183                + "      \"honorsCourse\":false\n"
184                + "   },\n"
185                + "   {\n"
186                + "      \"courseOfferingId\":\"bc3cafeb-5c1a-452c-9ab3-dabb992d1178\",\n"
187                + "      \"courseOfferingCode\":\"CHEM147\",\n"
188                + "      \"courseOfferingDesc\":\"Principles of Chemistry Laboratory\",\n"
189                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
190                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
191                + "      \"studentSelectablePassFail\":true,\n"
192                + "      \"auditCourse\":false,\n"
193                + "      \"honorsCourse\":false\n"
194                + "   },\n"
195                + "   {\n"
196                + "      \"courseOfferingId\":\"2d847317-1c21-4c8c-990c-ab56f0897c75\",\n"
197                + "      \"courseOfferingCode\":\"CHEM231\",\n"
198                + "      \"courseOfferingDesc\":\"Organic Chemistry I\",\n"
199                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
200                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
201                + "      \"studentSelectablePassFail\":true,\n"
202                + "      \"auditCourse\":true,\n"
203                + "      \"honorsCourse\":false\n"
204                + "   },\n"
205                + "   {\n"
206                + "      \"courseOfferingId\":\"9c5f138c-951b-4d3a-8cd5-369a23f89caa\",\n"
207                + "      \"courseOfferingCode\":\"CHEM232\",\n"
208                + "      \"courseOfferingDesc\":\"Organic Chemistry Laboratory I\",\n"
209                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
210                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
211                + "      \"studentSelectablePassFail\":false,\n"
212                + "      \"auditCourse\":false,\n"
213                + "      \"honorsCourse\":false\n"
214                + "   },\n"
215                + "   {\n"
216                + "      \"courseOfferingId\":\"ebe93736-4f75-45fc-a313-e375575cdf4a\",\n"
217                + "      \"courseOfferingCode\":\"CHEM241\",\n"
218                + "      \"courseOfferingDesc\":\"Organic Chemistry II\",\n"
219                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
220                + "      \"courseOfferingGradingOptionDisplay\":\"Pass/Fail Grading\",\n"
221                + "      \"studentSelectablePassFail\":true,\n"
222                + "      \"auditCourse\":true,\n"
223                + "      \"honorsCourse\":false\n"
224                + "   },\n"
225                + "   {\n"
226                + "      \"courseOfferingId\":\"9133914d-53a1-49d6-ab4d-cf83a3848262\",\n"
227                + "      \"courseOfferingCode\":\"CHEM242\",\n"
228                + "      \"courseOfferingDesc\":\"Organic Chemistry Laboratory II\",\n"
229                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
230                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
231                + "      \"studentSelectablePassFail\":false,\n"
232                + "      \"auditCourse\":false,\n"
233                + "      \"honorsCourse\":false\n"
234                + "   },\n"
235                + "   {\n"
236                + "      \"courseOfferingId\":\"759bba9a-0ccf-4ddd-bdb9-8abe46f2b784\",\n"
237                + "      \"courseOfferingCode\":\"CHEM247\",\n"
238                + "      \"courseOfferingDesc\":\"Principles of Organic Chemistry II\",\n"
239                + "      \"courseOfferingCreditOptionDisplay\":\"4.0\",\n"
240                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
241                + "      \"studentSelectablePassFail\":true,\n"
242                + "      \"auditCourse\":true,\n"
243                + "      \"honorsCourse\":false\n"
244                + "   },\n"
245                + "   {\n"
246                + "      \"courseOfferingId\":\"d4208ae9-7a2a-4ad7-b570-7c060aa74d90\",\n"
247                + "      \"courseOfferingCode\":\"CHEM271\",\n"
248                + "      \"courseOfferingDesc\":\"General Chemistry and Energetics\",\n"
249                + "      \"courseOfferingCreditOptionDisplay\":\"2.0\",\n"
250                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
251                + "      \"studentSelectablePassFail\":true,\n"
252                + "      \"auditCourse\":true,\n"
253                + "      \"honorsCourse\":false\n"
254                + "   },\n"
255                + "   {\n"
256                + "      \"courseOfferingId\":\"fdfd8711-e66e-4618-8321-f4bc74062792\",\n"
257                + "      \"courseOfferingCode\":\"CHEM272\",\n"
258                + "      \"courseOfferingDesc\":\"General Bioanalytical Chemistry Laboratory\",\n"
259                + "      \"courseOfferingCreditOptionDisplay\":\"2.0\",\n"
260                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
261                + "      \"studentSelectablePassFail\":true,\n"
262                + "      \"auditCourse\":false,\n"
263                + "      \"honorsCourse\":false\n"
264                + "   },\n"
265                + "   {\n"
266                + "      \"courseOfferingId\":\"8e7fa3b9-9560-4f2e-88c5-59c29dc9f126\",\n"
267                + "      \"courseOfferingCode\":\"CHEM277\",\n"
268                + "      \"courseOfferingDesc\":\"Fundamentals of Analytical and Bioanalytical Chemistry Laboratory\",\n"
269                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
270                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
271                + "      \"studentSelectablePassFail\":false,\n"
272                + "      \"auditCourse\":false,\n"
273                + "      \"honorsCourse\":false\n"
274                + "   },\n"
275                + "   {\n"
276                + "      \"courseOfferingId\":\"3b84eca8-8664-4de1-8703-b1aebeddc1fb\",\n"
277                + "      \"courseOfferingCode\":\"CHEM398\",\n"
278                + "      \"courseOfferingDesc\":\"Special Projects\",\n"
279                + "      \"courseOfferingCreditOptionDisplay\":\"2.0\",\n"
280                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
281                + "      \"studentSelectablePassFail\":true,\n"
282                + "      \"auditCourse\":true,\n"
283                + "      \"honorsCourse\":false\n"
284                + "   },\n"
285                + "   {\n"
286                + "      \"courseOfferingId\":\"075b54a0-133a-4e58-9b89-99cb1498e0f0\",\n"
287                + "      \"courseOfferingCode\":\"CHEM399A\",\n"
288                + "      \"courseOfferingDesc\":\"Introduction to Chemical Research\",\n"
289                + "      \"courseOfferingCreditOptionDisplay\":\"1.0,1.5,2.0,2.5,3.0\",\n"
290                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
291                + "      \"studentSelectablePassFail\":true,\n"
292                + "      \"auditCourse\":true,\n"
293                + "      \"honorsCourse\":false\n"
294                + "   },\n"
295                + "   {\n"
296                + "      \"courseOfferingId\":\"9a3126b4-bcad-403a-87ba-ddc438141039\",\n"
297                + "      \"courseOfferingCode\":\"CHEM399B\",\n"
298                + "      \"courseOfferingDesc\":\"Introduction to Chemical Research\",\n"
299                + "      \"courseOfferingCreditOptionDisplay\":\"1.0,1.5,2.0,2.5,3.0\",\n"
300                + "      \"courseOfferingGradingOptionDisplay\":\"Pass/Fail Grading\",\n"
301                + "      \"studentSelectablePassFail\":true,\n"
302                + "      \"auditCourse\":true,\n"
303                + "      \"honorsCourse\":false\n"
304                + "   },\n"
305                + "   {\n"
306                + "      \"courseOfferingId\":\"26a79829-b42c-441b-b9cf-0d8f7a35629f\",\n"
307                + "      \"courseOfferingCode\":\"CHEM399C\",\n"
308                + "      \"courseOfferingDesc\":\"Introduction to Chemical Research\",\n"
309                + "      \"courseOfferingCreditOptionDisplay\":\"1.0,1.5,2.0,2.5,3.0\",\n"
310                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
311                + "      \"studentSelectablePassFail\":true,\n"
312                + "      \"auditCourse\":true,\n"
313                + "      \"honorsCourse\":false\n"
314                + "   },\n"
315                + "   {\n"
316                + "      \"courseOfferingId\":\"84d4cc82-a24f-4775-8374-a5a4ebcab530\",\n"
317                + "      \"courseOfferingCode\":\"CHEM399X\",\n"
318                + "      \"courseOfferingDesc\":\"Introduction to Chemical Research; Chemistry Instruction\",\n"
319                + "      \"courseOfferingCreditOptionDisplay\":\"1.0,1.5,2.0,2.5,3.0\",\n"
320                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
321                + "      \"studentSelectablePassFail\":true,\n"
322                + "      \"auditCourse\":true,\n"
323                + "      \"honorsCourse\":false\n"
324                + "   },\n"
325                + "   {\n"
326                + "      \"courseOfferingId\":\"0c5fcfef-11dd-4e89-b9ab-a28b4b2d7fb0\",\n"
327                + "      \"courseOfferingCode\":\"CHEM403\",\n"
328                + "      \"courseOfferingDesc\":\"Radiochemistry\",\n"
329                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
330                + "      \"courseOfferingGradingOptionDisplay\":\"Pass/Fail Grading\",\n"
331                + "      \"studentSelectablePassFail\":true,\n"
332                + "      \"auditCourse\":true,\n"
333                + "      \"honorsCourse\":false\n"
334                + "   },\n"
335                + "   {\n"
336                + "      \"courseOfferingId\":\"195107f1-0afb-4af3-a78a-d287a57f8a3c\",\n"
337                + "      \"courseOfferingCode\":\"CHEM425\",\n"
338                + "      \"courseOfferingDesc\":\"Instrumental Methods of Analysis\",\n"
339                + "      \"courseOfferingCreditOptionDisplay\":\"4.0\",\n"
340                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
341                + "      \"studentSelectablePassFail\":true,\n"
342                + "      \"auditCourse\":true,\n"
343                + "      \"honorsCourse\":false\n"
344                + "   },\n"
345                + "   {\n"
346                + "      \"courseOfferingId\":\"e67d87d6-8d89-401a-86ac-08ca8bd5195b\",\n"
347                + "      \"courseOfferingCode\":\"CHEM441\",\n"
348                + "      \"courseOfferingDesc\":\"Advanced Organic Chemistry\",\n"
349                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
350                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
351                + "      \"studentSelectablePassFail\":true,\n"
352                + "      \"auditCourse\":true,\n"
353                + "      \"honorsCourse\":false\n"
354                + "   },\n"
355                + "   {\n"
356                + "      \"courseOfferingId\":\"6f2cb68a-b09d-4b2b-8459-7fe17de11055\",\n"
357                + "      \"courseOfferingCode\":\"CHEM460\",\n"
358                + "      \"courseOfferingDesc\":\"Structure Determination Using Spectroscopic Methods\",\n"
359                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
360                + "      \"courseOfferingGradingOptionDisplay\":\"Pass/Fail Grading\",\n"
361                + "      \"studentSelectablePassFail\":true,\n"
362                + "      \"auditCourse\":true,\n"
363                + "      \"honorsCourse\":false\n"
364                + "   },\n"
365                + "   {\n"
366                + "      \"courseOfferingId\":\"abf9196f-a0d2-4558-b47b-308bf0257c35\",\n"
367                + "      \"courseOfferingCode\":\"CHEM474\",\n"
368                + "      \"courseOfferingDesc\":\"Environmental Chemistry\",\n"
369                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
370                + "      \"courseOfferingGradingOptionDisplay\":\"Pass/Fail Grading\",\n"
371                + "      \"studentSelectablePassFail\":true,\n"
372                + "      \"auditCourse\":true,\n"
373                + "      \"honorsCourse\":false\n"
374                + "   },\n"
375                + "   {\n"
376                + "      \"courseOfferingId\":\"87521128-54b5-4c97-a756-b1ecd7dcc5f5\",\n"
377                + "      \"courseOfferingCode\":\"CHEM481\",\n"
378                + "      \"courseOfferingDesc\":\"Physical Chemistry I\",\n"
379                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
380                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
381                + "      \"studentSelectablePassFail\":true,\n"
382                + "      \"auditCourse\":true,\n"
383                + "      \"honorsCourse\":false\n"
384                + "   },\n"
385                + "   {\n"
386                + "      \"courseOfferingId\":\"99f82ba5-ad01-4489-b446-99ea8f62d292\",\n"
387                + "      \"courseOfferingCode\":\"CHEM482\",\n"
388                + "      \"courseOfferingDesc\":\"Physical Chemistry II\",\n"
389                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
390                + "      \"courseOfferingGradingOptionDisplay\":\"Pass/Fail Grading\",\n"
391                + "      \"studentSelectablePassFail\":true,\n"
392                + "      \"auditCourse\":true,\n"
393                + "      \"honorsCourse\":false\n"
394                + "   },\n"
395                + "   {\n"
396                + "      \"courseOfferingId\":\"7a84cb1d-51ad-44a5-a315-69451dea6154\",\n"
397                + "      \"courseOfferingCode\":\"CHEM483\",\n"
398                + "      \"courseOfferingDesc\":\"Physical Chemistry Laboratory I\",\n"
399                + "      \"courseOfferingCreditOptionDisplay\":\"2.0\",\n"
400                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
401                + "      \"studentSelectablePassFail\":true,\n"
402                + "      \"auditCourse\":true,\n"
403                + "      \"honorsCourse\":false\n"
404                + "   },\n"
405                + "   {\n"
406                + "      \"courseOfferingId\":\"9118cf6c-a573-4443-9208-89079ff89d8b\",\n"
407                + "      \"courseOfferingCode\":\"CHEM484\",\n"
408                + "      \"courseOfferingDesc\":\"Physical Chemistry Laboratory II\",\n"
409                + "      \"courseOfferingCreditOptionDisplay\":\"2.0\",\n"
410                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
411                + "      \"studentSelectablePassFail\":true,\n"
412                + "      \"auditCourse\":true,\n"
413                + "      \"honorsCourse\":false\n"
414                + "   },\n"
415                + "   {\n"
416                + "      \"courseOfferingId\":\"d5604c9f-664c-4dc1-94b1-695a821b7c8f\",\n"
417                + "      \"courseOfferingCode\":\"CHEM491\",\n"
418                + "      \"courseOfferingDesc\":\"Advanced Organic Chemistry Laboratory\",\n"
419                + "      \"courseOfferingCreditOptionDisplay\":\"4.0\",\n"
420                + "      \"courseOfferingGradingOptionDisplay\":\"Pass/Fail Grading\",\n"
421                + "      \"studentSelectablePassFail\":true,\n"
422                + "      \"auditCourse\":true,\n"
423                + "      \"honorsCourse\":false\n"
424                + "   },\n"
425                + "   {\n"
426                + "      \"courseOfferingId\":\"9218e1e8-8279-4ea2-9975-9decdf337eca\",\n"
427                + "      \"courseOfferingCode\":\"CHEM601\",\n"
428                + "      \"courseOfferingDesc\":\"Structure and Bonding of Molecules and Materials\",\n"
429                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
430                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
431                + "      \"studentSelectablePassFail\":false,\n"
432                + "      \"auditCourse\":true,\n"
433                + "      \"honorsCourse\":false\n"
434                + "   },\n"
435                + "   {\n"
436                + "      \"courseOfferingId\":\"eb942c03-0e7e-4bd7-a774-d26cb1c64f25\",\n"
437                + "      \"courseOfferingCode\":\"CHEM608K\",\n"
438                + "      \"courseOfferingDesc\":\"Selected Topics in Inorganic Chemistry; Chemistry Teaching and Learning in Higher Education\",\n"
439                + "      \"courseOfferingCreditOptionDisplay\":\"1.0,1.5,2.0,2.5,3.0\",\n"
440                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
441                + "      \"studentSelectablePassFail\":false,\n"
442                + "      \"auditCourse\":true,\n"
443                + "      \"honorsCourse\":false\n"
444                + "   },\n"
445                + "   {\n"
446                + "      \"courseOfferingId\":\"19bb06aa-a076-4937-8fc4-acccf85b9828\",\n"
447                + "      \"courseOfferingCode\":\"CHEM611\",\n"
448                + "      \"courseOfferingDesc\":\"Professional Skills for New Graduate Students\",\n"
449                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
450                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
451                + "      \"studentSelectablePassFail\":false,\n"
452                + "      \"auditCourse\":true,\n"
453                + "      \"honorsCourse\":false\n"
454                + "   },\n"
455                + "   {\n"
456                + "      \"courseOfferingId\":\"9dd9724e-efd6-4d31-9624-b46450b57027\",\n"
457                + "      \"courseOfferingCode\":\"CHEM625\",\n"
458                + "      \"courseOfferingDesc\":\"Separation Methods in Quantitative Analysis\",\n"
459                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
460                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
461                + "      \"studentSelectablePassFail\":false,\n"
462                + "      \"auditCourse\":true,\n"
463                + "      \"honorsCourse\":false\n"
464                + "   },\n"
465                + "   {\n"
466                + "      \"courseOfferingId\":\"8938913c-cbd0-4405-97ad-f7e179114b83\",\n"
467                + "      \"courseOfferingCode\":\"CHEM626\",\n"
468                + "      \"courseOfferingDesc\":\"Metrology for Chemistry and Biochemistry\",\n"
469                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
470                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
471                + "      \"studentSelectablePassFail\":false,\n"
472                + "      \"auditCourse\":true,\n"
473                + "      \"honorsCourse\":false\n"
474                + "   },\n"
475                + "   {\n"
476                + "      \"courseOfferingId\":\"39c50ead-18ef-4909-89dc-3341cf8f6fd5\",\n"
477                + "      \"courseOfferingCode\":\"CHEM640\",\n"
478                + "      \"courseOfferingDesc\":\"Problems in Organic Reaction Mechanisms\",\n"
479                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
480                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
481                + "      \"studentSelectablePassFail\":false,\n"
482                + "      \"auditCourse\":true,\n"
483                + "      \"honorsCourse\":false\n"
484                + "   },\n"
485                + "   {\n"
486                + "      \"courseOfferingId\":\"bc7d6a5e-b77c-400b-a79b-1e02164b2de8\",\n"
487                + "      \"courseOfferingCode\":\"CHEM641\",\n"
488                + "      \"courseOfferingDesc\":\"Organic Reaction Mechanisms\",\n"
489                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
490                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
491                + "      \"studentSelectablePassFail\":false,\n"
492                + "      \"auditCourse\":true,\n"
493                + "      \"honorsCourse\":false\n"
494                + "   },\n"
495                + "   {\n"
496                + "      \"courseOfferingId\":\"22f75db7-d9ac-4da7-ba0c-6def7b544718\",\n"
497                + "      \"courseOfferingCode\":\"CHEM682\",\n"
498                + "      \"courseOfferingDesc\":\"Chemical Kinetics and Dynamics\",\n"
499                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
500                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
501                + "      \"studentSelectablePassFail\":false,\n"
502                + "      \"auditCourse\":true,\n"
503                + "      \"honorsCourse\":false\n"
504                + "   },\n"
505                + "   {\n"
506                + "      \"courseOfferingId\":\"4a6f4368-2a17-4bef-b62c-872fa66f8211\",\n"
507                + "      \"courseOfferingCode\":\"CHEM684\",\n"
508                + "      \"courseOfferingDesc\":\"Chemical Thermodynamics\",\n"
509                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
510                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
511                + "      \"studentSelectablePassFail\":false,\n"
512                + "      \"auditCourse\":true,\n"
513                + "      \"honorsCourse\":false\n"
514                + "   },\n"
515                + "   {\n"
516                + "      \"courseOfferingId\":\"8ba3008b-cf09-4df3-99fe-403f44be4eed\",\n"
517                + "      \"courseOfferingCode\":\"CHEM689\",\n"
518                + "      \"courseOfferingDesc\":\"Special Topics in Physical Chemistry\",\n"
519                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
520                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
521                + "      \"studentSelectablePassFail\":false,\n"
522                + "      \"auditCourse\":true,\n"
523                + "      \"honorsCourse\":false\n"
524                + "   },\n"
525                + "   {\n"
526                + "      \"courseOfferingId\":\"73e0e856-d344-4946-a759-65209dfd6e3b\",\n"
527                + "      \"courseOfferingCode\":\"CHEM690\",\n"
528                + "      \"courseOfferingDesc\":\"Quantum Chemistry I\",\n"
529                + "      \"courseOfferingCreditOptionDisplay\":\"3.0\",\n"
530                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
531                + "      \"studentSelectablePassFail\":false,\n"
532                + "      \"auditCourse\":true,\n"
533                + "      \"honorsCourse\":false\n"
534                + "   },\n"
535                + "   {\n"
536                + "      \"courseOfferingId\":\"ce30b18d-5003-430c-9b8d-07d320785f4d\",\n"
537                + "      \"courseOfferingCode\":\"CHEM699\",\n"
538                + "      \"courseOfferingDesc\":\"Special Problems in Chemistry\",\n"
539                + "      \"courseOfferingCreditOptionDisplay\":\"1 - 6\",\n"
540                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
541                + "      \"studentSelectablePassFail\":false,\n"
542                + "      \"auditCourse\":true,\n"
543                + "      \"honorsCourse\":false\n"
544                + "   },\n"
545                + "   {\n"
546                + "      \"courseOfferingId\":\"af7586c2-92aa-4da7-81d0-82e757efae99\",\n"
547                + "      \"courseOfferingCode\":\"CHEM799\",\n"
548                + "      \"courseOfferingDesc\":\"Master's Thesis Research\",\n"
549                + "      \"courseOfferingCreditOptionDisplay\":\"1 - 6\",\n"
550                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
551                + "      \"studentSelectablePassFail\":false,\n"
552                + "      \"auditCourse\":false,\n"
553                + "      \"honorsCourse\":false\n"
554                + "   },\n"
555                + "   {\n"
556                + "      \"courseOfferingId\":\"47b27aeb-3506-4cef-9cab-ce82eb16b98a\",\n"
557                + "      \"courseOfferingCode\":\"CHEM889A\",\n"
558                + "      \"courseOfferingDesc\":\"Seminar; Analytical, Nuclear and Environmental Chemistry\",\n"
559                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
560                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
561                + "      \"studentSelectablePassFail\":false,\n"
562                + "      \"auditCourse\":true,\n"
563                + "      \"honorsCourse\":false\n"
564                + "   },\n"
565                + "   {\n"
566                + "      \"courseOfferingId\":\"81590cdf-e8bb-42b2-8192-9782ad9ca0e7\",\n"
567                + "      \"courseOfferingCode\":\"CHEM889C\",\n"
568                + "      \"courseOfferingDesc\":\"Seminar; Inorganic\",\n"
569                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
570                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
571                + "      \"studentSelectablePassFail\":false,\n"
572                + "      \"auditCourse\":true,\n"
573                + "      \"honorsCourse\":false\n"
574                + "   },\n"
575                + "   {\n"
576                + "      \"courseOfferingId\":\"2972d4f5-2670-4d69-8bc5-c3d0afb28a4a\",\n"
577                + "      \"courseOfferingCode\":\"CHEM889D\",\n"
578                + "      \"courseOfferingDesc\":\"Seminar; Organic\",\n"
579                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
580                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
581                + "      \"studentSelectablePassFail\":false,\n"
582                + "      \"auditCourse\":true,\n"
583                + "      \"honorsCourse\":false\n"
584                + "   },\n"
585                + "   {\n"
586                + "      \"courseOfferingId\":\"672d59b9-c2ae-4462-82f3-b0ebfc181c59\",\n"
587                + "      \"courseOfferingCode\":\"CHEM889E\",\n"
588                + "      \"courseOfferingDesc\":\"Seminar; Physical Chemistry\",\n"
589                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
590                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
591                + "      \"studentSelectablePassFail\":false,\n"
592                + "      \"auditCourse\":true,\n"
593                + "      \"honorsCourse\":false\n"
594                + "   },\n"
595                + "   {\n"
596                + "      \"courseOfferingId\":\"ee6838b4-40d8-419e-8838-a5286e269dc9\",\n"
597                + "      \"courseOfferingCode\":\"CHEM889F\",\n"
598                + "      \"courseOfferingDesc\":\"Seminar; Chemical Physics\",\n"
599                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
600                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
601                + "      \"studentSelectablePassFail\":false,\n"
602                + "      \"auditCourse\":true,\n"
603                + "      \"honorsCourse\":false\n"
604                + "   },\n"
605                + "   {\n"
606                + "      \"courseOfferingId\":\"fe0b4cbd-0796-4810-88ec-0dc22f570cc6\",\n"
607                + "      \"courseOfferingCode\":\"CHEM889G\",\n"
608                + "      \"courseOfferingDesc\":\"Seminar; Physical Organic\",\n"
609                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
610                + "      \"courseOfferingGradingOptionDisplay\":\"Allow students to audit\",\n"
611                + "      \"studentSelectablePassFail\":false,\n"
612                + "      \"auditCourse\":true,\n"
613                + "      \"honorsCourse\":false\n"
614                + "   },\n"
615                + "   {\n"
616                + "      \"courseOfferingId\":\"ac1a7153-1ceb-483e-bf3c-417494ac4522\",\n"
617                + "      \"courseOfferingCode\":\"CHEM889M\",\n"
618                + "      \"courseOfferingDesc\":\"Seminar; Materials Chemistry\",\n"
619                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
620                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
621                + "      \"studentSelectablePassFail\":false,\n"
622                + "      \"auditCourse\":true,\n"
623                + "      \"honorsCourse\":false\n"
624                + "   },\n"
625                + "   {\n"
626                + "      \"courseOfferingId\":\"019e01b1-695a-4513-92b6-4303af879b61\",\n"
627                + "      \"courseOfferingCode\":\"CHEM889P\",\n"
628                + "      \"courseOfferingDesc\":\"Seminar; Structure and Reactivity of Biopolymers\",\n"
629                + "      \"courseOfferingCreditOptionDisplay\":\"1.0\",\n"
630                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
631                + "      \"studentSelectablePassFail\":false,\n"
632                + "      \"auditCourse\":true,\n"
633                + "      \"honorsCourse\":false\n"
634                + "   },\n"
635                + "   {\n"
636                + "      \"courseOfferingId\":\"d0b9cf2f-879d-4bf4-8afd-05531b842219\",\n"
637                + "      \"courseOfferingCode\":\"CHEM898\",\n"
638                + "      \"courseOfferingDesc\":\"Pre-Candidacy Research\",\n"
639                + "      \"courseOfferingCreditOptionDisplay\":\"1 - 8\",\n"
640                + "      \"courseOfferingGradingOptionDisplay\":\"Administrative Grade of Satisfactory\",\n"
641                + "      \"studentSelectablePassFail\":false,\n"
642                + "      \"auditCourse\":false,\n"
643                + "      \"honorsCourse\":false\n"
644                + "   },\n"
645                + "   {\n"
646                + "      \"courseOfferingId\":\"a3c5e362-6343-4177-ae39-c2f55b32f56b\",\n"
647                + "      \"courseOfferingCode\":\"CHEM899\",\n"
648                + "      \"courseOfferingDesc\":\"Doctoral Dissertation Research\",\n"
649                + "      \"courseOfferingCreditOptionDisplay\":\"1 - 8\",\n"
650                + "      \"courseOfferingGradingOptionDisplay\":\"Letter\",\n"
651                + "      \"studentSelectablePassFail\":false,\n"
652                + "      \"auditCourse\":false,\n"
653                + "      \"honorsCourse\":false\n"
654                + "   }\n"
655                + "]";
656
657        JsonReader jsonReader = Json.createReader(new StringReader(temp));
658        JsonArray jsonArray = jsonReader.readArray();
659        List<CourseSearchResult> collectionList = new ArrayList<CourseSearchResult>();
660
661        populateCourseSearchResults(jsonArray, collectionList);
662        form.setPerfCollection(collectionList); // add collection to form.
663
664        return getModelAndView(form);
665    }
666
667    /**
668     *
669     * @param jsonArray
670     * @param collectionList
671     * @throws JsonException
672     */
673    public void populateCourseSearchResults(JsonArray jsonArray, List<CourseSearchResult> collectionList)throws JsonException {
674        int j = jsonArray.size();
675        int i;
676        for(i=0; i<j; i++) {
677            CourseSearchResult courseSearchResult = new CourseSearchResult();
678            JsonObject jsonObject = (JsonObject)jsonArray.get(i);
679            courseSearchResult.setCourseOfferingId(jsonObject.getString("courseOfferingId"));
680            courseSearchResult.setCourseOfferingCode(jsonObject.getString("courseOfferingCode"));
681            courseSearchResult.setHonorsCourse(jsonObject.getBoolean("honorsCourse"));
682            courseSearchResult.setAuditCourse(jsonObject.getBoolean("auditCourse"));
683            courseSearchResult.setStudentSelectablePassFail(jsonObject.getBoolean("studentSelectablePassFail"));
684            courseSearchResult.setCourseOfferingDesc(jsonObject.getString("courseOfferingDesc"));
685            courseSearchResult.setCourseOfferingCreditOptionDisplay(jsonObject.getString(
686                    "courseOfferingCreditOptionDisplay"));
687            courseSearchResult.setCourseOfferingGradingOptionDisplay(jsonObject.getString(
688                    "courseOfferingGradingOptionDisplay"));
689            collectionList.add(courseSearchResult);
690        }
691
692
693    }
694
695    /**
696     *
697     * @param urlToRead
698     * @return
699     */
700    public String getHTML(String urlToRead) {
701        URL url;
702        HttpURLConnection conn;
703        BufferedReader rd;
704        String line;
705        String result = "";
706        try {
707            url = new URL(urlToRead);
708            conn = (HttpURLConnection) url.openConnection();
709            conn.setRequestMethod("GET");
710            rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
711            while ((line = rd.readLine()) != null) {
712                result += line;
713            }
714            rd.close();
715        } catch (IOException e) {
716            e.printStackTrace();
717        } catch (Exception e) {
718            e.printStackTrace();
719        }
720        return result;
721    }
722
723}