1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.class2.appointment.keyvalue;
18
19 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20 import org.kuali.rice.core.api.util.ConcreteKeyValue;
21 import org.kuali.rice.core.api.util.KeyValue;
22 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
23 import org.kuali.rice.krad.uif.view.ViewModel;
24 import org.kuali.student.r2.common.util.ContextUtils;
25 import org.kuali.student.r2.core.enumerationmanagement.dto.EnumeratedValueInfo;
26 import org.kuali.student.r2.core.enumerationmanagement.dto.EnumerationInfo;
27 import org.kuali.student.r2.core.enumerationmanagement.service.EnumerationManagementService;
28
29 import org.kuali.student.mock.utilities.TestHelper;
30 import org.kuali.student.r2.common.constants.CommonServiceConstants;
31 import org.kuali.student.r2.common.dto.ContextInfo;
32
33 import javax.xml.namespace.QName;
34 import java.io.Serializable;
35 import java.util.ArrayList;
36 import java.util.List;
37
38
39
40
41
42
43 public class SlotRuleForAppWindowKeyValuesFinder extends UifKeyValuesFinderBase implements Serializable {
44 private static final long serialVersionUID = 1L;
45 private transient EnumerationManagementService enumerationService;
46
47 private String enumerationKey;
48
49 private ContextInfo contextInfo;
50
51
52
53 @Override
54 public List<KeyValue> getKeyValues(ViewModel model) {
55
56 List<KeyValue> keyValues = new ArrayList<KeyValue>();
57
58 try {
59 List<EnumeratedValueInfo> slotRuleTypeCodes = getEnumerationService().getEnumeratedValues(getEnumerationKey(),null,null,null, this.getContextInfo());
60 if(slotRuleTypeCodes!=null) {
61 for (EnumeratedValueInfo slotRuleTypeCode : slotRuleTypeCodes) {
62 ConcreteKeyValue keyValue = new ConcreteKeyValue();
63 keyValue.setKey(slotRuleTypeCode.getValue());
64 keyValue.setValue(slotRuleTypeCode.getAbbrevValue());
65 keyValues.add(keyValue);
66 }
67 }
68 } catch (Exception e) {
69 throw new RuntimeException(e);
70 }
71
72 return keyValues;
73 }
74
75 public String getEnumerationKey() {
76 return enumerationKey;
77 }
78
79 public void setEnumerationKey(String enumerationKey){
80 this.enumerationKey = enumerationKey;
81 }
82
83
84 public EnumerationManagementService getEnumerationService() {
85 if(enumerationService == null) {
86 enumerationService = GlobalResourceLoader.getService(new QName(CommonServiceConstants.REF_OBJECT_URI_GLOBAL_PREFIX+"enumerationmanagement", "EnumerationManagementService"));
87 }
88 return this.enumerationService;
89 }
90
91 public ContextInfo getContextInfo() {
92 if (contextInfo == null){
93 contextInfo = org.kuali.student.enrollment.common.util.ContextBuilder.loadContextInfo();
94 }
95 return contextInfo;
96 }
97 }