Search in sources :

Example 6 with ValueMetaAndData

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());
}
Also used : Column(com.healthmarketscience.jackcess.Column) ValueMetaAndData(org.pentaho.di.core.row.ValueMetaAndData) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 7 with ValueMetaAndData

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());
}
Also used : ValueMetaAndData(org.pentaho.di.core.row.ValueMetaAndData)

Example 8 with ValueMetaAndData

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);
}
Also used : DBObject(com.mongodb.DBObject) ValueMetaAndData(org.pentaho.di.core.row.ValueMetaAndData)

Example 9 with ValueMetaAndData

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);
}
Also used : Condition(org.pentaho.di.core.Condition) ParameterGenerationTest.newCondition(org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGenerationTest.newCondition) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaAndData(org.pentaho.di.core.row.ValueMetaAndData) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString)

Example 10 with ValueMetaAndData

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);
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleException(org.pentaho.di.core.exception.KettleException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaAndData(org.pentaho.di.core.row.ValueMetaAndData) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

ValueMetaAndData (org.pentaho.di.core.row.ValueMetaAndData)17 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)6 Condition (org.pentaho.di.core.Condition)4 KettleException (org.pentaho.di.core.exception.KettleException)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 KettleValueException (org.pentaho.di.core.exception.KettleValueException)3 RowMeta (org.pentaho.di.core.row.RowMeta)3 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)3 LongObjectId (org.pentaho.di.repository.LongObjectId)2 ObjectId (org.pentaho.di.repository.ObjectId)2 ParameterGenerationTest.newCondition (org.pentaho.di.trans.dataservice.optimization.paramgen.ParameterGenerationTest.newCondition)2 Node (org.w3c.dom.Node)2 Column (com.healthmarketscience.jackcess.Column)1 DataType (com.healthmarketscience.jackcess.DataType)1 DBObject (com.mongodb.DBObject)1 BigDecimal (java.math.BigDecimal)1 FileObject (org.apache.commons.vfs2.FileObject)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1