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.InquiryForm;
28 import org.kuali.rice.krad.web.form.UifFormBase;
29
30
31
32
33
34
35
36
37
38
39
40 public class InquiryViewPresentationControllerBase extends ViewPresentationControllerBase {
41 private static final long serialVersionUID = 7504225899471226403L;
42
43
44
45
46
47 @Override
48 public Set<String> getActionFlags(View view, UifFormBase model) {
49 Set<String> actionFlags = super.getActionFlags(view, model);
50
51 InquiryView inquiryView = (InquiryView) view;
52 InquiryForm inquiryForm = (InquiryForm) model;
53
54 if (isExportSupported(inquiryView, inquiryForm)) {
55 actionFlags.add(KRADConstants.KUALI_ACTION_CAN_EXPORT);
56 }
57
58 return actionFlags;
59 }
60
61
62
63
64
65
66
67 protected boolean isExportSupported(InquiryView view, InquiryForm form) {
68 Object dataObject = form.getDataObject();
69
70 if (dataObject == null) {
71 return false;
72 }
73
74 DataObjectEntry dataObjectEntry =
75 KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDataObjectEntry(
76 view.getDataObjectClassName().getName());
77
78 Class<? extends Exporter> exporterClass = dataObjectEntry.getExporterClass();
79 if (exporterClass != null) {
80 try {
81 Exporter exporter = exporterClass.newInstance();
82 if (exporter.getSupportedFormats(dataObjectEntry.getDataObjectClass()).contains(
83 KRADConstants.XML_FORMAT)) {
84 return true;
85 }
86 } catch (Exception e) {
87 throw new RuntimeException("Failed to locate or create exporter class: " + exporterClass);
88 }
89 }
90
91 return false;
92 }
93 }