use of io.irontest.models.DataTableColumn 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.DataTableColumn in project irontest by zheng-wang.
the class DataTableColumnMapper method map.
public DataTableColumn map(int index, ResultSet rs, StatementContext ctx) throws SQLException {
DataTableColumn result = new DataTableColumn();
result.setId(rs.getLong("id"));
result.setName(rs.getString("name"));
result.setType(DataTableColumnType.getByText(rs.getString("type")));
return result;
}
Aggregations