use of org.pentaho.di.trans.steps.textfileoutput.TextFileOutputData in project pentaho-metaverse by pentaho.
the class TextFileOutputExternalResourceConsumer method getResourcesFromRow.
@Override
public Collection<IExternalResourceInfo> getResourcesFromRow(TextFileOutput textFileOutput, RowMetaInterface rowMeta, Object[] row) {
Collection<IExternalResourceInfo> resources = new LinkedList<IExternalResourceInfo>();
// For some reason the step doesn't return the StepMetaInterface directly, so go around it
TextFileOutputMeta meta = (TextFileOutputMeta) textFileOutput.getStepMeta().getStepMetaInterface();
try {
TextFileOutputData data = ((TextFileOutputData) textFileOutput.getStepDataInterface());
String filename = rowMeta.getString(row, meta.getFileNameField(), meta.getFileName());
if (null != data) {
// For some reason, the first call to process row doesn't have the data.fileName filled in, so
// fall back to the filename field value, and then to the meta's filename
filename = textFileOutput.buildFilename(Const.isEmpty(data.fileName) ? filename : data.fileName, true);
}
if (!Const.isEmpty(filename)) {
FileObject fileObject = KettleVFS.getFileObject(filename);
resources.add(ExternalResourceInfoFactory.createFileResource(fileObject, false));
}
} catch (KettleException kve) {
// TODO throw exception or ignore?
}
return resources;
}
Aggregations