Red Hat Training

A Red Hat training course is available for Red Hat Fuse

Chapter 6. Mapping data to fields for the next connection

In most integrations, you need to map data fields that have been obtained or processed to data fields that the next connection can process. Ignite provides a data mapper to simplify doing this. In an integration, at each point where you need to map data fields, add a data mapper step. Details for mapping data fields are in the following topics:

6.1. About mapping data

The data mapper displays:

  • Sources - a list of the data fields that are obtained or processed in each previous step
  • Target - a list of the data fields that are processed in the next connection

According to the needs of your integration, you can:

  • Map one source field to one target field. This is the default mapping behavior. For example, map the Name field to the CustomerName field.
  • Combine multiple source fields into one target field. For example, map the FirstName and LastName fields to the CustomerName field.
  • Separate a source field into multiple target fields. For example, map the Name field to the FirstName and LastName fields.
  • Transform the target field to specify how Ignite stores it. For example, pad or trim the target field value, capitalize the first letter in a string, or create a time stamp.

6.2. Finding the data field you want to map

In an integration that has a few steps or that operates on a small set of data, it is probably easy to find the data field you want to map. But in an integration that has many steps, or that has a step that accesses a large set of data, the list of data fields might be very long. To quickly find the data field you want to map, you can:

  • Search for it. The Sources panel and the Target panel each have a search field at the top. If the search field is not visible, click Magnifying Glass at the top right of the Sources or Target panel.
  • Enter the names of the fields that you want to map. To do this, in the upper right of the Configure Mapper page, click the plus sign to display the Mapping Details panel. In the Sources section, enter the name of the source field. In the Action section, accept the default Map, which maps one field to one other field. Or, select Combine or Separate. In the Target section, enter the name of the field that you want to map to.
  • Expand and collapse folders to limit the visible fields. To view the data fields available in a particular step, expand the folder for that step.

    As you add steps to an integration, Ignite numbers and renumbers them to indicate the order in which the integration processes the steps. When you are creating or editing an integration, these numbers are visible in the integration visualization panel on the left. When you add a data mapping step, the step numbers appear in the folder labels in the Sources panel and in the Target panel.

    The folder label also displays the name of the data type that is output by that step. Connections to applications such as Twitter, Salesforce, and SQL define their own data types. For connecting to applications such as Amazon S3, AMQ, AMQP, Dropbox, and FTP/SFTP, you define the connection’s input and/or output type when you add the connection to an integration and select the action that the connection performs. When you specify the data type, you also give the type a name. The type name you specify appears as the name of a folder in the data mapper. If you specified a description when you declared the data type, then the type description appears when you hover over the step folder in the mapper.

6.3. Identifying where data mapping is needed

To identify where data mapping is needed:

  1. When you are creating or editing an integration, add all connections to the integration.
  2. In the integration visualization panel on the left, look for any Warning icons.
  3. Click the icon to see the message. A Data Type Mismatch notification indicates that you need to add a data mapper step before that connection.

To see the input type or output type for a particular connection:

  1. In the Ignite left panel, click Integrations.
  2. In the list of integrations, identify the integration that has the connection whose input type or output type you want to know.
  3. At the right of that integration’s entry click Kebab .
  4. Select Edit.
  5. In the integration’s visualization panel, to the right of a connection, click Info to display information about that connection, including its input and/or output type.

6.4. Mapping one source field to one target field

The default mapping behavior maps one source field to one target field. To do this:

  1. In the Sources panel, click the data field you want to map from.

    You might need to expand an integration step to see the data fields that it provides.

    When there are many source fields, you can search for the field of interest by clicking the Magnifying Glass and entering the name of the data field in the search field.

  2. In the Target panel, click the data field you want to map to.

The data mapper displays a line that connects the two fields you just selected.

To confirm that the mapping is defined, in the upper right, click Grid to display the defined mappings. Click Grid again to display the data field panels.

Here is another way to map a single source field to a single target field:

  1. In the Configure Mapper page, in the upper right, click the plus sign to display the Mapping Details panel.
  2. In the Sources section, enter the name of the source field.
  3. In the Action section, accept the default Map action.
  4. In the Target section, enter the name of the field that you want to map to and click Enter.

6.5. Combining multiple source fields into one target field

