Skip to content

Commit

Permalink
-norows implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
johncurrier committed Oct 5, 2006
1 parent 733485a commit 28330bc
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 31 deletions.
5 changes: 5 additions & 0 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ <h3><a name="Running_SchemaSpy">Running SchemaSpy </a></h3>
<td class="param">Don't display table-based comments.
for databases like MySQL that stuff unrelated data where comments belong.</td>
</tr>
<tr>
<td>&nbsp;</td>
<td class="param"><code>-norows</code></td>
<td class="param">Don't display row counts.</td>
</tr>
<tr>
<td>&nbsp;</td>
<td class="param"><code>-noimplied</code></td>
Expand Down
1 change: 1 addition & 0 deletions src/net/sourceforge/schemaspy/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public static void main(String[] argv) {
// ugh, some more...
System.setProperty("commentsInitiallyDisplayed", String.valueOf(args.remove("-cid")));
System.setProperty("displayTableComments", String.valueOf(!args.remove("-notablecomments")));
System.setProperty("displayNumRows", String.valueOf(!args.remove("-norows")));


Pattern exclusions;
Expand Down
2 changes: 1 addition & 1 deletion src/net/sourceforge/schemaspy/model/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Table(Database db, String schema, String name, String comments, DatabaseM
initColumns(meta);
initIndexes(db, meta, properties);
initPrimaryKeys(meta);
numRows = fetchNumRows(db);
numRows = Boolean.getBoolean("displayNumRows") ? fetchNumRows(db) : -1;
}

public void connectForeignKeys(Map tables, DatabaseMetaData meta) throws SQLException {
Expand Down
19 changes: 12 additions & 7 deletions src/net/sourceforge/schemaspy/view/DotNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class DotNode {
private final String path;
private final Set excludedColumns = new HashSet();
private final String lineSeparator = System.getProperty("line.separator");
private final boolean displayNumRows = Boolean.getBoolean("displayNumRows");

/**
* Create a DotNode that is a focal point of a graph
Expand Down Expand Up @@ -115,14 +116,18 @@ else if (indexColumns.contains(column))
buf.append(" ");
buf.append("</TD>");
buf.append("<TD ALIGN=\"RIGHT\" BGCOLOR=\"" + css.getBodyBackground() + "\">");
if (table.isView()) {
buf.append("view");
} else {
buf.append(NumberFormat.getInstance().format(table.getNumRows()));
buf.append(" row");
if (table.getNumRows() != 1)
buf.append('s');
if (displayNumRows) {
if (table.isView()) {
buf.append("view");
} else {
buf.append(NumberFormat.getInstance().format(table.getNumRows()));
buf.append(" row");
if (table.getNumRows() != 1)
buf.append('s');
}
}
else
buf.append(" ");
buf.append("</TD>");
buf.append("<TD ALIGN=\"RIGHT\" BGCOLOR=\"" + css.getBodyBackground() + "\">");
int numChildren = showImplied ? table.getNumChildren() : table.getNumRealChildren();
Expand Down
18 changes: 12 additions & 6 deletions src/net/sourceforge/schemaspy/view/HtmlAnomaliesPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,14 @@ private void writeTablesWithoutIndexes(List unindexedTables, LineWriter out) thr
if (!unindexedTables.isEmpty()) {
out.writeln("<table class='dataTable' border='1' rules='groups'>");
out.writeln("<colgroup>");
out.writeln("<colgroup>");
if (displayNumRows)
out.writeln("<colgroup>");
out.writeln("<thead align='left'>");
out.writeln("<tr>");
out.writeln(" <th>Table</th><th>Rows</th>");
out.write(" <th>Table</th>");
if (displayNumRows)
out.write("<th>Rows</th>");
out.writeln();
out.writeln("</tr>");
out.writeln("</thead>");
out.writeln("<tbody>");
Expand All @@ -137,10 +141,12 @@ private void writeTablesWithoutIndexes(List unindexedTables, LineWriter out) thr
out.write(table.getName());
out.write("</a>");
out.writeln("</td>");
out.write(" <td class='detail' align='right'>");
if (!table.isView())
out.write(String.valueOf(NumberFormat.getIntegerInstance().format(table.getNumRows())));
out.writeln("</td>");
if (displayNumRows) {
out.write(" <td class='detail' align='right'>");
if (!table.isView())
out.write(String.valueOf(NumberFormat.getIntegerInstance().format(table.getNumRows())));
out.writeln("</td>");
}
out.writeln(" </tr>");
}

Expand Down
7 changes: 3 additions & 4 deletions src/net/sourceforge/schemaspy/view/HtmlFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
import net.sourceforge.schemaspy.util.LineWriter;

public class HtmlFormatter {
protected final boolean encodeComments;
protected final boolean displayTableComments;
protected final boolean encodeComments = Boolean.getBoolean("encodeComments");
protected final boolean displayTableComments = Boolean.getBoolean("displayTableComments");;
protected final boolean displayNumRows = Boolean.getBoolean("displayNumRows");

protected HtmlFormatter() {
encodeComments = Boolean.getBoolean("encodeComments");
displayTableComments = Boolean.getBoolean("displayTableComments");
}

protected void writeHeader(Database db, Table table, String text, boolean showOrphans, LineWriter out) throws IOException {
Expand Down
25 changes: 15 additions & 10 deletions src/net/sourceforge/schemaspy/view/HtmlMainIndexPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private void writeHeader(Database db, int numberOfTables, int numberOfViews, boo
}
html.writeln(":</b>");
html.writeln("<TABLE class='dataTable' border='1' rules='groups'>");
int numGroups = 4 + (showIds ? 1 : 0) + (displayTableComments ? 1 : 0);
int numGroups = 3 + (showIds ? 1 : 0) + (displayTableComments ? 1 : 0) + (displayNumRows ? 1 : 0);
for (int i = 0; i < numGroups; ++i)
html.writeln("<colgroup>");
html.writeln("<thead align='left'>");
Expand All @@ -102,7 +102,8 @@ private void writeHeader(Database db, int numberOfTables, int numberOfViews, boo
html.writeln(" <th align='center' valign='bottom'>ID</th>");
html.writeln(" <th align='right' valign='bottom'>Children</th>");
html.writeln(" <th align='right' valign='bottom'>Parents</th>");
html.writeln(" <th align='right' valign='bottom'>Rows</th>");
if (displayNumRows)
html.writeln(" <th align='right' valign='bottom'>Rows</th>");
if (displayTableComments)
html.writeln(" <th align='left' valign='bottom'>Comments</th>");
html.writeln("</tr>");
Expand Down Expand Up @@ -135,12 +136,14 @@ private int writeLineItem(Table table, boolean showIds, LineWriter html) throws
html.write(String.valueOf(integerFormatter.format(numRelatives)));
html.writeln("</td>");

html.write(" <td class='detail' align='right'>");
if (!table.isView())
html.write(String.valueOf(integerFormatter.format(table.getNumRows())));
else
html.write("<span title='Views contain no real rows'>view</span>");
html.writeln("</td>");
if (displayNumRows) {
html.write(" <td class='detail' align='right'>");
if (!table.isView())
html.write(String.valueOf(integerFormatter.format(table.getNumRows())));
else
html.write("<span title='Views contain no real rows'>view</span>");
html.writeln("</td>");
}
if (displayTableComments) {
html.write(" <td class='detail'>");
String comments = table.getComments();
Expand All @@ -160,8 +163,10 @@ private int writeLineItem(Table table, boolean showIds, LineWriter html) throws

protected void writeFooter(int numRows, LineWriter html) throws IOException {
html.writeln("</TABLE>");
html.write("<p/>Total rows: ");
html.write(String.valueOf(integerFormatter.format(numRows)));
if (displayNumRows) {
html.write("<p/>Total rows: ");
html.write(String.valueOf(integerFormatter.format(numRows)));
}
html.writeln("</div>");
super.writeFooter(html);
}
Expand Down
7 changes: 5 additions & 2 deletions src/net/sourceforge/schemaspy/view/HtmlTablePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,11 @@ private boolean writeRelatives(TableColumn baseRelative, boolean dumpParents, St
}

private void writeNumRows(Database db, Table table, LineWriter out) throws IOException {
if (!table.isView())
out.writeln("<p/>Table contained " + NumberFormat.getIntegerInstance().format(table.getNumRows()) + " rows at " + db.getConnectTime());
if (displayNumRows && !table.isView())
out.write("<p/>Table contained " + NumberFormat.getIntegerInstance().format(table.getNumRows()) + " rows at ");
else
out.write("<p/>Analyzed at ");
out.writeln(db.getConnectTime());
}

private void writeCheckConstraints(Table table, LineWriter out) throws IOException {
Expand Down
3 changes: 2 additions & 1 deletion src/net/sourceforge/schemaspy/view/XmlTableFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ private void appendTable(Element tablesNode, Table table) {
if (table.getSchema() != null)
DOMUtil.appendAttribute(tableNode, "schema", table.getSchema());
DOMUtil.appendAttribute(tableNode, "name", table.getName());
DOMUtil.appendAttribute(tableNode, "numRows", String.valueOf(table.getNumRows()));
if (table.getNumRows() != -1)
DOMUtil.appendAttribute(tableNode, "numRows", String.valueOf(table.getNumRows()));
DOMUtil.appendAttribute(tableNode, "type", table.isView() ? "VIEW" : "TABLE");
DOMUtil.appendAttribute(tableNode, "remarks", table.getComments() == null ? "" : table.getComments());
appendColumns(tableNode, table);
Expand Down

0 comments on commit 28330bc

Please sign in to comment.