diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..2aa6b92 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +ActionModelsGenerator \ No newline at end of file diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml index 3dea796..6c68e02 100644 --- a/.idea/dictionaries/project.xml +++ b/.idea/dictionaries/project.xml @@ -2,6 +2,7 @@ actionbean + actionmodels \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index cf3bfab..25bb7c8 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -2,11 +2,13 @@ \ No newline at end of file diff --git a/.intellijPlatform/coroutines-javaagent-legacy.jar b/.intellijPlatform/coroutines-javaagent-legacy.jar new file mode 100644 index 0000000..a789255 Binary files /dev/null and b/.intellijPlatform/coroutines-javaagent-legacy.jar differ diff --git a/.intellijPlatform/coroutines-javaagent.jar b/.intellijPlatform/coroutines-javaagent.jar new file mode 100644 index 0000000..e4ba560 Binary files /dev/null and b/.intellijPlatform/coroutines-javaagent.jar differ diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij-platform-test-runtime-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij-platform-test-runtime-IU-252.23892.409.xml new file mode 100644 index 0000000..64c40b3 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij-platform-test-runtime-IU-252.23892.409.xml @@ -0,0 +1,138 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.charts-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.charts-IU-252.23892.409.xml new file mode 100644 index 0000000..d340de6 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.charts-IU-252.23892.409.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid-IU-252.23892.409.xml new file mode 100644 index 0000000..4e9a31c --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid-IU-252.23892.409.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.charts.impl-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.charts.impl-IU-252.23892.409.xml new file mode 100644 index 0000000..d38c796 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.charts.impl-IU-252.23892.409.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.core.impl-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.core.impl-IU-252.23892.409.xml new file mode 100644 index 0000000..77338c9 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.core.impl-IU-252.23892.409.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.csv.core.impl-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.csv.core.impl-IU-252.23892.409.xml new file mode 100644 index 0000000..07ce6b3 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.csv.core.impl-IU-252.23892.409.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.impl-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.impl-IU-252.23892.409.xml new file mode 100644 index 0000000..9beeea2 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.impl-IU-252.23892.409.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.scripting.impl-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.scripting.impl-IU-252.23892.409.xml new file mode 100644 index 0000000..15d06f8 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.scripting.impl-IU-252.23892.409.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.scripting.rt-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.scripting.rt-IU-252.23892.409.xml new file mode 100644 index 0000000..78b2442 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.scripting.rt-IU-252.23892.409.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.types-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.types-IU-252.23892.409.xml new file mode 100644 index 0000000..3f5152f --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.grid.types-IU-252.23892.409.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.libraries.ai.grazie.spell.gec.engine.local-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.libraries.ai.grazie.spell.gec.engine.local-IU-252.23892.409.xml new file mode 100644 index 0000000..635ad3c --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.libraries.ai.grazie.spell.gec.engine.local-IU-252.23892.409.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.libraries.lucene.common-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.libraries.lucene.common-IU-252.23892.409.xml new file mode 100644 index 0000000..c371eeb --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.libraries.lucene.common-IU-252.23892.409.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.libraries.microba-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.libraries.microba-IU-252.23892.409.xml new file mode 100644 index 0000000..8701104 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.libraries.microba-IU-252.23892.409.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.backend-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.backend-IU-252.23892.409.xml new file mode 100644 index 0000000..b91baa8 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.backend-IU-252.23892.409.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.navbar-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.navbar-IU-252.23892.409.xml new file mode 100644 index 0000000..9ed7634 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.navbar-IU-252.23892.409.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.navbar.frontend-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.navbar.frontend-IU-252.23892.409.xml new file mode 100644 index 0000000..6e4db0d --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.navbar.frontend-IU-252.23892.409.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.vcs.impl-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.vcs.impl-IU-252.23892.409.xml new file mode 100644 index 0000000..ecaf0cb --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.vcs.impl-IU-252.23892.409.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.vcs.impl.lang-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.vcs.impl.lang-IU-252.23892.409.xml new file mode 100644 index 0000000..434e02f --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.vcs.impl.lang-IU-252.23892.409.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.vcs.impl.shared-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.vcs.impl.shared-IU-252.23892.409.xml new file mode 100644 index 0000000..570ca72 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.platform.vcs.impl.shared-IU-252.23892.409.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.spellchecker-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.spellchecker-IU-252.23892.409.xml new file mode 100644 index 0000000..7ffad9b --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledModule-intellij.spellchecker-IU-252.23892.409.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-com.intellij.database-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-com.intellij.database-IU-252.23892.409.xml new file mode 100644 index 0000000..589a10b --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-com.intellij.database-IU-252.23892.409.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-com.intellij.java-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-com.intellij.java-IU-252.23892.409.xml new file mode 100644 index 0000000..cdde726 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-com.intellij.java-IU-252.23892.409.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-com.intellij.platform.images-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-com.intellij.platform.images-IU-252.23892.409.xml new file mode 100644 index 0000000..620f665 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-com.intellij.platform.images-IU-252.23892.409.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-intellij.grid.plugin-IU-252.23892.409.xml b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-intellij.grid.plugin-IU-252.23892.409.xml new file mode 100644 index 0000000..df966a2 --- /dev/null +++ b/.intellijPlatform/localPlatformArtifacts/IU-252.23892.409/bundledPlugin-intellij.grid.plugin-IU-252.23892.409.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.intellijPlatform/self-update.lock b/.intellijPlatform/self-update.lock index f914da4..07eb06f 100644 --- a/.intellijPlatform/self-update.lock +++ b/.intellijPlatform/self-update.lock @@ -1 +1 @@ -2025-07-08 \ No newline at end of file +2025-08-20 \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 18d3a1b..bb9377c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,12 +1,11 @@ plugins { id("java") id("org.jetbrains.kotlin.jvm") version "2.1.0" - id("org.jetbrains.intellij.platform") version "2.6.0" + id("org.jetbrains.intellij.platform") version "2.7.0" } - -group = "com.sdk.actionbean.generator" -version = "1.0-SNAPSHOT" +group = "com.sdk.generators.actionmodels" +version = "1.0.4" repositories { mavenCentral() @@ -26,8 +25,8 @@ dependencies { bundledPlugin("com.intellij.java") bundledPlugin("com.intellij.database") - implementation("org.freemarker:freemarker:2.3.32") - } + } + implementation("org.freemarker:freemarker:2.3.32") } diff --git a/gradle.properties b/gradle.properties index 24630b3..feaab5f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,3 +4,4 @@ kotlin.stdlib.default.dependency=false org.gradle.configuration-cache=true # Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html org.gradle.caching=true +org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e583..9bbc975 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2733ed5..2a84e18 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..faf9300 100755 --- a/gradlew +++ b/gradlew @@ -15,6 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## # @@ -55,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +82,11 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +133,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,11 +200,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ @@ -205,6 +216,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/gradlew.bat b/gradlew.bat index 107acd3..9d21a21 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -13,8 +13,10 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,7 +27,8 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -40,13 +43,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -56,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -75,13 +78,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..c0b0e27 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "ActionModelsGenerator", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 73417bd..e7833a6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1 @@ -rootProject.name = "ActionBeanGen" \ No newline at end of file +rootProject.name = "ActionModelsGenerator" \ No newline at end of file diff --git a/src/main/java/com/sdk/generators/GUtils.java b/src/main/java/com/sdk/generators/GUtils.java index a873a44..57bf5b8 100644 --- a/src/main/java/com/sdk/generators/GUtils.java +++ b/src/main/java/com/sdk/generators/GUtils.java @@ -1,4 +1,149 @@ package com.sdk.generators; +import com.intellij.database.model.DasColumn; +import com.intellij.database.model.ObjectKind; +import com.intellij.database.psi.DbObject; +import com.intellij.database.psi.DbTable; +import com.intellij.database.util.DasUtil; +import com.intellij.notification.NotificationGroupManager; +import com.intellij.notification.NotificationType; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.roots.PackageIndex; +import com.intellij.openapi.roots.ProjectRootManager; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VirtualFile; + +import java.io.IOException; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + public class GUtils { + + private static final LinkedHashMap TYPE_MAPPING = new LinkedHashMap<>(); + + static { + TYPE_MAPPING.put("bigint", "NUMBER"); + TYPE_MAPPING.put("bit", "STRING"); + TYPE_MAPPING.put("boolean", "STRING"); + TYPE_MAPPING.put("date", "DATE"); + TYPE_MAPPING.put("decimal", "NUMBER"); + TYPE_MAPPING.put("double", "NUMBER"); + TYPE_MAPPING.put("float", "NUMBER"); + TYPE_MAPPING.put("integer", "NUMBER"); + TYPE_MAPPING.put("numeric", "NUMBER"); + TYPE_MAPPING.put("smallint", "NUMBER"); + TYPE_MAPPING.put("timestamp", "DATE"); + TYPE_MAPPING.put("text", "STRING"); + TYPE_MAPPING.put("time", "DATE"); + TYPE_MAPPING.put("tinyint", "NUMBER"); + TYPE_MAPPING.put("varchar2", "STRING"); + TYPE_MAPPING.put("varchar", "STRING"); + TYPE_MAPPING.put("char", "STRING"); + } + + private static final Map userDefType = new HashMap<>(); + + private static String getRawType(String columnDefinition) { + String columnScript = columnDefinition.replaceAll("\s","#"); + for (String rawType : TYPE_MAPPING.keySet()) { + if (columnScript.contains("#"+rawType)) { + return rawType; + } + if (columnScript.contains("#"+rawType+"(")) { + return rawType; + } + if (columnScript.contains("#"+rawType+"#(")) { + return rawType; + } + } + return "varchar"; + } + + public static void createUserDefineType(DbTable table) { + String schemaName = table.getParent() != null ? table.getParent().getName() : ""; + DasUtil.getCatalogObject(table).getDasChildren(ObjectKind.SCHEMA).forEach(schema -> { + if (schema.getName().equals("public") || schema.getName().equals(schemaName)) { + schema.getDasChildren(ObjectKind.OBJECT_TYPE).forEach(domain -> { + String domainName = domain.getName(); + String domainScript = ((DbObject) domain).getText(); + userDefType.put(domainName, getRawType(domainScript)); + }); + } + }); + } + + public static String getFieldType(DasColumn column) { + String columnType = column.getDasType().toDataType().typeName; + String fieldType = TYPE_MAPPING.get(columnType); + if (fieldType == null) { + fieldType = TYPE_MAPPING.getOrDefault(userDefType.getOrDefault(columnType, "varchar"), "Object"); + } + return fieldType; + } + + public static String toCamelCase(String s, boolean capitalizeFirst) { + String[] parts = s.split("_"); + StringBuilder camelCaseString = new StringBuilder(); + for (int i = 0; i < parts.length; i++) { + String part = parts[i]; + if (i == 0 && !capitalizeFirst) { + camelCaseString.append(part.toLowerCase()); + } else { + camelCaseString.append(capitalize(part)); + } + } + return camelCaseString.toString(); + } + + public static String capitalize(String s) { + if (s == null || s.isEmpty()) { + return s; + } + return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); + } + + public static String getSelectedPackage(Project project, VirtualFile selectDirectory) { + if (selectDirectory == null) return ""; + return PackageIndex.getInstance(project).getPackageNameByDirectory(selectDirectory); + } + + public static VirtualFile findSourceRoot(Project project) { + for (VirtualFile root : ProjectRootManager.getInstance(project).getContentSourceRoots()) { + if (root.isDirectory() && !root.getName().equals("resources")) { + return root; + } + } + return null; + } + + public static VirtualFile createPackageDirs(Object requestor, VirtualFile sourceRoot, String path) throws IOException { + VirtualFile current = sourceRoot; + for (String part : path.split("/")) { + VirtualFile child = current.findChild(part); + if (child == null) { + child = current.createChildDirectory(requestor, part); + } + current = child; + } + return current; + } + + public static void showError(Project project, String message) { + ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog(project, message, "Generation Failed")); + NotificationGroupManager.getInstance() + // This ID should be registered in your plugin.xml + .getNotificationGroup("Action-Models-Generator-Notification") + .createNotification("ActionModels Generator", message, NotificationType.ERROR) + .notify(project); + } + + public static void showInfo(Project project, String title, String content) { + NotificationGroupManager.getInstance() + // This ID should be registered in your plugin.xml + .getNotificationGroup("Action-Models-Generator-Notification") + .createNotification(title, content, NotificationType.INFORMATION) + .notify(project); + } } diff --git a/src/main/java/com/sdk/generators/actionmodels/GenerateAction.java b/src/main/java/com/sdk/generators/actionmodels/GenerateAction.java index a971677..aa65808 100644 --- a/src/main/java/com/sdk/generators/actionmodels/GenerateAction.java +++ b/src/main/java/com/sdk/generators/actionmodels/GenerateAction.java @@ -1,22 +1,32 @@ -package com.sdk.actionbean.generator; +package com.sdk.generators.actionmodels; -import com.intellij.database.model.*; -import com.intellij.database.psi.*; -import com.intellij.database.util.*; -import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.application.*; -import com.intellij.openapi.fileChooser.*; -import com.intellij.openapi.project.*; -import com.intellij.openapi.ui.*; -import com.intellij.openapi.vfs.*; -import com.intellij.psi.*; -import com.intellij.util.containers.*; -import org.jetbrains.annotations.*; +import com.intellij.database.model.DasColumn; +import com.intellij.database.model.ObjectKind; +import com.intellij.database.psi.DbObject; +import com.intellij.database.psi.DbTable; +import com.intellij.database.util.DasUtil; +import com.intellij.openapi.actionSystem.AnAction; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.LangDataKeys; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.fileChooser.FileChooserFactory; +import com.intellij.openapi.fileChooser.FileSaverDescriptor; +import com.intellij.openapi.fileChooser.FileSaverDialog; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.VirtualFileWrapper; +import com.intellij.psi.PsiElement; +import com.intellij.util.containers.JBIterable; +import com.sdk.generators.GUtils; +import org.jetbrains.annotations.NotNull; -import java.io.*; -import java.nio.charset.*; -import java.util.*; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; public class GenerateAction extends AnAction { @@ -44,7 +54,7 @@ public class GenerateAction extends AnAction { private static final Map userDefType = new HashMap<>(); - private String getRawType(String columnDefinition ) { + private static String getRawType(String columnDefinition ) { for (String rawType : TYPE_MAPPING.keySet()) { if (columnDefinition.contains(rawType)) { return rawType; @@ -53,7 +63,7 @@ public class GenerateAction extends AnAction { return "varchar"; } - private void createUserDefineType(DbTable table) { + private static void createUserDefineType(DbTable table) { if (userDefType.isEmpty()) { String schemaName = table.getParent() != null ? table.getParent().getName() : ""; DasUtil.getCatalogObject(table).getDasChildren(ObjectKind.SCHEMA).forEach(schema -> { @@ -68,7 +78,7 @@ public class GenerateAction extends AnAction { } } - private String getFieldType(String columnType) { + public static String getFieldType(String columnType) { columnType = columnType.toLowerCase(); String fieldType = TYPE_MAPPING.get(columnType ); if (fieldType == null) { @@ -96,22 +106,22 @@ public class GenerateAction extends AnAction { createUserDefineType(table); } - String className = toCamelCase(table.getName(), true); + String className = GUtils.toCamelCase(table.getName(), true); StringBuilder builder = new StringBuilder(); builder.append("public class ").append(className).append(" {\n\n"); JBIterable columns = DasUtil.getColumns(table); for (DasColumn column : columns) { - String fieldName = toCamelCase(column.getName(), false); + String fieldName = GUtils.toCamelCase(column.getName(), false); String fieldType = getFieldType(column.getDasType().toDataType().typeName); builder.append(" private ").append(fieldType).append(" ").append(fieldName).append(";\n"); } builder.append("\n"); for (DasColumn column : columns) { - String fieldName = toCamelCase(column.getName(), false); + String fieldName = GUtils.toCamelCase(column.getName(), false); String fieldType = getFieldType(column.getDasType().toDataType().typeName); - String capitalizedFieldName = capitalize(fieldName); + String capitalizedFieldName = GUtils.capitalize(fieldName); builder.append(" public ").append(fieldType).append(" get").append(capitalizedFieldName).append("() {\n"); builder.append(" return ").append(fieldName).append(";\n"); @@ -139,25 +149,4 @@ public class GenerateAction extends AnAction { }); } } - - private String toCamelCase(String s, boolean capitalizeFirst) { - String[] parts = s.split("_"); - StringBuilder camelCaseString = new StringBuilder(); - for (int i = 0; i < parts.length; i++) { - String part = parts[i]; - if (i == 0 && !capitalizeFirst) { - camelCaseString.append(part.toLowerCase()); - } else { - camelCaseString.append(capitalize(part)); - } - } - return camelCaseString.toString(); - } - - private String capitalize(String s) { - if (s == null || s.isEmpty()) { - return s; - } - return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase(); - } } diff --git a/src/main/java/com/sdk/generators/actionmodels/GenerateBeanAction.java b/src/main/java/com/sdk/generators/actionmodels/GenerateBeanAction.java index 8bc547b..423d31e 100644 --- a/src/main/java/com/sdk/generators/actionmodels/GenerateBeanAction.java +++ b/src/main/java/com/sdk/generators/actionmodels/GenerateBeanAction.java @@ -1,4 +1,4 @@ -package com.sdk.actionbean.generator; +package com.sdk.generators.actionmodels; import com.intellij.database.psi.DbTable; import com.intellij.openapi.actionSystem.AnAction; @@ -13,12 +13,9 @@ import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; -import com.intellij.openapi.roots.ProjectRootManager; -import com.intellij.openapi.project.ProjectUtil; -import com.intellij.openapi.roots.PackageIndex; -import com.intellij.openapi.ui.Messages; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.PsiElement; +import com.sdk.generators.GUtils; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -35,9 +32,10 @@ public class GenerateBeanAction extends AnAction { FileChooserDescriptor descriptor = new FileChooserDescriptor(false,true,false,false,false,false); PathChooserDialog pathChooser = FileChooserFactory.getInstance().createPathChooser(descriptor, project, null); - VirtualFile baseDir = ProjectUtil.guessProjectDir(project); + VirtualFile baseDir = GUtils.findSourceRoot(project); + pathChooser.choose(baseDir, virtualFiles -> { - String packageName = getSelectedPackage(project, virtualFiles.getFirst()); + String packageName = GUtils.getSelectedPackage(project, virtualFiles.getFirst()); ArrayList tables = new ArrayList<>(); for (PsiElement psiElement : psiElements) { @@ -58,30 +56,11 @@ public class GenerateBeanAction extends AnAction { try { new GeneratorServices(project,tables,packageName).execute(indicator); } catch (Exception ex) { - showError(project, "An error occurred during code generation: " + ex.getMessage()); + GUtils.showError(project, "An error occurred during code generation: " + ex.getMessage()); } }) ); } }); } - - private void showError(Project project, String message) { - ApplicationManager.getApplication().invokeLater(() -> Messages.showErrorDialog(project, message, "Generation Failed")); - } - - private String getSelectedPackage(Project project, VirtualFile selectDirectory) { - if (selectDirectory == null) return ""; - String packageName = PackageIndex.getInstance(project).getPackageNameByDirectory(selectDirectory); - return packageName; - } - - private VirtualFile findSourceRoot(Project project, String packageName) { - for (VirtualFile root : ProjectRootManager.getInstance(project).getContentSourceRoots()) { - if (root.isDirectory() && !root.getName().equals("resources")) { - return root; - } - } - return null; - } } \ No newline at end of file diff --git a/src/main/java/com/sdk/generators/actionmodels/GeneratorServices.java b/src/main/java/com/sdk/generators/actionmodels/GeneratorServices.java index f0ff890..4663e12 100644 --- a/src/main/java/com/sdk/generators/actionmodels/GeneratorServices.java +++ b/src/main/java/com/sdk/generators/actionmodels/GeneratorServices.java @@ -1,84 +1,148 @@ -package com.sdk.actionbean.generator; +package com.sdk.generators.actionmodels; +import com.intellij.database.model.DasColumn; +import com.intellij.database.model.DasTableKey; import com.intellij.database.psi.DbTable; +import com.intellij.database.util.DasUtil; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.progress.ProgressIndicator; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.util.containers.JBIterable; +import com.sdk.generators.GUtils; +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateExceptionHandler; import org.jetbrains.annotations.NotNull; -import java.sql.DatabaseMetaData; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; public class GeneratorServices { - private final String packageName; + private final String basePackage; private final Project project; private final ArrayList tables; - public GeneratorServices(Project project, ArrayList tables, String packageName) { + public GeneratorServices(Project project, ArrayList tables, String basePackage) { this.tables = tables; this.project = project; - this.packageName = packageName; + this.basePackage = basePackage; + } + + private void genDataModel(Template template, Map model, VirtualFile targetDir, String classFile, ProgressIndicator indicator) { + try { + VirtualFile outputFile = targetDir.findOrCreateChildData(this, classFile); + ApplicationManager.getApplication().runWriteAction(() -> { + try (Writer writer = new OutputStreamWriter(outputFile.getOutputStream(this))) { + template.process(model, writer); + } catch (Exception e) { + throw new RuntimeException(e); + } + indicator.setText2("Generated " + outputFile.getName()); + GUtils.showInfo(project, "ActionModels Generator", "Generated " + outputFile.getName()); + }); + } catch (Exception e) { + throw new RuntimeException(e); + } } public void execute(@NotNull ProgressIndicator indicator) { -// String packagePath = packageName.replace('.', '/'); -// VirtualFile packageDir = createPackageDirs(sourceRoot, packagePath); -// -// Configuration cfg = new Configuration(Configuration.VERSION_2_3_32); -// cfg.setClassForTemplateLoading(this.getClass(), "/templates"); -// cfg.setDefaultEncoding("UTF-8"); -// cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); -// Template template = cfg.getTemplate("actionBean.ftl"); -// -// DatabaseMetaData metaData = conn.getMetaData(); -// try (ResultSet tables = metaData.getTables(null, dbSchema.toUpperCase(), tablePattern, new String[]{"TABLE"})) { -// while (tables.next()) { -// String tableName = tables.getString("TABLE_NAME"); -// indicator.setText("Processing table: " + tableName); -// -// Map model = createModelForTable(metaData, tableName, dbSchema); -// -// VirtualFile outputFile = packageDir.findOrCreateChildData(this, model.get("className") + ".java"); -// try (Writer writer = new OutputStreamWriter(outputFile.getOutputStream(this))) { -// template.process(model, writer); -// } -// indicator.setText2("Generated " + outputFile.getName()); -// } -// } + // Use AtomicInteger to safely count files within the lambda expression + AtomicInteger fileCount = new AtomicInteger(0); + try { + + VirtualFile sourceRoot = GUtils.findSourceRoot(project); + String packagePath = basePackage.replace('.', '/'); + + + Configuration cfg = new Configuration(Configuration.VERSION_2_3_32); + cfg.setClassForTemplateLoading(this.getClass(), "/templates"); + cfg.setDefaultEncoding("UTF-8"); + cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER); + + + VirtualFile beanExtDir = GUtils.createPackageDirs(this, sourceRoot, Path.of(packagePath, "/bean").toString()); + VirtualFile beanDir = GUtils.createPackageDirs(this, sourceRoot, Path.of(packagePath, "/bean/base").toString()); + Template tmpBean = cfg.getTemplate("actionBean.ftl"); + Template tmpBeanExt = cfg.getTemplate("actionBean.extend.ftl"); + + VirtualFile DTOExtDir = GUtils.createPackageDirs(this, sourceRoot, Path.of(packagePath, "/dto").toString()); + VirtualFile DTODir = GUtils.createPackageDirs(this, sourceRoot, Path.of(packagePath, "/dto/base").toString()); + Template tmpDTO = cfg.getTemplate("actionDTO.ftl"); + Template tmpDTOExt = cfg.getTemplate("actionDTO.extend.ftl"); + + tables.forEach(table -> { + Map model = createModelForTable(table); + + String className = model.get("className").toString(); + String classFile = className + ".java"; + + genDataModel(tmpBean, model, beanDir, classFile, indicator); + fileCount.getAndIncrement(); + + if (!Files.exists(Path.of(beanExtDir.toNioPath().toString(), classFile))) { + genDataModel(tmpBeanExt, model, beanExtDir, classFile, indicator); + fileCount.getAndIncrement(); + } + + // FIX: Use a separate variable for the DTO filename to avoid overwriting the wrong file. + String dtoClassFile = "DTO_" + className + ".java"; + genDataModel(tmpDTO, model, DTODir, dtoClassFile, indicator); + fileCount.getAndIncrement(); + + if (!Files.exists(Path.of(DTOExtDir.toNioPath().toString(), dtoClassFile))) { + genDataModel(tmpDTOExt, model, DTOExtDir, dtoClassFile, indicator); + fileCount.getAndIncrement(); + } + }); + + // After the loop finishes, show a single, helpful summary notification. + String message = String.format("Generated %d files for %d tables successfully.", fileCount.get(), tables.size()); + GUtils.showInfo(project, "ActionModels Generation Complete", message); + + } catch (Exception ex) { + GUtils.showError(project, "Generation Failed \n" + ex.getMessage()); + } } - private Map createModelForTable(DatabaseMetaData metaData, String tableName, String dbSchema) throws SQLException { + private Map createModelForTable(DbTable table) { + String tableName = table.getName().toUpperCase(); + String dbSchema = table.getParent() != null ? table.getParent().getName() : ""; + + GUtils.createUserDefineType(table); + Map model = new HashMap<>(); - model.put("packageName", packageName); + model.put("basePackage", basePackage); model.put("tableName", tableName); model.put("className", tableName); model.put("dbSchema", dbSchema); List> columns = new ArrayList<>(); Set primaryKeys = new HashSet<>(); - try (ResultSet pks = metaData.getPrimaryKeys(null, dbSchema.toUpperCase(), tableName)) { - while (pks.next()) { - primaryKeys.add(pks.getString("COLUMN_NAME")); - } - } + JBIterable dasKeys = DasUtil.getTableKeys(table); - try (ResultSet cols = metaData.getColumns(null, dbSchema.toUpperCase(), tableName, "%")) { - while (cols.next()) { - Map colModel = new HashMap<>(); - String colName = cols.getString("COLUMN_NAME"); - int dataType = cols.getInt("DATA_TYPE"); - - colModel.put("name", colName); - colModel.put("isPk", primaryKeys.contains(colName)); - colModel.put("customType", mapJdbcType(dataType)); - columns.add(colModel); + dasKeys.forEach(key -> { + if (key.isPrimary()) { + DasUtil.getColumns(key).forEach(column -> primaryKeys.add(column.getName().toUpperCase())); } - } + }); + + JBIterable dasColumns = DasUtil.getColumns(table); + dasColumns.forEach(column -> { + Map colModel = new HashMap<>(); + String colName = column.getName().toUpperCase(); + String dataType = GUtils.getFieldType(column); + colModel.put("name", colName); + colModel.put("isPk", primaryKeys.contains(colName)); + colModel.put("customType", dataType); + columns.add(colModel); + }); model.put("columns", columns); model.put("fieldList", columns.stream().map(c -> (String) c.get("name")).collect(Collectors.joining(","))); @@ -86,25 +150,4 @@ public class GeneratorServices { return model; } - - private VirtualFile createPackageDirs(VirtualFile sourceRoot, String path) throws java.io.IOException { - VirtualFile current = sourceRoot; - for (String part : path.split("/")) { - VirtualFile child = current.findChild(part); - if (child == null) { - child = current.createChildDirectory(this, part); - } - current = child; - } - return current; - } - - private String mapJdbcType(int jdbcType) { - return switch (jdbcType) { - case Types.NUMERIC, Types.DECIMAL, Types.INTEGER, Types.BIGINT, Types.SMALLINT, Types.TINYINT, Types.FLOAT, Types.DOUBLE -> "NUMBER"; - case Types.DATE, Types.TIMESTAMP, Types.TIMESTAMP_WITH_TIMEZONE -> "DATE"; - default -> "STRING"; - }; - } - -} +} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 034a22e..8db3015 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ - com.sdk.actionbean.generator + com.sdk.generators.actionmodels Database Action Models Generator Sakda Sakprapakorn @@ -16,13 +16,17 @@ - - - + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/actionBean.extend.ftl b/src/main/resources/templates/actionBean.extend.ftl index 7c73d63..4dd7cfe 100644 --- a/src/main/resources/templates/actionBean.extend.ftl +++ b/src/main/resources/templates/actionBean.extend.ftl @@ -1,13 +1,13 @@ -package ${packageName}.bean; +package ${basePackage}.bean; -/** -* Generated by IntelliJ ActionBean Generator -* Table: ${tableName} +/* + Generated by ActionBean Generator + For Table : ${tableName} */ import sdk.dbutils.*; -public class ${tableName} extends ${packageName}.bean.base.${tableName} { +public class ${tableName} extends ${basePackage}.bean.base.${tableName} { public ${tableName}(DBConnector connector) { //class construction super(connector); } diff --git a/src/main/resources/templates/actionBean.ftl b/src/main/resources/templates/actionBean.ftl index cfdbdfa..b966520 100644 --- a/src/main/resources/templates/actionBean.ftl +++ b/src/main/resources/templates/actionBean.ftl @@ -1,8 +1,8 @@ -package ${packageName}.bean.base; +package ${basePackage}.bean.base; -/** -* Generated by IntelliJ ActionBean Generator -* Table: ${tableName} +/* + Generated by ActionBean Generator + For Table : ${tableName} */ import sdk.dbutils.*; @@ -16,12 +16,22 @@ public class ${className} extends ActionBean { public static final String fullTableName = "${tableName}"; private DTO_${tableName} myDTO; +<#list columns as col> + public final ActionField afx${col.name}; + + public ${className}(DBConnector dbConnector) { //class construction super(dbConnector, fullTableName); myDTO = new DTO_${tableName}(); initFieldDefs(); fieldList = "${fieldList}"; keyList = "${keyList}"; + + // Create ActionField Instant (afx) for each field +<#list columns as col> + afx${col.name} = new ActionField(this,${col.name}); + + } public ${className}() { //class construction @@ -30,6 +40,11 @@ public class ${className} extends ActionBean { initFieldDefs(); fieldList = "${fieldList}"; keyList = "${keyList}"; + + // Create ActionField Instant (afx) for each field +<#list columns as col> + afx${col.name} = new ActionField(this,${col.name}); + } @Override @@ -58,10 +73,24 @@ public class ${className} extends ActionBean { Sql.append(" FROM ${tableName}\n"); Sql.append(" WHERE 0=0 \n"); - sqlSelect = new StringBuilder(Sql); } +<#-- Generate Field Constants --> +<#list columns as col> + public static final String ${col.name} = "${col.name}"; + + +<#-- Generate Getter --> +<#list columns as col> + public String get${col.name}() { + return getValue(${col.name}); + } + public String get${col.name}(String defValue) { + return getValue(${col.name}, defValue); + } + + <#-- Generate Setters --> <#list columns as col> public void set${col.name}(String value) { @@ -70,34 +99,34 @@ public class ${className} extends ActionBean { setKeyField(${col.name}, value); fieldByName(${col.name}).setAsString(value); } else { + <#if col.customType == "NUMBER"> setKeyField(${col.name}, JUtils.cleanUpNumber(value)); fieldByName(${col.name}).setAsString(JUtils.cleanUpNumber(value)); + <#elseif col.customType == "DATE"> + setKeyField(${col.name}, DateUtils.strToSqlDate(value)); + fieldByName(${col.name}).setAsString(value); + <#else> + setKeyField(${col.name}, value); + fieldByName(${col.name}).setAsString(value); + } - <#elseif col.customType == "DATE"> + <#else> if (JUtils.isMacro(value)) { setField(${col.name}, value); fieldByName(${col.name}).setAsString(value); } else { + <#if col.customType == "NUMBER"> + setField(${col.name}, JUtils.cleanUpNumber(value)); + fieldByName(${col.name}).setAsString(JUtils.cleanUpNumber(value)); + <#elseif col.customType == "DATE"> setField(${col.name}, DateUtils.strToSqlDate(value)); fieldByName(${col.name}).setAsString(value); + <#else> + setField(${col.name}, value); + fieldByName(${col.name}).setAsString(value); + } - <#else> - setField(${col.name}, value); - fieldByName(${col.name}).setAsString(value); } - - - -<#-- Generate Getters and Constants --> -<#list columns as col> - public static final String ${col.name} = "${col.name}"; - public String get${col.name}() { - return getValue(${col.name}); - } - public String get${col.name}(String defValue) { - return getValue(${col.name}, defValue); - } - } \ No newline at end of file diff --git a/src/main/resources/templates/actionDTO.extend.ftl b/src/main/resources/templates/actionDTO.extend.ftl index 5c51b76..abc9916 100644 --- a/src/main/resources/templates/actionDTO.extend.ftl +++ b/src/main/resources/templates/actionDTO.extend.ftl @@ -1,18 +1,18 @@ -package ${basePackage}.bean; +package ${basePackage}.dto; -/** -* Generated by IntelliJ ActionBean Generator -* For Table : ${tableName} +/* + Generated by ActionBean Generator + For Table : ${tableName} */ import sdk.dbutils.*; -public class ${tableName} extends ${basePackage}.bean.base.${tableName} { - public ${tableName}(DBConnector connector) { //class construction - super(connector); +public class DTO_${tableName} extends ${basePackage}.dto.base.DTO_${tableName} { + public DTO_${tableName}(DTO dto) { //class construction + super(dto); } - public ${tableName}() { //class construction + public DTO_${tableName}() { //class construction super(); } } diff --git a/src/main/resources/templates/actionDTO.ftl b/src/main/resources/templates/actionDTO.ftl index 4fcbcb5..5b7887b 100644 --- a/src/main/resources/templates/actionDTO.ftl +++ b/src/main/resources/templates/actionDTO.ftl @@ -1,103 +1,59 @@ -package ${basePackage}.bean.base; +package ${basePackage}.dto.base; -/** -* Generated by IntelliJ ActionBean Generator -* For Table: ${tableName} +/* + Generated by ActionBean Generator + For Table : ${tableName} */ import sdk.dbutils.*; import sdk.utils.*; -import ${basePackage}.dto.*; -public class ${className} extends ActionBean { +public class DTO_${className} extends DTO { - public static final String tableName = "${tableName}"; - public static final String schemaName = "${dbSchema}"; - public static final String fullTableName = "${tableName}"; - private DTO_${tableName} myDTO; - - public ${className}(DBConnector dbConnector) { //class construction - super(dbConnector, fullTableName); - myDTO = new DTO_${tableName}(); - initFieldDefs(); - fieldList = "${fieldList}"; - keyList = "${keyList}"; - } - - public ${className}() { //class construction - super(); - myDTO = new DTO_${tableName}(); - initFieldDefs(); - fieldList = "${fieldList}"; - keyList = "${keyList}"; - } - - @Override - protected void initFieldDefs() { - fieldDefs.clear(); - <#list columns as col> - fieldDefs.put("${col.name}", "${col.customType}<#if col.isPk>:KEY"); - - } - - public DTO_${tableName} getInstanceDTO() { - myDTO.setDTO(this.getDTO()); - return myDTO; - } - - @Override - protected void initSqlSelect() { - StringBuilder Sql = new StringBuilder(); - Sql.append("SELECT "); - <#list columns as col> - <#if col?is_first> - Sql.append(" <#if col.customType == 'DATE'>JDTOET(${col.name}) ${col.name}, ${col.name} AS DT_${col.name}<#else> ${col.name}\n"); - <#else> - Sql.append(" ,<#if col.customType == 'DATE'>JDTOET(${col.name}) ${col.name}, ${col.name} AS DT_${col.name}<#else>${col.name}\n"); - - - Sql.append(" FROM ${tableName}\n"); - Sql.append(" WHERE 0=0 \n"); - - sqlSelect = new StringBuilder(Sql); - } - -<#-- Generate Setters --> <#list columns as col> - public void set${col.name}(String value) { - <#if col.isPk> - if (JUtils.isMacro(value)) { - setKeyField(${col.name}, value); - fieldByName(${col.name}).setAsString(value); - } else { - setKeyField(${col.name}, JUtils.cleanUpNumber(value)); - fieldByName(${col.name}).setAsString(JUtils.cleanUpNumber(value)); - } - <#elseif col.customType == "DATE"> - if (JUtils.isMacro(value)) { - setField(${col.name}, value); - fieldByName(${col.name}).setAsString(value); - } else { - setField(${col.name}, DateUtils.strToSqlDate(value)); - fieldByName(${col.name}).setAsString(value); - } - <#else> - setField(${col.name}, value); - fieldByName(${col.name}).setAsString(value); - - } - + public final DTOField dfx${col.name}; -<#-- Generate Getters and Constants --> + public DTO_${className}() { //class construction + super(); + setFieldList("${fieldList}"); + + // Create DTOField Instant (dfx) for each field + <#list columns as col> + dfx${col.name} = new DTOField(this,${col.name}); + + } + + public DTO_${className}(DTO dto) { //class construction + super(); + setFieldList("${fieldList}"); + this.data = dto.getData(); + + // Create DTOField Instant (dfx) for each field + <#list columns as col> + dfx${col.name} = new DTOField(this,${col.name}); + + } + + public void setDTO(DTO dto) { + this.data = dto.getData(); + } + +<#-- Generate Field Constants --> <#list columns as col> public static final String ${col.name} = "${col.name}"; + + +<#-- Generate Getters and Setter --> +<#list columns as col> public String get${col.name}() { return getValue(${col.name}); } public String get${col.name}(String defValue) { return getValue(${col.name}, defValue); } - + public void set${col.name}(String value) { + setValue(${col.name}, value); + } } \ No newline at end of file