on 11-14-2009 9:28 PM
Hi folks i have a tricky mapping requirement.
I would appreciate your help. I think i need to go in for Java mapping but i am not very good at it. If required can someone guide me with doing it in DOM?
Thanks,
Hank
Source Structure
RequestBody->Summary(1-unbounded)
ManagerName(1)
ManagerID(1)
DistributerID(0-1)
Distributer(0-1)
Seller(0-1)
SellerID(0-1)
Here is how it goes:
-The summary has details about a manager.
-A manager may either have a Distributor directory under him - If he has a distributor under him , that distributor will always have a seller assigned to him.
- A manager can have a Seller directly assigned under him.
Pls look at this sample Source and Target XML desired
<RequestBody>
<Summary>
<ManagerName>Keith</ManagerName>
<ManagerID>K09090</ManagerID>
<DistributerID>Raymond</DistributerID>
<Distributer>R87877</Distributer>
<Seller>Alex</Seller>
<SellerID>A9876</SellerID>
</Summary>
<Summary>
<ManagerName>Keith</ManagerName>
<ManagerID>K09090</ManagerID>
<DistributerID>Robert</DistributerID>
<Distributer>R11111</Distributer>
<Seller>Blake</Seller>
<SellerID>B09976</SellerID>
</Summary>
<Summary>
<ManagerName>Keith</ManagerName>
<ManagerID>K09090</ManagerID>
<Seller>Marie</Seller>
<SellerID>M87656</SellerID>
</Summary>
<Summary>
<ManagerName>John</ManagerName>
<ManagerID>J97654</ManagerID>
<Seller>Charlie</Seller>
<SellerID>C98765</SellerID>
</Summary>
<Summary>
<ManagerName>John</ManagerName>
<ManagerID>J97654</ManagerID>
<Seller>Drew</Seller>
<SellerID>D98455</SellerID>
</Summary>
</RequestBody>
Hi,
This is possible without using UDF. Please see the mapping below:
Legend: rC = removeContext
sBv = splitByValue
mWd = mapWithDefault
cC = collapseContexts
fBe = formatByExample
For ManagerEntity:
ManagerID --> rC --> sBv:ValueChanged --> cC--> ManagerEntity
For ManagerName:
ManagerName --> rC --> sBv:ValueChanged --> cC --> sBv:EachValue --> ManagerName
For ManagerID:
ManagerID --> rC --> sBv:ValueChanged --> cC--> sBv:EachValue --> ManagerID
For Distributer: take note that "null" is the default value
DistributerID --> mWd:null --> rC --------> fBe --> equalsS --> not --> ifWithoutElse --> Distributer
ManagerName --> rC --> sBv:ValueChanged --> / / /
Constant:null ---------------------------------------> / /
/
DistributerID --> mWd:null --> rC --------> fBe -------------------------> /
ManagerName --> rC --> sBv:ValueChanged --> /
For DistributerName:
Copy mapping for Distributer and add splitByValue:Each Value at the end of ifWithoutElse
For DistributerID:
Copy mapping for DistributerName and replace DistributerID -->mWd:null with Distributer --> mWd:null at the start of the mapping
For Seller under Distributer:
Copy the mapping for Distributer
For SellerName under Distributer:
DistributerID --> mWd:null --> rC --------> fBe --> equalsS --> not --> ifWithoutElse --> SellerName
ManagerName --> rC --> sBv:ValueChanged --> / / /
Constant:null ---------------------------------------> / /
/
Seller --> rC ----------------------------> fBe -------------------------> /
ManagerName --> rC --> sBv:ValueChanged --> /
For SellerID under Distributer:
Copy the mapping for SellerName under Distributer but replace Seller with SellerID
to be continued...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
cont...
For Seller under ManagerEntity:
DistributerID --> mWd:null --> rC --------> fBe --> equalsS --> ifWithoutElse --> SellerName
ManagerName --> rC --> sBv:ValueChanged --> / / /
Constant:null ---------------------------------------> / /
/
Seller --> rC ----------------------------> fBe ---------------------> /
ManagerName --> rC --> sBv:ValueChanged --> /
For SellerName under ManagerEntity:
Copy the mapping for Seller and add splitByValue:each value after ifWithoutElse
For SellerID under ManagerEntity:
Copy the mapping for SellerName but replace Seller with SellerID
hope this helps,
Hi ,
its bit easy to achieve your requirement using XSLT,try to use XSLT mapping,easy to transfor your structure to desired format.
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
looking at the source it seems that the data is a little unstructured... the Manager and Distributor/Seller relationship could appear anywhere or inbetween other manager records. I would say you would need to feed the whole lot (context removed) into a UDF, sort it by manager (could do this outside of UDF) and then perform a search for each unique manager. As each Manager's relationships are found then prepare an output array with a context break in between. A bit of mucking about in the UDF but that is what I would do. Just an idea.
Jonny
i am trying to understand what you mentioned:
I would say you would need to feed the whole lot (context removed) into a UDF, sort it by manager (could do this outside of UDF) and then perform a search for each unique manager
Can you explain in detail what you mean when you said feed the whole lot? what values are you talking about here?
Thank you very much.
Hank
Hi Hank
I was suggesting doing this in PI graphical mapping but you will need a couple of JAVA UDF and know about contexts. The idea would be to get a list of managers (Keith|Robert|John - with context change in between) and pass/feed that into a UDFs for findDistributor, findSeller, findNonDistrbSeller. Those UDFs will need to produce a list of data that you can then pass into the target tags. Sorry but I can't supply you with more details or psuedocode. Good luck !
For the above Source XML here is the desired target xml:
Now for this source Structure/ XML below is the desired target XML
<ResponseBody>
<ManagerEntity>
<ManagerName>Keith</ManagerName>
<ManagerID>K09090</ManagerID>
<Distributer>
<DistributerName>Raymond</DistributerName>
<DistributerID>R87877</DistributerID>
<Seller>
<SellerName>Alex</SellerName>
<SellerID>A9876</SellerID>
</Seller>
</Distributer>
<Distributer>
<DistributerName>Robert</DistributerName>
<DistributerID>R11111</DistributerID>
<Seller>
<SellerName>Blake</SellerName>
<SellerID>B09976</SellerID>
</Seller>
</Distributer>
<Seller>
<SellerName>Marie</SellerName>
<SellerID>M87656</SellerID>
</Seller>
</ManagerEntity>
<ManagerEntity>
<ManagerName>John</ManagerName>
<ManagerID>J97654</ManagerID>
<Seller>
<SellerName>Charlie</SellerName>
<SellerID>C98765</SellerID>
</Seller>
<Seller>
<SellerName>Drew</SellerName>
<SellerID>D98455</SellerID>
</Seller>
</ManagerEntity>
</ResponseBody>
Appreciate your help very much, this is a challenging requirement to me.
Thanks
Hank
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.