Page History
Table of Contents |
---|
Introduction
JS7 offers an API for JVM jobs are executed in the Agent's Java Virtual Machine.
- Java Jobs
- JavaScript Jobs
Arguments
Arguments to jobs originate from a number of sources:
- Order Variables
- They are declared with the workflow and can hold default values. If no default value is specified then an order has to carry the variable and to assign a value.
- Declared Variables include all variables declared with the workflow.
- Order Variables include the variables specified with the order.
- Job Arguments
- The arguments are specified as key/value pairs with the given job. In case of multiple occurrence of the same job in a workflow the same arguments are used.
- Node Arguments
- The arguments are specified as key/value pairs with the job's node that is specific for the occurrence of a job in a workflow.
- Job Resource Variables
- The variables are specified as key/value pairs from JS7 - Job Resources.
- Job Resources can be assigned individually per job or to all jobs in a workflow.
Classes
Class js7.Job
The js7.Job
class is an abstract class that has to be implemented by a JS7Job
class in the job:
Methods
Method | Argument | Return Value |
---|---|---|
processOrder() | [object] js7Step | n/a |
Objects
Object | Purpose | |
---|---|---|
js7Step | The build-in object js7Step provides a number of methods | |
Method | Argument | Return Value |
getLogger() | [string] message | n/a |
getDeclaredArgument() | [string] argumentName | [object] argumentObject |
getDeclaredArgumentValue() | [string] argumentName |
|
Example
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JS7Job extends js7.Job { processOrder(js7Step) { js7Step.getLogger().info("Hello World"); } } |
Explanations:
- 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. - The
js7Step
object is used with itsgetLogger()
method to create some output to the job's log.
- The method is parameterized by the
Class js7.JobArgument
The js7.JobArgument
class can optionally be used to access declared variables.
- Users implement a class for arguments with an arbitrary name that creates objects for declared arguments
- Users instantiate the class for arguments in their
JS7Job
class implementation.
Constructor
Constructor | Argument | Return Value |
---|---|---|
js7.JobArgument() |
| [object] argumentObject |
Example: Access Declared Arguments
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JobArguments { workflowPath = new js7.JobArgument("js7Workflow.path", false); } class JS7Job extends js7.Job { declaredArguments = new JobArguments(); processOrder(js7Step) { // option 1: access declared argument object // option 1.a: access declared argument object by name js7Step.getLogger().info("[GetDeclaredArgument] by name:"); var da1 = js7Step.getDeclaredArgument('js7Workflow.path'); js7Step.getLogger().info("declaredArgument: " + da1.getName() + "=" + da1.getValue()); // option 1.b: access declared argument by object name js7Step.getLogger().info("[GetDeclaredArgument] by object name:"); var da2 = js7Step.getDeclaredArgument(this.declaredArguments.workflowPath.name); js7Step.getLogger().info("declaredArgument: " + da2.getName() + "=" + da2.getValue()); // option 2: access declared argument value // option 2.a: access declared argument value by name js7Step.getLogger().info("[GetDeclaredArgumentValue] by name:"); js7Step.getLogger().info(js7Step.getDeclaredArgumentValue('js7Workflow.path')); // option 2.b: access declared argument value by object name js7Step.getLogger().info("[GetDeclaredArgumentValue] by object name:"); js7Step.getLogger().info(js7Step.getDeclaredArgumentValue(this.declaredArguments.workflowPath.name)); } } |
Explanations:
- x
Example: List Declared Arguments
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
class JobArguments { // arguments with string data type colorBlue = new js7.JobArgument('color_blue', true, 'blue'); colorRed = new js7.JobArgument('color_red', true, 'red'); colorOrange = new js7.JobArgument('color_orange', true, 'orange'); // arguments with numeric data type numOfDays = new js7.JobArgument('num_of_days', true, 5); // arguments with Boolean data type isEndOfMonth = new js7.JobArgument('is_end_of_month', true, true); // arguments with masked output that prevents logging values password = new js7.JobArgument('password', true, 'secret', js7.DisplayMode.MASKED); } class JS7Job extends js7.Job { declaredArguments = new JobArguments(); processOrder(js7Step) { // get list of all declared arguments var allArgs = js7Step.getAllDeclaredArguments(); js7Step.getLogger().info('[getAllDeclaredArguments]:'); js7Step.getLogger().info('all declared arguments: ' + allArgs); for (var arg in allArgs) { js7Step.getLogger().info(' ' + arg + '=' + allArgs[arg]); } } } |
Explanations:
- x
Methods for Arguments
Methods for Return Values
Overview
Content Tools