Passing data from one Event Based Workflow state to another
Of course, your Event Based Workflow actions are not limited to services that just consume data, you could take that input and process
it by passing it around to other states. For this example, let's say you have two states.
The first state is set to the action String.upperCase(String)
;
the second state is set to call Logger.println(String)
; and there is a blank transition between them.
Let us also say, that there is a single Event Based Workflow input called input
that is of type String
.
- Click your first state. Once the state is selected, Event Based Workflow Input/Output will become State Input/Output.
- Add an output string property named
upperCased
. - In Mapper, map
input
to the action's inputstr
. - In Mapper still, map the action's output
output
toupperCased
.
- Click your second state.
- Under the State Input/Output view, create an input of type string with the name
toPrint
. - Going back to Mapper, map
toPrint
tomessage
. - Finally, click on the transition arrow and in Mapper, map
upperCased
totoPrint
.
What we've done here is send data between two states using a transition. Data becomes available via a state's inputs and outputs and the transition acts as the bridge for data between states. This way, each state is isolated. They perform their own action without having to rely on other states' implementations. Transitions act as adapters between states.
Map properties using only keyboard commands!
To make it easier for you, Martini has template proposals you can use to map property values accessible via the content-assist menu.
To map properties using template proposals in the Event Based Workflow canvas:
- Select the state or transition by clicking on it.
- Press the key; a pop-up will show with proposals.
- Select Map property.
- If the selection is a state and its action is an invoke step, there will be an Input or Output proposal. Select either of these options, depending on whether you want to set an input property or output property. Otherwise, ignore this step.
- Select the property whose value you want to map.
- Select the property to map the previously selected property to.
You can also use content-assist to map properties in the Mapper view.