This article describes how order and job parameters from a job are accessed using the JobScheduler internal API. This technique is used in the JITL jobs provided with the JobScheduler and this article provides sufficient information to allow users to access order and job parameters in their own jobs.
Order and job parameters are accessed API jobs and pre-/post-processing routines in Java or another scripting language that can implement the Job_impl interface, via JobScheduler objects.
Getting the Objects
JobScheduler has two different types of parameters:
- Task parameters that are used in jobs and
- Order parameters that are used in orders.
- Both types of parameters are stored in different objects of type Variable_set. To get all parameters that are defined for a job, it is required to read both and merge them into a new object, which is not known to JobScheduler but to the program. This new object contains all parameters and, if order parameters are merged after merging the task parameters, the order parameters will overwrite task parameters with the same name.
From a technical point of view the "merger" enables the program to run with "standalone" or with "Job Chain" jobs as well.
The code shown below is part of the superclass JobSchedulerJobAdapter that is used for most of the latest JITL Jobs:
Let's have a look at the Java code:
- On line 5 a Variable_set is created from scratch. It is empty.
- On line 6 the content of the task parameters is merged into this Variable_set.
- On line 7 and 8 the order parameter, if the job runs as a job chain job, will be merged as well into the Variable_set
Get variable values
To get a variable value from the object Variable_set one has to use the method
If the variable with the given name does not exist then the value of the result variable will be null. The values of the JobScheduler's variables are always of type "String".
Set variable values
To set a variable or to modify the current value of a variable you would have to code:
It is important to take into account that the modification of a variable is only effective for JobScheduler if this modification is done in the JobScheduler object and not in the copy which is provided by the
Job and Order Parameters
- How to set and read job and order parameters
- How to pass parameters to subsequent shell jobs in a job chain
- How to clone parameters from a persistent order