1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.enrollment.class2.courseoffering.keyvalue;
17
18 import org.kuali.rice.core.api.util.KeyValue;
19 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
20 import org.kuali.rice.krad.uif.view.ViewModel;
21 import org.kuali.rice.krad.web.form.InquiryForm;
22 import org.kuali.rice.krad.web.form.MaintenanceForm;
23 import org.kuali.student.enrollment.class2.courseoffering.dto.CourseOfferingCreateWrapper;
24 import org.kuali.student.enrollment.class2.courseoffering.dto.CourseOfferingEditWrapper;
25 import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingResourceLoader;
26 import org.kuali.student.enrollment.class2.courseoffering.util.ViewHelperUtil;
27 import org.kuali.student.r2.common.util.ContextUtils;
28 import org.kuali.student.r2.core.class1.type.service.TypeService;
29 import org.kuali.student.r2.lum.course.dto.CourseInfo;
30
31 import java.io.Serializable;
32 import java.util.ArrayList;
33 import java.util.Collections;
34 import java.util.List;
35
36
37
38
39
40
41 public class FinalExamDriverKeyValues extends UifKeyValuesFinderBase implements Serializable {
42
43 private static TypeService typeService;
44
45 @Override
46 public List<KeyValue> getKeyValues(ViewModel model) {
47 Object dataObject = null;
48 if (model instanceof MaintenanceForm) {
49 MaintenanceForm form = (MaintenanceForm)model;
50 dataObject = form.getDocument().getNewMaintainableObject().getDataObject();
51 } else if (model instanceof InquiryForm) {
52 InquiryForm form = (InquiryForm)model;
53 dataObject = form.getDataObject();
54 }
55
56 CourseInfo course;
57
58 if(dataObject instanceof CourseOfferingCreateWrapper) {
59 CourseOfferingCreateWrapper cWrapper = (CourseOfferingCreateWrapper) dataObject;
60 course = cWrapper.getCourse();
61 }
62 else if (dataObject instanceof CourseOfferingEditWrapper) {
63 CourseOfferingEditWrapper cWrapper = (CourseOfferingEditWrapper) dataObject;
64 course = cWrapper.getCourse();
65 }
66 else {
67 return Collections.emptyList();
68 }
69
70 List<KeyValue> results = new ArrayList<KeyValue>();
71
72 results.addAll(ViewHelperUtil.collectActivityTypeKeyValues(course, getTypeService(), ContextUtils.createDefaultContextInfo()));
73
74 return results;
75 }
76
77 private static TypeService getTypeService() {
78 if(typeService == null) {
79 typeService = CourseOfferingResourceLoader.loadTypeService();
80 }
81
82 return typeService;
83 }
84
85 }