One Star

tJava to output multiple rows?

Ok, so my input is a zip file containing multiple serialized objects, each containing various combinations of tokens that can be combined in multiple ways to create meaningful part numbers.
What I'm trying to do is use a tJava component to interface with that zip file (which I've done successfully), store the objects in a variable (also done successfully), then use a simple algorithm to create all possible combinations of the tokens.
The part I'm having trouble figuring out is how to output each one of these combinations as its own row to my next component in line (atm a tLogRow).
What I'm during currently (which only outputs one row):
for(String series : pnfNamePnFormatMap.keySet())
{
row1.series = series;
}
where row1's schema consists of a single field (for now) of type String.
This is outputting a single row to the log. How do i get it to iterate over all the possibilities?
7 REPLIES
Community Manager

Re: tJava to output multiple rows?

Hello
I show you a scenario to achieve it. Please see my screenshot.
Best regards

shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tJava to output multiple rows?

Ok, I've successfully done phase one of this. The next phase is I need to include a list of string values from an external file (csv) in the pn generation. Specifically, I need to generate all possible part numbers for each possible value that comes from the file, and put a complete list of them into an external csv.
I tried just attaching a file input to the java and inserting the value but it didn't work.
For example, I need to generate all possible part numbers as above, but i need to do it once each inserting values like these into the part number in each run:
1|TNPW0402TNPWXXXBHTA
2|TNPW0603TNPWXXXBHTA
3|TNPW0805TNPWXXXBHTA
4|TNPW1206TNPWXXXBHTA
5|TNPW1210TNPWXXXBHTA
6|TNPW2010TNPWXXXBHTA
100
101
102
104
105
106
where each of the values listed take the place of XXX in the part numbers listed, creating one instance of each pn above for each value listed. Ideally, it would be nice to just have a Java.util.List of the values extracted from the file because that would fit nicely with my logic that i'm using to generate the part numbers.
What is happening right now is that the input from the file is going straight through and ignoring all of my logic and being output as the ID to my .csv file.
Community Manager

Re: tJava to output multiple rows?

Hello
For example, I need to generate all possible part numbers as above, but i need to do it once each inserting values like these into the part number in each run:

Sorry, I can't understand your request. What are your input records and expected output result?
Please give us an example
Best regards
shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: tJava to output multiple rows?

Never mind, i just figured it out. I switched from a tJava component to a tJavaRow and fed the data through and it worked. Thanks for the help Smiley Happy
One Star

Re: tJava to output multiple rows?

Hello ! Hmm, did I miss something ? I don't see any screenshot Shong :/ And I would be interested by it ^^
Four Stars

Re: tJava to output multiple rows?

Hello
I show you a scenario to achieve it. Please see my screenshot.
Best regards

          shong

Hi Shong.
Could you please show me the screenshot? I really need the answer 'cause I need to send data to different outputs from a tJavaRow (I apply validation to the data with "if" and "else" sentences and depending the result of the validation I send it to an specific output, in this case, an insertion into an Oracle Database for error loggin or a transactional model).
Thanks
Community Manager

Re: tJava to output multiple rows?

Hi Shong.
Could you please show me the screenshot? I really need the answer 'cause I need to send data to different outputs from a tJavaRow (I apply validation to the data with "if" and "else" sentences and depending the result of the validation I send it to an specific output, in this case, an insertion into an Oracle Database for error loggin or a transactional model).
Thanks

Hi dazbellboy  
This topic was rather old, I don't have these screenshots any more. I would like you to open a new topic for your question and describe it with details, I will follow up your problem and help you.
Thanks!
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business