use of io.irontest.models.DataTableCell in project irontest by zheng-wang.
the class UtilsDAO method getTestcaseDataTable.
/**
* @param testcaseId
* @param fetchFirstRowOnly if true, only the first data table row (if exists) will be fetched; if false, all rows will be fetched.
* @return
*/
@Transaction
public DataTable getTestcaseDataTable(long testcaseId, boolean fetchFirstRowOnly) {
DataTable dataTable = new DataTable();
List<DataTableColumn> columns = dataTableColumnDAO().findByTestcaseId(testcaseId);
// populate the data table rows Java model column by column
List<LinkedHashMap<String, Object>> rows = new ArrayList<>();
for (DataTableColumn column : columns) {
List<DataTableCell> columnCells = dataTableCellDAO().findByColumnId(column.getId());
for (DataTableCell columnCell : columnCells) {
short rowSequence = columnCell.getRowSequence();
if (rows.size() < rowSequence) {
rows.add(new LinkedHashMap<String, Object>());
}
Object cellObject;
if (columnCell.getValue() != null) {
cellObject = columnCell.getValue();
} else {
cellObject = endpointDAO().findById(columnCell.getEndpointId());
}
rows.get(rowSequence - 1).put(column.getName(), cellObject);
if (fetchFirstRowOnly && rows.size() == 1) {
break;
}
}
}
if (columns.size() > 0) {
dataTable = new DataTable();
dataTable.setColumns(columns);
dataTable.setRows(rows);
}
return dataTable;
}
use of io.irontest.models.DataTableCell in project irontest by zheng-wang.
the class DataTableCellMapper method map.
public DataTableCell map(int index, ResultSet rs, StatementContext ctx) throws SQLException {
DataTableCell result = new DataTableCell();
result.setRowSequence(rs.getShort("row_sequence"));
result.setValue(rs.getString("value"));
result.setEndpointId(rs.getLong("endpoint_id"));
return result;
}
Aggregations