KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > efs > openreports > actions > ReportOptionsAction


1 /*
2  * Copyright (C) 2002 Erik Swenson - erik@oreports.com
3  *
4  * This program is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16  * Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */

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 JavaDoc exportType;
39     private boolean submitRun;
40     private boolean submitSchedule;
41     private Report report;
42     
43     private SchedulerProvider schedulerProvider;
44
45     public String JavaDoc 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         /*
77          * if report is displayed inline, export type already selected and
78          * scheduling not currently supported, so just run report...
79          */

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 JavaDoc getExportType()
96     {
97         return exportType;
98     }
99
100     public void setExportType(String JavaDoc 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 JavaDoc submitRun)
127     {
128         if (submitRun != null) this.submitRun = true;
129     }
130
131     public void setSubmitSchedule(String JavaDoc submitSchedule)
132     {
133         if (submitSchedule != null) this.submitSchedule = true;
134     }
135 }
Free Books   Free Magazines  
Popular Tags