Search in sources :

Example 91 with ValueMetaInteger

use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.

the class BaseMetadataInjectionTest method check.

/**
 * Check int property.
 */
protected void check(String propertyName, IntGetter getter) throws KettleException {
    ValueMetaInterface valueMetaString = new ValueMetaString("f");
    injector.setProperty(meta, propertyName, setValue(valueMetaString, "1"), "f");
    assertEquals(1, getter.get());
    injector.setProperty(meta, propertyName, setValue(valueMetaString, "45"), "f");
    assertEquals(45, getter.get());
    ValueMetaInterface valueMetaInteger = new ValueMetaInteger("f");
    injector.setProperty(meta, propertyName, setValue(valueMetaInteger, 1234L), "f");
    assertEquals(1234, getter.get());
    injector.setProperty(meta, propertyName, setValue(valueMetaInteger, (long) Integer.MAX_VALUE), "f");
    assertEquals(Integer.MAX_VALUE, getter.get());
    skipPropertyTest(propertyName);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 92 with ValueMetaInteger

use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.

the class SpeedTest method populateMetaAndData.

private static void populateMetaAndData(int i, Object[] rowString10, RowMetaInterface metaString10, Object[] rowMixed10, RowMetaInterface metaMixed10) {
    rowString10[i] = StringUtil.generateRandomString(20, "", "", false);
    ValueMetaInterface meta = new ValueMetaString("String" + (i + 1), 20, 0);
    metaString10.addValueMeta(meta);
    rowMixed10[i * 5 + 0] = StringUtil.generateRandomString(20, "", "", false);
    ValueMetaInterface meta0 = new ValueMetaString("String" + (i * 5 + 1), 20, 0);
    metaMixed10.addValueMeta(meta0);
    rowMixed10[i * 5 + 1] = new Date();
    ValueMetaInterface meta1 = new ValueMetaDate("String" + (i * 5 + 1));
    metaMixed10.addValueMeta(meta1);
    rowMixed10[i * 5 + 2] = new Double(Math.random() * 1000000);
    ValueMetaInterface meta2 = new ValueMetaNumber("String" + (i * 5 + 1), 12, 4);
    metaMixed10.addValueMeta(meta2);
    rowMixed10[i * 5 + 3] = new Long((long) (Math.random() * 1000000));
    ValueMetaInterface meta3 = new ValueMetaInteger("String" + (i * 5 + 1), 8, 0);
    metaMixed10.addValueMeta(meta3);
    rowMixed10[i * 5 + 4] = Boolean.valueOf(Math.random() > 0.5 ? true : false);
    ValueMetaInterface meta4 = new ValueMetaBoolean("String" + (i * 5 + 1));
    metaMixed10.addValueMeta(meta4);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) Date(java.util.Date) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate)

Example 93 with ValueMetaInteger

use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.

the class Database method getGeneratedKeys.

/**
 * @param ps The prepared insert statement to use
 * @return The generated keys in auto-increment fields
 * @throws KettleDatabaseException in case something goes wrong retrieving the keys.
 */
public RowMetaAndData getGeneratedKeys(PreparedStatement ps) throws KettleDatabaseException {
    ResultSet keys = null;
    try {
        // 1 row of keys
        keys = ps.getGeneratedKeys();
        ResultSetMetaData resultSetMetaData = keys.getMetaData();
        if (resultSetMetaData == null) {
            resultSetMetaData = ps.getMetaData();
        }
        RowMetaInterface rowMeta;
        if (resultSetMetaData == null) {
            rowMeta = new RowMeta();
            rowMeta.addValueMeta(new ValueMetaInteger("ai-key"));
        } else {
            rowMeta = getRowInfo(resultSetMetaData, false, false);
        }
        return new RowMetaAndData(rowMeta, getRow(keys, resultSetMetaData, rowMeta));
    } catch (Exception ex) {
        throw new KettleDatabaseException("Unable to retrieve key(s) from auto-increment field(s)", ex);
    } finally {
        if (keys != null) {
            try {
                keys.close();
            } catch (SQLException e) {
                throw new KettleDatabaseException("Unable to close resultset of auto-generated keys", e);
            }
        }
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RowMeta(org.pentaho.di.core.row.RowMeta) SQLException(java.sql.SQLException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) ResultSet(java.sql.ResultSet) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) KettleValueException(org.pentaho.di.core.exception.KettleValueException) BatchUpdateException(java.sql.BatchUpdateException) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) SQLException(java.sql.SQLException) KettleDatabaseBatchException(org.pentaho.di.core.exception.KettleDatabaseBatchException)

Example 94 with ValueMetaInteger

use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.

the class TableInputIT method createRowMetaInterface.

public RowMetaInterface createRowMetaInterface() {
    RowMetaInterface rm = new RowMeta();
    ValueMetaInterface[] valuesMeta = { new ValueMetaInteger("int_field") };
    for (int i = 0; i < valuesMeta.length; i++) {
        rm.addValueMeta(valuesMeta[i]);
    }
    return rm;
}
Also used : RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 95 with ValueMetaInteger

use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.

the class TextFileInputIT method createResultData2.

/**
 * Create result data for test case 2. Each Object array in element in list should mirror the data written by
 * writeInputFile().
 *
 * @return list of metadata/data couples of how the result should look like.
 */
public List<RowMetaAndData> createResultData2() {
    List<RowMetaAndData> list = new ArrayList<RowMetaAndData>();
    ValueMetaInterface[] valuesMeta = { new ValueMetaInteger("a", 15, -1), new ValueMetaInteger("b", 15, -1) };
    RowMetaInterface rm = createResultRowMetaInterface(valuesMeta);
    Object[] r1 = new Object[] { 123456L, (long) 1234567 };
    Object[] r2 = new Object[] { 654321L, (long) 7654321 };
    list.add(new RowMetaAndData(rm, r1));
    list.add(new RowMetaAndData(rm, r2));
    return list;
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Aggregations

ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)291 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)198 RowMeta (org.pentaho.di.core.row.RowMeta)132 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)124 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)110 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)89 Test (org.junit.Test)72 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)63 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)60 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)52 KettleException (org.pentaho.di.core.exception.KettleException)39 LongObjectId (org.pentaho.di.repository.LongObjectId)38 ObjectId (org.pentaho.di.repository.ObjectId)33 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)31 KettleStepException (org.pentaho.di.core.exception.KettleStepException)25 ArrayList (java.util.ArrayList)21 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)20 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)19 Date (java.util.Date)17 SQLException (java.sql.SQLException)16