public TableDetailsExporter(ReportContext context) {
this.context = context;
}
public void exportTableChange(TableChange tableChange) throws IOException {
FilePrintWriter out = null;
try {
DBTable oldTable = tableChange.getOldTable();
DBTable newTable = tableChange.getNewTable();
File htmlFile = tableFile(oldTable);
FileUtil.ensureDirectoryExists(htmlFile.getParentFile());
File cssFile = context.reportFile("mad4db.css");
out = HtmlReportUtil.createFile(htmlFile, "Modified Table " + oldTable.getName(), Encodings.UTF_8, cssFile);
context.printNavBarFor(tableFile(newTable), out);
out.println("<table width='90%'>");
// database name
out.println(" <tr>");
out.println(" <td width='50%' align='center'><h2>" + oldTable.getSchema().getCatalog().getDatabase().getEnvironment() + "</h2></td>");
out.println(" <td width='50%' align='center'><h2>" + newTable.getSchema().getCatalog().getDatabase().getEnvironment() + "</h2></td>");
out.println(" </tr>");
//columns
out.println(" <tr>");
out.println(" <td width='50%'>");
exportColumns(oldTable, tableChange, out);
out.println(" </td>");
out.println(" <td width='50%'>");
exportColumns(newTable, tableChange, out);
out.println(" </td>");
out.println(" </tr>");
//foreign keys
out.println(" <tr>");
out.println(" <td>");
exportForeignKeys(oldTable, tableChange, out);
out.println(" </td>");
out.println(" <td>");
exportForeignKeys(newTable, tableChange, out);
out.println(" </td>");
out.println(" </tr>");
//constraints
out.println(" <tr>");
out.println(" <td>");
exportConstraints(oldTable, tableChange, out);
out.println(" </td>");
out.println(" <td>");
exportConstraints(newTable, tableChange, out);
out.println(" </td>");
out.println(" </tr>");
// indexes
out.println(" <tr>");
out.println(" <td>");
exportIndexes(oldTable, tableChange, out);
out.println(" </td>");
out.println(" <td>");
exportIndexes(newTable, tableChange, out);
out.println(" </td>");
out.println(" </tr>");
// referrers
out.println(" <tr>");
out.println(" <td>");
exportReferers(oldTable, tableChange, out);
out.println(" </td>");
out.println(" <td>");
exportReferers(newTable, tableChange, out);
out.println(" </td>");
out.println(" </tr>");
out.println("</table>");
out.println(context.footer());
HtmlReportUtil.endHtmlFile(out);
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
IOUtil.close(out);