Skip to content

Commit

Permalink
JNG-5560 Cleanup and add rdbms naming parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
robertcsakany committed Feb 22, 2024
1 parent ada701e commit 89728ad
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 89 deletions.
79 changes: 43 additions & 36 deletions docs/pages/judo-tatami-jsl-workflow-maven-plugin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,22 @@ the correct measurement handling.
<ignoreAsm2RdbmsTrace>false</ignoreAsm2RdbmsTrace> <!--15-->
<ignoreRdbms2Liquibase>false</ignoreRdbms2Liquibase> <!--16-->
<ignoreAsm2Expression>false</ignoreAsm2Expression> <!--18-->
<runInParallel>true</runInParallel> <!--19-->
<saveModels>true</saveModels> <!--20-->
<enableMetrics>true</enableMetrics> <!--21-->
<validateModels>false</validateModels> <!--22-->
<sdkOutputDirectory/> <!--23-->
<sdkAddSourceToJar>true</sdkAddSourceToJar> <!--24-->
<generateSdk>true</generateSdk> <!--25-->
<generateSdkInternal>true</generateSdkInternal> <!--26-->
<generateSdkGuice>false</generateSdkGuice> <!--27-->
<generateSdkSpring>false</generateSdkSpring> <!--28-->
<generateOptionalTypes>true</generateOptionalTypes> <!--29-->
<generateSdkPayloadValidator>true</generateSdkPayloadValidator> <!--30-->
<useCache>false</useCache> <!--19-->
<runInParallel>true</runInParallel> <!--20-->
<saveModels>true</saveModels> <!--21-->
<enableMetrics>true</enableMetrics> <!--22-->
<validateModels>false</validateModels> <!--23-->
<rdbmsCreateSimpleName>false</rdbmsCreateSimpleName> <!--24-->
<rdbmsNameSize>-1</rdbmsNameSize> <!--25-->
<rdbmsShortNameSize>-1</rdbmsShortNameSize> <!--26-->
<rdbmsTablePrefix>T_</rdbmsTablePrefix> <!--27-->
<rdbmsColumnPrefix>C_</rdbmsColumnPrefix> <!--28-->
<rdbmsForeignKeyPrefix>FK_</rdbmsForeignKeyPrefix> <!--29-->
<rdbmsInverseForeignKeyPrefix>FK_INV_</rdbmsInverseForeignKeyPrefix> <!--30-->
<rdbmsJunctionTablePrefix>J_</rdbmsJunctionTablePrefix> <!--31-->
</configuration>
</execution>
----
Expand Down Expand Up @@ -204,56 +208,59 @@ Default: `false`
+
Default: `false`

<19> (Optional) Run in parallel when possible, parallel execution is used in multicore system
<19> (Optional) Use cache in model transformations.
+
Default: `false`

<20> (Optional) Run in parallel when possible, parallel execution is used in multicore system
+
(Default: `true`)

<20> (Optional) Save models after execution. After execution the models are stored on destination.
<21> (Optional) Save models after execution. After execution the models are stored on destination.
+
(Default: `false`)

<21> (Optional) Enable generation time statistics after execution
<22> (Optional) Enable generation time statistics after execution
+
(Default: `true`)

<22> (Optional) Validate model on load and save
<23> (Optional) Validate model on load and save
+
(Default: `false`)

<23> (Optional) When SDK output is defined, it is used instead of destination + modelName.
+
(Default: `<none>`)
<24> Create simple name. (Optional)
Using the model name as SQL name. It does not check namespace collosion.
(Default: `false`)

<24> (Optional) Add generared codes to JAR files. To work the `createSdkJar` option
have to be enabled.
<25> Full size of SQL name without abbreviation algorithm. When -1 is used it uses
database specific default.
+
(Default: `true`)
(Default: `-1`)

<25> (Optional) Generate SDK interfaces. When internal, guice or spring is generated, it have to be enabled
<26> Short size of SQL name without abbreviation algorithm. This size is used as namespace fragment size.
When -1 is used it uses database specific default.
+
(Default: `true`)
(Default: `-1`)

<26> (Optional) Generate Internal Wrapper implementation. When guice or spring is generated, it have to be enabled
<27> Table prefix used for table names.
+
(Default: `true`)
(Default: `T_`)

<27> (Optional) Generate Guice SDK implementation.
<28> Column prefix used for column names.
+
(Default: `false`)
(Default: `C_`)

<28> (Optional) Generate Spring SDK implementation.
<29> Foreign key prefix used for foreign key names.
+
(Default: `false`)
(Default: `FK_`)

<29> (Optional) Generate Optional types. It generates
Optional wrapper for Transfer Object fields and for single relations
where the cardinality is 0
<30> Inverse Foreign key prefix used for foreign key names.
+
(Default: `true`)
(Default: `FK_INV_`)

