1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.uif.authorization;
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.util.KRADConstants;
25 import org.kuali.rice.krad.web.form.UifFormBase;
26
27
28
29
30 public class InquiryPresentationControllerBase extends PresentationControllerBase {
31
32
33
34
35
36
37 @Override
38 public Set<String> getActionFlags(UifFormBase model) {
39 Set<String> actionFlags = super.getActionFlags(model);
40
41 if (isExportSupported((InquiryView) model.getView())) {
42 actionFlags.add(KRADConstants.KUALI_ACTION_CAN_EXPORT);
43 }
44
45 return actionFlags;
46 }
47
48
49
50
51
52
53 protected boolean isExportSupported(InquiryView view) {
54 DataObjectEntry dataObjectEntry = KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary()
55 .getDataObjectEntry(view.getDataObjectClassName().getName());
56
57 Class<? extends Exporter> exporterClass = dataObjectEntry.getExporterClass();
58 if (exporterClass != null) {
59 try {
60 Exporter exporter = exporterClass.newInstance();
61 if (exporter.getSupportedFormats(dataObjectEntry.getDataObjectClass())
62 .contains(KRADConstants.XML_FORMAT)) {
63 return true;
64 }
65 } catch (Exception e) {
66 throw new RuntimeException("Failed to locate or create exporter class: " + exporterClass);
67 }
68 }
69
70 return false;
71 }
72 }