Search in sources :

Example 1 with ExtendedTableRenderer

use of henplus.view.ExtendedTableRenderer in project henplus by neurolabs.

the class ResultTablePrinter method printResult.

public static int printResult(final TableDiffResult result) {
    /*
         * if all columns belong to the same table name, then don't report it. A
         * different table name may only occur in rare circumstance like object
         * oriented databases.
         */
    // boolean allSameTableName = true;
    /*
         * build up actual describe table.
         */
    final List<Column[]> rows = new ArrayList<Column[]>();
    if (result != null) {
        // first, print removed columns
        final SortedSet<henplus.sqlmodel.Column> removed = result.getRemovedColumns();
        if (removed != null) {
            // ExtendedColumn header = new ExtendedColumn("Removed Columns",
            // 8, ExtendedColumn.ALIGN_CENTER);
            // rows.add(header);
            appendLines(STAT_REMOVED, rows, removed);
        }
        // then, print added columns
        final SortedSet<henplus.sqlmodel.Column> added = result.getAddedColumns();
        if (added != null) {
            appendLines(STAT_ADDED, rows, added);
        }
        // at last, print modified columns
        final LinkedHashMap<henplus.sqlmodel.Column, henplus.sqlmodel.Column> modified = result.getModifiedColumns();
        if (modified != null) {
            appendModified(rows, modified);
        }
    }
    /*
         * we render the table now, since we only know know, whether we will
         * show the first column or not.
         */
    final ExtendedTableRenderer table = new ExtendedTableRenderer(DESC_META, HenPlus.out());
    for (Column[] row : rows) {
        table.addRow(row);
    }
    table.closeTable();
    return Command.SUCCESS;
}
Also used : ExtendedColumn(henplus.view.ExtendedColumn) Column(henplus.view.Column) ArrayList(java.util.ArrayList) ExtendedTableRenderer(henplus.view.ExtendedTableRenderer)

Aggregations

Column (henplus.view.Column)1 ExtendedColumn (henplus.view.ExtendedColumn)1 ExtendedTableRenderer (henplus.view.ExtendedTableRenderer)1 ArrayList (java.util.ArrayList)1