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
2 REPLIES
One Star

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