Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents
outlinh1. true
outlinh1. true
1printablefalse
2stylh1. none
3indent20px

Introduction

This article describes how To access the order and /or job parameter parameters from a job one must have access to the JS internal API. Implementing an API-Job in Java or a script language, which can implement "spooler_process", the access is possible via the JS objects.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 JS has two different types of paramtersparameters: 1) Task Params, which

  • 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 "JobchainJob Chain" jobs , as well.

The code shown below is part of the superclass JobSchedulerJobAdapter, which is that is used for most of the latest JITL jobsJobs:

Code Block

  1  protected [[http://www.sos-berlin.com/doc/en/scheduler.doc/api/Variable_set-java.xml |Variable_set]] getJobOrOrderParameters() \{
  2      @SuppressWarnings("unused")
  3      final String conMethodName = conClassName + "::getParameters";
  4      try \{
  5          [[http://www.sos-berlin.com/doc/en/scheduler.doc/api/Variable_set-java.xml |Variable_set]] objJobOrOrderParameters = spooler.create_variable_set();
  6          objJobOrOrderParameters.merge(getTaskParams());
  7          if (isJobchain() && hasOrderParameters()) \{
  8              objJobOrOrderParameters.merge(getOrderParams());
  9          \}
 10         logger.debug(String.format(Messages.getMsg(JSJ_D_0070), objJobOrOrderParameters.count()));
 11         return objJobOrOrderParameters;
 12     \}
 13     catch (Exception e) \{
 14         throw new JobSchedulerException(String.format(Messages.getMsg(JSJ_F_0050), e.getMessage()), e);
 15     \}
 16 \}
Code Block

 17   protected [[http://www.sos-berlin.com/doc/en/scheduler.doc/api/Variable_set-java.xml |Variable_set]] getTaskParams() \{
 18       return spooler_task.params();
   19 \}
Code Block

 20   protected [[http://www.sos-berlin.com/doc/en/scheduler.doc/api/Variable_set-java.xml |Variable_set]] getOrderParams() \{
   21     return spooler_task.order().params();
 22   \}

Lets Let's have a look at the Java code:

  1. On line 5 a Variable_set is created from scratch. It is empty.
  2. on On line 6 the content of the task parameters are merge is merged into this Variable_set.
  3. on On line 7 and 8 the order parameter, if the job runs as a jobchain job chain job, will be merged as well into the VarableVariable_set

...

Get variable

...

values

To get a variable value from the object "Variable_set" one have has to use the method "var"():

Code Block
    Variable_set objVariables = getJobOrOrderParameters();

...

Code Block
    String myVar = objVariables.var("myVarName");
    String myVar2 = objVariables.var("nextVarname);
    

If the variables variable with the given name does not exist then the value of the result variable will be null. The Values values of the JobSchedulers JobScheduler's variables are always of type "String".

Set variable values

Code Block

    public void setJSParam(final String pstrKey, final String pstrValue) \{
        @SuppressWarnings("unused")
        final String conMethodName = conClassName + "::setJSParam";
        if (isNotNull(spooler_task.params())) \{
            spooler_task.params().set_var(pstrKey, pstrValue);
        \}
        if (hasOrderParameters()) \{
            [http://www.sos-berlin.com/doc/en/scheduler.doc/api/Task-java.xml  spooler_task].order().params().set_var(pstrKey, pstrValue);
        \}
        if (isNotNull(objJobOrOrderParams)) \{
            objJobOrOrderParams.set_var(pstrKey, pstrValue);
        \}
    \} 

related downloads

see also

 

To set a variable or to modify the current value of a variable you would have to code:

Code Block
        setJSParam("myVariable", "the.value");

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 getJobOrOrderParameters() method.

Further References

Job and Order Parameters