Search in sources :

Example 16 with ValueMetaAndData

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);
}
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)

Example 17 with ValueMetaAndData

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