Attribute mapping for ingested data
Use Regular expressions, BeanShell scripts and SQL statements to map attributes.
When data flows between systems, it is often not possible to just pass the information as it is. Often it has to be split, joined, merged, transformed, reformatted, matched or restructured. This is almost always the case when information enters or leaves the censhare system. Examples are the interfaces to advertising systems, where information has to be converted from a businesslike manner to production structures, or the extraction of metadata within images, that have to be mapped to censhare’s metadata structure and normalized in their encodings.
As those conversion tasks can become arbitrarily complex, censhare provides a dedicated small metalanguage for data migration, the Attribute mapping language. Documents in this language are plain XML and normally part of a set of configuration files of a server module. The internal workflow requires a source-specific parser (for example an Exif-parser or a SAP communication interface) that prepares the source data as hierarchical XML structure. This structure is piped to the attribute mapper, which produces a target XML structure according to the attribute mapping rules. A post-process incorporates the data into the censhare database (incoming data) or to a file (exported data).
The Attribute mapping language allows the inclusion of Regular Expressions and BeanShell scripts. It is possible to execute direct SQL statements within the Attribute mapping language.
Syntax examples
Simple passing of an attribute:
<mapping src="source_attribute" dest="target_attribute"/>
Reformatting of the source attribute with Regular Expression:
<mapping src="@source_year" dest="@target_year" regex="..$"/>
Mapping of individual values of an attribute with default rule:
<mapping src="@objekt" dest="@domain">
<map default="root.">
<entry key="1" value="root.a."/>
<entry key="3" value="root.b."/>
<entry key="2" value="root.c."/>
</map>
</mapping>
Combination of attributes into one (with default separator):
<mapping separator=", " dest="@annotation" text-format="{1}, {0}">
<src key="@firstname" default=""/>
<src key="@lastname" default=""/>
</mapping>
Combination of attributes into one (with target formatting):
<mapping dest="@annotation" text-format="{2,number,00}: {1}, {0}">
<src key="@firstname" default=""/>
<src key="@lastname" default=""/>
<src key="@id" default=""/>
</mapping>
Using source attribute in an SQL statement:
<mapping dest-fct="@wf_id" src="@domain" do-update="false"
text-format="$SQL=(SELECT id FROM workflow WHERE domain=''{0}''
AND assettype_def=''issue'')"
/>