1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.inquiry;
17
18 import java.util.Set;
19
20 import org.kuali.rice.krad.bo.Exporter;
21 import org.kuali.rice.krad.datadictionary.DataObjectEntry;
22 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
23 import org.kuali.rice.krad.uif.view.InquiryView;
24 import org.kuali.rice.krad.uif.view.View;
25 import org.kuali.rice.krad.uif.view.ViewPresentationControllerBase;
26 import org.kuali.rice.krad.util.KRADConstants;
27 import org.kuali.rice.krad.web.form.UifFormBase;
28
29
30
31
32
33
34
35
36
37
38
39 public class InquiryViewPresentationControllerBase extends ViewPresentationControllerBase {
40 private static final long serialVersionUID = 7504225899471226403L;
41
42
43
44
45
46 @Override
47 public Set<String> getActionFlags(View view, UifFormBase model) {
48 Set<String> actionFlags = super.getActionFlags(view, model);
49
50 if (isExportSupported((InquiryView) model.getView())) {
51 actionFlags.add(KRADConstants.KUALI_ACTION_CAN_EXPORT);
52 }
53
54 return actionFlags;
55 }
56
57
58
59
60
61
62 protected boolean isExportSupported(InquiryView view) {
63 DataObjectEntry dataObjectEntry =
64 KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDataObjectEntry(
65 view.getDataObjectClassName().getName());
66
67 Class<? extends Exporter> exporterClass = dataObjectEntry.getExporterClass();
68 if (exporterClass != null) {
69 try {
70 Exporter exporter = exporterClass.newInstance();
71 if (exporter.getSupportedFormats(dataObjectEntry.getDataObjectClass()).contains(
72 KRADConstants.XML_FORMAT)) {
73 return true;
74 }
75 } catch (Exception e) {
76 throw new RuntimeException("Failed to locate or create exporter class: " + exporterClass);
77 }
78 }
79
80 return false;
81 }
82 }