use of org.pentaho.di.core.row.ValueMetaAndData 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.row.ValueMetaAndData in project pdi-dataservice-server-plugin by pentaho.
the class DataServiceExecutor method convertAtomicCondition.
private static void convertAtomicCondition(Condition condition, ValueMetaResolver resolver) {
// No need to convert conditions with no right side argument
if (condition.getRightExact() == null) {
return;
}
String fieldName = condition.getLeftValuename();
ValueMetaAndData rhs = condition.getRightExact();
try {
// Determine meta and resolve value
ValueMetaInterface resolvedValueMeta = resolver.getValueMeta(fieldName);
if (ValueMetaInterface.TYPE_INTEGER == resolvedValueMeta.getType() && ValueMetaInterface.TYPE_NUMBER == rhs.getValueMeta().getType()) {
// Do not round Double parameter value
return;
}
Object resolvedValue = resolver.getTypedValue(fieldName, rhs.getValueMeta().getType(), rhs.getValueData());
// We have normally stored object here, adjust value meta accordingly
if (resolvedValueMeta.getStorageType() != ValueMetaInterface.STORAGE_TYPE_NORMAL) {
resolvedValueMeta = resolvedValueMeta.clone();
resolvedValueMeta.setStorageType(ValueMetaInterface.STORAGE_TYPE_NORMAL);
}
// Set new condition meta and value
condition.setRightExact(new ValueMetaAndData(resolvedValueMeta, resolvedValue));
} catch (KettleException e) {
// Skip conversion of this condition?
}
}
Aggregations