📄 reportscheduleaction.java
字号:
/*
* Copyright (C) 2002 Erik Swenson - eswenson@opensourcesoft.net
*
* This program is free software; you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
* the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program; if
* not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
*/
package org.efs.openreports.actions;
import java.util.Date;
import java.util.Map;
import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;
import org.apache.log4j.Logger;
import org.efs.openreports.ORStatics;
import org.efs.openreports.objects.Report;
import org.efs.openreports.objects.ReportSchedule;
import org.efs.openreports.objects.ReportUser;
import org.efs.openreports.providers.*;
import org.efs.openreports.util.LocalStrings;
public class ReportScheduleAction
extends ActionSupport
implements SchedulerProviderAware, DateProviderAware
{
protected static Logger log = Logger.getLogger(ReportScheduleAction.class);
private boolean submitSchedule;
private Report report;
private int scheduleType;
private String startDate;
private String startHour;
private String startMinute;
private String startAmPm;
private String recipients;
private SchedulerProvider schedulerProvider;
private DateProvider dateProvider;
public String execute()
{
ReportUser user =
(ReportUser) ActionContext.getContext().getSession().get(ORStatics.REPORT_USER);
report = (Report) ActionContext.getContext().getSession().get(ORStatics.REPORT);
if (user.getEmail() == null || user.getEmail().length() < 1)
{
addActionError(LocalStrings.getString(LocalStrings.ERROR_EMAILADDRESS_REQUIRED));
return INPUT;
}
if (recipients == null || recipients.length() < 1)
{
recipients = user.getEmail();
}
if (submitSchedule)
{
if (startDate == null
|| startDate.length() < 1
|| startHour == null
|| startHour.length() < 1
|| startMinute == null
|| startMinute.length() < 1
|| startAmPm == null
|| startAmPm.length() < 1)
{
addActionError(LocalStrings.getString(LocalStrings.ERROR_DATEANDTIME_REQUIRED));
return INPUT;
}
try
{
Map reportParameters =
(Map) ActionContext.getContext().getSession().get(ORStatics.REPORT_PARAMETERS);
int exportType =
Integer.parseInt(
(String) ActionContext.getContext().getSession().get(ORStatics.EXPORT_TYPE));
ReportSchedule reportSchedule = new ReportSchedule();
reportSchedule.setReport(report);
reportSchedule.setUser(user);
reportSchedule.setReportParameters(reportParameters);
reportSchedule.setScheduleType(scheduleType);
reportSchedule.setStartDate(dateProvider.parseDate(startDate));
reportSchedule.setStartHour(startHour);
reportSchedule.setStartMinute(startMinute);
reportSchedule.setStartAmPm(startAmPm);
reportSchedule.setRecipients(recipients);
reportSchedule.setExportType(exportType);
reportSchedule.setScheduleName(report.getId() + "|" + new Date().getTime());
schedulerProvider.scheduleReport(reportSchedule);
}
catch (Exception e)
{
addActionError(e.getMessage());
return INPUT;
}
addActionError(LocalStrings.getString(LocalStrings.MESSAGE_SCHEDULE_SUCCESSFUL));
}
return INPUT;
}
public Report getReport()
{
return report;
}
public void setReport(Report report)
{
this.report = report;
}
public void setSchedulerProvider(SchedulerProvider schedulerProvider)
{
this.schedulerProvider = schedulerProvider;
}
public void setSubmitSchedule(String submitSchedule)
{
if (submitSchedule != null) this.submitSchedule = true;
}
public int getScheduleType()
{
return scheduleType;
}
public void setScheduleType(int scheduleType)
{
this.scheduleType = scheduleType;
}
public String getStartAmPm()
{
return startAmPm;
}
public void setStartAmPm(String startAmPm)
{
this.startAmPm = startAmPm;
}
public String getStartDate()
{
return startDate;
}
public void setStartDate(String startDate)
{
this.startDate = startDate;
}
public String getStartHour()
{
return startHour;
}
public void setStartHour(String startHour)
{
this.startHour = startHour;
}
public String getStartMinute()
{
return startMinute;
}
public void setStartMinute(String startMinute)
{
this.startMinute = startMinute;
}
public void setDateProvider(DateProvider dateProvider)
{
this.dateProvider = dateProvider;
}
public String getRecipients()
{
return recipients;
}
public void setRecipients(String recipients)
{
this.recipients = recipients;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -