Search in sources :

Example 1 with SqliteColumnItemTree

use of com.kyj.fx.voeditor.visual.component.sql.dbtree.sqlite.SqliteColumnItemTree in project Gargoyle by callakrsos.

the class H2TableItemTree method applyChildren.

//	private static final int GETPRIMARY_KEY_SEQ = 5;
//	private static final int GETPRIMARY_PRIMARYKEY_NAME = 6;
@Override
public ObservableList<TreeItem<DatabaseItemTree<String>>> applyChildren(Connection con, String... args) throws Exception {
    DatabaseMetaData metaData = con.getMetaData();
    ResultSet tables = metaData.getColumns(null, args[0], args[1], "%");
    Set<String> primaryKeySet = toSet(metaData.getPrimaryKeys(null, args[0], args[1]), COLUMN_NAME);
    ObservableList<TreeItem<DatabaseItemTree<String>>> observableArrayList = FXCollections.observableArrayList();
    while (tables.next()) {
        /* 
			 * references 
			 * http://docs.oracle.com/javase/6/docs/api/java/sql/ DatabaseMetaData.html#getTables%28java.lang.String,%20java.lang. String,%20java.lang.String,%20java.lang.String%5b%5d%29 
			 */
        String columnName = tables.getString(COLUMN_NAME);
        SqliteColumnItemTree coumnItem = new SqliteColumnItemTree(this, columnName);
        coumnItem.setPrimaryKey(primaryKeySet.contains(columnName));
        TreeItem<DatabaseItemTree<String>> treeItem = new TreeItem<>(coumnItem);
        observableArrayList.add(treeItem);
    }
    return observableArrayList;
}
Also used : TreeItem(javafx.scene.control.TreeItem) ResultSet(java.sql.ResultSet) SqliteColumnItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.sqlite.SqliteColumnItemTree) DatabaseItemTree(com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.DatabaseItemTree) DatabaseMetaData(java.sql.DatabaseMetaData)

Aggregations

DatabaseItemTree (com.kyj.fx.voeditor.visual.component.sql.dbtree.commons.DatabaseItemTree)1 SqliteColumnItemTree (com.kyj.fx.voeditor.visual.component.sql.dbtree.sqlite.SqliteColumnItemTree)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 ResultSet (java.sql.ResultSet)1 TreeItem (javafx.scene.control.TreeItem)1