Setting the action for a state
A workflow with transitions between action-less states won't do much. In fact, it won't do anything at all. Actions tell states what to do and by default, states are configured to map via map steps. Map steps in Flux work the same way they do in Gloop services – their main purpose is to transform data, and in this case, data between states. Aside from mapping, you can have a state call another service instead. In Flux, you can invoke any type of service that Gloop services can invoke because underneath the covers, the Flux engine uses Gloop.
Now, let's create a state invoking a Groovy service. For this example, we'll set them to call Groovy methods that print something to the terminal.
- Select the state whose action you want to re-specify. You'll know the state has been selected when its circle's color has changed.
- Press to trigger content assist. By doing so, you will be given a list of available services that you can call from the state.
- Select the service you want to invoke. For this example, we'll select
Under the Mapper view, you'll see that you have the ability to set the values of the arguments you will be feeding to the selected service. Do this if you need to.
For this example, we'll set the value of
messageby double clicking the parameter shown in the view. We'll do this for our first and second states.
Here's a demonstration of the steps above:
And just like that, you already have a workflow that transitions from one step to another executing an action at each step. Albeit simple, this example demonstrates how easy it is to get started on creating workflows. Of course, you'd like to create something more powerful. Let's continue by being able to set the message through an input.
Creating a state with action and transition
To quickly create a state with an action and transition, drag a transition to a blank part of the canvas. This will show dialogs for creating them and for setting the action.
Use template proposals to set property set expressions
You can set the expressions of properties in states or transitions using template proposals:
- Select the state or transition.
- Press the key; a pop up will show with proposals.
- Select the Set expression proposal.
- If the state's action is an invoke step, there will be an Input or Output proposal that will pop up after; select either Input or Output. Otherwise, ignore this step.
- Select the property whose expression must be set.
- The Expression dialog will appear; enter the expression. Your expression can either be a plain string or Groovy code (in which the expression must be evaluated).
- Click the OK button or press to save the expression.