cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping an String Array

Former Member
0 Kudos

Hi all,

I'm trying to put an incomming array of strings into a simple element. How can I do it with XI? The scenario is like this. I have data repository with software metrics data. In XI, there is a Web Service (sender) and a JDBC (receiver). The client application calls the Web Service, with a request "params" message:

<MetricsReportRequest>

<SystemName>Sytem1</SystemName>

<SystemName>Sytem2/SystemName>

<SystemName>Sytem3/SystemName>

<Periodicity>tstf</Periodicity>

<Level>fgsdf</Level>

<StartDate>gsdfg</StartDate>

<EndDate>sdfg</EndDate>

</MetricsReportRequest>

Then, there is a mapping to transform the incomming message to the JDBC "SQL_QUERY" message:

<MetricsReportJDBCMessageType>

<STATEMENTNAME>

<MY_TABLE ACTION="SQL_QUERY">

<ACCESS>SELECT FIELDS FROM MY_TABLE WHERE SYSTEMNAME in ($systemName$) and (DATE > to_date($startDate$,'yyyy-mm-dd') and DATE to_date($endDate$,'yyyy-mm-dd'))

</ACCESS>

<KEY>

<startDate>01/01/2001</startDate>

<endDate>01/01/2002</endDate>

<systemName>'Sytem1','Sytem2','Sytem3'</systemName>

</KEY>

</MY_TABLE>

</STATEMENTNAME>

</MetricsReportJDBCMessageType>

The problem is that I couldn't find a way to transform this

<SystemName>Sytem1</SystemName>

<SystemName>Sytem2/SystemName>

<SystemName>Sytem3/SystemName>

to this

<systemName>'Sytem1','Sytem2','Sytem3'</systemName>

Or, If someone has any other solution to query the data, would be very apreciated.

Thanks!

roberti

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Waldemar,

try to create a UDF (queue) with only one parameter (inputQueue) with the following code:

//******************************************************************************

ArrayList content = new ArrayList();

StringBuffer sbResult = new StringBuffer();

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

{

if(!inputQueue<i>.equals(ResultList.CC) && !inputQueue<i>.equals(ResultList.SUPPRESS))

{

sbResult.append(inputQueue<i>);

sbResult.append(",");

}

}

result.addValue(sbResult.toString().substring(0,sb.length() - 1));

//******************************************************************************

Hope this help,

Regards

Francesco

Former Member
0 Kudos

Thank you Francesco,

This was the solution for the problem

I corrected some details, but it solved the problem.

I didn't know that in the queue mode the "string" parameter were an array, this was the point.

Thank you very much!

cheers!

roberti

ps.: I don't know how to give you points... the buttons to give points disappeared from the page...

Former Member
0 Kudos

Hi Waldemar,

I'm happy that you solved the problem.

for the points i think that sdn point mechanism has some problem.

Can you try after

Kind Regards,

Francesco

Answers (2)

Answers (2)

Former Member
0 Kudos

Is possible to solve the problem creating a user defined function, typed as queue. This type of function allows to use an array as input parameter, then, looping on the array is possible to create a unique string.

roberti

Former Member
0 Kudos

Hi,

You can also create such function. But in your case context should be enough (here you have also array as an input).

Regards,

Wojciech

Former Member
0 Kudos

Hi Wojciech,

You are right. Context is even more properly to use in this case.

thanks!!!

cheers!

roberti

Former Member
0 Kudos

Hi,

Create UDF on context. Loop over it and concatenate it.

Regards,

Wojciech

Former Member
0 Kudos

Hi Wojciech,

Yes, I've already tried it. But the input parameter is only string, how can I have an input parameter as an array?

thanks!

roberti

Former Member
0 Kudos

Hi,

You should select correct type of function.

1) functional (only strings as parameters)

2) context (context as parameter) array

3) queue (queue as parameter) array

In old service packs you had to select something like "queue cache" or a little bit different.

regards,

Wojciech

Message was edited by: Wojciech Gasiorowski

Former Member
0 Kudos

Thanks Wojciech, that's the way.

I don't know how to give you more points... the radio buttons have disapeared from the conversation page.

Thank you very much!

roberti