Sunday, 5 February 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.



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.


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.

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.

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.
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.

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.

2 comments: