There are some concepts which apply to all types of configurations.
Converters
This section describes converters used in the system.
Example:
<converters>
<converter>
<name>groovy_epochDateParser</name>
<type>groovy</type>
<value><![CDATA[return new Date((prop =~ /.*Date\((\d+)\).*/)[0][1] as long)]]></value>
</converter>
<converter>
<name>conv_stringS4HANADateToDateTime</name>
<type>converterExpression</type>
<value>stringS4HANADateToDateTime</value>
</converter>
</converters>
Implementations
Currently, there are the following implementations of converters:
converterExpression
This implementation uses the element value to describe converterExpression. This is further used in a mapper definiton.
groovy
This implementation uses the element value to directly provide a Groovy script which will be used in mapper.
Use
Converters are referenced by their name in the metadata definition. This is very useful in custom transformer functions in which you define converter for type:
<transformer>
<language>groovy</language>
<script><![CDATA[
def mapping = [root: [:]]
def result = body.d.results[0]
result.entrySet().eachWithIndex { entry, i ->
if (!entry.key.startsWith('__')) {
mapping['root'][entry.key] = ['name': entry.key, 'type': 'string']
if (entry.key.contains('Date')) {
mapping['root'][entry.key]['type'] = 'Date'
mapping['root'][entry.key]['converterName'] = 'conv_stringS4HANADateToDateTime'
}
}
}
return mapping
]]></script>
</transformer>
Setting the converterName property for a field injects the actual converter into the metadata definition and further, e.g. in mapper.