Search in sources :

Example 6 with StepDataInterface

use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.

the class BaseStreamStep method init.

public boolean init(StepMetaInterface stepMetaInterface, StepDataInterface stepDataInterface) {
    Preconditions.checkNotNull(stepMetaInterface);
    stepMeta = (BaseStreamStepMeta) stepMetaInterface;
    stepMeta.setParentStepMeta(getStepMeta());
    stepMeta.setFileName(stepMeta.getTransformationPath());
    boolean superInit = super.init(stepMetaInterface, stepDataInterface);
    try {
        TransMeta transMeta = TransExecutorMeta.loadMappingMeta(stepMeta, getTransMeta().getRepository(), getTransMeta().getMetaStore(), getParentVariableSpace());
        subtransExecutor = new SubtransExecutor(getStepname(), getTrans(), transMeta, true, new TransExecutorParameters(), environmentSubstitute(stepMeta.getSubStep()));
    } catch (KettleException e) {
        log.logError(e.getLocalizedMessage(), e);
        return false;
    }
    List<CheckResultInterface> remarks = new ArrayList<>();
    stepMeta.check(remarks, getTransMeta(), stepMeta.getParentStepMeta(), // these parameters are not used inside the method
    null, // these parameters are not used inside the method
    null, // these parameters are not used inside the method
    null, // these parameters are not used inside the method
    null, variables, getRepository(), getMetaStore());
    boolean errorsPresent = remarks.stream().filter(result -> result.getType() == CheckResultInterface.TYPE_RESULT_ERROR).peek(result -> logError(result.getText())).count() > 0;
    if (errorsPresent) {
        return false;
    }
    return superInit;
}
Also used : Result(org.pentaho.di.core.Result) Trans(org.pentaho.di.trans.Trans) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) StreamWindow(org.pentaho.di.trans.streaming.api.StreamWindow) KettleException(org.pentaho.di.core.exception.KettleException) TransExecutorMeta(org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta) ArrayList(java.util.ArrayList) TransMeta(org.pentaho.di.trans.TransMeta) StepStatus(org.pentaho.di.trans.step.StepStatus) BaseMessages(org.pentaho.di.i18n.BaseMessages) StepMeta(org.pentaho.di.trans.step.StepMeta) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) Collection(java.util.Collection) Throwables(com.google.common.base.Throwables) StreamSource(org.pentaho.di.trans.streaming.api.StreamSource) BaseStep(org.pentaho.di.trans.step.BaseStep) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) List(java.util.List) SubtransExecutor(org.pentaho.di.trans.SubtransExecutor) KettleStepException(org.pentaho.di.core.exception.KettleStepException) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TransExecutorParameters(org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters) Collections(java.util.Collections) KettleException(org.pentaho.di.core.exception.KettleException) SubtransExecutor(org.pentaho.di.trans.SubtransExecutor) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) TransExecutorParameters(org.pentaho.di.trans.steps.transexecutor.TransExecutorParameters) CheckResultInterface(org.pentaho.di.core.CheckResultInterface)

Example 7 with StepDataInterface

use of org.pentaho.di.trans.step.StepDataInterface in project pdi-dataservice-server-plugin by pentaho.

the class AnnotationsQueryServiceTest method createPseudoAnnotate.

private DummyTransMeta createPseudoAnnotate(final ModelAnnotationGroup mag) {
    final String magicKey = "KEY_MODEL_ANNOTATIONS";
    DummyTransMeta annot1Meta = new DummyTransMeta() {

        @Override
        public StepInterface getStep(StepMeta stepMeta, StepDataInterface stepDataInterface, int cnr, TransMeta tr, final Trans trans) {
            return new DummyTrans(stepMeta, stepDataInterface, cnr, tr, trans) {

                @Override
                public boolean init(StepMetaInterface smi, StepDataInterface sdi) {
                    ModelAnnotationGroup existing = (ModelAnnotationGroup) trans.getExtensionDataMap().get(magicKey);
                    if (existing == null) {
                        trans.getExtensionDataMap().put(magicKey, mag);
                    } else {
                        existing.addAll(mag);
                    }
                    return true;
                }
            };
        }
    };
    return annot1Meta;
}
Also used : ModelAnnotationGroup(org.pentaho.agilebi.modeler.models.annotations.ModelAnnotationGroup) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) Trans(org.pentaho.di.trans.Trans) DummyTrans(org.pentaho.di.trans.steps.dummytrans.DummyTrans) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) DummyTrans(org.pentaho.di.trans.steps.dummytrans.DummyTrans)

Example 8 with StepDataInterface

use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.

the class Trans method getEnded.

/**
 * Gets the number of steps in the transformation that are in an end state, such as Finished, Halted, or Stopped.
 *
 * @return the number of ended steps
 */
