1.72 Scheduling (Experimental)

In 2.29 we introduced a new way of scheduling jobs on the server. Each type of job has different properties for configuration, giving you more control over how jobs are run. In addition, you can configure the same job to run with different configurations and at different intervals if required.

Main properties
Property Description Type
name Name of the job String
cronExpression The cron expression resembles a time interval. It must follow a specific pattern, see https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm for guidelines String (Cron expression)
jobType The job type represent which task is run. In the next table, you can get an overview of existing job types. Each job type can have a a specific set of parameters for job configuration https://play.dhis2.org/dev/api/jobConfigurations/jobTypesExtended for an overview of the parameters designed for a job type. A JobConfiguration has a “configurable” property which is adopted by the job type. Some jobs are system jobs which only allows for altering of the cron expression. String (Enum)
jobParameters Parameters of job if applicable for job type (See list of job types)
continuousExecution A job may be added as a continuous job which means, as soon as the job finished, it will be scheduled to run again right away. Set “continuouseExecution” to true in the payload if continuous execution is desired Boolean
enabled A job can be added to the system without it being scheduled by setting “enabled” to false in the JSON payload. Use this if you want to temporarily stop scheduling for a job, or if a job configuration is not complete yet. Boolean
Available job types
Job type Parameters Param(Type:Default)
DATA_INTEGRITY NONE
ANALYTICS_TABLE
  • lastYears: Number of years back to include

  • skipTableTypes: Skip generation of tables

    • Possible values: DATA_VALUE, COMPLETENESS, COMPLETENESS_TARGET, ORG_UNIT_TARGET, EVENT, ENROLLMENT, VALIDATION_RESULT

  • skipResourceTables: Skip generation of resource tables

  • lastYears (int:0)

  • skipTableTypes (Array of String (Enum):None )

  • skipResourceTables (Boolean)

DATA_SYNC NONE
META_DATA_SYNC NONE
SEND_SCHEDULED_MESSAGE NONE
PROGRAM_NOTIFICATIONS NONE
MONITORING (Validation rule analysis)
  • relativeStart: A number related to date of execution which resembles the start of the period to monitor

  • relativeEnd: A number related to date of execution which resembles the end of the period to monitor

  • validationRuleGroups: Validation rule groups(UIDs) to include in job

  • sendNotification: Set “true” if job should send notifications based on validation rule groups

  • persistsResults: Set “true” if job should persist validation results

  • relativeStart (int:0)

  • relativeEnd (int:0)

  • validationRuleGroups (Array of String (UIDs):None )

  • sendNotification (Boolean:false)

  • persistsResults (Boolean:false)

PUSH_ANALYSIS
  • pushAnalysis: The uid of the push analysis you want to run

  • pushAnalysis (String:None)

PREDICTOR
  • relativeStart: A number related to date of execution which resembles the start of the period to monitor

  • relativeEnd: A number related to date of execution which resembles the start of the period to monitor

  • predictors: Predictors(UIDs) to include in job

  • relativeStart (int:0)

  • relativeEnd (int:0)

  • predictors (Array of String (UIDs):None )

To configure jobs you can do a POST request to the following resource:

/api/jobConfigurations

Adding job without parameters in JSON format:

        {
          "name": "",
          "jobType": "JOBTYPE",
          "cronExpression": "0 * * ? * *",
        }

Adding job with parameters in JSON format (ANALYTICS_TABLE example):

        {
          "name": "Analytics last two years",
          "jobType": "ANALYTICS_TABLE",
          "cronExpression": "0 * * ? * *",
          "jobParameters":
          {
              "lastYears": "2",
              "skipTableTypes": [],
              "skipResourceTables": false
          }
        }

List all jobConfigurations:

GET /api/jobConfigurations

Retrieve a job: (ANALYTICS_TABLE example):

GET /api/jobConfigurations/KBcP6Qw37gT
        {
          "lastUpdated": "2018-02-22T15:15:34.067",
          "id": "KBcP6Qw37gT",
          "href": "http://localhost:8080/api/jobConfigurations/KBcP6Qw37gT",
          "created": "2018-02-22T15:15:34.067",
          "name": "analytics last two years",
          "jobStatus": "SCHEDULED",
          "displayName": "analytics last two years",
          "enabled": true,
          "externalAccess": false,
          "continuousExecution": false,
          "jobType": "ANALYTICS_TABLE",
          "nextExecutionTime": "2018-02-26T03:00:00.000",
          "cronExpression": "0 0 3 ? * MON",
          "jobParameters": {
            "lastYears": 2,
            "skipTableTypes": [],
            "skipResourceTables": false
          },
          "favorite": false,
          "configurable": true,
          "access": {
            "read": true,
            "update": true,
            "externalize": true,
            "delete": true,
            "write": true,
            "manage": true
          },
          "lastUpdatedBy": {
            "id": "GOLswS44mh8"
          },
          "favorites": [],
          "translations": [],
          "userGroupAccesses": [],
          "attributeValues": [],
          "userAccesses": []
        }

Updating job with parameters in JSON format (ANALYTICS_TABLE example):

PUT /api/jobConfiguration/KBcP6Qw37gT
        {
          "name": "analytics last two years",
          "enabled": true,
          "cronExpression": "0 0 3 ? * MON",
          "continuousExecution": false,
          "jobType": "ANALYTICS_TABLE",
          "jobParameters": {
            "lastYears": "3",
            "skipTableTypes": [],
            "skipResourceTables": false
          }
        }

Deleting a job:

DELETE /api/jobConfiguration/KBcP6Qw37gT

Some jobs with custom configuration parameters may not be added if the required system settings are not configured. An example of this is data synchronization, which requires remote server configuration.