javakettlepentaho-spoonpentaho-data-integrationspoon

Outgoing fields not showing in pentaho plugin


I have created a step plugin for pentaho which gives some output fields. It gets 2 Input fields from previous steps add some metadata and output fields . Although output is being sent to next step but when i do right click and click on output fields it only show field and value from previous steps not from the step plugin i created. Below is the Java Code for Meta class.

import org.eclipse.swt.widgets.Shell;
import org.pentaho.di.core.annotations.Step;
import org.pentaho.di.core.exception.KettleStepException;
import org.pentaho.di.core.row.RowMeta;
import org.pentaho.di.core.row.RowMetaInterface;
import org.pentaho.di.core.row.ValueMeta;
import org.pentaho.di.core.row.ValueMetaInterface;
import org.pentaho.di.core.variables.VariableSpace;
import org.pentaho.di.repository.Repository;
import org.pentaho.di.trans.Trans;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.di.trans.step.*;
import org.pentaho.metastore.api.IMetaStore;


@Step(
        id = "FlatJson",
        image = "com/cxps/flatjson/steps/resources/demo.svg",
        i18nPackageName = "com.cxps.flatjson",
        name = "FlatJson.name",
        description = "FlatJson.description",
        categoryDescription = "i18n:org.pentaho.di.trans.step:BaseStep.Category.Transform"
)
public class FlatJsonMeta extends BaseStepMeta implements StepMetaInterface {
    public FlatJsonMeta() {
        super();
    }

    @Override
    public void setDefault() {

    }

    @Override
    public StepInterface getStep(StepMeta stepMeta, StepDataInterface sdi, int i, TransMeta transMeta, Trans trans) {
        return new FlatJson(stepMeta, sdi, i, transMeta, trans);
    }

    @Override
    public StepDataInterface getStepData() {
        return new FlatJsonData();
    }

    public StepDialogInterface getDialog(Shell shell, StepMetaInterface smi, TransMeta transMeta, String name) {
        return new FlatJsonDialog(shell, smi, transMeta, name);
    }

    @Override
    public void getFields(RowMetaInterface r, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
        //RowMetaInterface fields = new RowMeta();
        //fields.addRowMeta(r);


        super.getFields(r, origin, info, nextStep, space, repository, metaStore);
    }

    @Override
    public Object clone() {
        FlatJsonMeta retVal = (FlatJsonMeta) super.clone();
        return retVal;
    }
}

This is the Spoon view of my plugin which doesn't show output fields.

enter image description here


Solution

  • The method getFields() is responsible for showing output fields of a step (or plugin). In your code, this method is just calling a super(); that's why it is not displaying the fields those are outcome of your logic.

    You need to implement this method to show up the fields. You can get a reference from how they have done for existing steps for example TableInput step.

    You can find source code on pentaho git repository at location pentaho-

    kettle/engine/src/main/java/org/pentaho/di/trans/steps/tableinput/TableInputMeta.java