use of org.pentaho.di.trans.steps.file.BaseFileInputMeta in project pentaho-metaverse by pentaho.
the class KettleAnalyzerUtil method getResourcesFromRow.
public static Collection<IExternalResourceInfo> getResourcesFromRow(BaseFileInputStep step, RowMetaInterface rowMeta, Object[] row) {
Collection<IExternalResourceInfo> resources = new LinkedList<>();
// For some reason the step doesn't return the StepMetaInterface directly, so go around it
BaseFileInputMeta meta = (BaseFileInputMeta) step.getStepMetaInterface();
if (meta == null) {
meta = (BaseFileInputMeta) step.getStepMeta().getStepMetaInterface();
}
try {
String filename = meta == null ? null : step.environmentSubstitute(rowMeta.getString(row, meta.getAcceptingField(), null));
if (!Const.isEmpty(filename)) {
FileObject fileObject = KettleVFS.getFileObject(filename, step);
resources.add(ExternalResourceInfoFactory.createFileResource(fileObject, true));
}
} catch (KettleException kve) {
// TODO throw exception or ignore?
}
return resources;
}
use of org.pentaho.di.trans.steps.file.BaseFileInputMeta in project pentaho-metaverse by pentaho.
the class ExternalResourceStepAnalyzer method getInputFieldsToIgnore.
/**
* Returns a {@lnk Set} of field names that are to be ignored when fetching "resource" fields. This set will
* typically include any field that is either provided by a previous step, or is some "additional" field.
*/
protected Set<String> getInputFieldsToIgnore(final T meta, final Map<String, RowMetaInterface> inputRows, final RowMetaInterface rowMeta) {
Set<String> inputFieldsToIgnore = new HashSet<>();
for (RowMetaInterface rowMetaInterface : inputRows.values()) {
for (ValueMetaInterface inputField : rowMetaInterface.getValueMetaList()) {
inputFieldsToIgnore.add(inputField.getName());
}
}
if (meta instanceof BaseFileInputMeta) {
final BaseFileInputMeta fileMeta = (BaseFileInputMeta) meta;
final BaseFileField[] inputFields = fileMeta.getInputFields();
final List<String> inputFieldNames = new ArrayList<>();
for (final BaseFileField inputField : inputFields) {
inputFieldNames.add(inputField.getName());
}
// get the fields within rowMeta - any field tha ISN'T a meta input field, should be ignored
final List<ValueMetaInterface> rowMetaValueMetaList = rowMeta.getValueMetaList();
for (final ValueMetaInterface rowMetaValueMeta : rowMetaValueMetaList) {
if (!inputFieldNames.contains(rowMetaValueMeta.getName())) {
inputFieldsToIgnore.add(rowMetaValueMeta.getName());
}
}
}
return inputFieldsToIgnore;
}
Aggregations