1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.class2.registration.admin.controller;
18
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.rice.core.api.util.io.SerializationUtils;
21 import org.kuali.rice.krad.uif.UifParameters;
22 import org.kuali.rice.krad.uif.util.ObjectPropertyUtils;
23 import org.kuali.rice.krad.util.GlobalVariables;
24 import org.kuali.rice.krad.web.controller.MethodAccessible;
25 import org.kuali.rice.krad.web.controller.UifControllerBase;
26 import org.kuali.rice.krad.web.form.UifFormBase;
27 import org.kuali.student.common.uif.util.KSControllerHelper;
28 import org.kuali.student.enrollment.class2.registration.admin.form.AdminRegistrationForm;
29 import org.kuali.student.enrollment.class2.registration.admin.form.RegistrationCourse;
30 import org.kuali.student.enrollment.class2.registration.admin.form.RegistrationResult;
31 import org.kuali.student.enrollment.class2.registration.admin.form.RegistrationResultItem;
32 import org.kuali.student.enrollment.class2.registration.admin.service.AdminRegistrationViewHelperService;
33 import org.kuali.student.enrollment.class2.registration.admin.util.AdminRegClientCache;
34 import org.kuali.student.enrollment.class2.registration.admin.util.AdminRegConstants;
35 import org.kuali.student.enrollment.class2.registration.admin.util.AdminRegistrationUtil;
36 import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo;
37 import org.kuali.student.enrollment.courseregistration.dto.RegistrationRequestInfo;
38 import org.kuali.student.enrollment.courseregistration.dto.RegistrationRequestItemInfo;
39 import org.kuali.student.r2.common.util.constants.LprServiceConstants;
40 import org.kuali.student.r2.lum.util.constants.LrcServiceConstants;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
43 import org.springframework.stereotype.Controller;
44 import org.springframework.validation.BindingResult;
45 import org.springframework.web.bind.annotation.ModelAttribute;
46 import org.springframework.web.bind.annotation.RequestMapping;
47 import org.springframework.web.bind.annotation.RequestMethod;
48 import org.springframework.web.bind.annotation.ResponseBody;
49 import org.springframework.web.servlet.ModelAndView;
50
51 import javax.servlet.http.HttpServletRequest;
52 import javax.servlet.http.HttpServletResponse;
53 import java.util.ArrayList;
54 import java.util.Collection;
55 import java.util.Date;
56 import java.util.HashMap;
57 import java.util.HashSet;
58 import java.util.List;
59 import java.util.Map;
60 import java.util.Set;
61
62
63
64
65
66
67
68
69 @Controller
70 @RequestMapping(value = "/adminreg")
71 public class AdminRegistrationController extends UifControllerBase {
72
73 private static final Logger LOG = LoggerFactory.getLogger(AdminRegistrationController.class);
74
75
76
77
78
79 @Override
80 protected AdminRegistrationForm createInitialForm(HttpServletRequest request) {
81 return new AdminRegistrationForm();
82 }
83
84 @Override
85 @RequestMapping(params = "methodToCall=refresh")
86 public ModelAndView refresh(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, HttpServletRequest request,
87 HttpServletResponse response) throws Exception {
88 if (!(form instanceof AdminRegistrationForm)){
89 throw new RuntimeException("Unexpected type: " + form);
90 }
91 AdminRegistrationForm adminForm = (AdminRegistrationForm) form;
92 if(AdminRegConstants.REG_COLL_ID.equals(form.getUpdateComponentId())) {
93 adminForm.setRegisteredCourses(getViewHelper(form).getCourseRegForStudentAndTerm(adminForm.getPerson().getId(), adminForm.getTerm().getId()));
94 } else if(AdminRegConstants.WAITLIST_COLL_ID.equals(form.getUpdateComponentId())) {
95 adminForm.setWaitlistedCourses(getViewHelper(form).getCourseWaitListForStudentAndTerm(adminForm.getPerson().getId(), adminForm.getTerm().getId()));
96 }
97 return super.refresh(form, result, request, response);
98 }
99
100
101
102
103
104
105
106
107
108
109
110
111
112 @MethodAccessible
113 @RequestMapping(params = "methodToCall=refreshCourseTitle")
114 public ModelAndView refreshCourseTitle(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result, HttpServletRequest request,
115 HttpServletResponse response) throws Exception {
116 return super.refresh(form, result, request, response);
117 }
118
119
120
121
122
123
124
125
126
127
128
129
130
131 @MethodAccessible
132 @RequestMapping(params = "methodToCall=refreshRegistrationResults")
133 public ModelAndView refreshRegistrationResults(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result, HttpServletRequest request,
134 HttpServletResponse response) throws Exception {
135
136
137 form.setRegRequestId(null);
138 if (form.getCoursesInProcess() != null) {
139 form.getCoursesInProcess().clear();
140 }
141 form.setPendingDropCourse(null);
142 if (form.getCoursesInEdit() != null) {
143 form.getCoursesInEdit().clear();
144 }
145 form.getEditingIssues().clear();
146 form.setClientState(AdminRegConstants.ClientStates.READY);
147 return super.refresh(form, result, request, response);
148 }
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=getStudentAndTermInfo")
164 public ModelAndView getStudentAndTermInfo(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
165 HttpServletRequest request, HttpServletResponse response) {
166 long start = System.currentTimeMillis();
167
168 form.clearCourseRegistrationValues();
169
170 form.setPerson(this.getViewHelper(form).getStudentById(form.getPersonId()));
171 form.setTerm(this.getViewHelper(form).getTermByCode(form.getTermCode()));
172 form.setContextBar(getViewHelper(form).getContextBarInfo(form.getTerm()));
173 if (GlobalVariables.getMessageMap().hasErrors()) {
174 form.setClientState(AdminRegConstants.ClientStates.OPEN);
175 form.setDisplayRegistrationTab(false);
176 return getUIFModelAndView(form);
177 }
178
179 form.setRegisteredCourses(getViewHelper(form).getCourseRegForStudentAndTerm(form.getPerson().getId(), form.getTerm().getId()));
180 form.setWaitlistedCourses(getViewHelper(form).getCourseWaitListForStudentAndTerm(form.getPerson().getId(), form.getTerm().getId()));
181
182 form.setDisplayRegistrationTab(true);
183 form.getTermIssues().addAll(getViewHelper(form).checkStudentEligibilityForTermLocal(form.getPerson().getId().toUpperCase(), form.getTerm()));
184
185 printTime(form.getMethodToCall(), start);
186
187 form.setClientState(AdminRegConstants.ClientStates.READY);
188 return getUIFModelAndView(form);
189 }
190
191 @MethodAccessible
192 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=cancelFailedEligibilityTerm")
193 public ModelAndView cancelFailedEligibilityTerm(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
194 HttpServletRequest request, HttpServletResponse response) {
195
196 form.clearCourseRegistrationValues();
197 form.setDisplayRegistrationTab(false);
198 form.setClientState(AdminRegConstants.ClientStates.READY);
199 return getUIFModelAndView(form);
200 }
201
202 @MethodAccessible
203 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=continueFailedEligibilityTerm")
204 public ModelAndView continueFailedEligibilityTerm(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
205 HttpServletRequest request, HttpServletResponse response) {
206
207 form.clearCourseRegistrationValues();
208 form.setDisplayRegistrationTab(true);
209 form.setClientState(AdminRegConstants.ClientStates.READY);
210 return getUIFModelAndView(form);
211 }
212
213
214
215
216
217
218 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=removeRegisterCourse")
219 public ModelAndView removeRegisterCourse(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
220 HttpServletRequest request, HttpServletResponse response) {
221 return deleteLine(form, result, request, response);
222 }
223
224 @MethodAccessible
225 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=register")
226 public ModelAndView register(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
227 HttpServletRequest request, HttpServletResponse response) {
228 long start = System.currentTimeMillis();
229
230
231 getViewHelper(form).validateForRegistration(form);
232 if (GlobalVariables.getMessageMap().hasErrors()) {
233 form.setClientState(AdminRegConstants.ClientStates.READY);
234
235 printTime(form.getMethodToCall(), start);
236
237 return getUIFModelAndView(form);
238 }
239
240
241 form.getCoursesInProcess().clear();
242 form.getCoursesInProcess().addAll(form.getPendingCourses());
243
244
245 for (RegistrationCourse course : form.getCoursesInProcess()) {
246 course.setActivities(getViewHelper(form).getRegistrationActivitiesForRegistrationCourse(course, form.getTerm().getCode()));
247 }
248 form.setConfirmationIssues(new ArrayList<String>());
249
250 printTime(form.getMethodToCall(), start);
251
252 return showDialog(AdminRegConstants.REG_CONFIRM_DIALOG, form, request, response);
253 }
254
255 @MethodAccessible
256 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=submit")
257 public ModelAndView submit(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
258 HttpServletRequest request, HttpServletResponse response) {
259
260
261 form.getConfirmationIssues().clear();
262 getViewHelper(form).validateForSubmission(form);
263 if (!form.getConfirmationIssues().isEmpty()) {
264 return showDialog(AdminRegConstants.REG_CONFIRM_DIALOG, form, request, response);
265 }
266
267
268 form.resetPendingCourseValues();
269 form.setRegRequestId(getViewHelper(form).submitCourses(form.getPerson().getId(), form.getTerm().getId(),
270 form.getCoursesInProcess(), LprServiceConstants.REQ_ITEM_ADD_TYPE_KEY));
271
272
273 form.setClientState(AdminRegConstants.ClientStates.REGISTERING);
274 return getUIFModelAndView(form);
275 }
276
277 @MethodAccessible
278 @RequestMapping(method = RequestMethod.GET, params = "methodToCall=queryForRegistrationStatus")
279 @ResponseBody
280 public Map queryForRegistrationStatus(@ModelAttribute("KualiForm") AdminRegistrationForm form) {
281
282 Map<String, Object> result = new HashMap<String, Object>();
283 Set<String> updateIds = new HashSet<String>();
284 List<String> growlMessages = new ArrayList<String>();
285
286
287 if ((!AdminRegConstants.ClientStates.REGISTERING.equals(form.getClientState()) || (form.getRegRequestId() == null))) {
288 result.put(AdminRegConstants.POLLING_STOP, true);
289 return result;
290 }
291
292
293 RegistrationRequestInfo regRequest = this.getViewHelper(form).getRegistrationRequest(form.getRegRequestId());
294 if ((regRequest.getStateKey().equals(LprServiceConstants.LPRTRANS_PROCESSING_STATE_KEY)) ||
295 (regRequest.getStateKey().equals(LprServiceConstants.LPRTRANS_NEW_STATE_KEY))) {
296 return result;
297 }
298
299 synchronized (form) {
300
301 for (RegistrationRequestItemInfo item : regRequest.getRegistrationRequestItems()) {
302
303
304 RegistrationResult regResult = null;
305 if (LprServiceConstants.REQ_ITEM_ADD_TYPE_KEY.equals(item.getTypeKey())) {
306 regResult = handleAddRequestItem(form, item);
307 } else if (LprServiceConstants.REQ_ITEM_UPDATE_TYPE_KEY.equals(item.getTypeKey())) {
308 regResult = handleEditRequestItem(form, item);
309 } else if (LprServiceConstants.REQ_ITEM_DROP_TYPE_KEY.equals(item.getTypeKey())) {
310 regResult = handleDropRequestItem(form, item);
311 }
312
313 if (regResult != null) {
314 if (regResult.getCollectionId() != null) {
315 updateIds.add(regResult.getCollectionId());
316 }
317 if (AdminRegConstants.ResultLevels.RESULT_LEVEL_SUCCESS.equals(regResult.getLevel())) {
318 for (RegistrationResultItem resultItem : regResult.getItems()) {
319 growlMessages.add(resultItem.getDescription());
320 }
321
322 } else {
323 form.getRegistrationResults().add(regResult);
324 }
325 }
326 }
327 }
328
329
330 result.put(AdminRegConstants.POLLING_GROWL_MESSAGES, growlMessages);
331 result.put(AdminRegConstants.POLLING_REFRESH, true);
332 result.put(AdminRegConstants.POLLING_CLIENT_STATE, AdminRegConstants.ClientStates.READY);
333 result.put(AdminRegConstants.POLLING_REGISTERED_CREDITS, form.getRegisteredCredits());
334 result.put(AdminRegConstants.POLLING_WAITLISTED_CREDITS, form.getWaitlistedCredits());
335
336
337 result.put(AdminRegConstants.POLLING_STOP, true);
338 result.put(AdminRegConstants.POLLING_UPDATE_IDS, updateIds);
339 return result;
340 }
341
342
343
344
345
346
347
348
349 private RegistrationResult handleAddRequestItem(AdminRegistrationForm form, RegistrationRequestItemInfo item) {
350
351 RegistrationResult result = null;
352 RegistrationCourse addCourse = AdminRegistrationUtil.retrieveFromCourseList(form.getCoursesInProcess(), item);
353 if (LprServiceConstants.LPRTRANS_ITEM_SUCCEEDED_STATE_KEY.equals(item.getStateKey())) {
354 if(item.getCourseRegistrationId()!=null) {
355 result = this.getViewHelper(form).buildRegistrationResult(addCourse, form.getTerm(),
356 AdminRegConstants.ADMIN_REG_MSG_INFO_SUCCESSFULLY_REGISTERED, item.getValidationResults());
357 result.setCollectionId(AdminRegConstants.REG_COLL_ID);
358 } else {
359 result = this.getViewHelper(form).buildRegistrationResult(addCourse, form.getTerm(),
360 AdminRegConstants.ADMIN_REG_MSG_INFO_SUCCESSFULLY_WAITLISTED, item.getValidationResults());
361 result.setCollectionId(AdminRegConstants.WAITLIST_COLL_ID);
362 }
363 } else if (LprServiceConstants.LPRTRANS_ITEM_FAILED_STATE_KEY.equals(item.getStateKey())) {
364 result = this.getViewHelper(form).buildRegistrationResult(addCourse, form.getTerm(), null, item.getValidationResults());
365
366 result.setCollectionId(AdminRegConstants.REG_COLL_ID);
367 }
368
369 return result;
370 }
371
372
373
374
375
376
377
378
379
380
381
382
383 private RegistrationResult handleEditRequestItem(AdminRegistrationForm form, RegistrationRequestItemInfo item) {
384
385
386 RegistrationResult result = null;
387 RegistrationCourse updatedCourse = AdminRegistrationUtil.retrieveFromCourseList(form.getCoursesInEdit(), item);
388
389 if (LprServiceConstants.LPRTRANS_ITEM_SUCCEEDED_STATE_KEY.equals(item.getStateKey())) {
390 result = this.getViewHelper(form).buildRegistrationResult(updatedCourse, form.getTerm(),
391 AdminRegConstants.ADMIN_REG_MSG_INFO_SUCCESSFULLY_UPDATED, item.getValidationResults());
392 result.setCollectionId(AdminRegConstants.REG_COLL_ID);
393 } else if (LprServiceConstants.LPRTRANS_ITEM_FAILED_STATE_KEY.equals(item.getStateKey())) {
394 result = this.getViewHelper(form).buildRegistrationResult(updatedCourse, form.getTerm(), null, item.getValidationResults());
395 result.setOriginRequestTypeKey(item.getTypeKey());
396 }
397
398 return result;
399 }
400
401
402
403
404
405
406
407
408 private RegistrationResult handleDropRequestItem(AdminRegistrationForm form, RegistrationRequestItemInfo item) {
409
410
411 RegistrationResult result = null;
412 RegistrationCourse dropCourse = form.getPendingDropCourse();
413 if (LprServiceConstants.LPRTRANS_ITEM_SUCCEEDED_STATE_KEY.equals(item.getStateKey())) {
414 result = this.getViewHelper(form).buildRegistrationResult(dropCourse, form.getTerm(),
415 AdminRegConstants.ADMIN_REG_MSG_INFO_SUCCESSFULLY_DROPPED, item.getValidationResults());
416 result.setCollectionId(AdminRegConstants.REG_COLL_ID);
417 } else if (LprServiceConstants.LPRTRANS_ITEM_FAILED_STATE_KEY.equals(item.getStateKey())) {
418 result = this.getViewHelper(form).buildRegistrationResult(dropCourse, form.getTerm(), null, item.getValidationResults());
419 result.setOriginRequestTypeKey(item.getTypeKey());
420 }
421
422 return result;
423 }
424
425
426
427
428
429 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=dropCourse")
430 public ModelAndView dropCourse(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
431 HttpServletRequest request, HttpServletResponse response) {
432
433
434 RegistrationCourse regCourse = getSelectedRegistrationCourse(form);
435
436 String selectedCollectionId = form.getActionParamaterValue(UifParameters.SELECTED_COLLECTION_ID);
437 if (selectedCollectionId.equals(AdminRegConstants.REG_COLL_ID)) {
438 regCourse.setRegisteredDropDate(new Date());
439 } else if (selectedCollectionId.equals(AdminRegConstants.WAITLIST_COLL_ID)) {
440 regCourse.setWaitlistedDropDate(new Date());
441 }
442
443 form.setPendingDropCourse(regCourse);
444 return showDialog(AdminRegConstants.DROP_COURSE_DIALOG, form, request, response);
445 }
446
447 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=dropRegisteredCourse")
448 public ModelAndView confirmDropCourse(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
449 HttpServletRequest request, HttpServletResponse response) throws Exception {
450
451 form.getDropIssues().clear();
452 getViewHelper(form).validateForDrop(form);
453 if (!form.getDropIssues().isEmpty()) {
454 return showDialog(AdminRegConstants.DROP_COURSE_DIALOG, form, request, response);
455 }
456
457
458 form.setRegRequestId(getViewHelper(form).submitCourse(form.getPerson().getId(), form.getTerm().getId(),
459 form.getPendingDropCourse(), LprServiceConstants.REQ_ITEM_DROP_TYPE_KEY));
460
461
462 form.setClientState(AdminRegConstants.ClientStates.REGISTERING);
463 return refresh(form, result, request, response);
464 }
465
466 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=removeWaitlistCourse")
467 public ModelAndView removeWaitlistCourse(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
468 HttpServletRequest request, HttpServletResponse response) {
469 return deleteLine(form, result, request, response);
470 }
471
472 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=editCourse")
473 public ModelAndView editCourse(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
474 HttpServletRequest request, HttpServletResponse response) throws Exception {
475
476 form.getEditingIssues().clear();
477 RegistrationCourse regCourse = getSelectedRegistrationCourse(form);
478
479 CourseOfferingInfo courseOffering = AdminRegClientCache.getCourseOfferingByCodeAndTerm(form.getTerm().getId(), regCourse.getCode());
480 if (regCourse.getCreditOptions() == null) {
481 regCourse.setCreditOptions(getViewHelper(form).getCourseOfferingCreditOptionValues(courseOffering.getCreditOptionId()));
482 if (regCourse.getCreditOptions().size() == 1) {
483 regCourse.setCreditType(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED);
484 } else {
485 regCourse.setCreditType(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE);
486 }
487 }
488
489 if (regCourse.getGradingOptions() == null) {
490 regCourse.setGradingOptions(getViewHelper(form).getGradingOptionsForCourseOffering(courseOffering));
491 }
492
493
494 RegistrationCourse editingCourse = (RegistrationCourse) (SerializationUtils.clone(regCourse));
495 editingCourse.setOriginCourse(regCourse);
496 form.getCoursesInEdit().clear();
497 form.getCoursesInEdit().add(editingCourse);
498
499 form.setClientState(AdminRegConstants.ClientStates.READY);
500 return showDialog(AdminRegConstants.COURSE_EDIT_DIALOG, form, request, response);
501 }
502
503 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=saveEdit")
504 public ModelAndView saveEdit(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
505 HttpServletRequest request, HttpServletResponse response) throws Exception {
506
507
508 form.getEditingIssues().clear();
509 getViewHelper(form).validateCourseEdit(form);
510 if (!form.getEditingIssues().isEmpty()) {
511 return showDialog(AdminRegConstants.COURSE_EDIT_DIALOG, form, request, response);
512 }
513
514
515
516 form.setRegRequestId(getViewHelper(form).submitCourses(form.getPerson().getId(), form.getTerm().getId(),
517 form.getCoursesInEdit(), LprServiceConstants.REQ_ITEM_UPDATE_TYPE_KEY));
518
519 form.setClientState(AdminRegConstants.ClientStates.REGISTERING);
520
521 form.getDialogManager().resetDialogStatus(AdminRegConstants.COURSE_EDIT_DIALOG);
522 return refresh(form, result, request, response);
523 }
524
525 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=cancelEdit")
526 public ModelAndView cancelEdit(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
527 HttpServletRequest request, HttpServletResponse response) throws Exception {
528
529 form.getCoursesInEdit().clear();
530 form.getEditingIssues().clear();
531 form.setClientState(AdminRegConstants.ClientStates.READY);
532
533 form.getDialogManager().resetDialogStatus(AdminRegConstants.COURSE_EDIT_DIALOG);
534 return refresh(form, result, request, response);
535 }
536
537 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=allowCourse")
538 public ModelAndView allowCourse(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
539 HttpServletRequest request, HttpServletResponse response) {
540
541 RegistrationResult regResult = (RegistrationResult) getSelectedCollectionObject(form);
542
543
544 form.setRegRequestId(getViewHelper(form).resubmitCourse(form.getPerson().getId(), form.getTerm().getId(),
545 regResult.getCourse(), regResult.getOriginRequestTypeKey()));
546
547
548 form.setClientState(AdminRegConstants.ClientStates.REGISTERING);
549 return getUIFModelAndView(form);
550 }
551
552
553 @RequestMapping(method = RequestMethod.POST, params = "methodToCall=denyCourse")
554 public ModelAndView denyCourse(@ModelAttribute("KualiForm") AdminRegistrationForm form, BindingResult result,
555 HttpServletRequest request, HttpServletResponse response) {
556
557 return deleteLine(form, result, request, response);
558 }
559
560
561
562
563
564 protected AdminRegistrationViewHelperService getViewHelper(UifFormBase form) {
565 return (AdminRegistrationViewHelperService) KSControllerHelper.getViewHelperService(form);
566 }
567
568 private RegistrationCourse getSelectedRegistrationCourse(AdminRegistrationForm form) {
569 return (RegistrationCourse) this.getSelectedCollectionObject(form);
570 }
571
572 private Object getSelectedCollectionObject(AdminRegistrationForm form) {
573
574 String selectedCollectionPath = form.getActionParamaterValue(UifParameters.SELECTED_COLLECTION_PATH);
575 if (StringUtils.isBlank(selectedCollectionPath)) {
576 throw new RuntimeException("Selected collection path was not set for collection action");
577 }
578
579 String selectedLine = form.getActionParamaterValue(UifParameters.SELECTED_LINE_INDEX);
580 int selectedLineIndex = -1;
581 if (StringUtils.isNotBlank(selectedLine)) {
582 selectedLineIndex = Integer.parseInt(selectedLine);
583 }
584
585
586 Collection<Object> collection = ObjectPropertyUtils.getPropertyValue(form, selectedCollectionPath);
587 Object item = ((List) collection).get(selectedLineIndex);
588
589 return item;
590
591 }
592
593 private void printTime(String methodName, long startTime){
594 LOG.info("*** " + methodName + ": " + (System.currentTimeMillis() - startTime));
595 }
596
597 }