7.7. Scheduler

7.7.1. Introduction

ERES has a scheduler interface through which charts and reports can be archived/exported at a specific times or at specific intervals. This allows ERES to handle mundane tasks such as exporting and archiving charts and reports rather than having a user log in at a specific time and explicitly perform the operation. For more information on how to use Scheduler, please see Section 2.2 - Scheduling & Archiving.

Both ERESOrganizer.jar (in the <ERES>/lib directory) and ERESServer.jar (in the <ERES>/WEB-INF/lib directory) need to be added to the CLASSPATH for any code using the Scheduler. The following snippet shows how to connect to Scheduler:

QbOrganizer.setServletRunner("http://localhost:8080");
QbOrganizer.setServletContext("ERES/servlet");
QbOrganizer organizer = new QbOrganizer(null, "admin", "admin");
      

The above code sets the connection information to connect to ERES Server and provides the username and password (in the above example, admin and admin) for Scheduler.

All examples and code given in the manual assume that ERES server is running locally (i.e. on your local machine) and on port 8080. You can change this by going to the source code (you can download the source code by clicking on the Full Source Code link in the corresponding chapter), editing the code to enter the new connection information and recompiling the code.

7.7.2. Scheduling an Export

You can schedule a chart/report to be exported using Scheduler. The following code, given below, shows how to do this:

QbOrganizer.setServletContext(ServletContext);
QbOrganizer.setServletRunner(ServletRunner);
QbOrganizer organizer = new QbOrganizer(null, "admin", "admin");

QbSchedulePackage sPack = new QbSchedulePackage("Report_OneTime", organizer);
sPack.setReportExportType(IExportConstants.DHTML);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 1);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setSendEmail(false);

QbScheduleObject sObj = new QbScheduleObject("report1",
		QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
sObj.setFileLocation("Account.rpt");
String exportLocation = sObj.pickDefaultExportLocation();

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

[Note]Note

Any references to a data source or a report file using the relative URL reference (e.g. help/examples/ReportGallery/templates/Account.rpt) are relative to the directory from where ERES is running in.

The above code schedules a report (Account.rpt) to be exported to DHTML, in the default export directory and sets the export to take place once and in one minute.

You can specify a chart file by changing the QbScheduleObject.TEMPLATE_TYPE_REPORT constant in the QbSchedulerObject constructor to QbScheduleObject.TEMPLATE_TYPE_REPORT. Please note that you will also need to specify a .cht or .tpl file as well as a valid export type (PNG, JPEG, GIF, etc) using the setChartExportType(int exportType) method. The following code shows how to modify the above code to schedule a chart:

QbSchedulePackage sPack = new QbSchedulePackage("Chart_OneTime", organizer);
sPack.setChartExportType(IExportConstants.GIF);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 1);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setSendEmail(false);

QbScheduleObject sObj = new QbScheduleObject("chart1",
		QbScheduleObject.TEMPLATE_TYPE_CHART, sPack);
sObj.setFileLocation("col2d.tpl");
String exportLocation = sObj.pickDefaultExportLocation();

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

Both examples, given above, show how to schedule a chart or a report for a one-time export. The examples below show how to set up a periodic schedule:

QbSchedulePackage sPack = new QbSchedulePackage("Report_Periodically", organizer);
sPack.setReportExportType(IExportConstants.DHTML);
sPack.setTaskOption(QbSchedulePackage.TIME_INTERVAL);

/*** every 5 mins ****/
sPack.setIntervalType(QbSchedulePackage.TIME);
sPack.setTimeInterval(5); // export every 5 mins

/*** every day ****/
//sPack.setIntervalType(QbSchedulePackage.DAYS);
//sPack.setDayInterval(1); // export everyday

Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 5);
sPack.setStartDate(calendar.getTimeInMillis());
Calendar calendar2 = Calendar.getInstance();
calendar2.add(Calendar.MINUTE, 26);
sPack.setEndDate(calendar2.getTimeInMillis());
sPack.setSendEmail(false);

QbScheduleObject sObj = new QbScheduleObject("report1",
		QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
sObj.setFileLocation("Account.rpt");
String exportLocation = sObj.pickDefaultExportLocation();

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

The above code snippet shows how to schedule a job to run every five minutes (or everyday depending on which section of the code you comment).

The following code snippet shows to schedule a job to run at certain time periods:

QbSchedulePackage sPack = new QbSchedulePackage("Report_Time", organizer);
sPack.setReportExportType(IExportConstants.PDF);
sPack.setTaskOption(QbSchedulePackage.FIXED_DAYS);

/*** export every 2 hrs. Monday through Friday ****/
sPack.setSpecifyDays(new int[] { 1, 2, 3, 4, 5 });
sPack.setStartTime(9 * 60); // 9:00AM in minutes
sPack.setEndTime(22 * 60); // 10:00PM in minutes
sPack.setTimeInterval(2 * 60); // export every 2 hours

/*** export at specific times on specific dates ***/
//sPack.setSpecifyDates(new int[]{26,27,28,29}); // export on specific dates
//sPack.setSpecifyTime(new int[]{16 * 60, 17 * 60, 18 * 60}); // 4PM, 5PM and 6PM in minute

Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 5);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setEndDate(-1); // run indefinitely
sPack.setSendEmail(false);

QbScheduleObject sObj = new QbScheduleObject("report1",
		QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
sObj.setFileLocation("Account.rpt");
String exportLocation = sObj.pickDefaultExportLocation();

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

You can also specify the parameters when scheduling a parameterized chart or report to be exported. The following code shows how:

QbSchedulePackage sPack = new QbSchedulePackage("ParamReport_OneTime", organizer);
sPack.setReportExportType(IExportConstants.DHTML);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 5);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setSendEmail(false);

QbScheduleObject sObj = new QbScheduleObject("report1",
		QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
//Single Param Report
sObj.setFileLocation("EmployeeDetails.pak");
String exportLocation = sObj.pickDefaultExportLocation();
//1st param set {"Denise Carron"}
Object tmp1[] = { "Denise Carron" };
//2nd param set {"Frank Carnody"}
Object tmp2[] = { "Frank Carnody" };
Vector paramList = new Vector();
paramList.addElement(tmp1);
paramList.addElement(tmp2);
sObj.setParamList(paramList);

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

You can also specify the schedules to be sent to one or more email addresses, either as a link or an attachment. The following code shows how to send a scheduled job which contains a non-parameterized report to multiple recipients:

QbSchedulePackage sPack = new QbSchedulePackage("Report_Email", organizer);
sPack.setReportExportType(IExportConstants.DHTML);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 10);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setSendEmail(true);
sPack.setFromAddress("user1@quadbase.com");
sPack.setSubject("Report Email Account Report");
sPack.setBodyText("Scheduled Export of Account from user1");
sPack.setEmailType(QbSchedulePackage.ASATTACHMENT);

QbScheduleObject sObj = new QbScheduleObject("report1", QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
sObj.setFileLocation("help/examples/ReportGallery/templates/Account.rpt");
String exportLocation = sObj.pickDefaultExportLocation();
sObj.setToAddresses(new String[]{"user2@quadbase.com", "user3@quadbase.com"});

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

Similarly, emails can be sent for each parameter set chosen for a parameterized report/chart when scheduling an export. Note that at least one email address must be specified for each parameter set and the same recipient can be used for multiple parameter sets.

QbSchedulePackage sPack = new QbSchedulePackage("ParamReport_Email", organizer);
sPack.setReportExportType(IExportConstants.DHTML);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);

Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 5);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setSendEmail(true);
sPack.setFromAddress("user1@quadbase.com");
sPack.setSubject("Param Report Email Account Report");
sPack.setBodyText("Scheduled Export of Employee Details from user1");
sPack.setEmailType(QbSchedulePackage.ASATTACHMENT);

