cancel
Showing results for 
Search instead for 
Did you mean: 

Tricky Mapping Scenario : Leads pls

Former Member
0 Kudos

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>

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

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

markangelo_dihiansan
Active Contributor
0 Kudos

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,

Former Member
0 Kudos

Thank you very much,

Appreciate it very much!!!!

Hank

Answers (2)

Answers (2)

rajasekhar_reddy14
Active Contributor
0 Kudos

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

Former Member
0 Kudos

I appreciate your reply Raja,

Is there a way i can achieve this via a UDF?

I am not that well versed with XSLT, and you mentioned that its eazier with XSLT transformation can you please help me with the XSLT code?

Thank you again

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi,I dont think XSLT or JAVA mapping required for this,i think Graphical mapping enough,I will in to this let u know...

Former Member
0 Kudos

Thank you ....Appreciate your help

former_member183909
Active Participant
0 Kudos

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.

Former Member
0 Kudos

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

former_member183909
Active Participant
0 Kudos

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 !

Former Member
0 Kudos

Thank you Jonny, It is making sense. I am working on it.

Experts,

If you have other suggestions on this requirement please post.

Thanks,

Hank

Former Member
0 Kudos

Hi Folks could anyone lead me on the UDF for this requirement please?

Former Member
0 Kudos

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