You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Introduction

JS7 offers a number of JS7 - Job Types including JS7 - Shell JobsJS7 - Java Jobs and JavaScript Jobs.

JS7 offers the JS7 - Job API to JavaScript Jobs that serves the purpose of

  • accessing arguments available to the job from various sources such as JS7 - Order Variables, job and node arguments, JS7 - Job Resources,
  • allowing to specify the outcome of a job including return values that are passed to subsequent jobs from order variables.

JavaScript jobs are available starting from the following releases:

FEATURE AVAILABILITY STARTING FROM RELEASE 2.5.4

FEATURE AVAILABILITY STARTING FROM RELEASE 2.6.1

Implementation

Basic Job

A JavaScript Job is implemented by a class with the name JS7Job like this:

Example for implementation of JS7Job with JavaScript
class JS7Job extends js7.Job {

	processOrder(js7Step) {
		js7Step.getLogger().info( 'hello world' ); 		

		// do some stuff
    }
}


Explanation:

  • The implementation class with the name JS7Job is required.
  • The processOrder() method is required to be implemented by the job.
    • The method is parameterized by the js7Step object provided by the Job API.
    • The js7Step object is used with its getLogger() method to write output to the job's log.

Accessing Arguments

A JavaScript Job can access arguments from a number of sources, see JS7 - Job API

Example: Access Arguments

Example for implementation of JS7Job with JavaScript
class JS7Job extends js7.Job {

	processOrder(js7Step) {
		var workflowPath = js7Step.getAllArgumentsAsNameValueMap['js7Workflow.path'];
	    js7Step.getLogger().info('argument: ' + workflowPath);
    }
}

Explanation:

  • The getAllArgumentsAsNameValueMap() method provides a map of all arguments. The map allows to read a single argument from the argument name.
  • For further methods to access arguments see JS7 - Job API

Example: List Arguments

Example for implementation of JS7Job with JavaScript
class JS7Job extends js7.Job {

	processOrder(js7Step) {
		var args = js7Step.getAllArguments();
        for (var arg in args) {
			js7Step.getLogger().info('argument: ' + arg + '=' + args[arg]);
		}
    }
}


Explanation:

  • The getAllArguments() method provides an array of argument objects for iteration.
  • For further methods to access arguments see JS7 - Job API


  • No labels