Gloop step editor
The main component of the service editor is the step editor. The step editor has two tabs, labeled Source and Design. The Source tab allows you to view the JSON definition of the opened Gloop service. The Design tab, as its name implies, is where you design your service. Here you can add, modify, and remove Gloop steps.
The Design tab contains two components: the step tree of the service and the toolbar above it. The step tree represents the Gloop service's steps, their order, and hierarchical structure. The toolbar above helps you navigate through the step tree, modify it, and view the details of its nodes.
In the tree, each step is decorated so that it's easy for you to infer the purpose and/or definition of the step. For example, different types of steps are given different icons. Additionally, certain steps can contain other steps and in order to show this arrangement, Martini renders parent steps collapsible or expandable in the tree. At the side of the step tree is also a ruler which displays the line numbers, breakpoints, and code errors of the service.
Adding steps
There are five different ways to add a step:
-
Using the toolbar
- Click the plus-shaped green button in the toolbar.
- Click one of the menu items below to indicate the type of step you want to add.
-
Using the context menu
Right click on the step tree, select Add, and then click on the type of step you want to add.
-
Using keyboard shortcuts (there is an assigned shortcut per property type)
-
Using drag and drop
Via dragging and dropping, you can either add a step or duplicate existing ones.
To add an invoke step, select one or more services from the Navigator view and then drag and drop them onto the step tree. To duplicate existing steps, select the steps you wish to duplicate and then drag and drop them onto the step tree while pressing .
-
Using content-assist
Using content-assist is a very convenient way to add steps quickly, especially for invoke steps. To trigger content-assist, press the key, then search for the name of the step you want to add or the name of the service to invoke.
If you've got a step selected while using content-assist, the new step will be added under the current step or after the current step, depending on the 'Add Mode' option of content-assist.
The 'Add Mode' has multiple options, depending on the step selected.
- Add To - This option adds the new step under the selected step. It is the default option if the selected step can have children.
- Add After - This option adds the new step after the selected step. It is the default option if the selected step cannot have children.
- Replace - This option replaces the selected step with the new step.
Pressing while adding a step to a step that can have children will prompt the editor to use the 'Add After' option.
Pressing while adding a step will prompt the editor to use the 'Replace' option. If the proposal you have selected is a template which produces multiple steps, the replacement will only be applied to the first step generated by the proposal.
To apply the change, press while holding the corresponding key of the option.
If no step is selected while adding a step via content-assist, the new step will be placed at the end of the Gloop service.
Deleting steps
There are three different ways to delete a step:
-
Using the toolbar
Select all steps you want to delete and then click on the red 'x' button in the toolbar.
-
Using the context menu
Select all the steps you want to delete, right click, and then select Delete from the appearing context menu.
-
Using keyboard shortcuts
Select the step and then press to remove the selected step.
Moving steps
You can move steps around in order to refine the sequence of actions your Gloop service will execute. Steps can be moved up, down, left, or right. Moving up or down would mean the step will move one line upwards or downwards, respectively; switching places with the step that comes before or after it. Moving left would prompt Martini to remove the step from its current parent and consequently transfer it under the first composite step1 below it. Moving right would prompt almost the same action except the step will be transferred under the first composite step above the selected step.
There are three ways to move steps:
-
Using the toolbar
To move steps using the toolbar, click on the step(s) you want to move and and then click on one of the arrowhead-shaped buttons.
-
Using keyboard shortcuts
-
Via dragging and dropping
- Select all steps you want to move. You can select multiple steps by holding in Martini Desktop or in Martini Online.
- Drag and drop them in-between or on top of other composite steps (in the same service or of a different Gloop service).
By default, dragging and dropping to another place will remove the steps from their original location; but if the key is pressed while doing so, the steps will be duplicated instead.
Copying and pasting steps
It is possible to copy the steps of one Gloop service and paste them to the same service (albeit to a different line) or a different Gloop service. To copy and paste steps:
- Select the steps you want to copy.
- Press or right-click > Copy.
- Select another step or Gloop service.
- Press or right-click > Paste.
Aside from this, you can also copy the map lines and set expressions of a map step or invoke step and paste them to another map step or invoke step. This can be done in the step tree or in the Mapper view. The map lines are validated before being pasted which means that if the map line or set expression is invalid, then it’s discarded. To do this:
- Select the map lines or set expressions you want to copy.
- Press or right-click > Copy.
- Select another map step or invoke step.
- Press or right-click > Paste.
It is also possible to copy and paste plain JSON text to create steps. For example, copying the JSON string below and pasting it in the step tree will create a new map step.
1 2 3 |
|
Expression dialog
The Expression dialog is for editing steps with expressions like the fork step, while step, break step, set expression step, or script step.
This dialog is composed of a text area on the left and a model tree on the right. The text area contains the actual expression and the model tree displays all the properties available for use in the step. Underneath the expression text area is a drop-down that's used for selecting the language of the expression.
When the chosen language is plain text, then no evaluation of the text will take place. In other words, selecting this is the same as hard-coding the value.
While writing Groovy code in the expression editor, it is possible to trigger content-assist by pressing or . This feature provides you with a list of accessible variables, methods, data types, keywords, and constructs based on the context of the current code2.
Inserting property expressions on the fly
If you wish to insert a property path and surround the path with ${
and }
, hold down whilst
double clicking. You can also use the context menu when you right click on the tree,
and then select 'Insert Property Path in Template String'.
If you wish to insert a property path with Groovy's safe navigation operator ?
as well, hold down
whilst double clicking. You can also use the context menu when you right click on the tree,
and then select 'Insert Property Path with Safe Navigation'.
These operations can also be used to replace existing content in the code text area. Simply select/highlight the text you wish to replace prior to using the menu or shortcuts to insert the path.
If you're editing an expression using Groovy, your expression will also be validated and checked for syntax and semantic errors. If an error is detected, the invalid code will be underlined in red. Hovering over the invalid code displays the error message, giving more information about what is wrong.
Content-assist is only supported in Martini Desktop
Code-related proposals are only available in Martini Desktop.
Step decoration
Each step is decorated with a different icon and label in the step tree. This is to help developers easily infer information about the step.
Map step decoration
When a map step has only one declared variable, no map lines, or has one set expression, it is displayed as:
1 |
|
... or
1 |
|
The map lines of a map step or invoke step, as well as set expressions are displayed under the step in the step tree when it is expanded; it can be used to delete or edit the map line or set expression. When double-clicking a map line, it opens the Mapper view and selects the line; similarly, double-clicking a set expression opens the Expression dialog.
Evaluated set expressions
When a set expression is evaluated, an orange dot icon is visible next to it.
Priority property
Map lines and set expressions are, by default, shown under map and invoke steps. You can disable this option by clicking Filters on the toolbar and un-checking "Show Map lines and Set steps".
Fork step and break step decoration
The expression of a fork step or break step is displayed next to the step like so:
1 |
|
Iterate step decoration
When an iterate step has both an input and output array, it will be displayed like so:
1 |
|
If it only has an input array, it will be displayed as:
1 |
|
If it only has an output array, it will be displayed as:
1 |
|
While step decoration
A while step's expression is displayed in the step tree like so:
1 |
|
Script step decoration
When the script of a script step is short enough, it is displayed next to the step like so:
1 |
|
But when the script contains more than one line, the lines of the script are displayed under the Script step. This option can be disabled by clicking Filters on the toolbar and then un-checking "Show Script lines".
Copying script lines
When the script of a script step is shown in the step tree, each line in the script is numbered and rendered selectable by Martini. To copy lines of code from the script, simply select lines you want to copy and then press the copy shortcut or right-click and then select Copy.
Asynchronous step decoration
When a concurrent step or invoke step is configured as asynchronous, a green thread overlay is visible on the top right of the concurrent or invoke step icon.
Invoke step decoration
The invocation signature (or method signature) of an invoke step is comprised of the service's return type, name, input parameters, and exceptions; it is displayed like so:
1 |
|
If a parameter is assigned via a map line, set expression, or has a default value, it will be visible in the signature;
in case the parameter is unassigned, null
will be displayed.
When a parameter is assigned via an evaluated set expression, an orange dot is visible next to the parameter. This option can be disabled by clicking Filters on the toolbar and un-checking "Show method signatures".
The name and value of each parameter is also indicated in the signature, <parameter name>: <parameter value>
, making
the invocation easier to read. This option can be disabled by clicking Filters on the toolbar
and un-checking "Show named parameters".
Content-Assist
Martini supports content-assist to help boost productivity when writing Gloop services. Using content-assist, you can generate pre-configured steps and/or be guided through their configuration.
To trigger content-assist, simply press ; then a pop-up will appear right under the line where you hit the key. This pop-up is composed of a search text field and a list of proposals. Proposals are possible content that can be injected based on the current code context; they have a name and a category. Proposals can be searched by their complete names or short names3. Meanwhile, categories can be cycled through to filter the proposals by simply pressing ; at the bottom right, the next category is indicated.
Here are the available proposal categories:
Category | Description |
---|---|
Step | Proposals to add a non-configured step |
Flat File Descriptor | Proposals to write or read from a flat file |
Invoke Gloop | Proposals to invoke a Gloop service |
Invoke Code | Proposals to invoke a different service (e.g. Groovy service) |
Invoke Flux | Proposals to invoke a Flux service |
Templates | Proposals to generate a group of configured steps based on a template |
You can use the and arrow keys to navigate through the proposals whilst still having focus on the search text field so you can search and select at the same time.
When a proposal is selected, a contextual pop-up will appear on the side to give some additional information about the selected proposal. Pressing applies the selected proposal. By default, the steps will be added to the currently selected step (or Gloop service) if that step can have children steps; else, it will be added bellow that step. Pressing the key while pressing forces the steps to be added after the selected step.
Search content-assist proposals
Proposals can be searched and applied without leaving the keyboard. After pressing the key, search right
away for a proposal by typing its name. The first match will be selected, and if it's the right one, press
. Pressing while the first proposal is selected will jump to the last proposal.
Some proposals have short names, for example the try-catch-finally proposal can be searched using the text tcf
.
Templates
There is a special type of proposal called template proposal. These proposals are designed to generate one or more pre-configured steps to make it very fast and easy to write common logic or code patterns. Template proposals usually require some additional input like filling in a field or selecting another proposal or property.
Below is a non-extensive list of proposal and their effects:
Flat file descriptor template
This template generates the necessary steps to read or write to a flat file using a flat file descriptor.
To use this template:
- Search for the name of the flat file descriptor.
- Select it.
- Choose whether to read or write.
The template generates a step that opens an input or output flat file cursor then iterate over it using an iterate step.
Iterate over an array template
This template generates an iterate step that iterates over one of the available arrays.
- Search and select
iterate over array
. - Choose the input array or none.
- Choose the output array or none.
The template generates a pre-configured iterate step with an input and output array.
Block step type template
To generate a block step, simply type try catch
, try catch finally
or try finally
and select any of these
templates from the content-assist pop-up. These templates can be searched using their respective initial letters like
tc
, tcf
, tf
, respectively.
Logging templates
These templates generate an invoke step which invokes one of the LoggerMethods
to log a message.
- Search a log level, either
info
,warn
,debug
,error
orprintln
then select it. - The Expression dialog will appear, where you can enter the message to be logged.
The template generates an invoke step which invokes the chosen LoggerMethods
function and adds a set expression on
the message
input of the method.
Fork true
/false
template
This template generates a fork step with two children, one with a true
label and one with a false
label.
- Search for
fork true/false
, then press to select it. - The content-assist pop-up will appear again; this time, select a step which will be executed if the expression
evaluates to
true
. The step you will choose will have the label oftrue
. - The content-assist pop-up will appear again; this time, select a step which will be executed if the expression
evaluates to
false
. The step you will choose will have the label offalse
. - The Expression dialog will appear, where you can then enter the expression of the fork step.