Search in sources :

Example 1 with TextFileOutputData

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;
}
Also used : TextFileOutputMeta(org.pentaho.di.trans.steps.textfileoutput.TextFileOutputMeta) KettleException(org.pentaho.di.core.exception.KettleException) IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) FileObject(org.apache.commons.vfs2.FileObject) LinkedList(java.util.LinkedList) TextFileOutputData(org.pentaho.di.trans.steps.textfileoutput.TextFileOutputData)

Aggregations

LinkedList (java.util.LinkedList)1 FileObject (org.apache.commons.vfs2.FileObject)1 KettleException (org.pentaho.di.core.exception.KettleException)1 TextFileOutputData (org.pentaho.di.trans.steps.textfileoutput.TextFileOutputData)1 TextFileOutputMeta (org.pentaho.di.trans.steps.textfileoutput.TextFileOutputMeta)1 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)1