HomeGuides
Log In
Guides

Mapping Functions

Functions in this category can be used for parsing field mapping strings in the format generated by the Field mapping editor for graph parameters.

The mapping may contain multiple sources and a single target. Mappings from one source are separated with a semicolon ;, the sources are separated with a hash #. Source and target fields are separated with an equals sign =, the target field is on the left-hand side. Both source and field names start with a dollar sign $. The mapping is M:N, in other words, a source field can be mapped to multiple target fields and multiple source fields can be mapped to one target field. See examples below for sample mapping strings.

getMappedSourceFields

string[] getMappedSourceFields( string mapping, string targetField, integer sourceIndex );
string[] getMappedSourceFields( string mapping, string targetField );
string[] getMappedSourceFields( string mapping );

The function getMappedSourceFields() returns a list of fields from the specified source (indexed from 0) mapped to a target field with the specified name.
If the source index is omitted, returns fields from all sources mapped to a target field with the specified name. Note that the result can be ambiguous if the sets of source fields are not disjoint.
If the target field name is omitted as well, returns all source fields that are mapped to some target field.
The function throws an exception, if the mapping is invalid or null. Also, if sourceIndex is out of bounds or null, an exception is thrown.

Example 254. Usage of getMappedSourceFields()
getMappedSourceFields("$target1=$srcA1;$target3=$srcA1;#$target1=$srcB4;$target2=$srcB2;", "target1", 1) returns ["srcB4"]
getMappedSourceFields("$target1=$source1;$target1=$source3;$target3=$source4;", "target1") returns ["source1", "source3"]
getMappedSourceFields("$target1=$source1;$target1=$source3;$target3=$source4;") returns ["source1", "source3", "source4"]

See also: getMappedTargetFields, isSourceFieldMapped

getMappedTargetFields

string[] getMappedTargetFields( string mapping, string sourceField, integer sourceIndex );
string[] getMappedTargetFields( string mapping, string sourceField );
string[] getMappedTargetFields( string mapping );

The function getMappedTargetFields() returns a list of target fields that are mapped from a field with the specified name from the specified source (indexed from 0).
If the source index is omitted, it returns target fields mapped from fields with the specified name from any source.
If the source field name is omitted as well, it returns target fields that have a mapping.
The function throws an exception, if the mapping is invalid or null. Also, if sourceIndex is out of bounds or null, an exception is thrown.

Example 255. Usage of getMappedTargetFields()
getMappedTargetFields("$target1=$src1;$target3=$src1;#$target1=$src4;$target2=$src1;", "src1", 1) returns ["target2"]
getMappedTargetFields("$target1=$src1;$target3=$src1;#$target1=$src4;$target2=$src1;", "src1") returns ["target1", "target3", "target2"]
getMappedTargetFields("$target1=$source1;$target1=$source3;$target3=$source4;") returns ["target1", "target3"]

See also: getMappedSourceFields, isTargetFieldMapped

isSourceFieldMapped

string[] isSourceFieldMapped( string mapping, string sourceField, integer sourceIndex );
string[] isSourceFieldMapped( string mapping, string sourceField );

The function isSourceFieldMapped() returns true if there is a mapping from the field with the specified name from the specified source to some target field.
If the source index is omitted, returns true, if there is a field with the specified name in any of the sources that is mapped to some target field.
The function throws an exception, if the mapping is invalid or null. Also, if sourceIndex is out of bounds or null, an exception is thrown.

Example 256. Usage of isSourceFieldMapped() isSourceFieldMapped("$target1=$srcA1;$target3=$srcA1;#$target1=$srcB4;$target2=$srcB2;", "srcB2", 1) returns true
isSourceFieldMapped("$target1=$srcA1;$target3=$srcA1;#$target1=$srcB4;$target2=$srcB2;", "srcB2", 0) returns false
isSourceFieldMapped("$target1=$source1;$target1=$source3;$target3=$source4;", "source3") returns true
isSourceFieldMapped("$target1=$source1;$target1=$source3;$target3=$source4;", "source2") returns false

See also: getMappedSourceFields, isTargetFieldMapped

isTargetFieldMapped

string[] isTargetFieldMapped( string mapping, string targetField );

The function isTargetFieldMapped() returns true if there is a mapping from any source field to the specified target field.
The function throws an exception if the mapping is invalid or null.

Example 257. Usage of isTargetFieldMapped()
isTargetFieldMapped("$target1=$srcA1;$target3=$srcA1;#$target1=$srcB4;$target2=$srcB2;", "target2") returns true
isTargetFieldMapped("$target1=$source1;$target1=$source3;$target3=$source4;", "target2") returns false

See also: getMappedTargetFields, isSourceFieldMapped