Both are based on ScriptContext and this is what they both have in common.
ProcessScriptContext
The ProcessScriptContext contains the input and output documents, in addition to the information in ScriptContext. A Document consists of the document content and its (dynamic document) properties.
public List<Document> inputDocuments = []
public List<Document> outputDocuments = []
Process ScriptContext example
The following examples demonstrates how to setup all kind of properties and documents to run a process script.
ProcessScriptContext context = new ProcessScriptContext()
// Initialize
// * Execution context : executionContexts
// * Dynamic Process Properties : dynProcPros
// * Process Properties : procPros
// * Documents : inputDocuments
// incl. Dynamic Document Properties
// --------------------------------------------------------------
// context.executionProperties.ACCOUNT_ID = "My Account ID"
context.dynProcPros.DPP_ProcPropString = "My Process Property"
context.dynProcPros.DPP_IntValue = 0
// region Process Property
final String PROCESS_PROPERTY_COMPONENT_ID = "8fb41f63-a988-4778-8cc8-0144f30ace81"
final String VAL1_ID = "eea9e988-cb14-4a84-ba37-ee455451a741"
final String VAL2_ID = "2c68fb60-8431-46cc-9da9-cbe10d446a0e"
// Wrap key in parenthesis so that the variables (Ids) are taken
// and not the text as a string
def procPropValue1 = 4711
def procPropValue2 = "Markus Schmidt"
context.procPros = [ (PROCESS_PROPERTY_COMPONENT_ID):
[
(VAL1_ID): procPropValue1,
(VAL2_ID): procPropValue2
]]
// endregion
// region Documents
final String DDP_Name = "DDP_IntValue"
int[] ddpValues = [ 10, 11, 12]
context.inputDocuments =
[
Document.fromText('''
{
"firstname" : "Walter",
"lastname" : "Schmidt"
}''', [(DDP_Name): ddpValues[0]]),
Document.fromFile( _testFiles.get( "demoDoc01.json") , [(DDP_Name): ddpValues[1]]),
Document.fromFile( _testFiles.get( "demoDoc02.json") , [(DDP_Name): ddpValues[2]])
]
// endregion
_testScript.run(context)
MapScriptContext
A MapScriptContext represents the input and output variables as they are defined on the platform, in addition to the information in ScriptContext.
MapScriptContext scriptContext = new MapScriptContext( [
a: 5,
b: 7
])
_testScript.run(scriptContext)
assert scriptContext.variables.total
== (scriptContext.variables.a as int)
+ (scriptContext.variables.b as int),
"Calculation result does not meet expectations!"
ScriptContext
The ScriptContext is the base class,MapScriptContext and ProcessScriptContext inherit from it. The ScriptContext hosts:
Process Properties - procProps
Dynamic Process Properties - dynProcProps
Execution Properties - executionProperties
public Map dynProcPros = [:]
public Map procPros = [:]
public final Map executionProperties =
[
ACCOUNT_ID : 'IntelliJ_IDEA-M42S66',
ATOM_ID : '0b6e3ab7-9d81-4954-b781-d212195e577c',
ATOM_NAME : 'Markus Groovy 4 Boomi',
// null on local Atom, some text on Cloud ATOM (e.g. NODE_ID = atom01)
NODE_ID : null,
// set before script starts - ProcessScriptContext run
DOCUMENT_COUNT: 0,
// see Process Call Chain
// If you do not plan to use ExecutionTask objects in your
// scripts you can live with the defaults and you won't care!
EXECUTION_ID : generateExecutionId(), // random
PROCESS_ID : UUID.randomUUID().toString(),
PROCESS_NAME : "My Main Process"
]
If you want to use ExecutionTask objects in your scripts,
read also about The Process Call Chain