cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Issue - - Part II

Former Member
0 Kudos

Hi All,

My source structure is

<root>

<a></a>

<type>

<val1>

</val1>

</type>

<type1>

<val2>

</val2>

</type1>

</root>

Here the cardinality goes like this

<a> 1..1

<type> 1..unbounded

<val1> 1..1

<type1> 1..unbounded

<val2> 1..1

Target structure

<test>

<action>insert</action>

<table>table1</table>

<access>

<tval></tval>

</access>

</test>

Here my requirement is if <b>a</b>'s value is "const" I need to have <b><access></b> node in my target as many times as <b><type></b> and <b><tval></b> must be mapped with <b><val1></b>. If <b>a</b>'s value is "const1" I need to have b]<access></b> node in my target as many times as <b><type1></b> and <b><tval></b> must be mapped with <b><val2></b>. Can this be achieved in graphical mapping???

Thanks & Regards,

Jai Shankar.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You will have.

a) <access> element

here you can use user defined function with two inputs we can call this function ifExtended. It will have three inputs. A is condition, B is queue no 1, C is queue no 2.

if(A.equals("true"){

for(int i=0;i<B.length;i++)

resultList.addValue(B<i>);

else{

for(int i=0;i<C.length;i++)

resultList.addValue(C<i>);

}

And now you are connecting your condition to condition input. And <type> to second input (without change of context) and <type1> to third.

Please check this function because I wrote it ad hoc.

b) <tval> element

here also use this function

Regards,

Wojtek

Former Member
0 Kudos

Wojtek,

>>><i>here you can use user defined function with two inputs we can call this function ifExtended. It will have three inputs. A is condition, B is queue no 1, C is queue no 2.</i>

Can you pls expalin this part? How to create this UDF? What is the cache for this UDF(value or context or queue)? How can a UDF have 2 input queues

Thanks & Regards,

Jai Shankar.

Former Member
0 Kudos

Hi,

It ahould be queue UDF with 3 inputs. On which service pack are you working on? Briefly this function should work like that if condition (first input) is fullfilled than pass first queue (second input) if not pass second queue (third input).

Regards,

Wojtek

Shabarish_Nair
Active Contributor
0 Kudos

from the above code i gather, you need to make a UDF with 3 inputs (in a UDF you can add any number of inputs) with the cache as <b>context</b>.

Just noticed;

<b>resultList.addValue(B);</b> in case it was B<i> etc it would be context but now it is queue ... My mistake

Message was edited by: Shabarish Vijayakumar

Former Member
0 Kudos

Dear Wojtek,

Am on XI/PI7.0 SP08. I have not worked on UDF with cache as context or queues, hence the problem...

I can create a UDF with 3 inputs and cache as context..

The 2nd input of ifExtended is <type> and 3rd input of ifExtended is <type1>.

Pls let me know the first input? Is it [b}if(<a>equals"const")</b>

Thanks a lot,

Jai Shankar..

Shabarish_Nair
Active Contributor
0 Kudos

i suppose then;

if(A.equals("true"){

for(int i=0;i<B.length;i++)

resultList.addValue(B['i]);

else{

for(int i=0;i<C.length;i++)

resultList.addValue(C['i]);

}

with the context will suffice ..

Former Member
0 Kudos

Hi,

First input is output from ( <a> equals "const" ). I can't remember the naming of parameters in UDF in SP08. But maybe they are called a,b,c and you should take it into account because java is case sensitive.

Regard,

Wojtek

Former Member
0 Kudos

Hi,

I am getting the following error pls do help...

ResultList cannot be applied to (java.lang.String[])

resultList.addValue(B);

ResultList.addValue(C);

Thanks & Regards,

Jai Shankar.

Shabarish_Nair
Active Contributor
0 Kudos

provide;

B and C since it will expect a string entry.

Note : Change { to [ .. in sdn ['i] means italics

Former Member
0 Kudos

Hi Shabz,

Yes the UDF worked, but I can get only one <access> node in my target. I am passing 3 inputs to the UDF

1. true(<a> equals "const")

2. <type>

3. <type1>

But when I pass false as 1st arguement I am getting <access> node as many times as <type1>

Pls help...

Thanks & Regards,

Jai Shankar.

Former Member
0 Kudos

Hi,

Is it not correct?

Regards,

Wojtek

Former Member
0 Kudos

Wojtek,

When I pass false as 1st arguement I am getting <access> node as many times as <type1>. This part is correct.

but I can get only one <access> node in my target. I am passing 3 inputs to the UDF when I pass "true" as first arguement. This part is not what I expected.

What I expected was <access> should be produced as many times as <type> if the first arguement is "true"...

Thanks & Regards,

Jai Shankar.

Former Member
0 Kudos

Hi,

Have you assigned <type> into second input?

Could you also provide full code of your function because it looks like that something is wrong with java if statement.

Regards,

Wojtek

Message was edited by: Wojciech Gasiorowski

Former Member
0 Kudos

Yes Wojtek, <type> is second input and <type1> is the 3rd input.

Thanks & Regards,

Jai Shankar.

Former Member
0 Kudos

Wojtek,

<b>if(a.equals("true"))

{

for(int i=0;i<b.length;i++)

result.addValue(b<i>);

}

else {

for(int i=0;i<c.length;i++)

result.addValue(c<i>);

}</b>

I think even if I pass true as input the control passes to else part in the JAVA code.... What might be the reason here????

Thanks & Regards,

Jai Shankar.

Former Member
0 Kudos

Hi,

I know what is wrong. Put here a remember to change brackets to [ .

Regards,

Wojtek

Former Member
0 Kudos

Wojtek,

Yes, now the if condition evaluates as expected. One last help to ebd this issue...

HOw do I need to map <tval> is it like this?

ifExtended inputs

1. true or false based on <a>

2. <val1>

3. <val2>

But if I map like this, I am getting array index out of bound exception...

Thanks & Regards,

Jai Shankar.

Former Member
0 Kudos

Hi,

Please check what is your first input queue this one with condition. Maybe it's empty.

Regards,

Wojtek

Former Member
0 Kudos

Hi,

If you are using the same function there shouldn't be any problems. You can also add some additional checks.

<b>if(a!=null){</b>

if(a.equals("true"))

{

for(int i=0;<b>(b!=null)&&</b>i<(b.length);i++)

result.addValue(b);

}

else {

for(int i=0;<b>(c!=null)&&</b>(i<c.length);i++)

result.addValue(c);

}

<b>}</b>

Regards,

Wojtek

Former Member
0 Kudos

Hi Wojtek & Shabz,

Yes you did it man...... The problex was with context change. <val1> and <val2> had context changes I used a remove contexts here before passing as input to UDF and then output I used Split by value and mapped to <tval>...

Now it is working perfectly the way I wanted....

Thanks a lot frnz.....

(P.S: Now I can have a joyful DIWALI - a festival of lights)

Wish you all SDNers a happy DIWALI

Thanks & Regards,

Jai Shankar.

Shabarish_Nair
Active Contributor
0 Kudos

Happy Diwali Jai

Wojtek, it is a pretty big festival out here in India that falls in the next 2 days !!! Happy diwali to you too !!

Former Member
0 Kudos

Happy Diwali!!!

Answers (2)

Answers (2)

Shabarish_Nair
Active Contributor
0 Kudos

use the same UDF as for the other field; except that replace it with <type1> & <val2> fields.

former_member187339
Active Contributor
0 Kudos

Hi,

I think this will do. I can't test it here bcoz i am not haveing any server

if(a="const")---> map tval to tval1, map type to access

else ---> map to tval to tval2, map type1 to access

Regards

Suraj