QbScheduleObject sObj = new QbScheduleObject("report1",
		QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
//Single Param Report
sObj.setFileLocation("EmployeeDetails.pak");
String exportLocation = sObj.pickDefaultExportLocation();
//1st param set {"Denise Carron"}
Object tmp1[] = { "Denise Carron" };
//2nd param set {"Frank Carnody"}
Object tmp2[] = { "Frank Carnody" };
Vector paramList = new Vector();
paramList.addElement(tmp1);
paramList.addElement(tmp2);
sObj.setParamList(paramList);
Vector paramNameList = new Vector();
paramNameList.addElement("Denise");
paramNameList.addElement("Frank");
sObj.setParamList(paramNameList, paramList);

Hashtable toAddr = new Hashtable();
toAddr.put("Denise", new String[] { "user2@quadbase.com" });
toAddr.put("Frank", new String[] { "user3@quadbase.com" });
sObj.setParamAddresses(toAddr);

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

You can also set up the schedule to send the export to a FTP location by providing the details. The following code shows how:

QbSchedulePackage sPack = new QbSchedulePackage("FTPReport_OneTime", organizer);
sPack.setReportExportType(IExportConstants.DHTML);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 1);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setFtpDelivery(true);
sPack.setFtpHost("someMachine.com");
sPack.setFtpFilePath("somePath");
sPack.setFtpUserName("user1");
sPack.setFtpPassword("password1");

QbScheduleObject sObj = new QbScheduleObject("report1",
		QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
sObj.setFileLocation("Account.rpt");
String exportLocation = sObj.pickDefaultExportLocation();

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

You can also request the schedule to send the export to a printer. The following code shows how:

QbSchedulePackage sPack = new QbSchedulePackage("PrintReport_OneTime", organizer);
sPack.setReportExportType(IExportConstants.DHTML);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 10);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setPrinterDelivery(true);
sPack.setSelectedPrinter("somePrinter");
sPack.setPrintFromPage(0);
sPack.setPrintToPage(-1);

QbScheduleObject sObj = new QbScheduleObject("report1",
	QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
sObj.setFileLocation("Account.rpt");
String exportLocation = sObj.pickDefaultExportLocation();

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

7.7.3. Scheduling Multiple Exports

Every schedule job can contain any combination of reports and/or charts. The following code, shows how to schedule a report and a chart in a single schedule:

QbSchedulePackage sPack = new QbSchedulePackage("Package_OneTime", organizer);
sPack.setReportExportType(IExportConstants.PDF);
sPack.setChartExportType(IExportConstants.PNG);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 1);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setSendEmail(false);

QbScheduleObject rptObj = new QbScheduleObject("new project/Account",
	QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
rptObj.setFileLocation("Account.rpt");
String exportLocation1 = rptObj.pickDefaultExportLocation();

QbScheduleObject chtObj = new QbScheduleObject("new project/col2d",
	QbScheduleObject.TEMPLATE_TYPE_CHART, sPack);
chtObj.setFileLocation("col2d.tpl");
String exportLocation2 = chtObj.pickDefaultExportLocation();

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

[Note]Note

Any references to a data source or a report file, using the relative URL reference (e.g. help/examples/ReportGallery/templates/Account.rpt) are relative to the directory from where ERES is running in.

The above code schedules a package containing a report (Account.rpt) and a chart (col2d.tpl) to be exported to PDF (report) and PNG (chart), in the default export directory and sets the export to take place once and in one minute.

Each report and chart in a schedule can have different email recipients. If the report/chart is parameterized, each parameter set can have different email recipients. The following code shows how to set email recipients for both a non-parameterized report and a parameterized report in a single schedule:

QbSchedulePackage sPack = new QbSchedulePackage("ParamPackage_Email", organizer);
sPack.setReportExportType(IExportConstants.PDF);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 10);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setSendEmail(true);
sPack.setFromAddress("user1@quadbase.com");
sPack.setSubject("Schedule Param Package Email");
sPack.setBodyText("Schedule Package export containing a report and a parameterized report\n"
	+
	"<SAVED_LINKS></SAVED_LINKS>");
