Search in sources :

Example 11 with ValueMetaString

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

the class KettleDatabaseRepositoryConditionDelegate method lookupValue.

public synchronized ObjectId lookupValue(String name, String type, String value_str, boolean isnull) throws KettleException {
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_NAME), name);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE), type);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_VALUE_VALUE_STR), value_str);
    table.addValue(new ValueMetaBoolean(KettleDatabaseRepository.FIELD_VALUE_IS_NULL), Boolean.valueOf(isnull));
    String sql = "SELECT " + quote(KettleDatabaseRepository.FIELD_VALUE_ID_VALUE) + " FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_VALUE) + " ";
    sql += "WHERE " + quote(KettleDatabaseRepository.FIELD_VALUE_NAME) + "       = ? ";
    sql += "AND   " + quote(KettleDatabaseRepository.FIELD_VALUE_VALUE_TYPE) + " = ? ";
    sql += "AND   " + quote(KettleDatabaseRepository.FIELD_VALUE_VALUE_STR) + "  = ? ";
    sql += "AND   " + quote(KettleDatabaseRepository.FIELD_VALUE_IS_NULL) + "    = ? ";
    RowMetaAndData result = repository.connectionDelegate.getOneRow(sql, table.getRowMeta(), table.getData());
    if (result != null && result.getData() != null && result.isNumeric(0)) {
        return new LongObjectId(result.getInteger(0, 0L));
    } else {
        return null;
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaBoolean(org.pentaho.di.core.row.value.ValueMetaBoolean) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 12 with ValueMetaString

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

the class KettleDatabaseRepositoryConnectionDelegate method getTransAttributes.

public synchronized List<Object[]> getTransAttributes(ObjectId id_transformation, String code, long nr) throws KettleException {
    String sql = "SELECT *" + " FROM " + databaseMeta.getQuotedSchemaTableCombination(null, KettleDatabaseRepository.TABLE_R_TRANS_ATTRIBUTE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION) + " = ? AND " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE) + " = ? AND " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_NR) + " = ?" + " ORDER BY " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_VALUE_NUM);
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION), new LongObjectId(id_transformation));
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE), code);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_NR), new Long(nr));
    return callRead(() -> database.getRows(sql, table.getRowMeta(), table.getData(), ResultSet.FETCH_FORWARD, false, 0, null));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 13 with ValueMetaString

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

the class KettleDatabaseRepositoryConnectionDelegate method getIDWithValue.

public synchronized ObjectId getIDWithValue(String tablename, String idfield, String lookupfield, String value, String lookupkey, ObjectId key) throws KettleException {
    RowMetaAndData par = new RowMetaAndData();
    par.addValue(new ValueMetaString("value"), value);
    par.addValue(new ValueMetaInteger("key"), new LongObjectId(key));
    RowMetaAndData result = getOneRow("SELECT " + idfield + " FROM " + tablename + " WHERE " + lookupfield + " = ? AND " + lookupkey + " = ?", par.getRowMeta(), par.getData());
    if (result != null && result.getRowMeta() != null && result.getData() != null && result.isNumeric(0)) {
        return new LongObjectId(result.getInteger(0, 0));
    }
    return null;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 14 with ValueMetaString

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

the class KettleDatabaseRepositoryConnectionDelegate method insertJobAttribute.

public synchronized ObjectId insertJobAttribute(ObjectId id_job, long nr, String code, long value_num, String value_str) throws KettleException {
    ObjectId id = getNextJobAttributeID();
    // System.out.println("Insert job attribute : id_job="+id_job+", code="+code+", value_str="+value_str);
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_ID_JOB_ATTRIBUTE), id);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_ID_JOB), id_job);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_NR), new Long(nr));
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_CODE), code);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_VALUE_NUM), new Long(value_num));
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOB_ATTRIBUTE_VALUE_STR), value_str);
    if (psJobAttributesInsert == null) {
        String sql = database.getInsertStatement(KettleDatabaseRepository.TABLE_R_JOB_ATTRIBUTE, table.getRowMeta());
        psJobAttributesInsert = database.prepareSQL(sql);
    }
    database.setValues(table, psJobAttributesInsert);
    database.insertRow(psJobAttributesInsert, useBatchProcessing);
    if (log.isDebug()) {
        log.logDebug("saved job attribute [" + code + "]");
    }
    return id;
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 15 with ValueMetaString

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

the class KettleDatabaseRepositoryConnectionDelegate method countNrTransAttributes.

public synchronized int countNrTransAttributes(ObjectId id_transformation, String code) throws KettleException {
    String sql = "SELECT COUNT(*) FROM " + databaseMeta.getQuotedSchemaTableCombination(null, KettleDatabaseRepository.TABLE_R_TRANS_ATTRIBUTE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION) + " = ? AND " + quote(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE) + " = ?";
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION), id_transformation);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_CODE), code);
    RowMetaAndData r = callRead(() -> database.getOneRow(sql, table.getRowMeta(), table.getData()));
    if (r == null || r.getData() == null) {
        return 0;
    }
    return (int) r.getInteger(0, 0L);
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Aggregations

ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)447 RowMeta (org.pentaho.di.core.row.RowMeta)219 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)181 Test (org.junit.Test)179 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)176 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)141 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)86 ValueMetaBoolean (org.pentaho.di.core.row.value.ValueMetaBoolean)67 ValueMetaNumber (org.pentaho.di.core.row.value.ValueMetaNumber)66 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)57 KettleException (org.pentaho.di.core.exception.KettleException)40 ArrayList (java.util.ArrayList)33 LongObjectId (org.pentaho.di.repository.LongObjectId)29 ValueMetaBigNumber (org.pentaho.di.core.row.value.ValueMetaBigNumber)27 ValueMetaBinary (org.pentaho.di.core.row.value.ValueMetaBinary)26 ObjectId (org.pentaho.di.repository.ObjectId)26 ValueMetaTimestamp (org.pentaho.di.core.row.value.ValueMetaTimestamp)21 RowSet (org.pentaho.di.core.RowSet)18 Date (java.util.Date)17 ValueMetaBase (org.pentaho.di.core.row.value.ValueMetaBase)16