[tJavaRow] Copy all properties from input_row to output_row

Highlighted
Five Stars

[tJavaRow] Copy all properties from input_row to output_row

I tried to search a solution in the forum but with no luck. There is a simple way to copy all the proprerties from input_row to output_row without doing it property by property? Something like in the perl examples where they write something like @output = @input and then they process only the properties of interest directly on the output data.
Thank you very much, Stefano.
Highlighted
One Star

Re: [tJavaRow] Copy all properties from input_row to output_row

do you have any examples of what you are trying to accomplish?
Highlighted
Five Stars

Re: [tJavaRow] Copy all properties from input_row to output_row

do you have any examples of what you are trying to accomplish?

Very simple: I'm importing a excel file with 10's columns in a db. I created the schema but ONE column need to be processed and modified based on a set of conditions (a set of if-elseif). So (condier I'm a newbie of Talend) I added a tJavaRow to code with java the set of if. But the row which I get at output are all empty.
I noted that if I write someting like output_row.fieldname = input_row.fieldname for the fields other the one I'm processing, they appear on the output. So I wonder if I have to write all such assignement for all the columns. If possible I want to avoid this coding: it's long and very "hard coded", so a change in the schema (you know... software is everything than stable) needs a relative change in the java code.
Just I note: I see the tMap component, but it seems not the right choose for this set of if.
I'm doing in the wrong way?
Thank you, Stefano.
Highlighted
One Star

Re: [tJavaRow] Copy all properties from input_row to output_row

What exactly are you trying to do to the one column? If you use the tMap and write your own custom routne you should be able to use use the tMap and have your field run through your code as well. In the tMap then you can map the rest of the fields like normal, however use an expression when mapping the field that needs to be modified, in that expressions do something like row.fieldName = MyCode.fucntion(row.fieldName)
Highlighted
One Star

Re: [tJavaRow] Copy all properties from input_row to output_row

Hi,
Please, I do not really understand the function input_row.
What are its properties.
Thank you
One Star

Re: [tJavaRow] Copy all properties from input_row to output_row

If someone is still interested, I suggest using the tJavaFlex component with the Auto Propagation option selected, and to put your code in the Main Code section. It works perfectly like this.
Cheers,

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog