The mapping-table functionality in Micro Focus IDM is a great feature to store ‘IF A THEN RETURN B’ results. Unfortunately, this is as far as the logic can be stretched. Basically, the mapping-table allows data to be stored and retrieved based on only one condition. Therefore, it is not possible to say ‘IF A AND B THEN RETURN C’. There is, however, a solution to this problem: store the mapping-table in operation-data and use XPATH to retrieve the data you are looking for.

By using XPATH, you can retrieve data using the code shown below.

<do-set-local-variable name="varMappingTableData">
    <arg-node-set>
    <token-xpath expression="./operation-data/mapping-table/row/@columnC[contains(../@columnA,'value1') and contains(../@columnB,'value2')]"/>
  </arg-node-set>
</do-set-local-variable>

This code will return, in a node-set, those values contained in column C where column A and column B resolve to ‘true’. The code to store a mapping-table in operation-data is shown below, along with a sample mapping-table. Once the data is stored, it is up to you to determine how best to use XPATH to get at the data you want.

The Mapping Table

<mapping-table>
    <col-def name="attribute-name"/>
    <col-def name="attribute-type"/>
    <col-def name="required"/>
    <col-def name="default-value"/>
    <col-def name="mapping"/>
    <row>
        <col>nspmDistributionPassword</col>
        <col>source</col>
        <col>true</col>
        <col/>
        <col>@@password@@</col>
    </row>
    <row>
        <col>Password Expiration Time</col>
        <col>source</col>
        <col>true</col>
        <col/>
        <col>@@expirationTime@@</col>
    </row>
</mapping-table>

The Code

<rule>
<description>[Mapping-table] Add in operation-data for attributes</description>
<conditions>
<and>
<if-xpath op="true">string-length(./@webservice-mapping) > 0</if-xpath>
</and>
</conditions>
<actions>
<do-set-local-variable name="varMappingTableLocation" scope="policy">
<arg-string>
<token-xpath expression="./@webservice-mapping"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="varMappingTable" scope="policy">
<arg-node-set>
<token-xml-parse>
<token-base64-decode>
<token-src-attr name="DirXML-Data">
<arg-dn>
<token-xpath expression="$varMappingTableLocation"/>
</arg-dn>
</token-src-attr>
</token-base64-decode>
</token-xml-parse>
</arg-node-set>
</do-set-local-variable>
<do-set-local-variable name="varColumnNumber">
<arg-string>
<token-xpath expression="count($varMappingTable/mapping-table/col-def)"/>
</arg-string>
</do-set-local-variable>
<do-append-xml-element expression="./operation-data" name="webservice-data"/>
<do-for-each>
<arg-node-set>
<token-xpath expression="$varMappingTable/mapping-table/row"/>
</arg-node-set>
<arg-actions>
<do-append-xml-element expression="./operation-data/webservice-data" name="attribute"/>
<do-set-local-variable name="varCounter">
<arg-string>
<token-text>0</token-text>
</arg-string>
</do-set-local-variable>
<do-while>
<arg-conditions>
<and>
<if-local-variable mode="numeric" name="varCounter" op="lt">$varColumnNumber$</if-local-variable>
</and>
</arg-conditions>
<arg-actions>
<do-set-local-variable name="varHeader">
<arg-string>
<token-xpath expression="$varMappingTable//col-def[$varCounter + 1]/@name"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="varValue">
<arg-string>
<token-xpath expression="$current-node//col[$varCounter + 1]/text()"/>
</arg-string>
</do-set-local-variable>
<do-set-local-variable name="varCounter">
<arg-string>
<token-xpath expression="$varCounter + 1"/>
</arg-string>
</do-set-local-variable>
<do-trace-message color="brblue">
<arg-string>
<token-text xml:space="preserve">Parsing column [</token-text>
<token-local-variable name="varCounter"/>
<token-text xml:space="preserve">] of mapping-table [</token-text>
<token-local-variable name="varMappingTableLocation"/>
<token-text xml:space="preserve">] - adding header '</token-text>
<token-local-variable name="varHeader"/>
<token-text xml:space="preserve">' with value '</token-text>
<token-local-variable name="varValue"/>
<token-text xml:space="preserve">' to webservice-data</token-text>
</arg-string>
</do-trace-message>
<do-set-xml-attr expression="./operation-data/webservice-data/attribute[last()]" name="$varHeader$">
<arg-string>
<token-xpath expression="$varValue"/>
</arg-string>
</do-set-xml-attr>
</arg-actions>
</do-while>
</arg-actions>
</do-for-each>
</actions>
</rule>