BackPrevious Page Next PageNext

Scheduling a Report Task

Scheduling a report task using time condition

Scheduling a report task using trigger

The properties for scheduling reports are available in jet.cs.util.APIConst in the JReport Server Javadoc which is located in <install_root>\help\api.

Scheduling a report task using time condition

There is an API sample of scheduling a report which is APIDemoPublishRpt.java in <install_root>\help\samples\APIServer for your reference.

The following introduces how to schedule a report task in your program using time condition:

  1. Connect to JReport Server as follows:
    RptServer server = null;
    server = HttpUtil.getHttpRptServer();
  2. Set scheduling task properties. The following example publishes the report Corporate Overview.cls in the Public Reports > SampleReports folder to PDF to disk:
    // Set task properties
    Properties props = new Properties();
    props.put(APIConst.TAG_TASK_CLASS, APIConst.TASK_TO_RPT);
    props.put(APIConst.TAG_LAUNCH_TYPE, String.valueOf(APIConst.IMMEDIATELY));
    props.put(APIConst.TAG_CATALOG, "/SampleReports/SampleReports.cat"); props.put(APIConst.TAG_REPORT, "Corporate Overview.cls");

    props.put(APIConst.TAG_TO_DISK, "true");

    // TO Disk // Set the value of PDF for TO_DISK props.put(APIConst.TAG_TO_PDF, "true");

    props.put(APIConst.TAG_PDF, "Corporate Overview.cls.pdf");

    props.put(APIConst.TAG_REPORT_LANGUAGE, "en_US"); String today = DateFormat.getDateInstance(DateFormat.LONG, new Locale("en", "US")).format(new Date());

    props.put(APIConst.TAG_PDF_DIR, "/SampleReports");

  3. Submit and trigger the task as follows:
    String taskID = server.submitScheduledTask("admin", props);
  4. Get the task result:
    CompletedTaskTable completeTable = server.getCompletedTaskTable();
  5. Shut down the server:
    server.shutdown();

Scheduling a report task using trigger

There is an API sample of scheduling a report using trigger which is DemoTrigger.java in <install_root>\help\samples\APIServer for your reference.

The following introduces how to schedule a report task using trigger in your program:

  1. Connect to JReport Server as follows:
    // get instance of RptServer
    RptServer svr = RemoteReportServerToolkit.getRemoteWrappedRptServer("127.0.0.1", "1129"); TriggerManager trigMan = svr.getTriggerManager(); String exTriggerName = "exTriggerDemo";
    if (!trigMan.contains(exTriggerName)) { trigMan.createTrigger(exTriggerName, "an external trigger demo"); }
  2. Set scheduling task properties. The following example publishes the report Invoice Report.cls in the Public Reports > SampleReports folder to PDF to the versioning system:
    Properties props = new Properties();
    props.put(APIConst.TAG_TASK_CLASS, APIConst.TASK_TO_RPT);
    props.put(APIConst.TAG_LAUNCH_TYPE, String.valueOf(APIConst.IMMEDIATELY));
    props.put(APIConst.TAG_TRIGGERS_LOGIC, "ONLY");
    props.put(APIConst.TAG_TRIGGERS_ARRAY, "exTriggerDemo");
    props.put(APIConst.TAG_CATALOG, "/SampleReports/SampleReports.cat");
    props.put(APIConst.TAG_REPORT, "/SampleReports/Invoice Report.cls");
    props.put(APIConst.TAG_TO_VERSION, "true");
    props.put(APIConst.TAG_TO_VERSION_PDF, "true");
  3. Submit the task as follows:
    taskID = svr.submitScheduledTask("admin", props);
  4. Trigger the task as follows:
    Properties userData = new Properties();
    trigMan.fire(exTriggerName, userData);

BackPrevious Page Next PageNext