Skip to content

Toro Cloud Dev Center


Setting the action for a Event Based Workflow 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 Event Based Workflow work the same way they do in 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 Event Based Workflow, you can invoke any type of service that services can invoke because underneath the covers, the Event Based Workflow 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.

  1. 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.
  2. Press to trigger content-assist. By doing so, you will be given a list of available services that you can call from the state.
  3. Select the service you want to invoke. For this example, we'll select LoggerMethods.println(String).
  4. 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 message by 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:

Setting a Event Based Workflow state's action

Setting a Event Based Workflow state's action

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.

Creating state with action and transition

Creating state with action and transition

Use template proposals to set property set expressions

You can set the expressions of properties in states or transitions using template proposals:

  1. Select the state or transition.
  2. Press the key; a pop up will show with proposals.
  3. Select the Set expression proposal.
  4. If the state's action is an invoke step, there would be two available proposals: Input and Output. Select Input to set an input property; Output to set an output property.
  5. Select the property whose expression must be set.
  6. The Expression dialog will appear; enter the expression. Your expression can either be plain text or code.
  7. Click the OK button, or press to save the expression.

Setting property expressions using content-assist

Setting property expressions using content-assist