Nav

Defining Metadata Using Edit Fields

When defining or updating input and output metadata for the different data types supported by Anypoint DataMapper, you use one of several very similar editors to create the structure and define fields, elements and attributes. Any of these editors is opened by selecting Edit Structure.

edit_structure

This document describes the use of the editor for key/value maps. The editors for other structured data are substantially similar, and the editors for flat data like CSV files are similar but simplified. 

DataMapper continues to be fully supported in all current and future versions of Mule 3.x, however it will be removed in Mule 4.0 in favor of the Transform Message component (based on DataWeave code). We recommend that if you wish to take advantage of the new capabilities of DataWeave or if you start new projects, upgrade now.

A migration tool is now included in Anypoint Studio, which assists in converting a DataMapper map to DataWeave. From the Anypoint Studio Canvas, right-click a DataMapper building block, select Migrate to DataWeave, and follow the instructions.

dw migrator

If you don’t see DataMapper on your palette, you can enable it by going to Preferences > Anypoint Studio > Palette Profiles and clicking the checkbox Show deprecated Mule Components and Attributes.

This document assumes the reader is familiar with the DataMapper Transformer. Consult the DataMapper User Guide and Reference document for details.

About the Examples

The illustrations used in this document are taken from the discussion "Shortcut: Creating Output Metadata based on Defined Input Metadata" in Defining DataMapper Input and Output Metadata. If you want to reproduce the tasks described here, follow the steps in the example in that discussion to set up your environment.

You can edit data structure definitions (that is, fields) in an existing DataMapper transformer within the Input and Output panes of its DataMapper View. Consult Updating Metadata in an Existing Mapping for details.

Adding a Field

  1. Click contacts to select the parent element for the new field. (This step does not apply when working with flat data like CSV or fixed width files.)

  2. Click the (plus) icon in the upper-left corner of the editor panel to create a new field under the selected parent. Alternatively, right-click the existing parent and select Add.

    3-2-edit.indiv.fields

    A new field is inserted.

  3. Click the field label to edit the name of the field, then press Enter.

    4-2-edit.indiv.fields

Alternative Method

  1. In the Edit Map Fields panel, right-click the parent element in the editor pane.

  2. Select Add to create a new field (see below, left; the new field is labeled field0 ).

  3. Click the field label o edit the name of the field, then press enter.

Renaming a Field

  1. To rename a field, click the field name.

  2. Type in the new field name, then press enter.

Modifying a Field’s Type

To change the type of a field:

  1. Click the field’s type in the Type column.

  2. Use the drop-down menu to select a new field type. 

    5-select.field.type

  3. Click outside the type menu to deselect the type value.

Deleting a Field

Use one of the following three methods to delete a field.

  • Right-click the field name, then select Remove from the drop-down menu.

  • Click to select the field, then press the red "X" icon in the upper-left corner of the editor panel.

  • Click to select the field, then press Delete (not Backspace). (On a Mac keyboard, press fn+delete.)

Changing the Order of Fields

To re-order the fields, such as changing the order of columns in a CSV file:

  1. Select the field to be moved to a new position.

  2. Click the up and down arrows until the field is in the desired position.

  3. Click OK when finished.