on 09-21-2010 12:13 PM
Hi Experts,
1) I need to repeat the date field in the target based on seqNo field value in source
2) in the counter field in the target i need to add 10,20,30,40 etc, if one event node got more than media nodes with same media->seqNum = event->eventSeqNum
Can anyone help me how can i achive this mapping.
<<TEXT REMOVED>>
my source message is look like this:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:session_mt xmlns:ns0="urn:gp:prototype">
<event>
<eventSeqNum>1</eventSeqNum>
<date>19-09-2010</date>
<eventType/>
</event>
<media>
<seqNum>1</seqNum>
<amount>100</amount>
</media>
<media>
<seqNum>1</seqNum>
<amount>299</amount>
</media>
<event>
<eventSeqNum>2</eventSeqNum>
<date>21-09-2010</date>
<eventType/>
</event>
<media>
<seqNum>2</seqNum>
<amount>199</amount>
</media>
<media>
<seqNum>2</seqNum>
<amount>499</amount>
</media>
<media>
<seqNum>2</seqNum>
<amount>699</amount>
</media>
</ns0:session_mt>
My target message is look like this:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:lineItems_mt xmlns:ns0="urn:gp:prototype">
<item>
<date>19-09-2010</date>
<seqNo>1</seqNo>
<amount>100</amount>
<counter>10</counter>
</item>
<item>
<date>19-09-2010</date>
<seqNo>1</seqNo>
<amount>299</amount>
<counter>20</counter>
</item>
<item>
<date>20-09-2010</date>
<seqNo>2</seqNo>
<amount>199</amount>
<counter>10</counter>
</item>
<item>
<date>20-09-2010</date>
<seqNo>2</seqNo>
<amount>499</amount>
<counter>20</counter>
</item>
<item>
<date>20-09-2010</date>
<seqNo>2</seqNo>
<amount>699</amount>
<counter>30</counter>
</item>
</ns0:lineItems_mt>
Thanks
Edited by: Matt on Sep 23, 2010 10:28 AM
Hi Praveen,
You should write UDF for this :
First media node is map to remove context and map to item node.
after second mapping
Media and date is map to UDF and take the Splitbyvalue(each value) and map to target Date field
UDF:
_________________________
public void copyPerValue(String[] a,String[] b,ResultList result,Container container){
//write your code here
for(int i=0;i<a.length;i++){
result.addValue(b[0]);
}
Try this ,Might be you achieve.
Thank you
Sateesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sateesh,
I tried what you mentioned in this thread but the the first date value only repeating all item nodes in the target, my requirement is if the /session_mt/event/eventSeqNum = /session_mt/media/seqNum then date must be map to /session_mt/event/date.
so i got two evet nodes for two eventSeqNum(1 and 2), so i need output like first two item nodes with the date '19-09-2010' and next three item nodes with date '21-09-2010', see above example.
Thanks Supriya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Praveen,
Try the below mappings:
1)For date field:
event-date -
>
media-seqNo >removeContext> splitByValue(value change) -
> useOneAsMany -
> target-date
media-seqNo -->removeContext -->splitByValue(each value) -
>
2) For counter field:
You can achieve this using std graphical functions as well.
media-seqNo -->removeContext -->splitByValue(value change) -->index (1,1) --> multiply --> splitByValue (each value)->counte
constant [10] -
>
-Supriya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.