TDIing out loud, ok SDIing as well

Ramblings on the paradigm-shift that is TDI.

Wednesday, January 13, 2016

Externalizing an Attribute Map to a file

Hit the More... button at the top of the AttMap - to the right of the Add and Delete buttons - and select Change inheritance. In the resulting dialog click External attribute map and select a file.

The external mapping feature of TDI uses text files that contain one or more mapping rules. Each mapping rule looks like this: name=assignment. Here is an example of a mapping rule:


This example rule specifies output attribute named 'uid'. The assignment follows the equal sign (=) and is empty in this example. As you can see from Table 1 below, this indicates that the value will come from a similarly named attribute found in the Work Entry. To explicitly specify the source attribute you must write a snippet of Javascript:


Now the value written for 'uid' will come from the work Entry attribute named 'employeeCode'.

If more complex script is needed to compute the value for a mapping assignment, you can use square-brackets notation shown in the first table below. This allows you to include multiple lines of Javascript for a single mapping rule.

Table 1: External mapping file syntax
When the assignment is empty then simple mapping is used.

In the example rule shown in the left column, the attribute named 'sn' gets its value(s) from a similarly named attribute in the source Entry. For an Input Map this would be the 'sn' attribute of the conn Entry. For all other map types (Output Maps or Attribute Map components) the source will be the work Entry.
Anything entered after the equal sign is considered the assignment of the mapping rule. It must be a snippet of Javascript, unless the Text with Substitution flag is used: {S}

In the example rule shown in the left column, the 'status' attribute will get the value specified by the Javascript snippet, resulting in the literal string value Updated
first = work.FirstName
last = work.LastName
return first + " " + last
Using square brackets as shown allows the Javascript assignment to stretch over multiple lines.

In the example mapping rule, a full name value is returned by concatenating the FirstName and LastName attributes in the Work Entry.

Flags can also be specified to control the behavior of a mapping rule. These flags must appear in curly braces immediately after the name of the attribute being mapped. Valid flags are: AM and S

The A and M flags correspond to the Add and Mod columns in the Output map of a Connector in Update mode, and control whether this attribute is mapped during Add and Modify operations. 

The S flag denotes that the assignment uses the TDI Text with Substitution feature, which allows for literal text values that can include one or more substitution tokens.

 For example:


Now the 'uid' attribute will only included when creating new entries (Add operations).

Table 2: Example mapping rule flags
The 'A' and 'M' flags are used to control when this attribute is enabled with regards to the Add and Modify operations of a Connector in Update mode. By default, attributes will be included for both Add and Modify operations unless only one is specified: A or M.

The A flag shown in this example specifies that the 'objectClass' attribute should only be mapped for Add operations.
The 'S' flag indicates that the following mapping rule uses Text with Substitution. As a result, any curly braces found will be replaced with the value of the substitution token specified in the braces.

For this example, the value of the uid attribute in the Work Entry is substituted for the token {work.uid} and then the literal string ' ' is appended to it. The resulting string is returned as the value for 'mail'.