1 package org.kuali.ole.alert.keyValue;
2
3 import org.kuali.ole.alert.bo.AlertEvent;
4 import org.kuali.ole.alert.bo.AlertField;
5 import org.kuali.rice.core.api.util.ConcreteKeyValue;
6 import org.kuali.rice.core.api.util.KeyValue;
7 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
8 import org.kuali.rice.krad.uif.control.UifKeyValuesFinderBase;
9 import org.kuali.rice.krad.uif.view.ViewModel;
10 import org.kuali.rice.krad.web.form.MaintenanceDocumentForm;
11
12 import java.lang.annotation.Annotation;
13 import java.lang.reflect.Field;
14 import java.util.ArrayList;
15 import java.util.List;
16
17
18
19
20 public class AlertFieldValueFinder extends UifKeyValuesFinderBase {
21
22
23
24 public List<KeyValue> getKeyValues(ViewModel viewModel) {
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 MaintenanceDocument maintenanceDocument= ((MaintenanceDocumentForm) viewModel).getDocument();
54 AlertEvent alertEvent=(AlertEvent)maintenanceDocument.getDocumentDataObject();
55 List<KeyValue> options = new ArrayList<KeyValue>();
56 Class alertDocumentClass = null;
57 try {
58 alertDocumentClass = Class.forName(alertEvent.getAlertDocumentClassName());
59 } catch (ClassNotFoundException e) {
60 e.printStackTrace();
61 }
62 Field[] declaredFields =alertDocumentClass.getDeclaredFields();
63 for(Field field:declaredFields){
64 Annotation[] annotations=field.getDeclaredAnnotations();
65 for(Annotation annotation:annotations){
66 if(annotation instanceof AlertField){
67 String sdd=field.getType().toString().replace(".", "-");
68 String[] value = sdd.split("-");
69 String lastOne = value[value.length-1];
70 options.add(new ConcreteKeyValue(lastOne, lastOne));
71 }
72 }
73 }
74
75
76
77
78 return options;
79 }
80 }