This page was generated
January  28,  2016
4:06  AM
XQuery & XSLT Built-In & Modules Function Reference

Module: Admin Library - Scheduler Functions

Function Summary
admin:group-add-scheduled-task This function adds one or more scheduled tasks to the specified group.
admin:group-daily-scheduled-task This function constructs a task to be invoked at daily intervals.
admin:group-delete-scheduled-task This function deletes one or more scheduled tasks from the specified group.
admin:group-get-scheduled-tasks This function returns all of the tasks scheduled for the specified group.
admin:group-hourly-scheduled-task This function constructs a task to be invoked at hourly intervals.
admin:group-minutely-scheduled-task This function constructs a task to be invoked at intervals defined in terms of minutes.
admin:group-monthly-scheduled-task This function constructs a task to be invoked at monthly intervals.
admin:group-one-time-scheduled-task This function constructs a task to be invoked once, at a specific calendar day and time.
admin:group-weekly-scheduled-task This function constructs a task to be invoked at weekly intervals.
Function Detail
admin:group-add-scheduled-task(
$config as element(configuration),
$group-id as xs:unsignedLong,
$scheduled-tasks as element(gr:scheduled-task)*
)  as   element(configuration)
Summary:

This function adds one or more scheduled tasks to the specified group.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$group-id : The ID of the group on which the scheduled tasks are configured. Typically, this is the result of an admin:group-get-id call.
$scheduled-tasks : One or more scheduled tasks, such as those created by the task-create functions.

Example:
  xquery version "1.0-ml";
  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";

  let $config := admin:get-configuration()
 
  let $task := admin:group-hourly-scheduled-task(
      "/Scheduler_test.xqy",
      "/Docs",
      2,
      30,
      xdmp:database("Documents"),
      0,
      xdmp:user("Jim"), 
      0)

  let $addTask := admin:group-add-scheduled-task($config, 
      admin:group-get-id($config, "Default"), $task)

  return 
      admin:save-configuration($addTask)
 
  (: Creates an hourly scheduled task and adds it to the "Default" group. :)
   

admin:group-daily-scheduled-task(
$task-path as xs:string,
$task-root as xs:string,
$task-period as xs:positiveInteger,
$task-start-time as xs:time,
$task-database as xs:unsignedLong,
$task-modules as xs:unsignedLong,
$task-user as xs:unsignedLong,
$task-host as xs:unsignedLong?,
[$task-priority as xs:string?]
)  as   element(gr:scheduled-task)
Summary:

This function constructs a task to be invoked at daily intervals.

Parameters:
$task-path : The name of the module to be invoked. The task path must begin with a forward slash (/) and cannot contain a question mark '?', colon ':' or pound '#' character.
$task-root : The root directory (files system) or URI root (database) that contains the module. For example, if the module is located in the filesystem under MarkLogic/Docs, specify Docs.
$task-period : The number of days to elapse between each invocation of the module.
$task-start-time : The time of day (in 24:00 notation) to invoke the module.
$task-database : The ID of the database on which the module is to be invoked.
$task-modules : The ID of the modules database. For example, xdmp:database("Modules"). To specify the filesystem, use 0.
$task-user : The ID of the user with permission to invoke the module. For example, xdmp:user("Jim").
$task-host : The ID of the host on which to invoke the module. Leave empty, (), to specify all hosts.
$task-priority (optional): The priority of the task. Either "normal" or "higher".

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";

  let $config := admin:get-configuration()
  return
     admin:group-daily-scheduled-task(
        "/Scheduler_test.xqy",
        "/Docs",
        2,
        xs:time("09:30:00"),
        xdmp:database("Documents"),
        xdmp:database("Modules"),
        xdmp:user("Jim"), 
        0,
        "normal")

  (: returns a daily scheduled task. :)
   

admin:group-delete-scheduled-task(
$config as element(configuration),
$group-id as xs:unsignedLong,
$scheduled-tasks as element(gr:scheduled-task)*
)  as   element(configuration)
Summary:

This function deletes one or more scheduled tasks from the specified group.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$group-id : The ID of the group on which the scheduled tasks are configured. Typically, this is the result of an admin:group-get-id call.
$scheduled-tasks : One or more scheduled tasks.

Example:
  xquery version "1.0-ml";
  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";

  let $config := admin:get-configuration()
  let $group := admin:group-get-id($config, "Default")
  let $tasks := admin:group-get-scheduled-tasks($config, $group)

  return  
   admin:group-delete-scheduled-task($config, $group, $tasks)
  
  (: Returns a configuration element with the scheduled tasks in the 
      "Default" group deleted -- use admin:save-configuration
      to save the changes to the configuration or pass the configuration
      to other Admin API functions to make other changes. :)
   

admin:group-get-scheduled-tasks(
$config as element(configuration),
$group-id as xs:unsignedLong
)  as   element(gr:scheduled-task)*
Summary:

This function returns all of the tasks scheduled for the specified group.

Parameters:
$config : A configuration specification, typically as returned from one of the Admin module functions.
$group-id : The ID of the group on which the scheduled tasks are configured. Typically, this is the result of an admin:group-get-id call.

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";

  let $config := admin:get-configuration()
  return
    admin:group-get-scheduled-tasks($config, 
      admin:group-get-id($config, "Default"))
  
   =>

  <scheduled-task xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns="http://marklogic.com/xdmp/group">
    <task-path>/Scheduler_test.xqy</task-path>
    <task-root>/Docs</task-root>
    <task-type>minutely</task-type>
    <task-period>15</task-period>
    <task-days/>
    <task-timestamp>2009-02-27T12:16:06.152-08:00</task-timestamp>
    <task-database>3439178527237237454</task-database>
    <task-modules>0</task-modules>
    <task-user>10677693687367813363</task-user>
  </scheduled-task>
   

admin:group-hourly-scheduled-task(
$task-path as xs:string,
$task-root as xs:string,
$task-period as xs:positiveInteger,
$task-minute as xs:nonNegativeInteger,
$task-database as xs:unsignedLong,
$task-modules as xs:unsignedLong,
$task-user as xs:unsignedLong,
$task-host as xs:unsignedLong?,
[$task-priority as xs:string?]
)  as   element(gr:scheduled-task)
Summary:

This function constructs a task to be invoked at hourly intervals.

Parameters:
$task-path : The name of the module to be invoked. The task path must begin with a forward slash (/) and cannot contain a question mark '?', colon ':' or pound '#' character.
$task-root : The root directory (filesystem) or URI root (database) that contains the module. For example, if the module is located in the filesystem under MarkLogic/Docs, specify Docs.
$task-period : The number of hours to elapse between each invocation of the module.
$task-minute : The number of minutes after the hour to invoke the module. This value must be 59 or less. Note that this setting does not add to the task-period value.
$task-database : The ID of the database on which the module is to be invoked.
$task-modules : The ID of the modules database. For example, xdmp:database("Modules"). To specify the filesystem, use 0.
$task-user : The ID of the user with permission to invoke the module. For example, xdmp:user("Jim").
$task-host : The ID of the host on which to invoke the module. Leave empty, (), to specify all hosts.
$task-priority (optional): The priority of the task. Either "normal" or "higher".

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";

  let $config := admin:get-configuration()
  return
     admin:group-hourly-scheduled-task(
         "/Scheduler_test.xqy",
         "/Docs",
         2,
         30,
         xdmp:database("Documents"),
         0,
         xdmp:user("Jim"), 
         0,
        "normal")
  
    (: returns an hourly scheduled task. :)
   

admin:group-minutely-scheduled-task(
$task-path as xs:string,
$task-root as xs:string,
$task-period as xs:positiveInteger,
$task-database as xs:unsignedLong,
$task-modules as xs:unsignedLong,
$task-user as xs:unsignedLong,
$task-host as xs:unsignedLong?,
[$task-priority as xs:string?]
)  as   element(gr:scheduled-task)
Summary:

This function constructs a task to be invoked at intervals defined in terms of minutes.

Parameters:
$task-path : The name of the module to be invoked. The task path must begin with a forward slash (/) and cannot contain a question mark '?', colon ':' or pound '#' character.
$task-root : The root directory (filesystem) or URI root (database) that contains the module. For example, if the module is located in the filesystem under MarkLogic/Docs, specify Docs.
$task-period : The number of minutes to elapse between each invocation of the module.
$task-database : The ID of the database on which the module is to be invoked.
$task-modules : The ID of the modules database. For example, xdmp:database("Modules"). To specify the filesystem, use 0.
$task-user : The ID of the user with permission to invoke the module. For example, xdmp:user("Jim").
$task-host : The ID of the host on which to invoke the module. Leave empty, (), to specify all hosts.
$task-priority (optional): The priority of the task. Either "normal" or "higher".

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";

  let $config := admin:get-configuration()
  return
     admin:group-minutely-scheduled-task(
        "/Scheduler_test.xqy",
        "/Docs",
        45,
        xdmp:database("Documents"),
        0,
        xdmp:user("Jim"), 
        0,
        "normal")

    (: returns a minutely scheduled task. :)
   

admin:group-monthly-scheduled-task(
$task-path as xs:string,
$task-root as xs:string,
$task-period as xs:positiveInteger,
$task-month-day as xs:unsignedLong,
$task-start-time as xs:time,
$task-database as xs:unsignedLong,
$task-modules as xs:unsignedLong,
$task-user as xs:unsignedLong,
$task-host as xs:unsignedLong?,
[$task-priority as xs:string?]
)  as   element(gr:scheduled-task)
Summary:

This function constructs a task to be invoked at monthly intervals.

