Search in sources :

Example 46 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pdi-dataservice-server-plugin by pentaho.

the class ValueMetaResolverTest method getTestRowMeta.

private RowMeta getTestRowMeta(String[] fieldNames, int[] types) {
    assert fieldNames.length == types.length;
    RowMeta rowMeta = new RowMeta();
    for (int i = 0; i < fieldNames.length; i++) {
        int type = types[i];
        String fieldName = fieldNames[i];
        rowMeta.addValueMeta(new ValueMeta(fieldName, type));
    }
    return rowMeta;
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) ValueMeta(org.pentaho.di.core.row.ValueMeta)

Example 47 with ValueMeta

use of org.pentaho.di.core.row.ValueMeta in project pdi-dataservice-server-plugin by pentaho.

the class ValueMetaResolver method convertToType.

private Object convertToType(ValueMetaInterface valueMeta, int originalType, Object value) throws PushDownOptimizationException {
    try {
        final ValueMeta meta = new ValueMeta(null, originalType);
        meta.setConversionMask(valueMeta.getConversionMask());
        return valueMeta.convertData(meta, value);
    } catch (KettleValueException valueException) {
        Object val = tryAnsiFormatConversion(valueMeta, originalType, value);
        if (val == null) {
            throw new PushDownOptimizationException("Failed to convert type", valueException);
        }
        return val;
    }
}
Also used : KettleValueException(org.pentaho.di.core.exception.KettleValueException) ValueMeta(org.pentaho.di.core.row.ValueMeta)

Aggregations

ValueMeta (org.pentaho.di.core.row.ValueMeta)47 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)39 Test (org.junit.Test)18 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)14 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)13 RowMeta (org.pentaho.di.core.row.RowMeta)12 IAnalysisContext (org.pentaho.metaverse.api.IAnalysisContext)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 KettleValueException (org.pentaho.di.core.exception.KettleValueException)5 MetaverseTransientNode (org.pentaho.dictionary.MetaverseTransientNode)5 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)5 KettleException (org.pentaho.di.core.exception.KettleException)4 KettleStepException (org.pentaho.di.core.exception.KettleStepException)4 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)3 Matchers.anyString (org.mockito.Matchers.anyString)2 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)2 BatchUpdateException (java.sql.BatchUpdateException)1 Blob (java.sql.Blob)1 ResultSet (java.sql.ResultSet)1