To combine the content from multiple source fields into one target field:

  1. In the Target panel, click the field into which you want to map more than one source field.
  2. In the Mapping Details panel, under Action, select Combine.
  3. In the Mapping Details panel, under Source, start to overtype [None] with the name of the first source field that you want to map into the target field.
  4. When the name of the first source field appears, click it. The data mapper displays a line from the first source field to the target field.
  5. For each additional source field:

    1. In the Mapping Details panel, click Add Source.
    2. Start to overtype Search with the name of the next source field.
    3. When the name of the next source field appears, click it. The data mapper displays another line to the target field but this line is from this source field.
  6. In the Mapping Details panel, in the Separator field, accept or select the character that the data mapper inserts in the target field between the source fields. The default is a space.

In the data mapper, blue lines indicates the current focus.

To confirm that the mapping is correctly defined, click Grid to display the mappings defined in this step. A mapping that combines the values of more than one source field into one target field looks like this: Combine Fields Mapping .

6.6. Separating one source field into multiple target fields

To separate and map the content in one source field to multiple target fields:

  1. In the Sources panel, click the field you want to map.
  2. If the Mapping Details panel is not already visible to the right of the Target panel, in the upper right, click the plust sign to display it.
  3. In the Mapping Details panel, under Action, click the down caret and select Separate.
  4. Below that, under Targets, click in Search and start to type the name of the first target data field.
  5. When the name of the first target data field appears, click it. The data mapper displays a line from the source field to the first target field.
  6. For each additional target field:

    1. In the lower right, click Add Target.
    2. In the new target, click in Search and start to type the name of the next target field.
    3. When the name of the next target data field appears, click it. The data mapper displays another line from the same source field, but this time it goes to this target data field.
  7. In the Mapping Details panel, in the Separator field, accept or select the character that indicates where to separate the source data field value. The default is a space.

In the data mapper, blue lines indicates the current focus.

To confirm that the mapping is correctly defined, click Grid to display the mappings defined in this step. A mapping that separates the value of a source field into multiple target fields looks like this: Separate Fields Mapping .

6.7. Transforming target data

After you define a mapping, you can transform the data in the target field to define how you want to store the date. For example, you could specify the Capitalize transformation to ensure that the first letter of a data value is uppercase.

To transform a target field:

  1. Create the mapping whose target you want to transform.
  2. In that mapping, click the target field you want to transform.
  3. In the Mapping Details panel, click Add Transformation.
  4. Click the down caret to display the list of transformations.
  5. Click the transformation you want to perform.
  6. If the transformation requires any input parameters, specify them in the appropriate input fields.

See Section 6.8, “Descriptions of available transformations”.

6.8. Descriptions of available transformations

The following table describes the available transformations. The date and number types refer generically to any of the various forms of these concepts. That is, number includes, for example, integer, long, double. Date includes, for example, date, Time, ZonedDateTime.

TransformationInput TypeOutput TypeParameter (* = required)Description

AbsoluteValue

number

number

None

Return the absolute value of a number.

AddDays

date

date

days

Add days to a date. The default is 0 days.

AddSeconds

date

date

seconds

Add seconds to a date. The default is 0 seconds.

Append

string

string

string

Append a string to the end of a string. The default is to append nothing.

Camelize

string

string

None

Convert a phrase to a camelized string by removing whitespace, making the first word lowercase, and capitalizing the first letter of each subsequent word.

Capitalize

string

string

None

Capitalize the first character in a string.

Ceiling

number

number

None

Return the whole number ceiling of a number.

Contains

any

Boolean

value

Return true if a field contains the specified value.

ConvertAreaUnit

number

number

fromUnit*

toUnit *

Convert a number that represents an area to another unit. For each of the fromUnit and toUnit parameters, specify a string whose value is Square Foot, Square Meter, or Square Mile.

ConvertDistanceUnit

number

number

fromUnit *

toUnit *

Convert a number that represents a distance to another unit. For each of the fromUnit and toUnit parameters, specify a string whose value is Foot, Inch, Meter, Mile, or Yard.

ConvertMassUnit

number

number

fromUnit *

toUnit *

Convert a number that represents mass to another unit. For each of the fromUnit and toUnit parameters, specify a string whose value is Kilo Gram or Pound.

ConvertVolumeUnit

number

number

fromUnit *

toUnit *

Convert a number that represents volume to another unit. For each of the fromUnit and toUnit parameters, specify a string whose value is Cubic Foot, Cubic Meter, Gallon US Fluid, or Liter.

