Skip to content

Commit 43f3226

Browse files
committed
288
1 parent 8f8367c commit 43f3226

6 files changed

Lines changed: 23 additions & 9 deletions

File tree

src/main/kotlin/com/github/mgramin/sqlboot/model/uri/Uri.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ interface Uri : Serializable {
7474
*/
7575
fun action(): String
7676

77+
/**
78+
* Connection name
79+
*/
80+
fun connection(): String
81+
82+
7783
fun pageNumber(): Int {
7884
val pageParameter = params()["page"]
7985
val pageNumber: Int

src/main/kotlin/com/github/mgramin/sqlboot/model/uri/impl/DbUri.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class DbUri : Uri {
8989

9090
override fun action() = this.action
9191

92+
override fun connection() = this.connection
93+
9294
override fun toString(): String {
9395
val result = StringBuilder(connection + "/" + type + "/" + objects.joinToString("."))
9496
if (action != "" && action != "create")

src/main/kotlin/com/github/mgramin/sqlboot/model/uri/impl/FakeUri.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import com.github.mgramin.sqlboot.model.uri.Uri
2828

2929
class FakeUri : Uri {
3030

31+
3132
override fun type(): String {
3233
return "table"
3334
}
@@ -48,4 +49,8 @@ class FakeUri : Uri {
4849
return "create"
4950
}
5051

52+
override fun connection(): String {
53+
return "prod"
54+
}
55+
5156
}

src/main/kotlin/com/github/mgramin/sqlboot/model/uri/wrappers/JsonWrapper.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class JsonWrapper(private val origin: Uri) : Uri {
4343

4444
override fun action() = origin.action()
4545

46+
override fun connection() = origin.connection()
47+
4648
override fun toString(): String {
4749
var s = "DbUri{" +
4850
"type='" + origin.type() + '\''.toString() +

src/main/kotlin/com/github/mgramin/sqlboot/model/uri/wrappers/SqlPlaceholdersWrapper.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class SqlPlaceholdersWrapper(private val origin: Uri) : Uri {
4646

4747
override fun action() = origin.action()
4848

49+
override fun connection() = origin.connection()
50+
4951
override fun toString() = origin.toString()
5052

5153
}

src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/ApiController.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,11 @@ class ApiController {
8181
.filter { it != "headers" }
8282
.joinToString(separator = "/") { it }
8383
val uri: Uri = SqlPlaceholdersWrapper(DbUri(parseUri(uriString, request)))
84-
return getListResponseEntityHeaders(uri, connectionName)
84+
return getListResponseEntityHeaders(uri)
8585
}
8686

87-
private fun getListResponseEntityHeaders(
88-
uri: Uri,
89-
connectionName: String
90-
): ResponseEntity<List<Map<String, Any>>> {
91-
val connections = dbConnectionList.getConnectionsByMask(connectionName)
87+
private fun getListResponseEntityHeaders(uri: Uri): ResponseEntity<List<Map<String, Any>>> {
88+
val connections = dbConnectionList.getConnectionsByMask(uri.connection())
9289
try {
9390
val headers = FsResourceTypes(connections, uri)
9491
.read(uri)
@@ -121,13 +118,13 @@ class ApiController {
121118
.filter { it != "meta" }
122119
.joinToString(separator = "/") { it }
123120
val uri = SqlPlaceholdersWrapper(DbUri(parseUri(uriString, request)))
124-
return responseEntity(connectionName, uri)
121+
return responseEntity(uri)
125122
}
126123

127124

128-
private fun responseEntity(connectionName: String, uri: Uri): ResponseEntity<List<Metadata>> {
125+
private fun responseEntity(uri: Uri): ResponseEntity<List<Metadata>> {
129126
val fsResourceTypes = FsResourceTypes(
130-
listOf(dbConnectionList.getConnectionByName(connectionName)), uri)
127+
listOf(dbConnectionList.getConnectionByName(uri.connection())), uri)
131128
val resourceType = fsResourceTypes
132129
.resourceTypes()
133130
.stream()

0 commit comments

Comments
 (0)