Martini Services Editor
The Service Editor in Martini is a specialized tool for editing service files. Activated upon opening a service file (with a .gloop extension), this editor is designed to enhance the efficiency and accuracy of service development. It integrates a range of features like content-assist, validation, linting, and quick-fix suggestions. Additionally, it offers numerous keyboard shortcuts tailored for advanced users, ensuring a streamlined and productive development experience within Martini.
Components of the Service Editor
The Service Editor is divided into several key components, each contributing to a different aspect of service development. The primary components are:
-
Step Editor: This is the main area where service steps are defined and managed. It provides tools for creating, modifying, and organizing the steps involved in a service.
-
Mapper View: This view assists in mapping data between different parts of the service. It offers a visual interface to define and manipulate data mappings, making it easier to handle data transformation and integration tasks.
-
Input/Output View: This section displays the input and output structures expected by the service. It allows developers to define and modify the data schema that the service will consume and produce.
-
Properties View: Here, you can view and edit various properties related to the service. This includes settings for execution, configuration parameters, and other metadata.
Specialized Service Types
In addition to standard services, Martini supports various specialized service types, each with its dedicated editor. These include:
- Script services: Designed for scripting and automation tasks.
- SQL services: Tailored for services that interact with SQL databases.
- Cassandra services: Optimized for services working with Cassandra databases.
- MongoDB services: Specialized for services that utilize MongoDB.
Each of these service types has unique features and tools in their editors, catering to the specific needs of the service being developed.
Step Editor
The Step Editor is the core component of the Service Editor. It features two distinct tabs: the Source and Design tabs. The Source tab provides a view of the service's JSON definition, allowing for direct interaction with the underlying code. The Design tab, on the other hand, is the interactive interface for designing and modifying service steps.
Design Tab Components
Step Tree
- Functionality: The step tree in the Design tab illustrates the structure of the service, including the sequence and hierarchy of steps.
- Visualization: Each step is visually differentiated, with unique icons for different step types. This design choice simplifies understanding the step's purpose at a glance.
- Interactivity: Parent steps in the tree can be expanded or collapsed, offering a clear view of the service's structure. Alongside the tree, a ruler displays line numbers, breakpoints, and code errors, enhancing the debugging and editing process.
Toolbar
- Purpose: Located above the step tree, the toolbar facilitates navigation, modification, and provides details about the steps within the service.
Adding Steps
There are multiple methods to add steps to your service:
-
Toolbar:
- Click the plus-shaped green button.
- Select the step type from the drop-down menu.
-
Context Menu:
- Right-click on the step tree.
- Choose 'Add', then select the desired step type.
-
Keyboard Shortcuts:
- Utilize predefined shortcuts for adding specific step types.
-
Drag and Drop:
- For new steps: Drag and drop onto the step tree.
- For duplication: Select steps, then drag and drop with the Alt key pressed.
-
Content-Assist:
- Trigger with the '.' key.
- Search and select the step or service to add.
- Placement of the new step depends on the selected 'Add Mode' (Add To, Add After, Replace).
- Modifying keys (Shift for 'Add After', Ctrl for 'Replace') can alter the placement logic.
- If no step is selected, the new step is added at the end of the service.
Navigating the Add Mode
- Add To: Adds the new step under the selected step (default if the selected step can have children).
- Add After: Adds the new step after the selected step (default if the selected step cannot have children).
- Replace: Replaces the selected step with the new one. If a template generating multiple steps is used, only the first generated step replaces the selected one.
Use Shift for 'Add After' and Ctrl for 'Replace' while pressing Enter to confirm the addition.
Deleting Steps
Efficiently removing steps from your service is a crucial aspect of the editing process. The Step Editor provides three convenient methods to delete steps:
-
Using the Toolbar:
- First, select the steps you wish to delete.
- Click on the red 'x' button in the toolbar to remove the selected steps.
-
Using the Context Menu:
- Select the steps you intend to delete.
- Right-click to open the context menu.
- Choose 'Delete' from the options presented.
-
Using Keyboard Shortcuts:
- Select the step you want to delete.
- Simply press the 'Delete' key to remove the selected step.
Each of these methods offers a streamlined approach to modify the service's structure quickly and effectively, catering to different user preferences and scenarios.
Moving Steps
Adjusting the sequence of steps is essential for optimizing the flow and functionality of your service. Steps can be repositioned to better align with the intended logic and execution order. This can be done by moving steps vertically within their current hierarchy or horizontally to adjust their nesting level.
Directions for Moving Steps
- Vertically (Up/Down): Moving a step up or down alters its position relative to adjacent steps, effectively changing the execution order.
- Horizontally (Left/Right): Adjusting a step's horizontal position changes its nesting within the service's structure. Moving a step left makes it a sibling of its current parent, while moving it right nests it under a different parent step, enhancing the logical grouping.
Methods for Moving Steps
-
Using the Toolbar:
- Select the step(s) you wish to reposition.
- Utilize the arrowhead-shaped buttons on the toolbar to move the selected steps in the desired direction.
-
Using Keyboard Shortcuts:
- Keyboard shortcuts provide a quick method to move steps without the need for mouse interactions. Select your step and use the designated shortcuts to move it up, down, left, or right.
-
Via Dragging and Dropping:
- To reorganize steps, you can drag and select multiple steps (use Ctrl in the Desktop version or Alt in the Online version for multi-selection).
- Drop the steps at the new location within the service. Steps can be moved to a different point in the same service or into another service.
- Holding the Alt key while dragging and dropping will duplicate the steps instead of moving them, allowing you to replicate functionality easily.
Considerations for Moving Steps
Moving steps is a powerful way to refine your service's logic and structure. It's important to understand the hierarchical implications of these movements, ensuring that the service's functionality aligns with its intended behavior.
By utilizing these methods, developers can efficiently restructure their service, ensuring optimal execution flow and logical organization.
Copying and Pasting Steps
Basic Copy and Paste Operations
Copying and pasting steps between services or within the same service is a straightforward process that enhances workflow efficiency. Here’s how to do it:
-
Copy Steps:
- Select the steps you wish to copy.
- Press
Ctrl + C
or use the right-click context menu and select 'Copy'.
-
Paste Steps:
- Navigate to the target location within the same or a different service.
- Press
Ctrl + V
or use the right-click context menu and select 'Paste'.
This functionality allows for the rapid duplication and reorganization of service components.
Advanced Copy and Paste: Mapping and Expressions
You can also copy specific configurations, such as map lines or set expressions, from one step and paste them into another, streamlining the configuration process. Here’s how:
-
Copy Configuration:
- Select the map lines or set expressions you intend to copy.
- Press
Ctrl + C
or use the right-click context menu and select 'Copy'.
-
Paste Configuration:
- Select the target map or invoke step.
- Press
Ctrl + V
or use the right-click context menu and select 'Paste'.
The system validates the copied configurations before pasting to ensure compatibility.
Copying and Pasting JSON Text
Additionally, you can create new steps by copying and pasting JSON text directly into the step tree. This method supports the quick addition of predefined configurations:
- Copy the JSON text.
- Paste it into the step tree to generate a new step based on the JSON definition.
Expression Dialog
The Expression Dialog facilitates the editing of steps that involve expressions. It comprises:
- Text Area: For writing the expression.
- Model Tree: Displays available properties for the expression.
- Language Selector: Choose the expression language. Selecting plain text will insert the text as-is, without evaluation.
Content-Assist and Property Insertion
- Content-Assist: Activated by
Ctrl + Space
, it suggests variables, methods, and constructs relevant to the expression context. - Inserting Property Expressions: Use shortcuts or the context menu to insert property paths directly into your expression, with options for template strings and safe navigation.
Validation
Expressions are validated in real-time, with syntax or semantic errors highlighted. Hovering over an error reveals details to assist in correction.
Note: Certain features, like content-assist, may be exclusive to desktop versions of the platform.
Map Step Decoration
Simplified Display for Single Operations
Map steps with a single operation (either a declaration or a set expression) simplify their display in the step tree for enhanced readability. Depending on the operation, they are presented as either:
- Declaration:
Declare <property>=<expression>
- Assignment:
Set <property>=<expression>
This concise representation allows developers to quickly grasp the step's purpose without needing to expand its details.
Visual Representation of Map Lines and Set Expressions
Map lines and set expressions associated with a map or invoke step are listed beneath the step in the step tree when expanded. This arrangement provides direct access for editing or deleting these elements. Interacting with a map line or set expression through a double-click will navigate you to the corresponding view for further action:
- Map Lines: Opens the Mapper view and highlights the selected line.
- Set Expressions: Activates the Expression dialog for editing.
Indicators for Evaluated Expressions
An evaluated set expression is marked with an orange dot icon next to it. This visual cue signifies that the expression has been processed, offering a quick indicator of its status.
Managing Visibility of Map Lines and Set Expressions
By default, map lines and set expressions are displayed under their respective steps for immediate access. However, you can customize this visibility to suit your working preferences:
- To alter this setting, click on 'Filters' in the toolbar.
- Uncheck the option "Show Map lines and Set steps" to hide these details from the step tree view.
This flexibility allows developers to tailor the step tree's complexity to their current focus, either streamlining the view for higher-level structure or expanding it for detailed editing.
Fork Step and Break Step Decoration
The visual representation of fork and break steps within the step tree incorporates the expression directly associated with the step for immediate clarity. These steps are displayed with their respective expressions in a straightforward format:
- Fork Step: Presented as
Fork <expression>
. - Break Step: Similarly, if applicable, would follow the format
Break <expression>
.
This decoration approach ensures that developers can quickly understand the logic behind each fork or break step without needing to delve into detailed views. By presenting the key expression alongside the step type, it streamlines the process of reviewing and navigating complex service flows.
Iterate Step Decoration
The decoration of an iterate step in the step tree clearly communicates the data flow between input and output arrays, enhancing the readability and understanding of the step's function. The presentation varies depending on whether the iterate step operates with input arrays, output arrays, or both:
-
Both Input and Output Arrays: When the iterate step processes both input and output arrays, its decoration reflects this dual operation as follows:
1
Iterate <input array> → <output array>
-
Only Input Array: If the iterate step is configured with only an input array, the decoration simplifies to highlight the input:
1
Iterate <input array>
-
Only Output Array: Conversely, when only an output array is specified, the decoration focuses on the output, indicating the generation of new data:
1
Iterate → <output array>
This method of decoration ensures a clear and immediate understanding of the data transformation and flow within each iterate step, aiding developers in quickly grasping the service's logic and structure.
While Step Decoration
The visual representation of a while step in the step tree is designed for immediate clarity regarding its control flow logic. It is displayed with its conditional expression directly adjacent to the step name, providing a quick overview of the loop's criteria:
1 |
|
This format ensures developers can easily identify the condition governing the while loop, facilitating a better understanding of the service's execution flow and logic.
Script Step Decoration
The Script step in the step tree adapts its display based on the length and complexity of the script it encapsulates:
- Single-line Scripts: For scripts concise enough to fit in one line, the representation is straightforward, shown directly next to the step label:
1
Script <script>
- Multi-line Scripts: Scripts extending beyond a single line are displayed beneath the Script step when it's expanded. Each line is individually numbered and selectable for ease of review and editing. This detailed view can be toggled off for a cleaner step tree by navigating to 'Filters' on the toolbar and deselecting "Show Script lines".
Copying Script Lines
Martini allows for intuitive interaction with script lines directly within the step tree, facilitating easy copying for reuse or reference:
- To copy specific lines from a script, select the desired lines. These are clearly numbered for convenience.
- Use the copy shortcut (
Ctrl + C
orCmd + C
on macOS) or the right-click context menu and choose 'Copy' to copy the selected lines.
This functionality ensures that developers can efficiently manage and reuse script code within their services, enhancing productivity and consistency across service development.
Asynchronous Step Decoration
To visually distinguish asynchronous operations within the service workflow, concurrent steps and invoke steps that are configured to execute asynchronously are marked with a distinctive green thread overlay. This overlay appears on the top right corner of the step's icon, signaling its asynchronous behavior at a glance.
This visual cue helps developers quickly identify which components of their service are designed to run concurrently, enhancing readability and facilitating a deeper understanding of the service's execution flow.
Invoke Step Decoration
Invocation Signature
The invoke step in the service editor is detailed with an invocation signature, which outlines the method's structure and provides essential insights into its operation. The signature includes the service's return type, name, input parameters, and any exceptions it may throw, formatted as follows:
1 |
|
Parameter Visibility
- Assigned Parameters: Parameters that are explicitly assigned through a map line, set expression, or have a default value are displayed within the signature with their respective assignments.
- Unassigned Parameters: Parameters without an explicit assignment are indicated as
null
in the signature to highlight their lack of assignment.
Evaluated Set Expressions
- An orange dot appears next to parameters that are assigned through evaluated set expressions, providing a visual indicator of dynamic evaluation.
- Visibility of method signatures and these dynamic indicators can be toggled through the 'Filters' option on the toolbar by un-checking "Show method signatures".
Named Parameters
- The signature also includes the name and value of each parameter in the format
<parameter name>: <parameter value>
, enhancing the readability and clarity of the invocation. - This detailed visibility of named parameters can be adjusted via the 'Filters' menu by un-checking "Show named parameters".
Content-Assist
Content-assist in Martini is engineered to boost productivity by offering an intuitive way to quickly insert and configure steps within services. This feature accelerates the development process by providing pre-configured steps and configuration guidance.
Activating Content-Assist
To activate content-assist:
1. Press .
at the location in your service where you wish to insert a step.
2. A pop-up will emerge, displaying a search field and a list of proposals relevant to the context of your code. Each proposal is categorized and labeled for easy identification.
Navigating Proposals
- Categories: You can filter through proposal categories by pressing
Ctrl + Space
. The upcoming category is highlighted in the pop-up's bottom right corner. - Search: Proposals can be found by typing their full or abbreviated names in the search field.
- Selection: Utilize the Up and Down arrow keys to navigate through proposals while keeping focus on the search field for efficient selection and search.
Proposal Categories
The table below summarizes the categories of proposals available, along with their descriptions:
Category | Description |
---|---|
Step | Basic, unconfigured steps for service logic |
Flat File Descriptor | Operations for reading or writing flat files |
Invoke Service | Invocation of different types of services (e.g., code services) |
Templates | Configured groups of steps or patterns for common logic implementations |
Applying Proposals
Upon selecting a proposal, additional details appear in a contextual pop-up. Steps are automatically integrated into the service at the current or a directly subsequent position, depending on the structural capacity of the selected location. Using Shift
+ Enter
modifies the insertion behavior to place steps sequentially after the selected point.
Searching and Applying Proposals
- Initiate a search by typing immediately after activating content-assist.
- Short names enable quick access to frequently used proposals (e.g., "tcf" for a try-catch-finally structure).
- Cycling to the first or last proposal is made simple with directional keys.
Special Proposals: Templates
Templates represent a powerful subset of proposals designed for quick instantiation of common service patterns or logic:
- Flat File Descriptor Template: Automates the creation of steps for flat file operations.
- Iterate Over Array Template: Simplifies the process of iterating over arrays with pre-configured steps.
Selecting a template may require additional inputs to customize the generated steps to fit specific service requirements.
Block Step Template
Martini's content-assist feature includes templates for quickly generating structured block steps, streamlining the process of implementing error handling and control flow within your services. To utilize these templates:
- Activate content-assist by pressing
.
where you want to insert a block step. - Begin typing the pattern you need, such as
try catch
,try catch finally
, ortry finally
. - As you type, content-assist will display matching templates. Select the appropriate template from the content-assist pop-up.
Searching Templates by Initials
For an even faster selection, you can search for these templates using their respective initial letters:
- TC: For try catch
blocks.
- TCF: For try catch finally
blocks.
- TF: For try finally
blocks.
This method allows you to quickly navigate through content-assist proposals and insert complex block structures efficiently, enhancing the robustness and readability of your service logic.
Logging Templates
Logging templates are designed to facilitate quick insertion of logging functionality within your service. By generating an invoke step tailored to utilize specific logging methods, these templates simplify the process of adding comprehensive logging:
- Selecting a Log Level: Begin by searching for your desired log level—options include info, warn, debug, error, or println. Select the appropriate level from the content-assist pop-up.
- Entering the Log Message: Upon selection, the Expression dialog will open. Here, you can specify the message you wish to log.
The completion of these steps results in the automatic generation of an invoke step. This step is configured to call the selected logging method, equipped with a set expression that directly inputs your specified message into the method's logging function.
Fork True/False Template
The Fork True/False template simplifies the creation of conditional branching within your service, enabling the definition of distinct paths based on a boolean condition:
- Initiating the Template: Begin by searching for the "fork true/false" option. Once found, press Enter to select it. This action triggers the content-assist feature, prompting the next steps.
- Configuring the True Path: The content-assist pop-up will reappear, allowing you to select a step to execute when the condition evaluates to true. Choose a step, and it will automatically be labeled as "true."
- Configuring the False Path: A subsequent pop-up asks for the selection of a step for when the condition evaluates to false. Select the desired step, which will then be labeled as "false."
- Specifying the Condition: Finally, the Expression dialog opens for you to enter the conditional expression that dictates the fork's branching logic.
By following these steps, the template effectively generates a fork step with two child steps, designated for the true and false outcomes of the specified condition, streamlining the process of implementing conditional logic within your services.