1 19 20 package org.efs.openreports.actions; 21 22 import com.opensymphony.xwork.ActionContext; 23 import com.opensymphony.xwork.ActionSupport; 24 25 import org.apache.log4j.Logger; 26 import org.efs.openreports.ORStatics; 27 import org.efs.openreports.objects.Report; 28 import org.efs.openreports.objects.ReportUser; 29 import org.efs.openreports.providers.*; 30 import org.efs.openreports.util.LocalStrings; 31 32 public class ReportOptionsAction extends ActionSupport 33 implements 34 SchedulerProviderAware 35 { 36 protected static Logger log = Logger.getLogger(ReportOptionsAction.class); 37 38 private String exportType; 39 private boolean submitRun; 40 private boolean submitSchedule; 41 private Report report; 42 43 private SchedulerProvider schedulerProvider; 44 45 public String execute() 46 { 47 ReportUser user = (ReportUser) ActionContext.getContext().getSession().get( 48 ORStatics.REPORT_USER); 49 50 report = (Report) ActionContext.getContext().getSession().get(ORStatics.REPORT); 51 52 if (report == null) 53 { 54 addActionError(LocalStrings.getString(LocalStrings.ERROR_REPORT_INVALID)); 55 return ERROR; 56 } 57 58 if (!user.isValidReport(report)) 59 { 60 addActionError(LocalStrings.getString(LocalStrings.ERROR_REPORT_NOTAUTHORIZED)); 61 return ERROR; 62 } 63 64 ActionContext.getContext().getSession().put(ORStatics.REPORT, report); 65 66 if (report.isQueryReport() && !submitSchedule) 67 { 68 return ORStatics.QUERY_REPORT_ACTION; 69 } 70 71 if (report.isChartReport() && !submitSchedule) 72 { 73 return ORStatics.CHART_REPORT_ACTION; 74 } 75 76 80 if (report.isDisplayInline()) return SUCCESS; 81 82 if (submitRun || submitSchedule) 83 { 84 if (exportType == null || exportType.length() < 1) return INPUT; 85 86 ActionContext.getContext().getSession().put(ORStatics.EXPORT_TYPE, exportType); 87 88 if (submitRun)return SUCCESS; 89 if (submitSchedule) return ORStatics.SCHEDULE_REPORT_ACTION; 90 } 91 92 return INPUT; 93 } 94 95 public String getExportType() 96 { 97 return exportType; 98 } 99 100 public void setExportType(String exportType) 101 { 102 this.exportType = exportType; 103 } 104 105 public Report getReport() 106 { 107 return report; 108 } 109 110 public void setReport(Report report) 111 { 112 this.report = report; 113 } 114 115 public boolean isSchedulerAvailable() 116 { 117 if (schedulerProvider != null) return true; 118 return false; 119 } 120 121 public void setSchedulerProvider(SchedulerProvider schedulerProvider) 122 { 123 this.schedulerProvider = schedulerProvider; 124 } 125 126 public void setSubmitRun(String submitRun) 127 { 128 if (submitRun != null) this.submitRun = true; 129 } 130 131 public void setSubmitSchedule(String submitSchedule) 132 { 133 if (submitSchedule != null) this.submitSchedule = true; 134 } 135 } | Popular Tags |