Monday 30 April 2012

How To Work with Domain Value Map




In the below Example I will create one DVM file using four Column CityCode, CityName, CityLocation and Country. Where Country and CityLocation Column will act as qualifier. Mediator will lookup value from .dvm file and write result to local file system.

Step1:- Create .DVM FILE using  Right click on project -> Select SOA-> Transformation-> Domain Value Map . Give some name to domain value map file and give some name to the domain fields then click OK.
Now in .DVM file click on add button -> select the option add domain. In this example I am adding one more domain with name CityLocation with Qualifier as true and hierarchical order as 1 and another domain with name Country with Qualifier as true and hierarchical order as 2 to show the hierarchy weightage.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi51UGtJlswDqrx4B0N2CzhhJqyZ7_zedXMh8RCbr-rs2boXlOmdFZREDmMB9Rn3Jlsj9N2VBnUM7qhzbt92jPUkCbc8hoPYtIZ95WxsAipWmgGAEX5071DssA37ruDenyAcHyrpWoI8_Y/s320/Pic.png

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMBZHske9utFbOKmPPlxfjk7fEIzNkClZ6mRiajnMxCQPyVplVPGI1ZEaYLMGG-zVvLIeBYep1ER-nb8exCSSmbOVoVp0VJy7aYuKn_uU9q7VgxLo-u3qIRhFFgJYlyRWVJw7LmEFlXdM/s320/Pic.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrtjP7ZubWdzs6lpLV5fq-VXkBbRwrGP6wbY-LQyO4cOISdu19uA9Ye9zrIDB16jrWaCvOw-JOyJVkzi8mGOVZIUY8OgPGT3i6bfZRLiVskBBjR23YZwSzfMqTX_YOpKmIAGT4vKojMEE/s400/Pic.png

Step 2:- Now I am creating one Asynchronous Mediator in composite and exposing it as web Service and created one file Adapter which will be writing onto the local system. Wire the Mediator with write File adapter.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyCTV4y7BucgMVBzuzt88PSQUbIS3NV-QUA42sWnJtEgu-gYDfkaol5AtYflKvDMIbg0nRCk0GpDWblsrCGxhGd0cUczN7b3E5_jB0kiH1TBPihpFn6hULN0DZW0x1JQYAk5cmXhFwZ7w/s400/Pic.png

Step 3:- Now open the mediator and click on the transformation icon and select the Advance Function in XSLT Mapper file in Component Palette. Then select the DVM Funtion->lookupValue1M.
Drag this function onto the line connecting field from source to target. Open the function and select the following below values in respective field. In the sourceValue  column  click and press the ctrl+Shift to get the field from XSD. In my case I have taken XSD as Employee. The XSD can be anyone.
Whatever value will come from field EmployeeName will go to Source Column CityCode in .dvm file.
Target column is selected as CityName will show the value of output means full name of City and default value is selected as “Not Known”. If the passed value while testing will not be present in the CityCode column then the default value “Not Known” will come as output.
Qualifier columns will pick values from the EmployeeDetail and EmployeeSummary field passed while testing in Employee XSD.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCuTFKyBY4aK-GA6-kovYjEp7y2e4VtQWjoW8Kk19bc91EwDR6CdjBAC-lhn-KfgRdRfRVUD91DK2kfPKYqxnku6KRxZmRl12PEc88slINyctB8b-4EIUXTPywXf1_SdoeoTS30vG2FXM/s400/Pic.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgW7pRxzYuuuKRKr9fPYi2oMKOUKsMuEdc46GMlCdOmtnB5UcaLJWpBbn3Ze-J7Bxwbiv_wubDLrQkXQCAi6fbx-8wLSM-PkT04aNJUOIsvovxRhtJlGYx8wGbvrZcLDHfgqBfly8YHuYg/s400/Pic.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4kXGPiVq-ap5zfflpkip3DuvBXvQMFSeytZDUPaB0Pccpo-Cok4RhSFXGwTuXxzPSFizIKmfRGHQ3FG5yTvjyecy04h0KRK6Spvs_wDBDD4QPHRUNfpe58-VNBk0WM56SFDDAOdAQEqE/s400/Pic.png
Step 4:- After  Mapping deploy the function on Application server and test the function.

A qualifier order is used to find the best match during lookup at runtime. The order of a qualifier varies from highest to lowest depending on the role of the qualifier in defining a more exact match. In the CityLocation qualifier(1) have a higher order  than the Country qualifier(2), as a matching CityLocation indicates a more exact match.

