use of org.pentaho.di.core.row.ValueMetaAndData in project pentaho-kettle by pentaho.
the class AccessInput method convert.
private Object convert(Object obj, AccessInputField field, int index) throws Exception {
// Get column
Column c = data.t.getColumn(field.getColumn());
// Find out field type
ValueMetaAndData sourceValueMetaAndData = AccessInputMeta.getValueMetaAndData(c, field.getName(), obj);
// DO CONVERSIONS...
//
ValueMetaInterface targetValueMeta = data.outputRowMeta.getValueMeta(data.totalpreviousfields + index);
return targetValueMeta.convertData(sourceValueMetaAndData.getValueMeta(), sourceValueMetaAndData.getValueData());
}
use of org.pentaho.di.core.row.ValueMetaAndData in project pdi-dataservice-server-plugin by pentaho.
the class TableInputParameterGeneration method getResolvedValue.
private Object getResolvedValue(Condition condition) throws PushDownOptimizationException {
ValueMetaAndData metaAndData = condition.getRightExact();
String fieldName = getFieldName(condition);
return valueMetaResolver.getTypedValue(fieldName, metaAndData.getValueMeta().getType(), metaAndData.getValueData());
}
use of org.pentaho.di.core.row.ValueMetaAndData in project pdi-dataservice-server-plugin by pentaho.
the class MongodbPredicate method getResolvedValue.
/**
* Gets the Object value associated with the Condition's rightExact.
* Also handles IN list conversion to typed array.
*/
private Object getResolvedValue(Condition condition) throws PushDownOptimizationException {
final ValueMetaAndData rightExact = condition.getRightExact();
Object value = rightExact.getValueData();
int type = rightExact.getValueMeta().getType();
String fieldName = condition.getLeftValuename();
if (condition.getFunction() == Condition.FUNC_IN_LIST) {
return valueMetaResolver.inListToTypedObjectArray(fieldName, (String) value);
}
return valueMetaResolver.getTypedValue(fieldName, type, value);
}
use of org.pentaho.di.core.row.ValueMetaAndData in project pdi-dataservice-server-plugin by pentaho.
the class TableInputParameterGenerationTest method testInListCondition.
@SuppressWarnings("unchecked")
protected void testInListCondition(String valueData, String[] inListExpectedValues, String expectedSql) throws KettleValueException, PushDownOptimizationException {
ValueMetaAndData rightExactInList = new ValueMetaAndData("mock_value", valueData);
Condition inListCondition = new Condition("field_name", Condition.FUNC_IN_LIST, null, rightExactInList);
RowMeta inListParamsMeta = mock(RowMeta.class);
List<Object> inListParams = mock(List.class);
assertThat(service.convertAtomicCondition(inListCondition, inListParamsMeta, inListParams), equalTo(expectedSql));
for (String inListValue : inListExpectedValues) {
verify(inListParams).add(inListValue);
}
verify(inListParamsMeta, times(inListExpectedValues.length)).addValueMeta(resolvedValueMeta);
verifyNoMoreInteractions(inListParams, inListParamsMeta);
}
use of org.pentaho.di.core.row.ValueMetaAndData in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryValueDelegate method loadValueMetaAndData.
public ValueMetaAndData loadValueMetaAndData(ObjectId id_value) throws KettleException {
ValueMetaAndData valueMetaAndData = new ValueMetaAndData();
try {
RowMetaAndData r = getValue(id_value);
if (r != null) {
String name = r.getString(KettleDatabaseRepository.FIELD_VALUE_NAME, null);
int valtype = ValueMetaFactory.getIdForValueMeta(r.getString(KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE, null));
boolean isNull = r.getBoolean(KettleDatabaseRepository.FIELD_VALUE_IS_NULL, false);
ValueMetaInterface v = ValueMetaFactory.createValueMeta(name, valtype);
valueMetaAndData.setValueMeta(v);
if (isNull) {
valueMetaAndData.setValueData(null);
} else {
ValueMetaInterface stringValueMeta = new ValueMetaString(name);
ValueMetaInterface valueMeta = valueMetaAndData.getValueMeta();
stringValueMeta.setConversionMetadata(valueMeta);
valueMeta.setDecimalSymbol(ValueMetaAndData.VALUE_REPOSITORY_DECIMAL_SYMBOL);
valueMeta.setGroupingSymbol(ValueMetaAndData.VALUE_REPOSITORY_GROUPING_SYMBOL);
switch(valueMeta.getType()) {
case ValueMetaInterface.TYPE_NUMBER:
valueMeta.setConversionMask(ValueMetaAndData.VALUE_REPOSITORY_NUMBER_CONVERSION_MASK);
break;
case ValueMetaInterface.TYPE_INTEGER:
valueMeta.setConversionMask(ValueMetaAndData.VALUE_REPOSITORY_INTEGER_CONVERSION_MASK);
break;
default:
break;
}
String string = r.getString("VALUE_STR", null);
valueMetaAndData.setValueData(stringValueMeta.convertDataUsingConversionMetaData(string));
// OK, now comes the dirty part...
// We want the defaults back on there...
//
valueMeta = ValueMetaFactory.createValueMeta(name, valueMeta.getType());
}
}
return valueMetaAndData;
} catch (KettleException dbe) {
throw new KettleException("Unable to load Value from repository with id_value=" + id_value, dbe);
}
}
Aggregations