How to handle Custom Complex Transformation in APPSeCONNECT
Transformation is a technique to change format of one xml packet to another. In case of transformation we generally consider two types of structure, we call it a Schema. A schema is an XML hierarchy which lets you define an xml document of the data coming from an application or a data source.
In APPSeCONNECT, we transform data coming form one application to another using Transformation block called as Mapper. In ProcessFlow, we drag a mapper and connect two actions which leads to the creation of transformation script.
Now let us take an example of an XML Document.
(We take this document as simple as possible to ensure we understand the transformation better. )
<customers>
<customer>
<Name>Abhishek</Name>
<Age>30</Age>
<Addresses>
<Address type=”Business”>
<FlNo>17</FlNo>
<Street>Main Street</Street>
<ZipCode>83888</ZipCode>
<Country>India</Country>
</Address>
<Address type=”Personal”>
<FlNo>16</FlNo>
<Street>Linkcoln Sarani</Street>
<ZipCode>83888</ZipCode>
<Country>India</Country>
</Address>
</Addresses>
<email>abhishek@abhisheksur.com</email>
</customer>
<customer>
<Name>Samar</Name>
<Age>30</Age>
<Addresses>
<Address type=”Personal”>
<FlNo>40</FlNo>
<Street>Woodland Lane</Street>
<ZipCode>83888</ZipCode>
<Country>India</Country>
</Address>
</Addresses>
<email>samar@abhisheksur.com</email>
</customer>
</customers>
Now here in the XML document, we have two data one for Abhishek and another for Samar. The data Abhishek contains two addressees while Samar is having one address. If we consider the schema to map this document, we do it like the one below :
Hence it is clear, that the schema needs to be defined correctly to map the elements of an XML. Now as you know the work of the transformation is to transform the data based on the output schema defined on the other application. In certain scenario, let’s say if it is CSV or XLS or any other API which does not have concrete schema defined, there might be a case where an unusual data format needs to be produced. For instance, let us suppose the output we require to generate is something like the one below:
<Data>
<row>
<column Name=”Name” value=”Abhishek”></column>
<column Name=”Age” value=”30″></column>
<column Name=”Email” value=”abhishek@abhisheksur.com”></column>
<column Name=”Address”>
<row>
<column Name=”FLNo” value=”17″></column>
<column Name=”Street” value=”Main Street”></column>
<column Name=”ZipCode” value=”83888″></column>
<column Name=”Country” value=”India”></column>
</row>
</column>
</row>
<row>
<column Name=”Name” value=”Samar”></column>
<column Name=”Age” value=”30″></column>
<column Name=”Email” value=”samar@abhisheksur.com”></column>
<column Name=”Address”>
<row>
<column Name=”FLNo” value=”40″></column>
<column Name=”Street” value=”Woodland Lane”></column>
<column Name=”ZipCode” value=”83888″></column>
<column Name=”Country” value=”India”></column>
</row>
</column>
</row>
</Data>
Now this data structure is completely different, and you cannot create a valid schema out of the same. Now logically every data is inside the column of same name and hence make it very much difficult to create a schema definition of a column field. Here comes the utility of a custom Renderer.
In case of Custom Renderer, we allow users to use a schema as concrete as possible, but we change the rendering engine a bit such that the rendering gives you a different output.
Let us consider the schema again
This same schema could be used to again generate the output xml. We map the fields one to one, and we rely on our renderer to specify the rendering type.
Now here we have defined a custom renderer in the mapping to ensure the rendering does not follow the default rendering technique which is <field>value</field>. We have just changed the way each row will be going to be rendered and the rendering of each row will be like the one defined above.
Now during mapping if you just say
Here the email will use the custom renderer rather than the default rendering technique.
Conclusion
In APPSeCONNECT we always want to have better visibility of data transformation, and hence we came up with a feature which can help in developing the mapping inside an integration easier even though the output of a rendering looks ugly. The custom rendering allows you to specify a custom rendering in an application from a straight forward mapping.
I hope this post will help you using the feature.
Thanks.
Leave a reply