1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.enrollment.class2.acal.keyvalue; |
17 | |
|
18 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
19 | |
import org.kuali.rice.core.api.util.ConcreteKeyValue; |
20 | |
import org.kuali.rice.core.api.util.KeyValue; |
21 | |
import org.kuali.rice.krad.keyvalues.KeyValuesBase; |
22 | |
import org.kuali.student.enrollment.acal.constants.AcademicCalendarServiceConstants; |
23 | |
import org.kuali.student.enrollment.acal.service.AcademicCalendarService; |
24 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
25 | |
import org.kuali.student.r2.core.type.dto.TypeInfo; |
26 | |
import org.kuali.student.mock.utilities.TestHelper; |
27 | |
|
28 | |
import javax.xml.namespace.QName; |
29 | |
import java.io.Serializable; |
30 | |
import java.util.ArrayList; |
31 | |
import java.util.List; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | 0 | public class HolidayTypeKeyValues extends KeyValuesBase implements Serializable { |
39 | |
private static final long serialVersionUID = 1L; |
40 | |
|
41 | |
private transient AcademicCalendarService acalService; |
42 | |
|
43 | |
public List<KeyValue> getKeyValues() { |
44 | 0 | List<KeyValue> keyValues = new ArrayList<KeyValue>(); |
45 | |
|
46 | |
|
47 | 0 | ConcreteKeyValue topKeyValue = new ConcreteKeyValue(); |
48 | 0 | topKeyValue.setKey(""); |
49 | 0 | topKeyValue.setValue("Select holiday type"); |
50 | 0 | keyValues.add(topKeyValue); |
51 | |
|
52 | |
|
53 | 0 | ContextInfo context = TestHelper.getContext1(); |
54 | |
|
55 | |
try { |
56 | 0 | List<TypeInfo> types = getAcalService().getHolidayTypes(context); |
57 | 0 | for (TypeInfo type : types) { |
58 | 0 | ConcreteKeyValue keyValue = new ConcreteKeyValue(); |
59 | 0 | keyValue.setKey(type.getKey()); |
60 | 0 | keyValue.setValue(type.getName()); |
61 | 0 | keyValues.add(keyValue); |
62 | 0 | } |
63 | 0 | } catch (Exception e) { |
64 | 0 | throw new RuntimeException(e); |
65 | 0 | } |
66 | |
|
67 | 0 | return keyValues; |
68 | |
} |
69 | |
|
70 | |
public AcademicCalendarService getAcalService() { |
71 | 0 | if(acalService == null) { |
72 | 0 | acalService = (AcademicCalendarService) GlobalResourceLoader.getService(new QName(AcademicCalendarServiceConstants.NAMESPACE, AcademicCalendarServiceConstants.SERVICE_NAME_LOCAL_PART)); |
73 | |
} |
74 | 0 | return this.acalService; |
75 | |
} |
76 | |
} |