-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add jooq module with default maven codegen
- Loading branch information
1 parent
708479d
commit b6fac3e
Showing
9 changed files
with
224 additions
and
95 deletions.
There are no files selected for viewing
157 changes: 157 additions & 0 deletions
157
...lite/generator/server/springboot/database/jooq/domain/JooqModuleCodegenConfiguration.java
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,157 @@ | ||
package tech.jhipster.lite.generator.server.springboot.database.jooq.domain; | ||
|
||
import tech.jhipster.lite.shared.error.domain.Assert; | ||
|
||
public final class JooqModuleCodegenConfiguration { | ||
|
||
private final DatabaseType database; | ||
private final String databaseUrl; | ||
private final String user; | ||
private final String inputSchema; | ||
private final String jooqGenerationPackage; | ||
private final String password; | ||
|
||
private JooqModuleCodegenConfiguration(JooqModuleCodegenConfigurationBuilder builder) { | ||
Assert.notNull("database", builder.database); | ||
Assert.notNull("databaseUrl", builder.databaseUrl); | ||
Assert.notNull("user", builder.user); | ||
Assert.notNull("inputSchema", builder.inputSchema); | ||
Assert.notNull("jooqGenerationPackage", builder.jooqGenerationPackage); | ||
|
||
this.database = builder.database; | ||
this.databaseUrl = builder.databaseUrl; | ||
this.user = builder.user; | ||
this.inputSchema = builder.inputSchema; | ||
this.jooqGenerationPackage = builder.jooqGenerationPackage; | ||
this.password = builder.password == null ? "" : builder.password; | ||
} | ||
|
||
public String getConfiguration() { | ||
return String.format( | ||
""" | ||
<jdbc> | ||
<url>%s</url> | ||
<user>%s</user> | ||
<password>%s</password> | ||
</jdbc> | ||
<generator> | ||
<database> | ||
<name>%s</name> | ||
<includes>.*</includes> | ||
<inputSchema>%s</inputSchema> | ||
</database> | ||
<target> | ||
<packageName>%s</packageName> | ||
<directory>target/generated-sources/jooq</directory> | ||
</target> | ||
</generator> | ||
""", | ||
databaseUrl, | ||
user, | ||
password, | ||
databaseJooqName(), | ||
inputSchema, | ||
jooqGenerationPackage | ||
); | ||
} | ||
|
||
private String databaseJooqName() { | ||
return switch (database) { | ||
case POSTGRESQL -> "org.jooq.meta.postgres.PostgresDatabase"; | ||
case MYSQL -> "org.jooq.meta.mysql.MySQLDatabase"; | ||
case MARIADB -> "org.jooq.meta.mariadb.MariaDBDatabase"; | ||
case MSSQL -> "org.jooq.meta.sqlserver.SQLServerDatabase"; | ||
}; | ||
} | ||
|
||
public static JooqModuleCodegenConfigurationBuilder builder() { | ||
return new JooqModuleCodegenConfigurationBuilder(); | ||
} | ||
|
||
public interface JooqModuleCodegenConfigurationDatabaseBuilder { | ||
JooqModuleCodegenConfigurationDatabaseUrlBuilder database(DatabaseType database); | ||
} | ||
|
||
public interface JooqModuleCodegenConfigurationDatabaseUrlBuilder { | ||
JooqModuleCodegenConfigurationUserBuilder databaseUrl(String databaseUrl); | ||
} | ||
|
||
public interface JooqModuleCodegenConfigurationUserBuilder { | ||
JooqModuleCodegenConfigurationInputSchemaBuilder user(String user); | ||
} | ||
|
||
public interface JooqModuleCodegenConfigurationInputSchemaBuilder { | ||
JooqModuleCodegenConfigurationJooqGenerationPackageBuilder inputSchema(String inputSchema); | ||
} | ||
|
||
public interface JooqModuleCodegenConfigurationJooqGenerationPackageBuilder { | ||
JooqModuleCodegenConfigurationBuilder jooqGenerationPackage(String jooqGenerationPackage); | ||
} | ||
|
||
public interface JooqModuleCodegenConfigurationPasswordBuilder { | ||
JooqModuleCodegenConfiguration password(String password); | ||
} | ||
|
||
public static final class JooqModuleCodegenConfigurationBuilder | ||
implements | ||
JooqModuleCodegenConfigurationDatabaseBuilder, | ||
JooqModuleCodegenConfigurationDatabaseUrlBuilder, | ||
JooqModuleCodegenConfigurationUserBuilder, | ||
JooqModuleCodegenConfigurationInputSchemaBuilder, | ||
JooqModuleCodegenConfigurationJooqGenerationPackageBuilder, | ||
JooqModuleCodegenConfigurationPasswordBuilder { | ||
|
||
private DatabaseType database; | ||
private String databaseUrl; | ||
private String user; | ||
private String inputSchema; | ||
private String jooqGenerationPackage; | ||
private String password; | ||
|
||
@Override | ||
public JooqModuleCodegenConfigurationDatabaseUrlBuilder database(DatabaseType database) { | ||
this.database = database; | ||
|
||
return this; | ||
} | ||
|
||
@Override | ||
public JooqModuleCodegenConfigurationUserBuilder databaseUrl(String databaseUrl) { | ||
this.databaseUrl = databaseUrl; | ||
|
||
return this; | ||
} | ||
|
||
@Override | ||
public JooqModuleCodegenConfigurationInputSchemaBuilder user(String user) { | ||
this.user = user; | ||
|
||
return this; | ||
} | ||
|
||
@Override | ||
public JooqModuleCodegenConfigurationJooqGenerationPackageBuilder inputSchema(String inputSchema) { | ||
this.inputSchema = inputSchema; | ||
|
||
return this; | ||
} | ||
|
||
@Override | ||
public JooqModuleCodegenConfigurationBuilder jooqGenerationPackage(String jooqGenerationPackage) { | ||
this.jooqGenerationPackage = jooqGenerationPackage; | ||
|
||
return this; | ||
} | ||
|
||
@Override | ||
public JooqModuleCodegenConfiguration password(String password) { | ||
this.password = password; | ||
|
||
return build(); | ||
} | ||
|
||
public JooqModuleCodegenConfiguration build() { | ||
return new JooqModuleCodegenConfiguration(this); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.