Show TOC

Background documentationUsing the RedwoodScript Job Definition Type Locate this document in the navigation structure

 

Note Note

The RedwoodScript job definition type is available with the Scripting module, which requires a specific license.

End of the note.

RedwoodScript is based on the Java language. It allows you to create job definitions with RedwoodScript in its source. The RedwoodScript job definition type is used to to create jobs that interact primarily with the server interfaces themselves. For instance, you can write a job that submits other jobs or retrieves and combines meta data or job output from other jobs.

Note Note

You must assign at least one process server to run RedwoodScript job definitions in order to use the job definition type.

End of the note.
Variable and Parameters

Variables that you require to hold intermediary values are defined in the same way as you would normally define variables in Java, using the standard syntax var myVar or var myVar = "initial value".

Job definition parameters are available directly in RedwoodScript as Java variables, as shown in the examples below.

Examples

The following code shows how to access the job's input parameter names and values:

{

jcsOutLog.debug("Job parameters");

for (Iterator it = jcsJob.getJobParameters(); it.hasNext(); )

{

JobParameter par = (JobParameter) it.next();

jcsOutLog.debug(par.getJobDefinitionParameter().getName() + "=" + par.getInValue());

}

}

Within a job chain you can not only access the job parameters, but also the job chain parameters -- if needed. The following code shows how to do this, by creating an object that is the grandparent of the current job. The parent of the job is the 'step' within the job chain, and the grandparent is the job for the job chain itself. If you need to access further ancestors the method would be to call getParentJob() recursively. The following code can also be used to execute code depending on the depth of the job in the chain, or if the job is part of a chain or not.

{

// Does this job have a step - which would imply that we are part of a job chain

if (jcsJob.getJobChainStep() != null)

{

JobChain chain = jcsJob.getJobChainStep().getJobChain();

if (chain != null)

{

Job chainJob = jcsJob.getParentJob().getParentJob();

// We are in a chain, our parent's parent is the chain job

// Since our parent is the step job, the step's parent is the job chain job.

jcsOutLog.debug("Part of a chain " + chain.getJobDefinition().getName());

jcsOutLog.debug("Chain parameters");

for (Iterator it = chainJob.getJobParameters(); it.hasNext(); )

{

JobParameter par = (JobParameter) it.next();

jcsOutLog.debug(par.getJobDefinitionParameter().getName() + "=" + par.getInValue());

}

}

}

else

{

jcsOutLog.debug("Not in a chain");

}

}

More examples are available in the Using RedwoodScript in Jobs section.