From 89728ade891634738fb75e120d71b45c71d2e564 Mon Sep 17 00:00:00 2001 From: Robert Csakany Date: Thu, 22 Feb 2024 22:30:23 +0100 Subject: [PATCH] JNG-5560 Cleanup and add rdbms naming parameters --- ...judo-tatami-jsl-workflow-maven-plugin.adoc | 79 ++++++++++--------- .../maven/plugin/DefaultWorkflowMojo.java | 64 ++++++++------- .../AbstractTatamiPipelineWorkflow.java | 26 +++++- .../DefaultWorkflowSetupParameters.java | 27 +++++++ .../tatami/jsl/workflow/WorkflowHelper.java | 18 +---- pom.xml | 2 +- 6 files changed, 127 insertions(+), 89 deletions(-) diff --git a/docs/pages/judo-tatami-jsl-workflow-maven-plugin.adoc b/docs/pages/judo-tatami-jsl-workflow-maven-plugin.adoc index a58ddd5f..08f90ff7 100644 --- a/docs/pages/judo-tatami-jsl-workflow-maven-plugin.adoc +++ b/docs/pages/judo-tatami-jsl-workflow-maven-plugin.adoc @@ -104,18 +104,22 @@ the correct measurement handling. false false false - true - true - true - false - - true - true - true - false - false - true - true + false + true + true + true + false + false + -1 + -1 + T_ + C_ + FK_ + FK_INV_ + J_ + + + ---- @@ -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: ``) +<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 diff --git a/judo-tatami-jsl-workflow-maven-plugin/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/maven/plugin/DefaultWorkflowMojo.java b/judo-tatami-jsl-workflow-maven-plugin/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/maven/plugin/DefaultWorkflowMojo.java index 7670890d..487ca1f3 100644 --- a/judo-tatami-jsl-workflow-maven-plugin/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/maven/plugin/DefaultWorkflowMojo.java +++ b/judo-tatami-jsl-workflow-maven-plugin/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/maven/plugin/DefaultWorkflowMojo.java @@ -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; @@ -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; @@ -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 @@ -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); @@ -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 entry : dialects.entrySet()) { diff --git a/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/AbstractTatamiPipelineWorkflow.java b/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/AbstractTatamiPipelineWorkflow.java index a25a39c9..8181eb47 100644 --- a/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/AbstractTatamiPipelineWorkflow.java +++ b/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/AbstractTatamiPipelineWorkflow.java @@ -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 @@ -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); diff --git a/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/DefaultWorkflowSetupParameters.java b/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/DefaultWorkflowSetupParameters.java index f95c2259..ee21ea95 100644 --- a/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/DefaultWorkflowSetupParameters.java +++ b/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/DefaultWorkflowSetupParameters.java @@ -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_"; + } diff --git a/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/WorkflowHelper.java b/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/WorkflowHelper.java index 4b6f9e5d..eea70910 100644 --- a/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/WorkflowHelper.java +++ b/judo-tatami-jsl-workflow/src/main/java/hu/blackbelt/judo/tatami/jsl/workflow/WorkflowHelper.java @@ -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") diff --git a/pom.xml b/pom.xml index dfec6df9..80a9cb22 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ 1.0.6.20240219_005830_58ed3934_develop 2.0.0.20231122_182717_c1fe065e_develop - 1.1.6.20240209_041515_d6c64f8b_develop + 1.1.6-SNAPSHOT 1.1.4.20231107_041032_332be90a_develop