Search in sources :

Example 16 with TableInputMeta

use of org.pentaho.di.trans.steps.tableinput.TableInputMeta in project pdi-dataservice-server-plugin by pentaho.

the class TableInputValidation method checkMissingDefinedParam.

private void checkMissingDefinedParam(CheckStepsExtension checkStepExtension, DataServiceMeta dataServiceMeta) {
    StepMeta checkedStepMeta = checkStepExtension.getStepMetas()[0];
    TableInputMeta tableInputMeta = (TableInputMeta) checkedStepMeta.getStepMetaInterface();
    for (ParameterGeneration paramGen : getParameterGenerationsForStep(dataServiceMeta, checkedStepMeta.getName())) {
        if (Const.isEmpty(tableInputMeta.getSQL()) || !tableInputMeta.getSQL().contains(paramGen.getParameterName())) {
            checkStepExtension.getRemarks().add(warn(BaseMessages.getString(PKG, "TableInputValidation.MissingDefinedParam.Message", checkedStepMeta.getName(), paramGen.getParameterName()), checkedStepMeta));
        }
    }
}
Also used : ParameterGeneration(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGeneration) StepMeta(org.pentaho.di.trans.step.StepMeta) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta)

Example 17 with TableInputMeta

use of org.pentaho.di.trans.steps.tableinput.TableInputMeta in project pdi-dataservice-server-plugin by pentaho.

the class TableInputValidation method checkPushdownParameter.

private void checkPushdownParameter(CheckStepsExtension checkStepExtension) {
    StepMeta checkedStepMeta = checkStepExtension.getStepMetas()[0];
    TableInputMeta tableInputMeta = (TableInputMeta) checkedStepMeta.getStepMetaInterface();
    String sql = tableInputMeta.getSQL();
    if (Const.isEmpty(sql) || !paramSubstitutionModifiesString(sql, checkStepExtension.getVariableSpace())) {
        // No change after variable substitution, so no parameter must have been present
        checkStepExtension.getRemarks().add(warn(BaseMessages.getString(PKG, "TableInputValidation.NoParameters.Message", checkedStepMeta.getName()), checkedStepMeta));
    }
}
Also used : ValidationUtil.paramSubstitutionModifiesString(org.pentaho.di.trans.dataservice.validation.ValidationUtil.paramSubstitutionModifiesString) StepMeta(org.pentaho.di.trans.step.StepMeta) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta)

Example 18 with TableInputMeta

use of org.pentaho.di.trans.steps.tableinput.TableInputMeta in project pdi-dataservice-server-plugin by pentaho.

the class TableInputParameterGenerationTest method testPreview.

@Test
public void testPreview() throws KettleValueException, PushDownOptimizationException {
    ParameterGeneration param = factory.createPushDown();
    param.setParameterName("param");
    Condition employeeFilter = newCondition("fooField", "barValue");
    when(stepInterface.getStepMeta()).thenReturn(mock(StepMeta.class));
    TableInputMeta mockTableInput = mock(TableInputMeta.class);
    String origQuery = "SELECT * FROM TABLE WHERE ${param}";
    when(mockTableInput.getSQL()).thenReturn("SELECT * FROM TABLE WHERE ${param}");
    when(stepInterface.getStepMeta().getStepMetaInterface()).thenReturn(mockTableInput);
    when(stepInterface.getStepname()).thenReturn("testStepName");
    OptimizationImpactInfo impact = service.preview(employeeFilter, param, stepInterface);
    assertThat(impact.getQueryBeforeOptimization(), equalTo(origQuery));
    assertThat(impact.getStepName(), equalTo("testStepName"));
    assertThat(impact.getQueryAfterOptimization(), equalTo("Parameterized SQL:  SELECT * FROM TABLE WHERE fooField = ?   {1: barValue}"));
    assertTrue(impact.isModified());
}
Also used : Condition(org.pentaho.di.core.Condition) ParameterGenerationTest.newCondition(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGenerationTest.newCondition) OptimizationImpactInfo(org.pentaho.di.trans.dataservice.optimization.OptimizationImpactInfo) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) StepMeta(org.pentaho.di.trans.step.StepMeta) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta) Test(org.junit.Test)

Aggregations

TableInputMeta (org.pentaho.di.trans.steps.tableinput.TableInputMeta)18 StepMeta (org.pentaho.di.trans.step.StepMeta)14 TransMeta (org.pentaho.di.trans.TransMeta)8 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)6 Test (org.junit.Test)5 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)4 TransHopMeta (org.pentaho.di.trans.TransHopMeta)4 ArrayList (java.util.ArrayList)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 MessageBox (org.eclipse.swt.widgets.MessageBox)2 Matchers.anyString (org.mockito.Matchers.anyString)2 NotePadMeta (org.pentaho.di.core.NotePadMeta)2 Database (org.pentaho.di.core.database.Database)2 KettleException (org.pentaho.di.core.exception.KettleException)2 Point (org.pentaho.di.core.gui.Point)2 StepPluginType (org.pentaho.di.core.plugins.StepPluginType)2 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)2 Trans (org.pentaho.di.trans.Trans)2 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)2