Search in sources :

Example 56 with RowMetaAndData

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

the class KettleDatabaseRepositoryConnectionDelegate method getTransAttributesWithPrefix.

public synchronized List<Object[]> getTransAttributesWithPrefix(ObjectId id_transformation, String codePrefix) 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) + " LIKE '" + codePrefix + "%'";
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_TRANS_ATTRIBUTE_ID_TRANSFORMATION), new LongObjectId(id_transformation));
    return callRead(() -> database.getRows(sql, table.getRowMeta(), table.getData(), ResultSet.FETCH_FORWARD, false, 0, null));
}
Also used : 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 57 with RowMetaAndData

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

the class KettleDatabaseRepositoryConnectionDelegate method getJobEntryAttributeRow.

private RowMetaAndData getJobEntryAttributeRow(ObjectId id_jobentry, int nr, String code) throws KettleException {
    RowMetaAndData par = new RowMetaAndData();
    par.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_ID_JOBENTRY), id_jobentry);
    par.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_CODE), code);
    par.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_ATTRIBUTE_NR), new Long(nr));
    if (pstmt_entry_attributes == null) {
        setLookupJobEntryAttribute();
    }
    database.setValues(par.getRowMeta(), par.getData(), pstmt_entry_attributes);
    return callRead(new Callable<RowMetaAndData>() {

        @Override
        public RowMetaAndData call() throws Exception {
            Object[] lookup = database.getLookup(pstmt_entry_attributes);
            return new RowMetaAndData(database.getReturnRowMeta(), lookup);
        }
    });
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) KettleException(org.pentaho.di.core.exception.KettleException) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) SQLException(java.sql.SQLException) KettleValueException(org.pentaho.di.core.exception.KettleValueException)

Example 58 with RowMetaAndData

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

the class KettleDatabaseRepositoryDatabaseDelegate method getNrDatabases.

public synchronized int getNrDatabases(ObjectId id_transformation) throws KettleException {
    int retval = 0;
    RowMetaAndData transIdRow = repository.connectionDelegate.getParameterMetaData(id_transformation);
    String sql = "SELECT COUNT(*) FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_STEP_DATABASE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_TRANSFORMATION) + " = ? ";
    RowMetaAndData r = repository.connectionDelegate.getOneRow(sql, transIdRow.getRowMeta(), transIdRow.getData());
    if (r != null) {
        retval = (int) r.getInteger(0, 0L);
    }
    return retval;
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 59 with RowMetaAndData

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

the class KettleDatabaseRepositoryDatabaseDelegate method getNrDatabaseAttributes.

public synchronized int getNrDatabaseAttributes(ObjectId id_database) throws KettleException {
    int retval = 0;
    String sql = "SELECT COUNT(*) FROM " + quoteTable(KettleDatabaseRepository.TABLE_R_DATABASE_ATTRIBUTE) + " WHERE " + quote(KettleDatabaseRepository.FIELD_DATABASE_ATTRIBUTE_ID_DATABASE) + " = " + id_database;
    RowMetaAndData r = repository.connectionDelegate.getOneRow(sql);
    if (r != null) {
        retval = (int) r.getInteger(0, 0L);
    }
    return retval;
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 60 with RowMetaAndData

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

the class KettleDatabaseRepositoryDatabaseDelegate method insertDatabase.

public synchronized ObjectId insertDatabase(String name, String type, String access, String host, String dbname, String port, String user, String pass, String servername, String data_tablespace, String index_tablespace) throws KettleException {
    ObjectId id = repository.connectionDelegate.getNextDatabaseID();
    ObjectId id_database_type = getDatabaseTypeID(type);
    if (id_database_type == null) {
        // New support database type: add it!
        id_database_type = repository.connectionDelegate.getNextDatabaseTypeID();
        String tablename = KettleDatabaseRepository.TABLE_R_DATABASE_TYPE;
        RowMetaInterface tableMeta = new RowMeta();
        tableMeta.addValueMeta(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_TYPE_ID_DATABASE_TYPE, 5, 0));
        tableMeta.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_TYPE_CODE, KettleDatabaseRepository.REP_STRING_CODE_LENGTH, 0));
        tableMeta.addValueMeta(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_TYPE_DESCRIPTION, KettleDatabaseRepository.REP_STRING_LENGTH, 0));
        repository.connectionDelegate.getDatabase().prepareInsert(tableMeta, tablename);
        Object[] tableData = new Object[3];
        int tableIndex = 0;
        tableData[tableIndex++] = new LongObjectId(id_database_type).longValue();
        tableData[tableIndex++] = type;
        tableData[tableIndex++] = type;
        repository.connectionDelegate.getDatabase().setValuesInsert(tableMeta, tableData);
        repository.connectionDelegate.getDatabase().insertRow();
        repository.connectionDelegate.getDatabase().closeInsert();
    }
    ObjectId id_database_contype = getDatabaseConTypeID(access);
    RowMetaAndData table = new RowMetaAndData();
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE), id);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_NAME), name);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_TYPE), id_database_type);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_ID_DATABASE_CONTYPE), id_database_contype);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_HOST_NAME), host);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_DATABASE_NAME), dbname);
    table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_DATABASE_PORT), Long.valueOf(Const.toLong(port, -1)));
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_USERNAME), user);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_PASSWORD), Encr.encryptPasswordIfNotUsingVariables(pass));
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_SERVERNAME), servername);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_DATA_TBS), data_tablespace);
    table.addValue(new ValueMetaString(KettleDatabaseRepository.FIELD_DATABASE_INDEX_TBS), index_tablespace);
    repository.connectionDelegate.getDatabase().prepareInsert(table.getRowMeta(), KettleDatabaseRepository.TABLE_R_DATABASE);
    repository.connectionDelegate.getDatabase().setValuesInsert(table);
    repository.connectionDelegate.getDatabase().insertRow();
    repository.connectionDelegate.getDatabase().closeInsert();
    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) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) LongObjectId(org.pentaho.di.repository.LongObjectId)

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