Search in sources :

Example 1 with DbColumn

use of com.axway.ats.core.dbaccess.DbColumn in project ats-framework by Axway.

the class CassandraDbProvider method select.

@Override
public DbRecordValuesList[] select(DbQuery dbQuery, DbReturnModes dbReturnMode) throws DbException {
    connect();
    ArrayList<DbRecordValuesList> dbRecords = new ArrayList<DbRecordValuesList>();
    String sqlQuery = dbQuery.getQuery();
    if (allowFiltering) {
        sqlQuery += " ALLOW FILTERING";
    }
    if (log.isDebugEnabled()) {
        log.debug(sqlQuery);
    }
    ResultSet results = session.execute(sqlQuery);
    int currentRow = 0;
    Iterator<Row> it = results.iterator();
    while (it.hasNext()) {
        Row row = it.next();
        currentRow++;
        if (log.isDebugEnabled()) {
            log.debug("Result row number: " + currentRow);
        }
        DbRecordValuesList recordList = new DbRecordValuesList();
        for (Definition columnDefinition : row.getColumnDefinitions()) {
            DbColumn dbColumn = new DbColumn(columnDefinition.getTable(), columnDefinition.getName());
            dbColumn.setColumnType(columnDefinition.getType().getName().toString());
            Object value = extractObjectFromResultSet(row, columnDefinition);
            DbRecordValue recordValue = new DbRecordValue(dbColumn, value);
            recordList.add(recordValue);
        }
        dbRecords.add(recordList);
    }
    return dbRecords.toArray(new DbRecordValuesList[] {});
}
Also used : DbColumn(com.axway.ats.core.dbaccess.DbColumn) DbRecordValuesList(com.axway.ats.core.dbaccess.DbRecordValuesList) DbRecordValue(com.axway.ats.core.dbaccess.DbRecordValue) ArrayList(java.util.ArrayList) ResultSet(com.datastax.driver.core.ResultSet) Definition(com.datastax.driver.core.ColumnDefinitions.Definition) Row(com.datastax.driver.core.Row)

Example 2 with DbColumn

use of com.axway.ats.core.dbaccess.DbColumn in project ats-framework by Axway.

the class Test_DbMetaDataKey method verifyConstructorDbColumn.

@Test
public void verifyConstructorDbColumn() {
    DbMetaDataKey metaKey;
    metaKey = new DbMetaDataKey(new DbColumn("table", "column", 13));
    assertEquals(metaKey.getTableName(), "table");
    assertEquals(metaKey.getColumnName(), "column");
    assertEquals(metaKey.getIndex(), 13);
    assertEquals(metaKey.toString(), "table.column.13");
    metaKey = new DbMetaDataKey(new DbColumn("column", 5));
    assertEquals(metaKey.getTableName(), "");
    assertEquals(metaKey.getColumnName(), "column");
    assertEquals(metaKey.getIndex(), 5);
    assertEquals(metaKey.toString(), "column.5");
    metaKey = new DbMetaDataKey(new DbColumn("table", "column"));
    assertEquals(metaKey.getTableName(), "table");
    assertEquals(metaKey.getColumnName(), "column");
    assertEquals(metaKey.getIndex(), 0);
    assertEquals(metaKey.toString(), "table.column");
}
Also used : DbColumn(com.axway.ats.core.dbaccess.DbColumn) DbMetaDataKey(com.axway.ats.rbv.db.DbMetaDataKey) BaseTest(com.axway.ats.rbv.BaseTest) Test(org.junit.Test)

Aggregations

DbColumn (com.axway.ats.core.dbaccess.DbColumn)2 DbRecordValue (com.axway.ats.core.dbaccess.DbRecordValue)1 DbRecordValuesList (com.axway.ats.core.dbaccess.DbRecordValuesList)1 BaseTest (com.axway.ats.rbv.BaseTest)1 DbMetaDataKey (com.axway.ats.rbv.db.DbMetaDataKey)1 Definition (com.datastax.driver.core.ColumnDefinitions.Definition)1 ResultSet (com.datastax.driver.core.ResultSet)1 Row (com.datastax.driver.core.Row)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1