1 | |
package org.kuali.student.enrollment.class2.appointment.keyvalue; |
2 | |
|
3 | |
import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader; |
4 | |
import org.kuali.rice.core.api.util.ConcreteKeyValue; |
5 | |
import org.kuali.rice.core.api.util.KeyValue; |
6 | |
import org.kuali.rice.krad.keyvalues.KeyValuesBase; |
7 | |
import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase; |
8 | |
import org.kuali.rice.krad.uif.view.ViewModel; |
9 | |
import org.kuali.student.mock.utilities.TestHelper; |
10 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
11 | |
import org.kuali.student.r2.common.util.constants.TypeServiceConstants; |
12 | |
import org.kuali.student.r2.core.appointment.constants.AppointmentServiceConstants; |
13 | |
import org.kuali.student.r2.core.type.dto.TypeInfo; |
14 | |
import org.kuali.student.r2.core.type.service.TypeService; |
15 | |
|
16 | |
import javax.xml.namespace.QName; |
17 | |
import java.io.Serializable; |
18 | |
import java.util.ArrayList; |
19 | |
import java.util.List; |
20 | |
|
21 | 0 | public class RegWindowTypeKeyValues extends UifKeyValuesFinderBase implements Serializable { |
22 | |
private static final long serialVersionUID = 1L; |
23 | |
|
24 | |
private transient TypeService typeService; |
25 | |
|
26 | |
@Override |
27 | |
public List<KeyValue> getKeyValues(ViewModel model) { |
28 | 0 | List<KeyValue> keyValues = new ArrayList<KeyValue>(); |
29 | |
|
30 | |
|
31 | 0 | ContextInfo context = TestHelper.getContext1(); |
32 | |
|
33 | |
try { |
34 | 0 | List<TypeInfo> types = getTypeService().getTypesByRefObjectUri(AppointmentServiceConstants.REF_OBJECT_URI_APPOINTMENT_WINDOW, context); |
35 | 0 | for (TypeInfo type : types) { |
36 | 0 | if(type.getKey().startsWith("kuali.appointment.window.type")){ |
37 | 0 | ConcreteKeyValue keyValue = new ConcreteKeyValue(); |
38 | 0 | keyValue.setKey(type.getKey()); |
39 | 0 | keyValue.setValue(type.getName()); |
40 | 0 | keyValues.add(keyValue); |
41 | 0 | } |
42 | |
} |
43 | 0 | } catch (Exception e) { |
44 | 0 | throw new RuntimeException(e); |
45 | 0 | } |
46 | |
|
47 | 0 | return keyValues; |
48 | |
} |
49 | |
|
50 | |
public TypeService getTypeService() { |
51 | 0 | if(typeService == null) { |
52 | 0 | typeService = (TypeService) GlobalResourceLoader.getService(new QName(TypeServiceConstants.NAMESPACE, TypeServiceConstants.SERVICE_NAME_LOCAL_PART)); |
53 | |
} |
54 | 0 | return this.typeService; |
55 | |
} |
56 | |
} |