Skip to content

Commit

Permalink
Merge pull request #2 from octgsoftware/master
Browse files Browse the repository at this point in the history
Merge work from master
  • Loading branch information
octgsoftware committed Nov 20, 2022
2 parents 50e71e4 + ab0fe3b commit ebe954c
Show file tree
Hide file tree
Showing 174 changed files with 554 additions and 32,908 deletions.
2 changes: 0 additions & 2 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
# Ignore jOOQ generated files:
/src/main/java/org/blackdread/sqltojava/jooq/generated
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This implementation works with
- mariadb 10.x
- postgresql 9.x+

Help is requested on MsSQL and Oracle support. This will require implementation of InformationSchemaRepository and SqlJdlTypeService. See the MySQL and PosrgreSQL implemtaitons for a jOOQ and raw native SQL examples.
Help is requested on MsSQL and Oracle support. This will require implementation of SqlJdlTypeService and creating the raw SQL files. See the MySQL, MariaDB, and PosrgreSQL implemtaitons for examples.

# Testing
Setting up tests for new databases types or versions is easy. Have a look existing tests.
Expand Down Expand Up @@ -47,8 +47,6 @@ Different criterias, support for JPA and jOOQ dynamic filtering and sorting
https://github.com/Blackdread/rest-filter

# How to use
<s>Run "mvn compile" at least once to let jOOQ generate some required tables (see [Issue solved](https://github.com/Blackdread/sql-to-jdl/issues/2)).</s> I have removed generated code, it is directly part of the codebase.

Just execute the code from IDE or use "mvn" to run the code, it will connect to your DB (see application config yml) and it will generate the JDL.

Set properties file:
Expand All @@ -69,7 +67,6 @@ Still have some manual steps to do:
- review validations of entities

# Use of
- jOOQ
- Spring boot

# Default specific rules
Expand Down
50 changes: 4 additions & 46 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>

<skip.jooq.generation>true</skip.jooq.generation>
<database.url>jdbc:mysql:https://localhost:3306/?serverTimezone=UTC</database.url>
<database.user>root</database.user>
<database.password></database.password>
Expand Down Expand Up @@ -113,10 +112,11 @@
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jooq</artifactId>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
Expand Down Expand Up @@ -230,48 +230,6 @@
<forkCount>2.5C</forkCount>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
<plugin>
<!-- We cannot use org.jooq.util.jpa.JPADatabase to generate from entities because we would need to move entities in another module -->
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>


<executions>
<execution>
<id>jooq-codegen</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<skip>${skip.jooq.generation}</skip>
</configuration>
</execution>
</executions>
<configuration>
<jdbc>
<driver>com.mysql.cj.jdbc.Driver</driver>
<url>${database.url}</url>
<user>${database.user}</user>
<password>${database.password}</password>
</jdbc>
<generator>
<name>org.jooq.codegen.JavaGenerator</name>
<database>
<name>org.jooq.meta.mysql.MySQLDatabase</name>
<includes>.*</includes>
<excludes></excludes>
<!--<inputSchema></inputSchema>--> <!-- This will generate all schema of db, better to only generate the one interested in -->
<inputSchema>information_schema</inputSchema>
</database>
<target>
<packageName>org.blackdread.sqltojava.jooq</packageName>
<directory>target/generated-sources/jooq</directory>
</target>
</generator>
</configuration>
</plugin>
<plugin>
<groupId>com.hubspot.maven.plugins</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class ApplicationProperties {
private final String databaseToExport;
private final List<String> databaseObjectPrefix;
private final Boolean addTableNameJdl;
private final UndefinedJdlTypeHandlingEnum undefinedTypeHandling;
private final List<String> ignoredTableNames;

private final Export export;
Expand All @@ -42,13 +43,15 @@ public ApplicationProperties(
final String databaseToExport,
List<String> databaseObjectPrefix,
Boolean addTableNameJdl,
String undefinedTypeHandling,
final List<String> ignoredTableNames,
final Export export,
final String reservedKeywords
) {
log.info("Loading ApplicationProperties...");
this.databaseToExport = databaseToExport;
this.databaseObjectPrefix = databaseObjectPrefix;
this.undefinedTypeHandling = UndefinedJdlTypeHandlingEnum.valueOf(undefinedTypeHandling);
this.addTableNameJdl = Optional.of(addTableNameJdl).orElse(false);
this.ignoredTableNames = ignoredTableNames;
this.export = export;
Expand Down Expand Up @@ -83,6 +86,10 @@ public Boolean getAddTableNameJdl() {
return addTableNameJdl;
}

public UndefinedJdlTypeHandlingEnum getUndefinedTypeHandling() {
return undefinedTypeHandling;
}

public List<String> getDatabaseObjectPrefix() {
return databaseObjectPrefix;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.blackdread.sqltojava.config;

public enum UndefinedJdlTypeHandlingEnum {
ERROR,
SKIP,
UNSUPPORTED,
}

This file was deleted.

Loading

0 comments on commit ebe954c

Please sign in to comment.