public DatasetFilterInput getFilterInput() {
return filterInput;
}
private void loadRecordValues(DatasetFilterInput filterInput) throws SQLException {
DBDataset dataset = getDataset();
StringBuilder selectStatement = new StringBuilder();
selectStatement.append("select ");
Iterator<DBColumn> iterator = dataset.getColumns().iterator();
while (iterator.hasNext()) {
DBColumn column = iterator.next();
selectStatement.append(column.getName());
if (iterator.hasNext()) {
selectStatement.append(", ");
}
}
selectStatement.append(" from ");
selectStatement.append(dataset.getQualifiedName());
selectStatement.append(" where ");
iterator = filterInput.getColumns().iterator();
while (iterator.hasNext()) {
DBColumn column = iterator.next();
selectStatement.append(column.getName());
selectStatement.append(" = ? ");
if (iterator.hasNext()) {
selectStatement.append(" and ");
}
}
Connection connection = dataset.getConnectionHandler().getPoolConnection();
PreparedStatement statement = connection.prepareStatement(selectStatement.toString());
int index = 1;
iterator = filterInput.getColumns().iterator();
while (iterator.hasNext()) {
DBColumn column = iterator.next();
Object value = filterInput.getColumnValue(column);
column.getDataType().setValueToPreparedStatement(statement, index, value);
index++;
}
resultSet = statement.executeQuery();
if (resultSet.next()) {
index = 1;
for (DBColumn column : dataset.getColumns()) {
Object value = column.getDataType().getValueFromResultSet(resultSet, index);
values.put(column.getName(), value);
index++;
}
}