Page History
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
import java.util.List; import com.sos.js7.job.Job; import com.sos.js7.job.JobArgument; import com.sos.js7.job.OrderProcessStep; import com.sos.js7.job.OrderProcessStepOutcome; public class JobWithParams extends Job<MyJobArguments> { @Override public void processOrder(OrderProcessStep<MyJobArguments> step) throws Exception { // reading all arguments with "getAllArgumentsAsNameValueMap" step.getAllArgumentsAsNameValueMap().forEach((name, value) -> { step.getLogger().info("argument: " + name + "=" + value.toString()); }); // reading all arguments with "getAllArguments" step.getAllArguments().forEach((name, jobArgument) -> { step.getLogger().info("argument: " + name + "=" + jobArgument.getValue().toString()); }); MyJobArguments MyJobArguments myArgs = step.getDeclaredArguments(); // reading job-specific argument: myString JobArgument<String> myString = myArgs.getMyString(); step.getLogger().info(myString.getName() + "=" + myString.getValue()); // reading job-specific argument: myBool JobArgument<Boolean> myBool = myArgs.getMyBool(); step.getLogger().info(myBool.getName() + "=" + myBool.getValue()); // reading job-specific argument: myList JobArgument<List<String>> myList = myArgs.getMyList(); step.getLogger().info(myList.getName() + "=" + myList.getValue().toString()); // return values OrderProcessStepOutcome outcome = step.getOutcome(); outcome.putVariable(myString.getName(), "hello world"); outcome.putVariable("myInteger", 42); } } |
...
- The
getAllArgumentsAsNameValueMap()
method provides a map of all argumentsargument values. - The map allows to read a single argument from the argument name
getAllArguments()
method provides a map of argument objects. - The OrderProcessStep object is here typed by
MyJobArguments
that is a class with job-specific declared arguments.A class with job specific declared arguments extends
com.sos.js7.job.JobArguments
Code Block language java title Example of a class of the job-specific declared arguments import java.util.List; import com.sos.js7.job.JobArgument; import com.sos.js7.job.JobArguments; public class MyJobArguments extends JobArguments { private JobArgument<String> myString = new JobArgument<String>("myString", false); private JobArgument<List<String>> myList = new JobArgument<>("myList", false); private JobArgument<Boolean> myBool = new JobArgument<>("test", false, true); public JobArgument<String> getMyString() { return myString; } public JobArgument<List<String>> getMyList() { return myList; } public JobArgument<Boolean> getMyBool() { return myBool; } }
- For further methods to access arguments see JS7 - Job API.
Explanation:
Further Resources
Features
- The
getAllArguments()
method provides a list of argument objects for iteration. - For further methods to access arguments see JS7 - Job API.
- JS7 - Job Types
Articles
Display children header |
---|
Overview
Content Tools