01: package liquibase.dbdoc;
02:
03: import liquibase.change.Change;
04: import liquibase.database.Database;
05: import liquibase.database.structure.Column;
06: import liquibase.database.structure.Table;
07:
08: import java.io.File;
09: import java.io.FileWriter;
10: import java.io.IOException;
11: import java.util.ArrayList;
12: import java.util.Arrays;
13: import java.util.List;
14:
15: public class TableWriter extends HTMLWriter {
16:
17: public TableWriter(File rootOutputDir, Database database) {
18: super (new File(rootOutputDir, "tables"), database);
19: }
20:
21: protected String createTitle(Object object) {
22: return "Changes affecting table \"" + object.toString() + "\"";
23: }
24:
25: protected void writeCustomHTML(FileWriter fileWriter,
26: Object object, List<Change> changes, Database database)
27: throws IOException {
28: writeColumns(fileWriter, ((Table) object), database);
29: }
30:
31: private void writeColumns(FileWriter fileWriter, Table table,
32: Database database) throws IOException {
33: List<List<String>> cells = new ArrayList<List<String>>();
34:
35: for (Column column : table.getColumns()) {
36: cells.add(Arrays.asList(column.getDataTypeString(database),
37: "<A HREF=\"../columns/" + table.getName() + "."
38: + column.getName() + ".html" + "\">"
39: + column.getName() + "</A>"));
40: //todo: add foreign key info to columns?
41: }
42:
43: writeTable("Current Columns", cells, fileWriter);
44:
45: }
46: }
|