Add ShadowJar compatibility and Query file can be define name with comment
Add Migration and Query definition class Add Docker DB for tests
This commit is contained in:
@@ -1,11 +1,38 @@
|
||||
package fr.postgresjson.definition
|
||||
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.nio.file.Path
|
||||
|
||||
interface Resource {
|
||||
val name: String
|
||||
val script: String
|
||||
var source: File?
|
||||
var source: Path?
|
||||
|
||||
open class ParseException(message: String, cause: Throwable? = null) : Exception(message, cause)
|
||||
|
||||
companion object {
|
||||
fun build(file: File): Resource =
|
||||
build(file.readText(), Path.of(file.toURI()))
|
||||
|
||||
fun build(url: URL): Resource =
|
||||
build(url.readText(), Path.of(url.toURI()))
|
||||
|
||||
fun build(resource: String, path: Path): Resource =
|
||||
try {
|
||||
Function(resource, path)
|
||||
} catch (e: ParseException) {
|
||||
try {
|
||||
Migration(resource, path)
|
||||
} catch (e: ParseException) {
|
||||
try {
|
||||
Query(resource, path)
|
||||
} catch (e: ParseException) {
|
||||
throw ParseException("No SQL resource found")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface ResourceCollection {
|
||||
|
||||
Reference in New Issue
Block a user