1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.class2.courseoffering.keyvalue;
18
19 import org.kuali.rice.core.api.util.ConcreteKeyValue;
20 import org.kuali.rice.core.api.util.KeyValue;
21 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
22 import org.kuali.rice.krad.uif.view.ViewModel;
23 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
24 import org.kuali.student.enrollment.class2.courseoffering.dto.CourseOfferingEditWrapper;
25 import org.kuali.student.enrollment.class2.courseoffering.util.CourseOfferingManagementUtil;
26 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
27 import org.kuali.student.r2.common.util.ContextUtils;
28 import org.kuali.student.r2.lum.course.dto.CourseInfo;
29 import org.kuali.student.r2.lum.lrc.dto.ResultValuesGroupInfo;
30 import org.kuali.student.r2.lum.util.constants.LrcServiceConstants;
31
32 import javax.xml.namespace.QName;
33 import java.io.Serializable;
34 import java.util.ArrayList;
35 import java.util.List;
36
37
38
39
40
41
42 public class CreditOptionsKeyValues extends UifKeyValuesFinderBase implements Serializable {
43
44 private static final long serialVersionUID = 1L;
45
46 @Override
47 public List<KeyValue> getKeyValues(ViewModel model) {
48
49 List<KeyValue> keyValues = new ArrayList<KeyValue>();
50
51 MaintenanceDocumentForm form1 = (MaintenanceDocumentForm)model;
52 CourseOfferingEditWrapper form = (CourseOfferingEditWrapper)form1.getDocument().getDocumentDataObject();
53
54 String courseId = form.getCourseOfferingInfo().getCourseId();
55 List<ResultValuesGroupInfo> creditOptions;
56
57 if (courseId != null) {
58 try {
59 CourseInfo courseInfo = CourseOfferingManagementUtil.getCourseService().getCourse(courseId, ContextUtils.getContextInfo());
60 creditOptions = courseInfo.getCreditOptions();
61 } catch (DoesNotExistException e) {
62 throw new RuntimeException("No subject areas found! There should be some in the database", e);
63 } catch (Exception e) {
64 throw new RuntimeException("Error finding subject Areas", e);
65 }
66
67 for (ResultValuesGroupInfo rVGI : creditOptions) {
68 String typeKey = rVGI.getTypeKey();
69 if(typeKey.equals(LrcServiceConstants.R1_RESULT_COMPONENT_TYPE_KEY_FIXED)||typeKey.equals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED)) {
70 keyValues.add(new ConcreteKeyValue(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED, "Fixed"));
71 } else if (typeKey.equals(LrcServiceConstants.R1_RESULT_COMPONENT_TYPE_KEY_RANGE) || typeKey.equals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_RANGE)) {
72 keyValues.add(new ConcreteKeyValue(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED, "Fixed"));
73 keyValues.add(new ConcreteKeyValue(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_RANGE, "Variable"));
74 keyValues.add(new ConcreteKeyValue(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE, "Multiple"));
75 } else if (typeKey.equals(LrcServiceConstants.R1_RESULT_COMPONENT_TYPE_KEY_MULTIPLE) || typeKey.equals(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE)) {
76 keyValues.add(new ConcreteKeyValue(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED, "Fixed"));
77 keyValues.add(new ConcreteKeyValue(LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE, "Multiple"));
78 } else {
79 keyValues.add(new ConcreteKeyValue(typeKey, "Unknown Type"));
80 }
81 }
82 }
83
84 return keyValues;
85 }
86 }