sPack.setEmailType(QbSchedulePackage.NONE);

QbScheduleObject rptObj1 = new QbScheduleObject("new project/Account",
	QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
rptObj1.setFileLocation("Account.rpt");
String exportLocation1 = rptObj1.pickDefaultExportLocation();
rptObj1.setToAddresses(new String[] { "user2@quadbase.com" });

QbScheduleObject rptObj2 = new QbScheduleObject("new project/EmployeeDetails",
	QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
rptObj2.setFileLocation("EmployeeDetails.pak");
String exportLocation2 = rptObj2.pickDefaultExportLocation();
//1st param set {"Denise Carron"}
Object tmp1[] = { "Denise Carron" };
//2nd param set {"Frank Carnody"}
Object tmp2[] = { "Frank Carnody" };
Vector paramList = new Vector();
paramList.addElement(tmp1);
paramList.addElement(tmp2);

Vector paramNameList = new Vector();
paramNameList.addElement("Denise");
paramNameList.addElement("Frank");
rptObj2.setParamList(paramNameList, paramList);

Hashtable toAddr = new Hashtable();
toAddr.put("Denise", new String[] { "user2@quadbase.com" });
toAddr.put("Frank", new String[] { "user3@quadbase.com" });
rptObj2.setParamAddresses(toAddr);

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

The code above also shows how to use a runtime variable (<SAVED_LINKS>) in the email body. For more information about runtime variables see Section 2.2.1.2.1 - Email Delivery Options.

7.7.4. Scheduling an Archive

Along with scheduling exports, you can also schedule archiving of reports and charts. The following code shows how to do that:

QbSchedulePackage sPack = new QbSchedulePackage("ArchiveReport_OneTime", organizer);
sPack.setArchive(true);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 5);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setSendEmail(false);

QbScheduleObject sObj = new QbScheduleObject("report1",
	QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
sObj.setFileLocation("Account.rpt");
String exportLocation = sObj.pickDefaultExportLocation();

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

An archive job can also contain any combination of reports and/or charts. The following code shows how to schedule archiving of a report and a chart:

QbSchedulePackage sPack = new QbSchedulePackage("ArchivePackage_OneTime", organizer);
sPack.setArchive(true);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 1);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setSendEmail(false);

QbScheduleObject rptObj = new QbScheduleObject("new project/Account",
	QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
rptObj.setFileLocation("Account.rpt");
String exportLocation1 = rptObj.pickDefaultExportLocation();

QbScheduleObject chtObj = new QbScheduleObject("new project/col2d",
	QbScheduleObject.TEMPLATE_TYPE_CHART, sPack);
chtObj.setFileLocation("col2d.tpl");
String exportLocation2 = chtObj.pickDefaultExportLocation();

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

7.7.5. Removing a Schedule

In addition to adding schedules, you can also use the API to remove any schedules. This is done by getting a list of all the jobs scheduled and then deleting a particular job.

The following code shows how to delete a particular job:

Vector schedList = organizer.getScheduler().getSchedulePackageList();

QbSchedulePackage sPack = (QbSchedulePackage) schedList.elementAt(0);
organizer.getScheduler().removeSchedulePackageTask(sPack);
      

Full Source Code

Note that the above code removes the first job in the schedule list. The job may not be visible if it has been already marked for deletion. The recommended approach is to go through the vector and search each QbScheduleObject by the name and then to delete the correct one.

7.7.5.1. Getting Details of a Failed Schedule

Sometimes, a schedule job may fail for some reason or another. ERES Server keeps a track of all the failed jobs so that its details can be obtained later. The following code shows how to obtain the details:

Vector vec = organizer.getScheduler().getFailedScheduledJob();
for (int i = 0; i < vec.size(); i++) {
	FailedScheduledJob obj = (FailedScheduledJob) vec.elementAt(i);
	System.out.println("FAIL # " + i + ": Name = " +
		obj.getScheduledJobName());
	System.out.println("File Location = " + obj.getFileLocation());
	System.out.println("Time = " + obj.getExportTime());
	System.out.println("StackTrace = " + obj.getStackTrace());
}
      

Full Source Code

You can also set up an email to be sent in case the schedule fails. The following code illustrates how:

QbSchedulePackage sPack = new QbSchedulePackage("Package_FailedEmail", organizer);
sPack.setReportExportType(IExportConstants.PDF);
sPack.setChartExportType(IExportConstants.PNG);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 10);
sPack.setStartDate(calendar.getTimeInMillis());

sPack.setSendEmail(true);
sPack.setFromAddress("user1@quadbase.com");
sPack.setSubject("Schedule Package Email");
sPack.setBodyText("Schedule Package export containing a report and chart");
sPack.setFailSubject("Package_FailedEmail schedule failed");
sPack.setFailBodyText("Cannot send report and/or charts from Package_FailedEmail");
sPack.setFailToAddress("user1@quadbase.com");
sPack.setEmailType(QbSchedulePackage.ASATTACHMENT);

QbScheduleObject rptObj = new QbScheduleObject("new project/Account",
	QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
rptObj.setFileLocation("Account.rpt");
String exportLocation1 = rptObj.pickDefaultExportLocation();
rptObj.setToAddresses(new String[] { "user2@quadbase.com" });

QbScheduleObject chtObj = new QbScheduleObject("new project/col2d",
	QbScheduleObject.TEMPLATE_TYPE_CHART, sPack);
chtObj.setFileLocation("col2d.tpl");
String exportLocation2 = chtObj.pickDefaultExportLocation();
chtObj.setToAddresses(new String[] { "user3@quadbase.com" });

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

7.7.5.2. ICallBackScheduler Interface

You can also create an additional code that performs certain actions based on the Scheduler performing a job (regardless of if it was sucessful). This code implements the ICallBackScheduler interface and specifies what to do when a job has been successfully completed or not.

Please note that after creating the code you need to change QB.properties (in the <ERES-installation-directory>/WEB-INF/classes directory) and add the following argument to the ServerCommands= line:

-SchedulerCallBackClass:<name of class file implementing ICallBackScheduler>
      

The following code shows how to use the ICallBackScheduler interface:

      import quadbase.reportorganizer.organizerAPI.ICallBackScheduler;
      import quadbase.reportorganizer.organizerAPI.QbScheduleObject;

      public class CallBackScheduler implements ICallBackScheduler {

            public CallBackScheduler() {};

            public void exportSucceeded(QbScheduleObject obj, String path) {

                  System.out.println(obj.getName() + "- EXPORT SUCCEEDED");
                  System.out.println("PATH = " + path);

            }

            public void exportFailed(QbScheduleObject obj, String path, Throwable e) {

                  System.out.println(obj.getName() + "- EXPORT FAILED");
                  System.out.println("PATH = " + path);
                  System.out.println("ERROR = " + e.toString());

            }

      }
      

To use the above code, add the following to the ServerCommands= line of the QB.properties INI file:

-SchedulerCallbackClass:CallBackScheduler
      

Make sure that CallBackScheduler is in the CLASSPATH. The code will then print messages at the end of each job saying whether the job was run successfully or not.

7.7.5.3. Scheduler Listener

ERES allows scheduled reports to be modified via custom code using server extensions. These custom classes will intercept reports before they are exported and allow users to implement additional business logic to the scheduling process.

To use the Scheduler Listener, you will have to write your own custom class that implements EresSchedulerListener. Given below is an example:

      import quadbase.ChartAPI.QbChart;
      import quadbase.reportdesigner.ReportAPI.QbReport;
      import quadbase.reportorganizer.organizerAPI.*;
      import quadbase.reportorganizer.ext.*;

      public class MyEresSchedulerListener implements EresSchedulerListener {

            public QbReport modifyBeforeExport(QbReport report, QbScheduleObject so, String exportPath, String username) {

                  System.out.println("modifyBeforeExport(" + report + "," + so + "," + exportPath + "," + username + ")");
                  return report;

            }

            public QbChart modifyBeforeExport(QbChart chart, QbScheduleObject so, String exportPath, String username) {

                  System.out.println("modifyBeforeExport(" + chart + "," + so + "," + exportPath + "," + username + ")");
                  return chart;

            }

      }
      

The above example prints a simple System.out.println statement before exporting either the report or chart.

To use any custom class implementing SchedulerListener, you will have to implement another custom class implementing DefaultListenerManager. For example:

      import quadbase.reportorganizer.ext.*;

      public class MyEresListenerManager extends DefaultListenerManager {

            public MyEresListenerManager() {}

            public EresSchedulerListener getSchedulerListener() {

                  return new MyEresSchedulerListener();

            }

            public MenuPageListener getMenuPageListener() {

                  return new MyMenuPageListener();

            }

      }
      

To use the above code, add the following to the ServerCommands= line of the QB.properties INI file:

-ListenerManagerClass:MyEresListenerManager
      

Make sure that both MyEresListenerManager and MyEresSchedulerListener are in the CLASSPATH.

More information about the the MenuPageListener can be found in Section 6.4 - Menu Page Listener.

7.7.5.4. Report Bursting

You can also use the Report Bursting feature in Scheduler by using the API. For more details on report bursting, please refer to Section 2.2.1.3.1 - Report Bursting. Note that the report must use a database as the data source and must be grouped in order for the report to be bursted.

Given below is an example on how to use report bursting:

QbSchedulePackage sPack = new QbSchedulePackage("PackageBursting_All", organizer);
sPack.setReportExportType(IExportConstants.PDF);
sPack.setChartExportType(IExportConstants.PNG);
sPack.setTaskOption(QbSchedulePackage.ONE_TIME);
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MINUTE, 10);
sPack.setStartDate(calendar.getTimeInMillis());
sPack.setSendEmail(true);
sPack.setFromAddress("user1@quadbase.com");
sPack.setSubject("Test Package Bursting");
sPack.setBodyText("You should find a report of one group");
sPack.setEmailType(QbSchedulePackage.ASATTACHMENT);

QbScheduleObject rptObj = new QbScheduleObject("new project/InventoryInformation",
		QbScheduleObject.TEMPLATE_TYPE_REPORT, sPack);
rptObj.setFileLocation("help/examples/ReportGallery/templates/InventoryInformation.rpt");
String exportLocation1 = rptObj.pickDefaultExportLocation();
rptObj.setBurstReport(QbScheduleObject.ALLBURSTING);
rptObj.setEmailColumnIndex(16);

QbScheduleObject chtObj = new QbScheduleObject("new project/col2d",
	QbScheduleObject.TEMPLATE_TYPE_CHART, sPack);
chtObj.setFileLocation("help/examples/ChartGallery/data/col2d.tpl");
String exportLocation2 = chtObj.pickDefaultExportLocation();

organizer.getScheduler().addSchedulePackageTask(sPack);
      

Full Source Code

The above code bursts all groups and sends out an email using a report column as the source for the addresses. As you can see, bursting can be set individually for each scheduled report. The above example contains a report that is bursted and a chart that is not bursted (because bursting is not supported for charts).

Note that in the above code, column 16 does not exist in the template. The method is provided in the example to show how to pass in the email column for bursting.

7.7.5.5. Javadoc

Javadoc for the entire API is provided along with ERES. It is located here (Reports and charts) and here (ES functions).

7.7.5.6. Summary

ERES API provides an easy-to-use and powerful API to query the scheduler interface as well as add and remove schedules. You can also write code to perform your own action when a job has been completed successfully (or not) in Scheduler.

Please note that the API requires a JDK 1.5 or above. The ERES API has been tested on Windows, Solaris, Linux, AIX ,and HP platforms.