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 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 one must have access to the JS internal API. Implementing an API-Job, or a pre-/post-Processing routine, processing routines in Java or a script another scripting language that can implement the Job_impl interface, the access is possible via the [ JS objects|http://www.sos-berlin.com/doc/en/scheduler.doc/api/api-java.xml].

getting the objects

via JobScheduler objects.

Getting the Objects

JobScheduler JS has two different types of parameters: 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|http://www.sos-berlin.com/doc/doxygen-docs/scheduler/html/classsos_1_1scheduler_1_1job_1_1_job_scheduler_job_adapter.html], which is JobSchedulerJobAdapter 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 = [http://www.sos-berlin.com/doc/en/scheduler.doc/api/Spooler-java.xml  spooler].create_variable_set();
  6          objJobOrOrderParameters.merge(getTaskParams());
  7          if (isJobchain() && hasOrderParameters()) \{
  8              objJobOrOrderParameters.merge(getOrderParams());
  9          \}
 10         [http://www.sos-berlin.com/doc/en/scheduler.doc/api/Log-java.xml  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 [http://www.sos-berlin.com/doc/en/scheduler.doc/api/Task-java.xml  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 [http://www.sos-berlin.com/doc/en/scheduler.doc/api/Task-java.xml  spooler_task].order().params();
 22 \}

Let's have a look at the Java code:

  1. On line 5 a [ Variable_set|http://www.sos-berlin.com/doc/en/scheduler.doc/api/Variable_set-java.xml] is created from scratch. It is empty.
  2. on On line 6 the content of the task parameters 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 Variable_set

...

Get variable

...

values

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

Code Block

      [http://www.sos-berlin.com/doc/en/scheduler.doc/api/Variable_set-java.xml  Variable_set] objVariables = getJobOrOrderParameters();
    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())) \{
            [http://www.sos-berlin.com/doc/en/scheduler.doc/api/Task-java.xml  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);
        \}
    \} 

 

To set a variable or change to modify the actual current value of a variable one must codeyou 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 JS JobScheduler if this modification is done in the JS JobScheduler object and not in the copy which is provided by the Method getJobOrOrderParameters() method.

<!--

related downloads

Code Block

 -->
 

see also

  • [ internal API for Java|http://www.sos-berlin.com/doc/en/scheduler.doc/api/api-java.xml]
  • [ Variable_set|http://www.sos-berlin.com/doc/en/scheduler.doc/api/Variable_set-java.xml]
  • [ JobSchedulerJobAdapter|http://www.sos-berlin.com/doc/doxygen-docs/scheduler/html/classsos_1_1scheduler_1_1job_1_1_job_scheduler_job_adapter.html]
  • [ internal API-Jobs|http://www.sos-berlin.com/doc/en/scheduler_tutorial.pdf]

Further References

Job and Order Parameters

 Wiki-rabbit-left.jpg << JobScheduler_FAQ back to all FAQs