Display primary keys in the tree

This commit is contained in:
Naoki Takezoe
2018-01-06 17:32:01 +09:00
parent a64741011c
commit f8e9093273
2 changed files with 14 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ class SystemSettingsController extends SystemSettingsControllerBase
with AccountService with RepositoryService with AdminAuthenticator
case class Table(name: String, columns: Seq[Column])
case class Column(name: String)
case class Column(name: String, primaryKey: Boolean)
trait SystemSettingsControllerBase extends AccountManagementControllerBase {
self: AccountService with RepositoryService with AdminAuthenticator =>
@@ -165,10 +165,19 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
using(meta.getTables(null, "%", "%", Array("TABLE", "VIEW"))){ rs =>
while(rs.next()){
val tableName = rs.getString("TABLE_NAME")
val pkColumns = ListBuffer[String]()
using(meta.getPrimaryKeys(null, null, tableName)){ rs =>
while(rs.next()){
pkColumns += rs.getString("COLUMN_NAME").toUpperCase
}
}
val columns = ListBuffer[Column]()
using(meta.getColumns(null, "%", tableName, "%")){ rs =>
while(rs.next()){
columns += Column(rs.getString("COLUMN_NAME").toUpperCase)
val columnName = rs.getString("COLUMN_NAME").toUpperCase
columns += Column(columnName, pkColumns.contains(columnName))
}
}

View File

@@ -10,7 +10,9 @@
<li data-jstree='{"icon":"@context.path/assets/common/images/table.gif"}'><a href="javascript:void(0);" class="table-link">@table.name</a>
<ul>
@table.columns.map { column =>
<li data-jstree='{"icon":"@context.path/assets/common/images/column.gif"}'>@column.name</li>
<li data-jstree='{"icon":"@context.path/assets/common/images/column.gif"}'>@column.name
@if(column.primaryKey){ (PK) }
</li>
}
</ul>
</li>