Export headers in tBufferOutput (for webservice display)

One Star

Export headers in tBufferOutput (for webservice display)

Hello,
I'm looking for a clean way to add in a tBufferOutput the column name from schema.
IE: more or less what tFileOutputDelimited do when we tick add header.
We have a xslt style sheet that retrieves the output of talend webservice and handles the first row as a header.
I've tried to find a way to extract the schema, but except doing a manual export, and then re-import the xml, I wasn't able to find something lean.
any idea ?
Thanks,
NH
Four Stars

Re: Export headers in tBufferOutput (for webservice display)

I don't know if this is what you meant by manual export - but what about the following?
... Flow --> tFileOutputDelimited (with Headers included) --> onsubjob oK ---> tFileInputDelimited --> tBufferOutput
One Star

Re: Export headers in tBufferOutput (for webservice display)

Hello willm,
thanks for your feedback, I was hoping to have something more... pushed button Smiley Happy
I've created a sub job run before the main job. I've created a tFixedRowInput, in order to initiate the schema, I'm adding a tUnite, then I connect output from the main job, and finally the output of the tFixedRowInput.
TIS ask to initiate the Schema, I select yes.
I delete the tUnite, and then I connect the tFixedFlowInput to a tJavaRow with this source code :
for (java.lang.reflect.Field field: input_row.getClass().getDeclaredFields()) {
String columnName=field.getName();
if(!columnName.startsWith("commonByteArray") ) {
output_row.getClass().getField(columnName).set(output_row, columnName);
}
}
As tFixedFlowInput creates 1 row, the tJavaRow will drop the column name in the first row. I then push everything to a tBufferOutput.
I'm going to investigate a way to auto generate the schema metadata from another output.
I also would like to use field comment instead of name (if setup).
Thanks again,
NH

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch