for (Table t : tables) {
String typeString = null;
if (t.getType() != null) {
typeString = t.getType().toString();
}
data.add(new DefaultRow(header, new Object[] { t.getName(), typeString, t.getColumnCount(),
t.getRemarks() }));
}
} else if ("columns".equals(tableName)) {
// "columns" columns: name, type, native_type, size, nullable,
// indexed, table, remarks
for (Table t : tables) {
for (Column c : t.getColumns()) {
String typeString = null;
if (t.getType() != null) {
typeString = c.getType().toString();
}
data.add(new DefaultRow(header, new Object[] { c.getName(), typeString, c.getNativeType(),
c.getColumnSize(), c.isNullable(), c.isIndexed(), t.getName(), c.getRemarks() }));
}
}
} else if ("relationships".equals(tableName)) {
// "relationships" columns: primary_table, primary_column,
// foreign_table, foreign_column
for (Relationship r : getMainSchemaInternal().getRelationships()) {
Column[] primaryColumns = r.getPrimaryColumns();
Column[] foreignColumns = r.getForeignColumns();
Table pTable = r.getPrimaryTable();
Table fTable = r.getForeignTable();
for (int i = 0; i < primaryColumns.length; i++) {
Column pColumn = primaryColumns[i];
Column fColumn = foreignColumns[i];
data.add(new DefaultRow(header, new Object[] { pTable.getName(), pColumn.getName(),
fTable.getName(), fColumn.getName() }));
}
}
} else {
throw new IllegalArgumentException("Cannot materialize non information_schema table: " + table);