Search in sources :

Example 96 with ValueMetaInteger

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

the class DatabaseIT method testDatabaseCasing.

@Test
public void testDatabaseCasing() throws Exception {
    String tableName = "mIxCaSiNG";
    Database db = setupDatabase();
    db.connect();
    RowMetaInterface rm = new RowMeta();
    ValueMetaInterface[] valuesMeta = { new ValueMetaInteger("ID"), new ValueMetaInteger("DLR_CD") };
    for (int i = 0; i < valuesMeta.length; i++) {
        valuesMeta[i].setLength(8);
        valuesMeta[i].setPrecision(0);
        rm.addValueMeta(valuesMeta[i]);
    }
    String createStatement = db.getCreateTableStatement(tableName, rm, null, false, null, true);
    db.execStatement(createStatement);
    // Make sure that the tablename is of mixed case
    assertFalse(tableName.equals(tableName.toLowerCase()));
    assertTrue(db.checkTableExists(tableName));
    assertEquals(false, db.checkTableExists("unknown"));
    // We're testing here whether tables names are case insensitive.
    // If this would fail, it can either be a problem with PDI or
    // be a problem with a new H2 JDBC driver.
    assertTrue(db.checkTableExists(tableName.toLowerCase()));
    db.disconnect();
}
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) Test(org.junit.Test)

Example 97 with ValueMetaInteger

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

the class DatabaseIT method testBatchCommit.

@Test
public void testBatchCommit() throws Exception {
    String tableName = "CommitTest";
    Database db = setupDatabase();
    db.connect();
    RowMetaInterface rm = new RowMeta();
    ValueMetaInterface[] valuesMeta = { new ValueMetaInteger("ID"), new ValueMetaInteger("VALUE") };
    for (int i = 0; i < valuesMeta.length; i++) {
        valuesMeta[i].setLength(8);
        valuesMeta[i].setPrecision(0);
        rm.addValueMeta(valuesMeta[i]);
    }
    String createStatement = db.getCreateTableStatement(tableName, rm, null, false, null, true);
    db.execStatement(createStatement);
    int insertSize = 3;
    db.setCommit(insertSize - 1);
    fillDbInBatch(tableName, db, insertSize);
    db.truncateTable(tableName);
    insertSize = 3;
    db.setCommit(insertSize);
    fillDbInBatch(tableName, db, insertSize);
    db.disconnect();
}
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) Test(org.junit.Test)

Example 98 with ValueMetaInteger

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

the class CloneRowMeta method getFields.

public void getFields(RowMetaInterface rowMeta, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    // Output field (boolean) ?
    if (addcloneflag) {
        String realfieldValue = space.environmentSubstitute(cloneflagfield);
        if (!Utils.isEmpty(realfieldValue)) {
            ValueMetaInterface v = new ValueMetaBoolean(realfieldValue);
            v.setOrigin(origin);
            rowMeta.addValueMeta(v);
        }
    }
    // Output clone row number
    if (addclonenum) {
        String realfieldValue = space.environmentSubstitute(clonenumfield);
        if (!Utils.isEmpty(realfieldValue)) {
            ValueMetaInterface v = new ValueMetaInteger(realfieldValue);
            v.setOrigin(origin);
            rowMeta.addValueMeta(v);
        }
    }
}
Also used : ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface)

Example 99 with ValueMetaInteger

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

the class ClosureGeneratorMeta method getFields.

@Override
public void getFields(RowMetaInterface row, String origin, RowMetaInterface[] info, StepMeta nextStep, VariableSpace space, Repository repository, IMetaStore metaStore) throws KettleStepException {
    // The output for the closure table is:
    // 
    // - parentId
    // - childId
    // - distance
    // 
    // Nothing else.
    // 
    RowMetaInterface result = new RowMeta();
    ValueMetaInterface parentValueMeta = row.searchValueMeta(parentIdFieldName);
    if (parentValueMeta != null) {
        result.addValueMeta(parentValueMeta);
    }
    ValueMetaInterface childValueMeta = row.searchValueMeta(childIdFieldName);
    if (childValueMeta != null) {
        result.addValueMeta(childValueMeta);
    }
    ValueMetaInterface distanceValueMeta = new ValueMetaInteger(distanceFieldName);
    distanceValueMeta.setLength(ValueMetaInterface.DEFAULT_INTEGER_LENGTH);
    result.addValueMeta(distanceValueMeta);
    row.clear();
    row.addRowMeta(result);
}
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 100 with ValueMetaInteger

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

the class InjectorIT method createRowMetaInterface.

public RowMetaInterface createRowMetaInterface() {
    RowMetaInterface rm = new RowMeta();
    ValueMetaInterface[] valuesMeta = { new ValueMetaString("field1"), new ValueMetaInteger("field2"), new ValueMetaNumber("field3"), new ValueMetaDate("field4"), new ValueMetaBoolean("field5"), new ValueMetaBigNumber("field6"), new ValueMetaBigNumber("field7") };
    for (int i = 0; i < valuesMeta.length; i++) {
        rm.addValueMeta(valuesMeta[i]);
    }
    return rm;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) ValueMetaNumber(org.pentaho.di.core.row.value.ValueMetaNumber) ValueMetaBigNumber(org.pentaho.di.core.row.value.ValueMetaBigNumber) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) 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