One Star

[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.
5 REPLIES
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?
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?

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.
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)
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,