KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > efs > openreports > actions > schedule > DeleteScheduledReportAction


1 /*
2  * Copyright (C) 2003 Erik Swenson - eswenson@opensourcesoft.net
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the Free
6  * Software Foundation; either version 2 of the License, or (at your option)
7  * any later 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
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more 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.schedule;
21
22 import com.opensymphony.xwork.ActionContext;
23 import com.opensymphony.xwork.ActionSupport;
24
25 import org.efs.openreports.ORStatics;
26 import org.efs.openreports.objects.ReportSchedule;
27 import org.efs.openreports.objects.ReportUser;
28 import org.efs.openreports.providers.*;
29
30 public class DeleteScheduledReportAction
31     extends ActionSupport
32     implements SchedulerProviderAware, DateProviderAware, UserProviderAware
33 {
34     private SchedulerProvider schedulerProvider;
35     private DateProvider dateProvider;
36     private UserProvider userProvider;
37
38     protected boolean submitDelete;
39     protected boolean submitCancel;
40     
41     private String JavaDoc scheduleName;
42     private int userId = Integer.MIN_VALUE;
43     
44     private String JavaDoc name;
45     private String JavaDoc description;
46     private String JavaDoc startDate;
47     private String JavaDoc scheduleTypeName;
48
49     public String JavaDoc execute()
50     {
51         try
52         {
53             ReportUser reportUser = null;
54             
55             if (userId >= 0)
56             {
57                 reportUser = userProvider.getUser(new Integer JavaDoc(userId));
58             }
59             else
60             {
61                 reportUser = (ReportUser) ActionContext.getContext().getSession().get(
62                     ORStatics.REPORT_USER);
63             }
64
65             ReportSchedule reportSchedule =
66                 schedulerProvider.getScheduledReport(reportUser, scheduleName);
67
68             name = reportSchedule.getReport().getName();
69             description = reportSchedule.getScheduleDescription();
70             startDate = dateProvider.formatDate(reportSchedule.getStartDate());
71             scheduleTypeName = reportSchedule.getScheduleTypeName();
72
73             if (!submitDelete && !submitCancel)
74             {
75                 return INPUT;
76             }
77
78             if (submitDelete)
79             {
80                 schedulerProvider.deleteScheduledReport(
81                     reportUser,
82                     scheduleName);
83             }
84         }
85         catch (Exception JavaDoc e)
86         {
87             addActionError(e.getMessage());
88             return INPUT;
89         }
90
91         return SUCCESS;
92     }
93
94     public void setSchedulerProvider(SchedulerProvider schedulerProvider)
95     {
96         this.schedulerProvider = schedulerProvider;
97     }
98     
99     public void setSubmitDelete(String JavaDoc submitDelete)
100     {
101         if (submitDelete != null) this.submitDelete = true;
102     }
103     
104     public void setSubmitCancel(String JavaDoc submitCancel)
105     {
106         if (submitCancel != null) this.submitCancel = true;
107     }
108
109     public String JavaDoc getScheduleName()
110     {
111         return scheduleName;
112     }
113
114     public void setScheduleName(String JavaDoc scheduleName)
115     {
116         this.scheduleName = scheduleName;
117     }
118
119     public String JavaDoc getName()
120     {
121         return name;
122     }
123
124     public void setName(String JavaDoc name)
125     {
126         this.name = name;
127     }
128
129     public String JavaDoc getScheduleTypeName()
130     {
131         return scheduleTypeName;
132     }
133
134     public void setScheduleTypeName(String JavaDoc scheduleTypeName)
135     {
136         this.scheduleTypeName = scheduleTypeName;
137     }
138
139     public String JavaDoc getStartDate()
140     {
141         return startDate;
142     }
143
144     public void setStartDate(String JavaDoc startDate)
145     {
146         this.startDate = startDate;
147     }
148
149     public void setDateProvider(DateProvider dateProvider)
150     {
151         this.dateProvider = dateProvider;
152     }
153     
154     public int getUserId()
155     {
156         return userId;
157     }
158
159     public void setUserId(int userId)
160     {
161         this.userId = userId;
162     }
163
164     public void setUserProvider(UserProvider userProvider)
165     {
166         this.userProvider = userProvider;
167     }
168
169     public String JavaDoc getDescription()
170     {
171         return description;
172     }
173
174     public void setDescription(String JavaDoc description)
175     {
176         this.description = description;
177     }
178
179 }
Popular Tags