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.

http://1.bp.blogspot.com/-mRjlNIrTv0c/Ty6whtA6yuI/AAAAAAAAAME/esgPUoG3Rbk/s320/Pic.png

http://3.bp.blogspot.com/-_Vuv9C7MmvE/Ty6wu_8e6RI/AAAAAAAAAMM/Ir7dRPDClbI/s320/Pic.png
http://3.bp.blogspot.com/-PNotKT5ENJg/Ty6w5lynoUI/AAAAAAAAAMU/MCoy0Mh_ERA/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.

http://1.bp.blogspot.com/-Sb3U-rf18zo/Ty6xZ8zm7dI/AAAAAAAAAMc/ZXRUlbx5AbA/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.

http://4.bp.blogspot.com/-rCT42kvrgok/Ty6x0diadnI/AAAAAAAAAMk/9zW3fKofmAM/s400/Pic.png
http://2.bp.blogspot.com/-2x5bhQZu5UM/Ty6yAo75G8I/AAAAAAAAAMs/t2HfScMXMXo/s400/Pic.png
http://1.bp.blogspot.com/-EV2N4GfWs9o/Ty6ySmxfsjI/AAAAAAAAAM0/XXXCCrf-VmE/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.

http://1.bp.blogspot.com/-3pTzOki6RSU/Ty6yyq1Cj9I/AAAAAAAAAM8/b_mO0WQjzNY/s400/Pic.png
http://1.bp.blogspot.com/-6g20ixXvFZU/Ty6zAGvnjaI/AAAAAAAAANE/RnQxmsioOfk/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.
http://4.bp.blogspot.com/-e9ZwAC3In3c/Ty6zvMExWDI/AAAAAAAAANM/gCW80zGPpMI/s400/Pic.png
http://2.bp.blogspot.com/-O-hT7TKABM0/Ty6z6PiNjHI/AAAAAAAAANU/ZnChlDLzC0A/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.
http://2.bp.blogspot.com/-g6_I18ru0p8/Ty60RcoRXfI/AAAAAAAAANc/TCS8rtceUjg/s400/Pic.png
http://1.bp.blogspot.com/-YHIcnoVhPwg/Ty60eMH3HSI/AAAAAAAAANk/scqeru7sLkU/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