on 11-18-2011 8:01 AM
Hello,
I am trying to develop a mapping between the below source and target:
SOURCE:
<?xml version="1.0" encoding="UTF-8"?>
<test_source>
<DOC>
<Node>
<status>I0001</status>
<activ>X</activ>
</Node>
<Node>
<status>I0001</status>
</Node>
<Node>
<status>I0005</status>
<activ>X</activ>
</Node>
</DOC>
<DOC>
<Node>
<status>I0001</status>
<activ>X</activ>
</Node>
<Node>
<status>I0001</status>
</Node>
<Node>
<status>I0005</status>
<activ>X</activ>
</Node>
</DOC>
</test_source>
TARGET:
<?xml version="1.0" encoding="UTF-8"?>
<test_target>
<targetnode>
<statustype>U</statustype>
<statustype>U</statustype>
</targetnode>
</test_target>
Hi Pankaj,
Try this logic...
test_source--->test_target
test_source-->targetnode
status>removeContext>sort->SplitByValueChange>CollapseContext->UDF>StatusType.
UDF:
for(int i=0; i<var1.length;i++){
result.addValue("U");
}
Regards
Priyanka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oops only part of my question got posted
Here is the condition:
1 -
> If status = I0002 AND acvtiv = X
(both the conditions evaluated separately)
2 ---> If status = I0045 AND activ = X
If 1 && 2 = true
Then statustype = A
Else statustype = U
I tried using standard functions but could not succeed.
How to solve?
Thanks
test_source--->test_target
test_source-->targetnode
UDF-->StatusType
UDF:
input1:status>removeContext>sort->SplitByValueChange>CollapseContext
input2:formatByExample-->collapseContext
sortByKey:
input1:statusremovecontext
input2:active-->removeContext
formatByExample:
input1:resultOfSortByKey
input2:tatus>removeContext>sort--->SplitByValueChange
UDF:
for(int i=0;i<var1.length;i++){
if((var1(i).equals("I0002") && var2(i).equals("X")) || (var1(i).equals("I0045") && var2(i).equals("X")))
result.addVAlue("A");
else
result.addVAlue("U");
}
Regards,
Priyanka
what i have understood from ur output payload and example is that for each DOC segment u r checking condition (1&&2) and if it is true then ur statustype is "A" else "U"??
If yes then chk below mapping
status (set its context to DOC)------------\
-------------------------------------UDF--------statustype
active---mapwithdefault /
----------FormatByExample---
status (set its context to DOC)
UDF: input will be var1 and var2
execution type:all values of a context.
int a= var1.length;
int count = 0;
for( int i=0;i<a;i++)
{
if (var1<i>.equals("I0002") && var2<i>.equals("X"))
{
for(int j=0; j<var1.length;j++)
{
if (var1[j].equals("I0045") && var2[j].equals("X"))
{
result.addValue("A");
count = count+ 1;
break;
}
}
}
}
if(count==0)
{
result.addValue("U");
}
Hello Amit,
I used your code and mapping logic, however it works only when the DOC is having one occurence.
For more occurences of DOC the target mapping fails.
I think i gave a bit wrong target structure. Below is the actual:
<?xml version="1.0" encoding="UTF-8"?>
<test_target>
<targetnode>
<statustype>U</statustype> ..1..1
</targetnode>
<targetnode>
<statustype>U</statustype>1..1
</targetnode>
</test_target>
Can you please help?
Thanks.
it seems bit strange because i have tested the mapping with the input source payload which u have provided and it's resulting the expected output...
use the display queue option and chk whats the UDF output is coming in the mapping
give a try with splitbyvalue
mapping-UDFsplitbyvalue--statustype
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.