Search in sources :

Example 41 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData 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 42 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData 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 43 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryConnectionDelegate method findStepAttributeID.

public synchronized ObjectId findStepAttributeID(ObjectId id_step, int nr, String code) throws KettleException {
    RowMetaAndData r = null;
    if (stepAttributesBuffer != null) {
        r = searchStepAttributeInBuffer(id_step, code, nr);
    } else {
        r = getStepAttributeRow(id_step, nr, code);
    }
    if (r == null) {
        return null;
    }
    long id = r.getInteger(KettleDatabaseRepository.FIELD_STEP_ATTRIBUTE_ID_STEP, -1L);
    if (id < 0) {
        return null;
    }
    return new LongObjectId(id);
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId)

Example 44 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData 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 45 with RowMetaAndData

use of org.pentaho.di.core.RowMetaAndData in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryConnectionDelegate method getJobEntryAttributeBoolean.

public synchronized boolean getJobEntryAttributeBoolean(ObjectId id_jobentry, int nr, String code, boolean def) throws KettleException {
    RowMetaAndData r = getJobEntryAttributeRow(id_jobentry, nr, code);
    if (r == null) {
        return def;
    }
    String v = r.getString(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_VALUE_STR, null);
    if (v == null || Utils.isEmpty(v)) {
        return def;
    }
    return ValueMetaString.convertStringToBoolean(v).booleanValue();
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Aggregations

RowMetaAndData (org.pentaho.di.core.RowMetaAndData)563 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)225 ArrayList (java.util.ArrayList)172 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)145 TransMeta (org.pentaho.di.trans.TransMeta)116 Test (org.junit.Test)108 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)94 KettleException (org.pentaho.di.core.exception.KettleException)89 StepMeta (org.pentaho.di.trans.step.StepMeta)80 LongObjectId (org.pentaho.di.repository.LongObjectId)75 StepInterface (org.pentaho.di.trans.step.StepInterface)75 RowStepCollector (org.pentaho.di.trans.RowStepCollector)73 Trans (org.pentaho.di.trans.Trans)73 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)71 TransHopMeta (org.pentaho.di.trans.TransHopMeta)71 KettleValueException (org.pentaho.di.core.exception.KettleValueException)58 RowProducer (org.pentaho.di.trans.RowProducer)56 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)54 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)53 RowMeta (org.pentaho.di.core.row.RowMeta)51