-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR removes the obsolete `core/util` package which is used to generate jooq code. The generation logics has been moved to `dao` as class `JooqCodeGenerator`
- Loading branch information
Showing
7 changed files
with
101 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<configuration> | ||
<generator> | ||
<!-- The generator for dao --> | ||
<generate> | ||
<generatedAnnotation>false</generatedAnnotation> | ||
|
||
<daos>true</daos> | ||
<interfaces>true</interfaces> | ||
</generate> | ||
<!-- The default code generator. You can override this one, to generate your own code style. | ||
Supported generators: | ||
- org.jooq.codegen.JavaGenerator | ||
- org.jooq.codegen.ScalaGenerator | ||
Defaults to org.jooq.codegen.JavaGenerator --> | ||
<name>org.jooq.codegen.JavaGenerator</name> | ||
|
||
<database> | ||
<!-- The database type. The format here is: | ||
org.jooq.meta.[database].[database]Database --> | ||
<name>org.jooq.meta.mysql.MySQLDatabase</name> | ||
|
||
<!-- The database schema (or in the absence of schema support, in your RDBMS this | ||
can be the owner, user, database name) to be generated --> | ||
<inputSchema>texera_db</inputSchema> | ||
|
||
<!-- All elements that are generated from your schema | ||
(A Java regular expression. Use the pipe to separate several expressions) | ||
Watch out for case-sensitivity. Depending on your database, this might be important! --> | ||
<includes>.*</includes> | ||
|
||
<!-- All elements that are excluded from your schema | ||
(A Java regular expression. Use the pipe to separate several expressions). | ||
Excludes match before includes, i.e. excludes have a higher priority --> | ||
<excludes>(test_.*)|(ignore_.*)</excludes> | ||
|
||
</database> | ||
|
||
<target> | ||
<!-- The destination package of your generated classes (within the destination directory) --> | ||
<packageName>edu.uci.ics.texera.dao.jooq.generated</packageName> | ||
|
||
<!-- The destination directory of your generated classes. Using Maven directory layout here --> | ||
<directory>dao/src/main/scala</directory> | ||
</target> | ||
</generator> | ||
</configuration> |
54 changes: 54 additions & 0 deletions
54
core/dao/src/main/scala/edu/uci/ics/texera/dao/JooqCodeGenerator.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package edu.uci.ics.texera.dao | ||
|
||
import org.jooq.codegen.GenerationTool | ||
import org.jooq.meta.jaxb.{Configuration, Jdbc} | ||
import org.yaml.snakeyaml.Yaml | ||
|
||
import java.io.InputStream | ||
import java.nio.file.{Files, Path} | ||
import java.util.{Map => JMap} | ||
import scala.jdk.CollectionConverters._ | ||
|
||
object JooqCodeGenerator { | ||
@throws[Exception] | ||
def main(args: Array[String]): Unit = { | ||
// Load jOOQ configuration XML | ||
val jooqXmlPath: Path = | ||
Path.of("dao").resolve("src").resolve("main").resolve("resources").resolve("jooq-conf.xml") | ||
val jooqConfig: Configuration = GenerationTool.load(Files.newInputStream(jooqXmlPath)) | ||
|
||
// Load YAML configuration | ||
val yamlConfPath: Path = Path | ||
.of("workflow-core") | ||
.resolve("src") | ||
.resolve("main") | ||
.resolve("resources") | ||
.resolve("storage-config.yaml") | ||
val yaml = new Yaml | ||
val inputStream: InputStream = Files.newInputStream(yamlConfPath) | ||
|
||
val conf: Map[String, Any] = | ||
yaml.load(inputStream).asInstanceOf[JMap[String, Any]].asScala.toMap | ||
|
||
val jdbcConfig = conf("storage") | ||
.asInstanceOf[JMap[String, Any]] | ||
.asScala("jdbc") | ||
.asInstanceOf[JMap[String, Any]] | ||
.asScala | ||
|
||
// Set JDBC configuration for jOOQ | ||
val jooqJdbcConfig = new Jdbc | ||
jooqJdbcConfig.setDriver("com.mysql.cj.jdbc.Driver") | ||
jooqJdbcConfig.setUrl(jdbcConfig("url").toString) | ||
jooqJdbcConfig.setUsername(jdbcConfig("username").toString) | ||
jooqJdbcConfig.setPassword(jdbcConfig("password").toString) | ||
|
||
jooqConfig.setJdbc(jooqJdbcConfig) | ||
|
||
// Generate the code | ||
GenerationTool.generate(jooqConfig) | ||
|
||
// Close input stream | ||
inputStream.close() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.