1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.lum.lu.ui.course.keyvalues;
18
19 import java.util.ArrayList;
20 import java.util.List;
21 import java.util.Locale;
22
23 import javax.xml.namespace.QName;
24
25 import org.kuali.rice.core.api.criteria.Predicate;
26 import org.kuali.rice.core.api.criteria.PredicateFactory;
27 import org.kuali.rice.core.api.criteria.QueryByCriteria;
28 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
29 import org.kuali.rice.core.api.util.ConcreteKeyValue;
30 import org.kuali.rice.core.api.util.KeyValue;
31 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
32 import org.kuali.rice.krad.util.GlobalVariables;
33 import org.kuali.student.r2.common.dto.ContextInfo;
34 import org.kuali.student.r2.common.dto.LocaleInfo;
35 import org.kuali.student.r2.common.util.ContextUtils;
36 import org.kuali.student.r2.lum.lrc.dto.ResultScaleInfo;
37 import org.kuali.student.r2.lum.lrc.dto.ResultValuesGroupInfo;
38 import org.kuali.student.r2.lum.lrc.service.LRCService;
39 import org.kuali.student.r2.lum.util.constants.LrcServiceConstants;
40
41
42
43
44
45
46 public class AssesmentKeyValueFinder extends KeyValuesBase {
47
48 private LRCService lrcService;
49
50 @Override
51 public List<KeyValue> getKeyValues() {
52 List<KeyValue> keyValues = new ArrayList<KeyValue>();
53 QueryByCriteria.Builder qBuilder = QueryByCriteria.Builder.create();
54 Predicate typePredicate = PredicateFactory.in("type", LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_FIXED,
55 LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_RANGE,
56 LrcServiceConstants.RESULT_VALUES_GROUP_TYPE_KEY_MULTIPLE);
57 Predicate idPredicate = PredicateFactory.in("id", LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER_PLUS_MINUS_STANDARD,
58 LrcServiceConstants.RESULT_GROUP_KEY_GRADE_LETTER,
59 LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PASSFAIL,
60 LrcServiceConstants.RESULT_GROUP_KEY_GRADE_SATISFACTORY,
61 LrcServiceConstants.RESULT_GROUP_KEY_GRADE_COMPLETEDNOTATION,
62 LrcServiceConstants.RESULT_GROUP_KEY_GRADE_PERCENTAGE);
63 qBuilder.setPredicates(PredicateFactory.and(typePredicate, idPredicate));
64 try
65 {
66 List<ResultValuesGroupInfo> list = this.getLRCService().searchForResultValuesGroups(qBuilder.build(), getContextInfo());
67 if (list != null) {
68 for (ResultValuesGroupInfo info : list) {
69 keyValues.add(new ConcreteKeyValue(info.getKey(), info.getName()));
70 }
71 }
72 } catch (Exception ex) {
73 throw new RuntimeException(ex);
74 }
75 return keyValues;
76 }
77
78 private LRCService getLRCService() {
79 if (lrcService == null)
80 {
81 QName qname = new QName(LrcServiceConstants.NAMESPACE, LrcServiceConstants.SERVICE_NAME_LOCAL_PART);
82 lrcService = (LRCService) GlobalResourceLoader.getService(qname);
83 }
84 return lrcService;
85 }
86
87 private ContextInfo getContextInfo() {
88 return ContextUtils.createDefaultContextInfo();
89 }
90
91 }