use of org.pentaho.di.core.Condition in project pdi-dataservice-server-plugin by pentaho.
the class TableInputParameterGenerationTest method testConvertCondition.
@Test
public void testConvertCondition() throws Exception {
// ( ( A | B ) & !C )
Condition condition = new Condition();
condition.addCondition(newCondition("A", "valA"));
condition.getCondition(0).addCondition(newCondition(OR, "B", 32));
condition.addCondition(newCondition(AND, "C", "valC"));
condition.getCondition(1).negate();
StringBuilder sqlBuilder = new StringBuilder();
RowMeta paramsMeta = mock(RowMeta.class);
List<Object> values = new LinkedList<Object>();
service.convertCondition(condition, sqlBuilder, paramsMeta, values);
assertThat(sqlBuilder.toString(), equalTo("( ( A = ? OR B = ? ) AND NOT C = ? )"));
// Verify that resolved ValueMeta added 3 times, and data stored in order
verify(paramsMeta, times(3)).addValueMeta(resolvedValueMeta);
verify(databaseMeta, times(3)).quoteField(anyString());
assertThat(values, equalTo(Arrays.<Object>asList("valA", 32, "valC")));
}
use of org.pentaho.di.core.Condition in project pdi-dataservice-server-plugin by pentaho.
the class TableInputParameterGenerationTest method testFunctionType.
@SuppressWarnings("unchecked")
private void testFunctionType(int function, String expected, Object value) throws Exception {
ValueMetaAndData right_exact = new ValueMetaAndData("mock_value", value);
Condition condition = new Condition("field_name", function, null, right_exact);
RowMeta paramsMeta = mock(RowMeta.class);
List<Object> params = mock(List.class);
assertThat(service.convertAtomicCondition(condition, paramsMeta, params), equalTo(expected));
if (value != null) {
verify(paramsMeta).addValueMeta(resolvedValueMeta);
verify(params).add(value);
}
verifyNoMoreInteractions(paramsMeta, params);
}
use of org.pentaho.di.core.Condition in project pdi-dataservice-server-plugin by pentaho.
the class MongodbPredicate method getMongoOp.
private MongoOp getMongoOp(Condition condition) throws PushDownOptimizationException {
validateConditionForOpDetermination(condition);
final Condition firstChild = condition.getChildren().get(1);
MongoOp op = MongoOp.getMongoOp(firstChild.getOperator());
if (op == null) {
throw new PushDownOptimizationException("Unsupported operator: " + firstChild.getOperatorDesc());
}
return op;
}
use of org.pentaho.di.core.Condition in project pdi-dataservice-server-plugin by pentaho.
the class ParameterGeneration method preview.
@Override
public OptimizationImpactInfo preview(DataServiceExecutor executor, StepInterface stepInterface) {
ParameterGenerationService service = serviceProvider.getService(stepInterface.getStepMeta());
Condition pushDownCondition = getPushDownCondition(executor.getSql());
return service.preview(pushDownCondition, this, stepInterface);
}
use of org.pentaho.di.core.Condition in project pdi-dataservice-server-plugin by pentaho.
the class ParameterGeneration method activate.
@Override
public boolean activate(DataServiceExecutor executor, StepInterface stepInterface) {
ParameterGenerationService service = serviceProvider.getService(stepInterface.getStepMeta());
Condition pushDownCondition = getPushDownCondition(executor.getSql());
return handlePushDown(service, pushDownCondition, stepInterface);
}
Aggregations