DayOfWeek

date

number

None

Return the day of the week (1 through 7) that corresponds to the date.

DayOfYear

date

number

None

Return the day of the year (1 through 366) that corresponds to the date.

EndsWith

string

Boolean

string

Return true if a string ends with the specified string, including case.

Equals

any

Boolean

value

Return true if a field is equal to the specified value, including case.

FileExtension

string

string

None

From a string that represents a file name, return the file extension without the dot.

Floor

number

number

None

Return the whole number floor of a number.

Format

any

string

template *

In template, replace each placeholder (such as %s) with the value of the input field and return a string that contains the result. This is similar to mechanisms that are available in programming languages such as Java and C.

IndexOf

string

number

string

In a string, starting at 0, return the first index of the specified string. Return -1 if it is not found.

IsNull

any

Boolean

None

Return true if a field is null.

LastIndexOf

string

number

string

In a string, starting at 0, return the last index of the specified string. Return -1 if it is not found.

Length

any

number

None

Return the length of the field, or -1 if the field is null.

Lowercase

string

string

None

Convert a string to lowercase.

Normalize

string

string

None

Replace consecutive whitespace characters with a single space and trim leading and trailing whitespace from a string.

PadStringLeft

string

string

padCharacter *

padCount *

Insert the character supplied in padCharacter at the beginning of a string. Do this the number of times specified in padCount.

PadStringRight

string

string

padCharacter *

padCount *

Insert the character supplied in padCharacter at the end of a string. Do this the number of times specified in padCount.

Prepend

string

string

string

Prefix string to the beginning of a string. the default is to prepend nothing.

ReplaceAll

string

string

match *

newString

In a string, replace all occurrences of the supplied matching string with the supplied newString. The default newString is an empty string.

ReplaceFirst

string

string

match *

newString *

In a string, replace the first occurrence of the specified match string with the specified newString. The default newString is an empty string.

Round

number

number

None

Return the rounded whole number of a number.

SeparateByDash

string

string

None

Replace each occurrence of whitespace, colon (:), underscore (_), plus (+), and equals (=) with a hyphen (-).

SeparateByUnderscore

string

string

None

Replace each occurrence of whitespace, colon (:), hyphen (-), plus (+), and equals (=) with an underscore (_).

StartsWith

string

Boolean

string

Return true if a string starts with the specified string (including case).

Substring

string

string

startIndex *

endIndex

Retrieve a segment of a string from the specified inclusive startIndex to the specified exclusive endIndex. Both indexes start at zero. startIndex is inclusive. endIndex is exclusive. The default value of endIndex is the length of the string.

SubstringAfter

string

string

startIndex *

endIndex

match *

Retrieve the segment of a string after the specified match string from the specified inclusive startIndex to the specified exclusive endIndex. Both indexes start at zero. The default value of endIndex is the length of the string after the supplied match string.

SubstringBefore

string

string

startIndex *

endIndex

match *

Retrieve a segment of a string before the supplied match string from the supplied inclusive startIndex to the supplied exclusive endIndex. Both indexes start at zero. The default value of endIndex is the length of the string before the supplied match string.

Trim

string

string

None

Trim leading and trailing whitespace from a string.

TrimLeft

string

string

None

Trim leading whitespace from a string.

TrimRight

string

string

None

Trim trailing whitespace from a string.

Uppercase

string

string

None

Convert a string to uppercase.

6.9. Viewing the mappings in a step

While you are adding or editing a data mapper step, you can view the mappings already defined in this step. This lets you check whether the correct mappings are in place.

To view mappings when you are already in the data mapper, in the upper right, click grid .

To dismiss the list of mappings and redisplay the source and target fields, click grid again.

To view mappings when you are editing an integration but you are not adding or editing a data mapper step:

  1. In the integration visualization panel on the left, click the data mapper step for which you want view the defined mappings.
  2. In the data mapper, in the upper right, click grid .

To view mappings when you are not editing a data mapper step:

  1. In the left panel, click Integrations.
  2. In the entry for the integration whose data mappings you want to view, on the right, click the Three Vertical Dots .
  3. In the popup menu, click Edit.
  4. In the integration visualization panel on the left, click the data mapper step for which you want view the defined mappings.
  5. In the data mapper, in the upper right, click grid .