Search in sources :

Example 6 with IStepExternalResourceConsumer

use of org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer in project pentaho-metaverse by pentaho.

the class StepExternalResourceConsumerListener method callExtensionPoint.

/**
 * This method is called by the Kettle code when a step is about to start
 *
 * @param log    the logging channel to log debugging information to
 * @param object The subject object that is passed to the plugin code
 * @throws org.pentaho.di.core.exception.KettleException In case the plugin decides that an error has occurred
 *                                                       and the parent process should stop.
 */
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
    if (stepConsumerProvider == null) {
        stepConsumerProvider = (IStepExternalResourceConsumerProvider) MetaverseBeanUtil.getInstance().get("IStepExternalResourceConsumerProvider");
    }
    StepMetaDataCombi stepCombi = (StepMetaDataCombi) object;
    if (stepCombi != null) {
        StepMetaInterface meta = stepCombi.meta;
        StepInterface step = stepCombi.step;
        if (meta != null) {
            Class<?> metaClass = meta.getClass();
            if (BaseStepMeta.class.isAssignableFrom(metaClass)) {
                if (stepConsumerProvider != null) {
                    // Put the class into a collection and get the consumers that can process this class
                    Set<Class<?>> metaClassSet = new HashSet<Class<?>>(1);
                    metaClassSet.add(metaClass);
                    List<IStepExternalResourceConsumer> stepConsumers = stepConsumerProvider.getExternalResourceConsumers(metaClassSet);
                    if (stepConsumers != null) {
                        for (IStepExternalResourceConsumer stepConsumer : stepConsumers) {
                            // We might know enough at this point, so call the consumer
                            Collection<IExternalResourceInfo> resources = stepConsumer.getResourcesFromMeta(meta);
                            addExternalResources(resources, step);
                            // Add a RowListener if the step is data-driven
                            if (stepConsumer.isDataDriven(meta)) {
                                stepCombi.step.addRowListener(new StepExternalConsumerRowListener(stepConsumer, step));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : StepInterface(org.pentaho.di.trans.step.StepInterface) IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) StepMetaDataCombi(org.pentaho.di.trans.step.StepMetaDataCombi) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) IStepExternalResourceConsumer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer) HashSet(java.util.HashSet)

Aggregations

IStepExternalResourceConsumer (org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumer)6 HashSet (java.util.HashSet)4 Test (org.junit.Test)3 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)3 StepInterface (org.pentaho.di.trans.step.StepInterface)3 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)3 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)3 Trans (org.pentaho.di.trans.Trans)2 StepMeta (org.pentaho.di.trans.step.StepMeta)2 StepMetaDataCombi (org.pentaho.di.trans.step.StepMetaDataCombi)2 StepExternalResourceConsumerProvider (org.pentaho.metaverse.analyzer.kettle.step.StepExternalResourceConsumerProvider)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Set (java.util.Set)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 BaseStep (org.pentaho.di.trans.step.BaseStep)1 IStepExternalResourceConsumerProvider (org.pentaho.metaverse.api.analyzer.kettle.step.IStepExternalResourceConsumerProvider)1 IExecutionData (org.pentaho.metaverse.api.model.IExecutionData)1 IExecutionProfile (org.pentaho.metaverse.api.model.IExecutionProfile)1 LineageHolder (org.pentaho.metaverse.api.model.LineageHolder)1