diff --git a/src/main/kotlin/com/github/mgramin/sqlboot/model/connection/EndpointList.kt b/src/main/kotlin/com/github/mgramin/sqlboot/model/connection/EndpointList.kt index 27927a88..05386784 100644 --- a/src/main/kotlin/com/github/mgramin/sqlboot/model/connection/EndpointList.kt +++ b/src/main/kotlin/com/github/mgramin/sqlboot/model/connection/EndpointList.kt @@ -38,8 +38,8 @@ import org.springframework.stereotype.Service @ConfigurationProperties(prefix = "conf") open class EndpointList(val endpoints: List) { - fun getConnectionByName(name: String) = endpoints.first { v -> v.name().equals(name, ignoreCase = true) } + fun getByName(name: String) = endpoints.first { v -> v.name().equals(name, ignoreCase = true) } - fun getConnectionsByMask(name: String) = endpoints.filter { v -> v.name().matches(name.toRegex()) } + fun getByMask(mask: String) = endpoints.filter { v -> v.name().matches(mask.toRegex()) } } diff --git a/src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/ApiController.kt b/src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/ApiController.kt index 1202522b..60f31d96 100644 --- a/src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/ApiController.kt +++ b/src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/ApiController.kt @@ -66,7 +66,7 @@ class ApiController { @RequestMapping(value = ["/api/{connectionName}/types"]) fun types(@PathVariable connectionName: String): String { val jsonArray = JsonArray() - FsResourceType(endpointList.getConnectionsByMask(connectionName), emptyList()) + FsResourceType(endpointList.getByMask(connectionName), emptyList()) .resourceTypes() .forEach { jsonArray.add(it.toJson()) } return jsonArray.toString() @@ -75,7 +75,7 @@ class ApiController { @RequestMapping(value = ["/api/{connectionName}/types/{typeMask}"]) fun typesByMask(@PathVariable connectionName: String, @PathVariable typeMask: String): String { val jsonArray = JsonArray() - FsResourceType(endpointList.getConnectionsByMask(connectionName), emptyList()) + FsResourceType(endpointList.getByMask(connectionName), emptyList()) .resourceTypes() .filter { it.name().matches(wildcardToRegex(typeMask)) } .forEach { jsonArray.add(it.toJson()) } @@ -91,7 +91,7 @@ class ApiController { val jsonArray = JsonArray() val uri = SqlPlaceholdersWrapper( DbUri("$connection/$type")) - FsResourceType(listOf(endpointList.getConnectionByName(uri.connection())), emptyList()) + FsResourceType(listOf(endpointList.getByName(uri.connection())), emptyList()) .resourceTypes() .asSequence() .filter { v -> v.name().equals(uri.type(), ignoreCase = true) } @@ -109,7 +109,7 @@ class ApiController { val jsonArray = JsonArray() val uri = SqlPlaceholdersWrapper( DbUri("$connection/$type/$path")) - FsResourceType(listOf(endpointList.getConnectionByName(uri.connection())), emptyList()) + FsResourceType(listOf(endpointList.getByName(uri.connection())), emptyList()) .resourceTypes() .asSequence() .filter { v -> v.name().equals(uri.type(), ignoreCase = true) } @@ -134,7 +134,7 @@ class ApiController { getListResponseEntityHeaders(SqlPlaceholdersWrapper(DbUri("$connection/$type/$path"))) private fun getListResponseEntityHeaders(uri: Uri): ResponseEntity>> { - val connections = endpointList.getConnectionsByMask(uri.connection()) + val connections = endpointList.getByMask(uri.connection()) try { val headers = FsResourceType(connections, dbDialectList.dialects) .read(uri) diff --git a/src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/SwaggerController.kt b/src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/SwaggerController.kt index cbcec12f..37e68957 100644 --- a/src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/SwaggerController.kt +++ b/src/main/kotlin/com/github/mgramin/sqlboot/rest/controllers/SwaggerController.kt @@ -85,7 +85,7 @@ class SwaggerController { private fun getSwaggerDescription(request: HttpServletRequest, connectionName: String): Swagger { val fsResourceTypes = FsResourceType( - listOf(endpointList.getConnectionByName(connectionName)), emptyList()) + listOf(endpointList.getByName(connectionName)), emptyList()) val resourceTypes = fsResourceTypes.resourceTypes() val swagger = Swagger() diff --git a/src/test/kotlin/com/github/mgramin/sqlboot/model/connection/EndpointListTest.kt b/src/test/kotlin/com/github/mgramin/sqlboot/model/connection/EndpointListTest.kt index b98b31fa..27ab06e9 100644 --- a/src/test/kotlin/com/github/mgramin/sqlboot/model/connection/EndpointListTest.kt +++ b/src/test/kotlin/com/github/mgramin/sqlboot/model/connection/EndpointListTest.kt @@ -46,13 +46,13 @@ internal class EndpointListTest { @ParameterizedTest @ValueSource(strings = ["test", "dev", "prod"]) fun getConnectionByName(connectionName: String) { - assertEquals(connectionName, endpointList.getConnectionByName(connectionName).name()) + assertEquals(connectionName, endpointList.getByName(connectionName).name()) } @ParameterizedTest @ValueSource(strings = ["test", "dev", "prod"]) fun getConnectionsByMask(connectionMask: String) { - assertEquals(connectionMask, endpointList.getConnectionsByMask(connectionMask).first().name()) + assertEquals(connectionMask, endpointList.getByMask(connectionMask).first().name()) } @Test