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[] {});
}
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");
}
Aggregations