public int getEnded() {
    int nrEnded = 0;
    if (steps == null) {
        return 0;
    }
    for (int i = 0; i < steps.size(); i++) {
        StepMetaDataCombi sid = steps.get(i);
        StepDataInterface data = sid.data;
        if ((sid.step != null && !sid.step.isRunning()) || // Should normally not be needed anymore, status is kept in data.
        data.getStatus() == // Finished processing
        StepExecutionStatus.STATUS_FINISHED || // Not launching because of init error
        data.getStatus() == StepExecutionStatus.STATUS_HALTED || // Stopped because of an error
        data.getStatus() == StepExecutionStatus.STATUS_STOPPED) {
            nrEnded++;
        }
    }
    return nrEnded;
}
Also used : StepMetaDataCombi(org.pentaho.di.trans.step.StepMetaDataCombi) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 9 with StepDataInterface

use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.

the class RowGeneratorUnitTest method setUp.

@Before
public void setUp() throws KettleException {
    // add variable to row generator step
    StepMetaInterface stepMetaInterface = spy(new RowGeneratorMeta());
    ((RowGeneratorMeta) stepMetaInterface).setRowLimit("${ROW_LIMIT}");
    String[] strings = {};
    when(((RowGeneratorMeta) stepMetaInterface).getFieldName()).thenReturn(strings);
    StepMeta stepMeta = new StepMeta();
    stepMeta.setStepMetaInterface(stepMetaInterface);
    stepMeta.setName("ROW_STEP_META");
    StepDataInterface stepDataInterface = stepMeta.getStepMetaInterface().getStepData();
    // add variable to transformation variable space
    Map<String, String> map = new HashMap<String, String>();
    map.put("ROW_LIMIT", "1440");
    TransMeta transMeta = spy(new TransMeta());
    transMeta.injectVariables(map);
    when(transMeta.findStep(anyString())).thenReturn(stepMeta);
    Trans trans = spy(new Trans(transMeta, null));
    when(trans.getSocketRepository()).thenReturn(null);
    when(trans.getLogChannelId()).thenReturn("ROW_LIMIT");
    // prepare row generator, substitutes variable by value from transformation variable space
    rowGenerator = spy(new RowGenerator(stepMeta, stepDataInterface, 0, transMeta, trans));
    rowGenerator.initializeVariablesFrom(trans);
    rowGenerator.init(stepMetaInterface, stepDataInterface);
}
Also used : HashMap(java.util.HashMap) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) TransMeta(org.pentaho.di.trans.TransMeta) Mockito.anyString(org.mockito.Mockito.anyString) StepMeta(org.pentaho.di.trans.step.StepMeta) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) Trans(org.pentaho.di.trans.Trans) Before(org.junit.Before)

Example 10 with StepDataInterface

use of org.pentaho.di.trans.step.StepDataInterface in project pentaho-kettle by pentaho.

the class UnivariateStatsMetaTest method testGetStep.

@Test
public void testGetStep() {
    StepMeta mockStepMeta = mock(StepMeta.class);
    when(mockStepMeta.getName()).thenReturn("testName");
    StepDataInterface mockStepDataInterface = mock(StepDataInterface.class);
    int cnr = 10;
    TransMeta mockTransMeta = mock(TransMeta.class);
    Trans mockTrans = mock(Trans.class);
    when(mockTransMeta.findStep("testName")).thenReturn(mockStepMeta);
    StepInterface step = new UnivariateStatsMeta().getStep(mockStepMeta, mockStepDataInterface, cnr, mockTransMeta, mockTrans);
    assertTrue("Expected Step to be instanceof " + UnivariateStats.class, step instanceof UnivariateStats);
}
Also used : StepInterface(org.pentaho.di.trans.step.StepInterface) TransMeta(org.pentaho.di.trans.TransMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) StepDataInterface(org.pentaho.di.trans.step.StepDataInterface) Trans(org.pentaho.di.trans.Trans) Test(org.junit.Test)

Aggregations

StepDataInterface (org.pentaho.di.trans.step.StepDataInterface)11 StepMeta (org.pentaho.di.trans.step.StepMeta)8 Trans (org.pentaho.di.trans.Trans)7 TransMeta (org.pentaho.di.trans.TransMeta)7 Test (org.junit.Test)6 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)5 QueueRowSet (org.pentaho.di.core.QueueRowSet)2 RowSet (org.pentaho.di.core.RowSet)2 KettleException (org.pentaho.di.core.exception.KettleException)2 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Throwables (com.google.common.base.Throwables)1 OutputStreamWriter (java.io.OutputStreamWriter)1 PrintWriter (java.io.PrintWriter)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Field (java.lang.reflect.Field)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1