use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class StepExternalResourceConsumerListener method addExternalResources.
protected void addExternalResources(Collection<IExternalResourceInfo> resources, StepInterface step) {
if (resources != null) {
// Add the resources to the execution profile
IExecutionProfile executionProfile = TransLineageHolderMap.getInstance().getLineageHolder(step.getTrans()).getExecutionProfile();
if (executionProfile != null) {
String stepName = step.getStepname();
Map<String, List<IExternalResourceInfo>> resourceMap = executionProfile.getExecutionData().getExternalResources();
List<IExternalResourceInfo> externalResources = resourceMap.get(stepName);
if (externalResources == null) {
externalResources = new LinkedList<IExternalResourceInfo>();
}
externalResources.addAll(resources);
resourceMap.put(stepName, externalResources);
}
}
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class ExcelInputExternalResourceConsumer method getResourcesFromRow.
@Override
public Collection<IExternalResourceInfo> getResourcesFromRow(ExcelInput excelInput, RowMetaInterface rowMeta, Object[] row) {
Collection<IExternalResourceInfo> resources = new LinkedList<IExternalResourceInfo>();
ExcelInputMeta meta = (ExcelInputMeta) excelInput.getStepMetaInterface();
if (meta == null) {
meta = (ExcelInputMeta) excelInput.getStepMeta().getStepMetaInterface();
}
try {
String filename = rowMeta.getString(row, meta.getAcceptingField(), null);
if (!Const.isEmpty(filename)) {
FileObject fileObject = KettleVFS.getFileObject(filename);
resources.add(ExternalResourceInfoFactory.createFileResource(fileObject, true));
}
} catch (KettleException kve) {
// TODO throw exception or ignore?
}
return resources;
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class ExcelOutputExternalResourceConsumer method getResourcesFromRow.
@Override
public Collection<IExternalResourceInfo> getResourcesFromRow(ExcelOutput excelOutput, RowMetaInterface rowMeta, Object[] row) {
Collection<IExternalResourceInfo> resources = new LinkedList<IExternalResourceInfo>();
try {
String filename = excelOutput.buildFilename();
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;
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class TextFileInputExternalResourceConsumer method getResourcesFromRow.
@Override
public Collection<IExternalResourceInfo> getResourcesFromRow(TextFileInput textFileInput, RowMetaInterface rowMeta, Object[] row) {
Collection<IExternalResourceInfo> resources = new LinkedList<>();
// For some reason the step doesn't return the StepMetaInterface directly, so go around it
TextFileInputMeta meta = (TextFileInputMeta) textFileInput.getStepMetaInterface();
if (meta == null) {
meta = (TextFileInputMeta) textFileInput.getStepMeta().getStepMetaInterface();
}
try {
String filename = meta == null ? null : rowMeta.getString(row, meta.getAcceptingField(), null);
if (!Const.isEmpty(filename)) {
FileObject fileObject = KettleVFS.getFileObject(filename);
resources.add(ExternalResourceInfoFactory.createFileResource(fileObject, true));
}
} catch (KettleException kve) {
// TODO throw exception or ignore?
}
return resources;
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class JobEntryExternalResourceConsumerListenerTest method testCallJobEntryAddExternalResources.
@Test
public void testCallJobEntryAddExternalResources() {
JobEntryExternalResourceConsumerListener stepExtensionPoint = new JobEntryExternalResourceConsumerListener();
stepExtensionPoint.addExternalResources(null, null);
JobEntryInterface mockJobEntry = mock(JobEntryInterface.class);
Job mockJob = mock(Job.class);
when(mockJobEntry.getParentJob()).thenReturn(mockJob);
IExecutionProfile executionProfile = mock(IExecutionProfile.class);
IExecutionData executionData = mock(IExecutionData.class);
when(executionProfile.getExecutionData()).thenReturn(executionData);
JobLineageHolderMap.getInstance().getLineageHolder(mockJob).setExecutionProfile(executionProfile);
Collection<IExternalResourceInfo> externalResources = new ArrayList<IExternalResourceInfo>();
stepExtensionPoint.addExternalResources(externalResources, mockJobEntry);
IExternalResourceInfo externalResource = mock(IExternalResourceInfo.class);
externalResources.add(externalResource);
stepExtensionPoint.addExternalResources(externalResources, mockJobEntry);
}
Aggregations