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