Parameters:
$task-path : The name of the module to be invoked. The task path must begin with a forward slash (/) and cannot contain a question mark '?', colon ':' or pound '#' character.
$task-root : The root directory (files system) or URI root (database) that contains the module. For example, if the module is located in the filesystem under MarkLogic/Docs, specify Docs.
$task-period : The number of months to elapse between each invocation of the module.
$task-month-day : The day of the month to invoke the module.
$task-start-time : The time of day (in 24:00 notation) to invoke the module.
$task-database : The ID of the database on which the module is to be invoked.
$task-modules : The ID of the modules database. For example, xdmp:database("Modules"). To specify the filesystem, use 0.
$task-user : The ID of the user with permission to invoke the module. For example, xdmp:user("Jim").
$task-host : The ID of the host on which to invoke the module. Leave empty, (), to specify all hosts.
$task-priority (optional): The priority of the task. Either "normal" or "higher".

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";

  let $config := admin:get-configuration()
  return
     admin:group-monthly-scheduled-task(
        "/Scheduler_test.xqy",
        "/Docs",
	2,
	3,
	xs:time("14:42:52"),
        xdmp:database("Documents"),
        0,
        xdmp:user("Jim"), 
	0,
        "normal")

     (: returns a monthly scheduled task. :) 
   

admin:group-one-time-scheduled-task(
$task-path as xs:string,
$task-root as xs:string,
$task-start as xs:dateTime,
$task-database as xs:unsignedLong,
$task-modules as xs:unsignedLong,
$task-user as xs:unsignedLong,
$task-host as xs:unsignedLong?,
[$task-priority as xs:string?]
)  as   element(gr:scheduled-task)
Summary:

This function constructs a task to be invoked once, at a specific calendar day and time.

Parameters:
$task-path : The name of the module to be invoked. The task path must begin with a forward slash (/) and cannot contain a question mark '?', colon ':' or pound '#' character.
$task-root : The root directory (files system) or URI root (database) that contains the module. For example, if the module is located in the filesystem under MarkLogic/Docs, specify Docs.
$task-start : The date and time on which the task is to start.
$task-database : The ID of the database on which the module is to be invoked.
$task-modules : The ID of the modules database. For example, xdmp:database("Modules"). To specify the filesystem, use 0.
$task-user : The ID of the user with permission to invoke the module. For example, xdmp:user("Jim").
$task-host : The ID of the host on which to invoke the module. Leave empty, (), to specify all hosts.
$task-priority (optional): The priority of the task. Either "normal" or "higher".

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";

  let $config := admin:get-configuration()
  return
     admin:group-one-time-scheduled-task(
        "/Scheduler_test.xqy",
        "/Docs",
        xs:dateTime("2009-03-29T14:42:52"),
        xdmp:database("Documents"),
        xdmp:database("Documents"),
        xdmp:user("Jim"), 
	admin:host-get-id($config, xdmp:host-name()),
        "normal")

    (: returns a one-time scheduled task. :)
   

admin:group-weekly-scheduled-task(
$task-path as xs:string,
$task-root as xs:string,
$task-period as xs:positiveInteger,
$task-days as xs:string+,
$task-start-time as xs:time,
$task-database as xs:unsignedLong,
$task-modules as xs:unsignedLong,
$task-user as xs:unsignedLong,
$task-host as xs:unsignedLong?,
[$task-priority as xs:string?]
)  as   element(gr:scheduled-task)
Summary:

This function constructs a task to be invoked at weekly intervals.

Parameters:
$task-path : The name of the module to be invoked. The task path must begin with a forward slash (/) and cannot contain a question mark '?', colon ':' or pound '#' character.
$task-root : The root directory (files system) or URI root (database) that contains the module. For example, if the module is located in the filesystem under MarkLogic/Docs, specify Docs.
$task-period : The number of weeks to elapse between each invocation of the module.
$task-days : One or more days on the specified week to invoke the module
$task-start-time : The time of day (in 24:00 notation) to invoke the module.
$task-database : The ID of the database on which the module is to be invoked.
$task-modules : The ID of the modules database. For example, xdmp:database("Modules"). To specify the filesystem, use 0.
$task-user : The ID of the user with permission to invoke the module. For example, xdmp:user("Jim").
$task-host : The ID of the host on which to invoke the module. Leave empty, (), to specify all hosts.
$task-priority (optional): The priority of the task. Either "normal" or "higher".

Example:
  xquery version "1.0-ml";

  import module namespace admin = "http://marklogic.com/xdmp/admin" 
      at "/MarkLogic/admin.xqy";

  let $config := admin:get-configuration()
  return
     admin:group-weekly-scheduled-task(
        "/Scheduler_test.xqy",
        "/Docs",
        2,
        ("Monday", "Wednesday"),
        xs:time("14:42:52"),
        xdmp:database("Documents"),
        xdmp:database("Documents"),
        xdmp:user("Jim"), 
        admin:host-get-id($config, xdmp:host-name()),
        "normal")

     (: returns a weekly scheduled task. :)