Domain value maps support hierarchical lookup. If we specify a qualifier value during a lookup and no exact match is found, then the lookup mechanism tries to find a more generalized match by setting the higher order qualifiers to a "".

First Test case in the Usecase:-
Pass value BO in all four field. Now the result will come as Boston1 because it picks value where the CityLocation and Country Value Column has no value entered.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjf6mIRL6PNdlq6_8H1VOLx9QXE_leZpT1TcZK30s7op01w1lpuvTgO5TKkhSg_p1YGzzbR1cU_zSUoGj8NnnwMmikeroms7YXUg6v3YTO0CCDpAZXqjCLmvyUsRIr3FAaKG4lb61ra014/s400/Pic.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjBoO5HvluyzJUeF9M3LkjsCcBAE9oE0Lil8jaQVbWdOefvZeGXxU-gtT1iJTEprCwOfb58BoK4fvJPr4qUo-ruPkcTew4A-EGVRksTg85lR31WOcw_jJXj2abB-DkhpG2qx07cpR8Xdlg/s400/Pic.png
Second Test case in the Usecase:-
Pass value BO in all three field. Now the result will come as Boston1 because it picks value where the CityLocation is blank and Country is blank. It happens because CityLocation Column has hierarchy set 1 which is taking precedence over the Country Column. That’s why it did not pick value from the field where Country name is set as USA because in that case CityLocation is not set as BO.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEido2kDeH6q6yPEFgSlXfD3ck1WIGnKf85aIU0bWH2_18ILp-PIO39OhkimkRifMxfQffdT-EOYjpwvRs13fytnUX_WK3qYmJHj6d3t9Ld0BcyxhObK8cjubq5tWqOahP1jsJbVOlIGMMY/s400/Pic.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj1ur1tNlitk4GocN8IVvq10cD_HTkdMetA2CO9sGXTTMiNU3mMXzG7520Y0Gig4cgljsVmOKIEAXKxnFOfNMJY0tZc6GBOdTZjrDnbwV5RW_O_fWUQtvbDIti99VlHp05AAqcG8FK5OqA/s400/Pic.png
Third Test case in the Usecase:-
Pass value BO in all two field. Now the result will come as Boston because it picks value where the CityLocation is EastUSA and Country is USA.
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEir1SCKVP5e5yS65WeW127cIYRE_CESoQ4Z4Z2Bzknk_NFcci6NLnlsur7dVc_ZqKe3kaf8UjtsSCD2HGsAOo4-tQlneu3yIPGYE6YN8SrZ1Nbe1jSxqshsMLz7y8SQRDn7WgjRy8vD1Io/s400/Pic.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0-gNvriWbksUfnKf01SYkrqgXY86xvNDkTv6SqDLFvqFOD8VBlVBknBnPsNhYVuF_PEPH03JpV97VxR43CymC8XtT_6nv5u9AnO0uHMOVbhKfBwZnofTe9imBy95aR5REN-sGoZgeqCw/s400/Pic.png

Hope this Example would help in understating DVM concept.

Domain Value Map Features:-
(i)                  Qualifier Support:- Qualifiers qualify mappings. A mapping may not be valid unless qualified with additional information. For example, a domain value map containing city code to city name mapping may have multiple mappings from KN to Kensington as Kensington is a city in Canada as well as USA. Hence this mapping requires a qualifier (USA or Canada) to qualify when the mapping becomes valid . You can also specify multiple qualifiers for a domain value map. Qualifiers are used only to qualify the mappings. Therefore, the qualifier values can not be looked up.
(ii)                Qualifier Order Support:- A qualifier order is used to find the best match during lookup at run time. Domain value maps support hierarchical lookup. If you specify a qualifier value during a lookup and no exact match is found, then the lookup mechanism tries to find a more generalized match by setting the higher order qualifiers to "". It proceeds until a match is found, or until a match is not found with all qualifiers set to "".
(iii)               One-to-Many Mapping Support:- You can map one value to a multiple values in a domain value map. For example, a domain value map for Payment Terms can contain mapping of payment terms to three values such as discount percentage, discount period, and total payment period.

No comments:

Post a Comment

xslt padding with characters call template for left pad and right pad

  Could a call-template be written that took two parameters ?   a string, and a   number) return the string with empty spaces appended t...