<30> (Optional) Generate SDK Payload validation on DAO calls.
<31> Junction table prefix used for table names.
+
(Default: `true`)
(Default: `J_`)


== Example
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,6 @@ public class DefaultWorkflowMojo extends AbstractMojo {
@Parameter(property = "expression")
private String expression;

@Parameter(property = "sdk")
private String sdk;

@Parameter(property = "sdkInternal")
private String sdkInternal;

@Parameter(property = "sdkGuice")
private String sdkGuice;

@Parameter(property = "sdkSpring")
private String sdkSpring;

@Parameter(property = "ignorePsm2Asm", defaultValue = "false")
private Boolean ignorePsm2Asm = false;

Expand Down Expand Up @@ -139,6 +127,9 @@ public class DefaultWorkflowMojo extends AbstractMojo {
@Parameter(property = "modelName")
private String modelName;

@Parameter(property = "useCache", defaultValue = "true")
private Boolean useCache = true;

@Parameter(property = "modelVersion", defaultValue = "${project.version}")
private String modelVersion;

Expand All @@ -163,27 +154,32 @@ public class DefaultWorkflowMojo extends AbstractMojo {
@Parameter(property = "saveModels", defaultValue = "true")
private Boolean saveModels = true;

@Parameter(property = "sdkAddSourceToJar", defaultValue = "true")
private Boolean sdkAddSourceToJar = true;
@Parameter(property = "generateBehaviours", defaultValue = "true")
private Boolean generateBehaviours = true;

@Parameter(property = "rdbmsCreateSimpleName", defaultValue = "false")
private boolean rdbmsCreateSimpleName = false;

@Parameter(property = "generateSdk", defaultValue = "true")
private Boolean generateSdk = true;
@Parameter(property = "rdbmsNameSize", defaultValue = "-1")
private Integer rdbmsNameSize = -1;

@Parameter(property = "generateSdkInternal", defaultValue = "true")
private Boolean generateSdkInternal = true;
@Parameter(property = "rdbmsShortNameSize", defaultValue = "-1")
private Integer rdbmsShortNameSize = -1;

@Parameter(property = "generateSdkGuice", defaultValue = "false")
private Boolean generateSdkGuice = false;
@Parameter(property = "rdbmsTablePrefix", defaultValue = "T_")
private String rdbmsTablePrefix = "T_";

@Parameter(property = "generateSdkSpring", defaultValue = "false")
private Boolean generateSdkSpring = false;
@Parameter(property = "rdbmsColumnPrefix", defaultValue = "C_")
private String rdbmsColumnPrefix = "C_";

@Parameter(property = "generateSdkPayloadValidator", defaultValue = "true")
private Boolean generateSdkPayloadValidator = true;
@Parameter(property = "rdbmsForeignKeyPrefix", defaultValue = "FK_")
private String rdbmsForeignKeyPrefix = "FK_";

@Parameter(property = "rdbmsInverseForeignKeyPrefix", defaultValue = "FK_INV_")
private String rdbmsInverseForeignKeyPrefix = "FK_INV_";

@Parameter(property = "generateBehaviours", defaultValue = "true")
private Boolean generateBehaviours = true;
@Parameter(property = "rdbmsJunctionTablePrefix", defaultValue = "J_")
private String rdbmsJunctionTablePrefix = "J_";


@Parameter
Expand Down Expand Up @@ -284,6 +280,15 @@ public void execute() throws MojoExecutionException, MojoFailureException {
.generateBehaviours(true)
.validateModels(validateModels)
.modelName(modelName)
.useCache(useCache)
.rdbmsNameSize(rdbmsNameSize)
.rdbmsShortNameSize(rdbmsShortNameSize)
.rdbmsCreateSimpleName(rdbmsCreateSimpleName)
.rdbmsTablePrefix(rdbmsTablePrefix)
.rdbmsColumnPrefix(rdbmsTablePrefix)
.rdbmsForeignKeyPrefix(rdbmsForeignKeyPrefix)
.rdbmsInverseForeignKeyPrefix(rdbmsInverseForeignKeyPrefix)
.rdbmsJunctionTablePrefix(rdbmsJunctionTablePrefix)
.dialectList(dialectList);

defaultWorkflow = new DefaultWorkflow(parameters);
Expand Down Expand Up @@ -311,13 +316,6 @@ public void execute() throws MojoExecutionException, MojoFailureException {
workflowHelper.loadExpressionModel(modelName, null, artifactResolver.getArtifact(expression).toURI());
}

if (sdk != null && !sdk.trim().equals("") && sdkInternal != null && !sdkInternal.trim().equals("")) {
workflowHelper.loadSdk(null, artifactResolver.getArtifact(sdk).toURI(),
null, artifactResolver.getArtifact(sdkInternal).toURI(),
null, sdkGuice != null && !sdkGuice.isBlank() ? artifactResolver.getArtifact(sdkGuice).toURI() : null,
null, sdkSpring != null && !sdkSpring.isBlank() ? artifactResolver.getArtifact(sdkSpring).toURI() : null);
}

if (dialects != null) {
for (Map.Entry<String, DialectParam> entry : dialects.entrySet()) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import static hu.blackbelt.judo.tatami.core.workflow.flow.ParallelFlow.Builder.aNewParallelFlow;
import static hu.blackbelt.judo.tatami.core.workflow.flow.SequentialFlow.Builder.aNewSequentialFlow;
import static hu.blackbelt.judo.tatami.psm2asm.Psm2AsmWork.Psm2AsmWorkParameter.psm2AsmWorkParameter;
import static hu.blackbelt.judo.tatami.psm2measure.Psm2MeasureWork.Psm2MeasureWorkParameter.psm2MeasureWorkParameter;


@Slf4j
Expand Down Expand Up @@ -78,8 +79,29 @@ public WorkReport startDefaultWorkflow() {
.generateBehaviours(parameters.getGenerateBehaviours())
.createTrace(!parameters.getIgnoreJsl2PsmTrace()).build());

transformationContext.put(psm2AsmWorkParameter().createTrace(!parameters.getIgnorePsm2AsmTrace()).build());
transformationContext.put(asm2RdbmsWorkParameter().createTrace(!parameters.getIgnoreAsm2Rdbms()).build());
transformationContext.put(psm2AsmWorkParameter()
.createTrace(!parameters.getIgnorePsm2AsmTrace())
.useCache(parameters.getUseCache())
.parallel(parameters.getRunInParallel())
.build());
transformationContext.put(psm2MeasureWorkParameter()
.createTrace(!parameters.getIgnorePsm2MeasureTrace())
.useCache(parameters.getUseCache())
.parallel(parameters.getRunInParallel())
.build());
transformationContext.put(asm2RdbmsWorkParameter()
.createTrace(!parameters.getIgnoreAsm2RdbmsTrace())
.useCache(parameters.getUseCache())
.parallel(parameters.getRunInParallel())
.createSimpleName(parameters.getRdbmsCreateSimpleName())
.nameSize(parameters.getRdbmsNameSize())
.shortNameSize(parameters.getRdbmsShortNameSize())
.tablePrefix(parameters.getRdbmsTablePrefix())
.columnPrefix(parameters.getRdbmsColumnPrefix())
.foreignKeyPrefix(parameters.getRdbmsForeignKeyPrefix())
.inverseForeignKeyPrefix(parameters.getRdbmsInverseForeignKeyPrefix())
.junctionTablePrefix(parameters.getRdbmsJunctionTablePrefix())
.build());

loadModels(workflowHelper, metrics, transformationContext, parameters);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,31 @@ public class DefaultWorkflowSetupParameters {
@Builder.Default
private Boolean validateModels = false;

@Builder.Default
private Boolean useCache = true;

@Builder.Default
boolean rdbmsCreateSimpleName = false;

@Builder.Default
Integer rdbmsNameSize = -1;

@Builder.Default
Integer rdbmsShortNameSize = -1;

@Builder.Default
String rdbmsTablePrefix = "T_";

@Builder.Default
String rdbmsColumnPrefix = "C_";

@Builder.Default
String rdbmsForeignKeyPrefix = "FK_";

@Builder.Default
String rdbmsInverseForeignKeyPrefix = "FK_INV_";

@Builder.Default
String rdbmsJunctionTablePrefix = "J_";

}
Original file line number Diff line number Diff line change
Expand Up @@ -248,23 +248,7 @@ public void loadLiquibaseModel(final String modelName,
.toURL().openStream())
.name(modelName)))));
}

public void loadSdk(final InputStream sdk,
final URI sdkSourceURI,
final InputStream sdkInternal,
final URI sdkInternalSourceURI,
final InputStream sdkGuice,
final URI sdkGuiceSourceURI,
final InputStream sdkSpring,
final URI sdkSpringSourceURI

) {

if (sdk == null && sdkSourceURI == null || sdkInternal == null && sdkInternalSourceURI == null ) {
return;
}
}


public Work createPsmValidateWork() {
return aNewConditionalFlow()
.named("Conditional when Psm model exists then Execute PsmValidation")
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

<judo-runtime-core-version>1.0.6.20240219_005830_58ed3934_develop</judo-runtime-core-version>
<structured-map-proxy-version>2.0.0.20231122_182717_c1fe065e_develop</structured-map-proxy-version>
<judo-tatami-base-version>1.1.6.20240209_041515_d6c64f8b_develop</judo-tatami-base-version>
<judo-tatami-base-version>1.1.6-SNAPSHOT</judo-tatami-base-version>
<judo-tatami-core-version>1.1.4.20231107_041032_332be90a_develop</judo-tatami-core-version>

<!-- Code Quality-->
Expand Down

0 comments on commit 89728ad

Please sign in to comment.