Skip to content

Martini Services Iterate Step

Overview

The Iterate Step is a fundamental component in Martini, akin to the 'for' loop in many programming languages. Its primary function is to sequentially process elements in an array, facilitating operations such as mappings or transformations.

Key Properties

  1. Input Array: Determines the array to be iterated over. Each element in this array triggers the execution of child steps within the Iterate Step.

  2. Output Array: Facilitates mapping or transforming data from the input array to this array. By default, it overwrites existing entries. However, this behavior can be adjusted to append new entries instead.

  3. Append Property: Altering this property from false to true allows the Iterate Step to continuously add records to the Output Array, irrespective of the Input Array's size.

Display in Editor

  • Single Array Configuration: If only the Input Array is set, the Iterate Step will display as Iterate over <inputArrayName> in the service editor.
  • Dual Array Configuration: With both Input and Output Arrays configured, the display changes to Iterate over <inputArray> → <outputArray>.

Additional Features

  • Delay Option: Configurable delay at the end of each iteration.
  • Cursor Management: Automatic closure of cursors upon completion of iterations.

Variables Introduced

  • $index: Zero-based index counter for each iteration.
  • $count: One-based total count of iterations.

Mapper View Integration

In the context of an Iterate Step, the array being processed will be represented as a single item in the Mapper view. This changes the typical display, highlighting the $index and $count variables, and alters the representation of the iterated array.

Quick Iteration Setup

To iterate over an existing array in the Mapper view: 1. Activate content-assist by pressing . in the editor. 2. Select Iterate over array. 3. Specify the Input and Output Arrays as prompted.

This automatic setup simplifies the process of configuring the Iterate Step, streamlining the development workflow.