Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey friends,
First of all let me say i'm new to Talend and making my first steps in now and additionally doesn't have any JAVA coding knowledge.
After this promising start i will explain what i need,have and the problem.
i need to create an API connection to store their data into my MySQL DB and to do so i used tRESTClient,
the API limit the results to 30 rows per page, so i need to paginate (i think this is the term) between the pages.
I used tLoop for that and configures it as 'For loop' the problem is that if i set the loop for 10 it might run in the end few times without retrieving any data, cause page 10 in the API is currently empty.
I'm looking for a way to stop the loop if the output is empty.
i have created a tJavaFlex component that check if there is data in the out put and store it in globalMap.
But i currently cant config the tloop as while to stop when globalMap=false.
this is the project:
the loop runs 5 times each time the page number increased in tRESTClient.
java component that check if there is data out from tMap
and here you cans see that when there is data it prints true and for the next pages it print false
i want to make condition in tloop while "hasData" is true increase the page.
appreciate any help
Dima K
If you use a while loop (in tLoop component , just switch from 'For' to 'While') : you can then use 2 conditions in the 'Condition' field : one for the amount of exec already done (1 to 10) and another one on your global variable :
Condition for iteration is : currentIteration <= MaxIteration AND hasData==true . This way if one or the other of these conditions are not met anymore, the loop will stop.
You'll have to define MaxIteration as a context or global variable for example, and use the globalVariable you have already created ('hasData')
i have edited my answer with further precisions.