Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] How to create a java Map from iterate ?

Hello,
I need to read a row from input and create a new Map in output.
Can tJavaFlex do this, and how can I forword the new flow map for output ? :/
My java code is like this:

java.util.List<String> fibres= new java.util.ArrayList<String>();
String Id_cable=input_row.Noeud.trim();
Integer Nb_tube=input_row.TUBES;
Integer Compositio=input_row.COMPOSITIO;
String Id_tube=input_row.Id_tube;
if (Nb_tube>0)
{ // only one tube input
for (int i=1;i<=Nb_tube; i++) {
Id_tube=Id_cable+"T"+i;
if(Compositio>0)
{
String Id_fibre="";
for(int j=1;j<=Compositio;j++){
//a new calculated row,for one input row of tube
// I will have many rows of calculated fibres.
Id_fibre= Id_tube.trim()+"F"+j;
fibres.add(Id_fibre,Id_fibre);
fibres.add(Id_tube,Id_tube);
}
}
}
}

May I use tJavaFlex+tFlowtoIterate+tFixedFlow, and how can I use tJavaFlex with 2* for loop ? 😕
Thank you in advance .
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hello
Yes, tJavaFlex component fix your need. See my screenshots.
code on begin part:
// start part of your Java code
java.util.Map<String,String> fibres= new java.util.HashMap<String,String>();
String Id_cable;
Integer Nb_tube;
Integer Compositio;
String Id_tube;

code on main part:
			  Id_cable=row1.Noeud.trim();
Nb_tube=row1.TUBES;
Compositio=row1.COMPOSITIO;
Id_tube=row1.Id_tube;
if (Nb_tube>0)
{ // only one tube input
for (int i=1;i<=Nb_tube; i++) {
Id_tube=Id_cable+"T"+i;
if(Compositio>0)
{
String Id_fibre="";
for(int j=1;j<=Compositio;j++){
//a new calculated row,for one input row of tube
// I will have many rows of calculated fibres.
Id_fibre= Id_tube.trim()+"F"+j;
fibres.put(Id_fibre,Id_fibre);
fibres.put(Id_tube,Id_tube);
}
}
}
}

code on end part:
// end of the component, outside/closing the loop
globalMap.put("fibres",fibres);

Best regards

shong

View solution in original post

2 Replies
Anonymous
Not applicable
Author

Hello
Yes, tJavaFlex component fix your need. See my screenshots.
code on begin part:
// start part of your Java code
java.util.Map<String,String> fibres= new java.util.HashMap<String,String>();
String Id_cable;
Integer Nb_tube;
Integer Compositio;
String Id_tube;

code on main part:
			  Id_cable=row1.Noeud.trim();
Nb_tube=row1.TUBES;
Compositio=row1.COMPOSITIO;
Id_tube=row1.Id_tube;
if (Nb_tube>0)
{ // only one tube input
for (int i=1;i<=Nb_tube; i++) {
Id_tube=Id_cable+"T"+i;
if(Compositio>0)
{
String Id_fibre="";
for(int j=1;j<=Compositio;j++){
//a new calculated row,for one input row of tube
// I will have many rows of calculated fibres.
Id_fibre= Id_tube.trim()+"F"+j;
fibres.put(Id_fibre,Id_fibre);
fibres.put(Id_tube,Id_tube);
}
}
}
}

code on end part:
// end of the component, outside/closing the loop
globalMap.put("fibres",fibres);

Best regards

shong
Anonymous
Not applicable
Author

It's work, thank you shong. :cool: