Commit 2b427b23 authored by SKRIS40's avatar SKRIS40

intial commit

parent 3be83b4e
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.2.0
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "$(uname)" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
else
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=$(java-config --jre-home)
fi
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="$(which javac)"
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=$(which readlink)
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
if $darwin ; then
javaHome="$(dirname "\"$javaExecutable\"")"
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
else
javaExecutable="$(readlink -f "\"$javaExecutable\"")"
fi
javaHome="$(dirname "\"$javaExecutable\"")"
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=$(cd "$wdir/.." || exit 1; pwd)
fi
# end of workaround
done
printf '%s' "$(cd "$basedir" || exit 1; pwd)"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
# Remove \r in case we run on Windows within Git Bash
# and check out the repository with auto CRLF management
# enabled. Otherwise, we may read lines that are delimited with
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
# splitting rules.
tr -s '\r\n' ' ' < "$1"
fi
}
log() {
if [ "$MVNW_VERBOSE" = true ]; then
printf '%s\n' "$1"
fi
}
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
log "$MAVEN_PROJECTBASEDIR"
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
if [ -r "$wrapperJarPath" ]; then
log "Found $wrapperJarPath"
else
log "Couldn't find $wrapperJarPath, downloading it ..."
if [ -n "$MVNW_REPOURL" ]; then
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
else
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
fi
while IFS="=" read -r key value; do
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
safeValue=$(echo "$value" | tr -d '\r')
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
esac
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
log "Downloading from: $wrapperUrl"
if $cygwin; then
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
fi
if command -v wget > /dev/null; then
log "Found wget ... using wget"
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
log "Found curl ... using curl"
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
else
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
fi
else
log "Falling back to using Java to download"
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaSource=$(cygpath --path --windows "$javaSource")
javaClass=$(cygpath --path --windows "$javaClass")
fi
if [ -e "$javaSource" ]; then
if [ ! -e "$javaClass" ]; then
log " - Compiling MavenWrapperDownloader.java ..."
("$JAVA_HOME/bin/javac" "$javaSource")
fi
if [ -e "$javaClass" ]; then
log " - Running MavenWrapperDownloader.java ..."
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
wrapperSha256Sum=""
while IFS="=" read -r key value; do
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
esac
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
if [ -n "$wrapperSha256Sum" ]; then
wrapperSha256Result=false
if command -v sha256sum > /dev/null; then
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
wrapperSha256Result=true
fi
elif command -v shasum > /dev/null; then
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
wrapperSha256Result=true
fi
else
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
exit 1
fi
if [ $wrapperSha256Result = false ]; then
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
exit 1
fi
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
# shellcheck disable=SC2086 # safe args
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.2.0
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %WRAPPER_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
SET WRAPPER_SHA_256_SUM=""
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
)
IF NOT %WRAPPER_SHA_256_SUM%=="" (
powershell -Command "&{"^
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
" exit 1;"^
"}"^
"}"
if ERRORLEVEL 1 goto error
)
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.practice</groupId>
<artifactId>ftl-json-migration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ftl-vue-migration</name>
<description>ftl-vue-migration</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.javassist/javassist -->
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.29.2-GA</version>
</dependency>
<!-- https://mvnrepository.com/artifact/asm/asm-all -->
<dependency>
<groupId>asm</groupId>
<artifactId>asm-all</artifactId>
<version>3.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.antlr/antlr4-runtime -->
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.13.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.freemarker/freemarker -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.32</version>
</dependency>
<!-- &lt;!&ndash; https://mvnrepository.com/artifact/org.apache.flex.flexjs.framework/Core &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.apache.flex.flexjs.framework</groupId>-->
<!-- <artifactId>Core</artifactId>-->
<!-- <version>0.8.0</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.15.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20231013</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.jflex</groupId>-->
<!-- <artifactId>jflex</artifactId>-->
<!-- <version>1.9.8</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>net.sf.cup</groupId>-->
<!-- <artifactId>cup</artifactId>-->
<!-- <version>0.11b</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.jflex</groupId>
<artifactId>jflex</artifactId>
<version>1.8.2</version> <!-- Use the latest version available -->
</dependency>
<dependency>
<groupId>org.jcuda</groupId>
<artifactId>jcusparse</artifactId>
<version>11.8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<builder>paketobuildpacks/builder-jammy-base:latest</builder>
</image>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>clojars</id>
<name>Clojars</name>
<url>https://repo.clojars.org/</url>
</repository>
</repositories>
</project>
package com.practice.migration;
import com.practice.migration.nov_10_23.FTLToIR;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class FtlVueMigrationApplication {
public static void main(String[] args) {
FTLToIR ftlToIR = new FTLToIR();
ftlToIR.convertFTLtoIR();
SpringApplication.run(FtlVueMigrationApplication.class, args);
}
}
package com.practice.migration.nov_10_23;
import freemarker.cache.NullCacheStorage;
import freemarker.cache.StringTemplateLoader;
import freemarker.core.ParseException;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.json.JSONObject;
import org.springframework.ui.Model;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
public class FTLToIR {
public void convertFTLtoIR() {
try {
// Initialize FreeMarker Configuration
Configuration cfg = new Configuration(Configuration.VERSION_2_3_31);
// FTL Template
String ftlTemplate = "[#assign f=1]\n" +
"[#if f gt 0]\n" +
" {f} > 0\n" +
"[#else]\n" +
" {f} < 0\n" +
"[/#if]";
// Load FTL Template
StringTemplateLoader templateLoader = new StringTemplateLoader();
templateLoader.putTemplate("myTemplate", ftlTemplate);
cfg.setTemplateLoader(templateLoader);
// Get the Template
Template template = cfg.getTemplate("myTemplate");
// Create a data model (context)
Map<String, Object> dataModel = new HashMap<>();
// Process the template
StringWriter out = new StringWriter();
template.process(dataModel, out);
// Extract the result as a JSON object
JSONObject jsonObject = new JSONObject();
jsonObject.put("IR", out.toString());
// Print the IR JSON
System.out.println("----- print thte data ----");
System.out.println(jsonObject.toString(4)); // Pretty print with 4 spaces
System.out.println(jsonObject +" :"+ jsonObject );
} catch (IOException | TemplateException e) {
e.printStackTrace();
}
}
}
package com.practice.migration.nov_10_23;
import freemarker.cache.StringTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
public class FtlToIRConverter {
public static void main(String[] args) {
String ftlTemplate = "[#assign f=1]\n\n[#if f gt 0]\n ${f} > 0\n[#else]\n ${f} < 0\n[/#if]";
try {
Map<String, Object> dataModel = new HashMap<>();
dataModel.put("f", 1);
String irJson = convertFtlToIR(ftlTemplate, dataModel);
System.out.println("Intermediate Representation (IR):");
System.out.println(irJson);
} catch (IOException | TemplateException e) {
e.printStackTrace();
}
}
private static String convertFtlToIR(String ftlTemplate, Map<String, Object> dataModel)
throws IOException, TemplateException {
Configuration cfg = new Configuration(Configuration.VERSION_2_3_31);
StringTemplateLoader stringLoader = new StringTemplateLoader();
stringLoader.putTemplate("myTemplate", ftlTemplate);
cfg.setTemplateLoader(stringLoader);
Template template = cfg.getTemplate("myTemplate");
StringWriter writer = new StringWriter();
template.process(dataModel, writer);
return writer.toString();
}
}
package com.practice.migration.nov_10_23;
import javassist.*;
public class IRExtractor {
public static void main(String[] args) {
try {
// Load the class
ClassPool classPool = ClassPool.getDefault();
CtClass ctClass = classPool.get("SampleClass");
// Extracting fields
CtField[] fields = ctClass.getDeclaredFields();
for (CtField field : fields) {
System.out.println("Field: " + field.getName());
}
// Extracting methods
CtMethod[] methods = ctClass.getDeclaredMethods();
for (CtMethod method : methods) {
System.out.println("Method: " + method.getName());
}
// You can further explore the method bodies, annotations, etc.
} catch (NotFoundException e) {
e.printStackTrace();
}
}
}
class SampleClass {
private int value;
public SampleClass(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
public void printValue() {
System.out.println("Value: " + value);
}
}
\ No newline at end of file
//package com.practice.migration.nov_11_23.custom;
//
////import static sun.security.x509.AVA.readChar;
//
////import static sun.security.x509.AVA.readChar;
//import java.io.Reader;
//
//public class FtlLexer extends FlexLexer {
//
// public static final int EOF = 0;
// public static final int TEXT = 1;
// public static final int VARIABLE = 2;
// public static final int COMMENT = 3;
//
// @Override
// public int lex() throws Exception {
// int c = readChar();
//
// switch (c) {
// case EOF:
// return EOF;
// case '$':
// return VARIABLE;
// case '#':
// return readComment();
// default:
// return TEXT;
// }
// }
//
// private int readComment() throws Exception {
// int c;
// do {
// c = readChar();
// } while (c != EOF && c != '\n');
//
// return COMMENT;
// }
//}
\ No newline at end of file
//package com.practice.migration.nov_11_23.custom;
//
//public class FtlParser extends CupParser {
//
// public FtlParser(Lexer lexer) {
// super(lexer);
// }
//
// @Override
// public void parse() throws Exception {
// root = parseTemplate();
// }
//
// private TemplateNode parseTemplate() throws Exception {
// TemplateNode root = new TemplateNode("template");
//
// while (true) {
// int token = lexer.lex();
//
// switch (token) {
// case EOF:
// return root;
// case FtlLexer.TEXT:
// root.addChild(new TextNode(lexer.yytext()));
// break;
// case FtlLexer.VARIABLE:
// root.addChild(new VariableNode(lexer.yytext()));
// break;
// case FtlLexer.COMMENT:
// // Ignore comments.
// break;
// default:
// throw new Exception("Unexpected token: " + token);
// }
// }
// }
//}
package com.practice.migration.nov_11_23.old;
//public class FreeMarkerListener extends FreeMarkerBaseListener {
// @Override
// public void enterIfStatement(FreeMarkerParser.IfStatementContext ctx) {
// System.out.println("Found an if statement");
// }
//
// // Add more methods as needed for other template constructs
//}
package com.practice.migration.nov_11_23.old;
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
public class Main {
// public static void main(String[] args) {
// String input = "[#if x=10]Hello[#else]World[/#if]";
// FreeMarkerLexer lexer = new FreeMarkerLexer(CharStreams.fromString(input));
// FreeMarkerParser parser = new FreeMarkerParser(new CommonTokenStream(lexer));
//
// ParseTree tree = parser.template();
// FreeMarkerListener listener = new FreeMarkerListener();
// ParseTreeWalker walker = new ParseTreeWalker();
// walker.walk(listener, tree);
// }
}
package com.practice.migration.nov_11_23.tryagain;
public class AssignmentNode {
private String variable;
private String value;
public AssignmentNode(String variable, String value) {
this.variable = variable;
this.value = value;
}
public String getVariable() {
return variable;
}
public void setVariable(String variable) {
this.variable = variable;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.practice.migration.nov_11_23.tryagain;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.tree.*;
public class CustomMain {
public static void main(String[] args) {
String ftlCode = "[#assign name='John']\n" +
"[#if age > 18]\n" +
" Welcome, ${name}!\n" +
"[#else]\n" +
" You are too young, ${name}!\n" +
"[/#if]";
// FreeMarkerLexer lexer = new FreeMarkerLexer(CharStreams.fromString(ftlCode));
// CommonTokenStream tokens = new CommonTokenStream(lexer);
// FreeMarkerParser parser = new FreeMarkerParser(tokens);
//
// ParseTree tree = parser.template();
// Create a custom listener to build the IR
// FreeMarkerCustomListener listener = new FreeMarkerCustomListener();
ParseTreeWalker walker = new ParseTreeWalker();
// walker.walk(listener, tree);
// Get the resulting IR
// Object result = listener.getResult();
// System.out.println(result);
}
}
grammar FreeMarker;
// Parser rules
template: (tag | text)*;
tag: assignmentTag | conditionalTag;
assignmentTag: '#assign' ID '=' STRING;
conditionalTag: '#if' expression
(tag | text)*
('#else'
(tag | text)*
)?
'#end';
expression: ID ('>' | '<') NUMBER;
// Lexer rules
ID: [a-zA-Z]+;
NUMBER: [0-9]+;
STRING: '\'' ~'\''* '\'';
WS: [ \t\r\n]+ -> skip;
// Ignoring everything else for simplicity
ANY: . -> skip;
\ No newline at end of file
//package com.practice.migration.nov_11_23.tryagain;
//
//import org.antlr.v4.runtime.ParserRuleContext;
//import org.antlr.v4.runtime.tree.ParseTree;
//import org.antlr.v4.runtime.tree.ParseTreeProperty;
//
//public class FreeMarkerCustomListener extends FreeMarkerBaseListener {
// private ParseTreeProperty<Object> values = new ParseTreeProperty<>();
// private Object result;
//
// public Object getResult() {
// return result;
// }
//
// @Override
// public void exitTag(FreeMarkerParser.TagContext ctx) {
// // Handle different tag types and build IR accordingly
// // For simplicity, this example only prints the tag content
// result = values.get(ctx);
// }
//
// @Override
// public void exitAssignmentTag(FreeMarkerParser.AssignmentTagContext ctx) {
// String variable = ctx.ID().getText();
// String value = ctx.STRING().getText();
// values.put(ctx, new AssignmentNode(variable, value));
// }
//
// @Override
// public void exitConditionalTag(FreeMarkerParser.ConditionalTagContext ctx) {
// // Handle conditional tags and build IR accordingly
// // For simplicity, this example only prints the tag content
// result = values.get(ctx);
// }
//
// @Override
// public void exitExpression(FreeMarkerParser.ExpressionContext ctx) {
// // Handle expressions and build IR accordingly
// // For simplicity, this example only prints the expression content
// result = values.get(ctx);
// }
//
// @Override
// public void visitTerminal(TerminalNode node) {
// // Store text content in the parse tree property
// values.put(node, node.getText());
// }
//}
package com.practice.migration.nov_13_23.before;
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
import java.io.*;
public class DynamicCompilationExample {
public static void main(String[] args) throws Exception {
// Java source code to be compiled dynamically
String sourceCode = "public class DynamicClass {\n" +
" public void printMessage() {\n" +
" System.out.println(\"Hello from dynamically generated class!\");\n" +
" }\n" +
"}\n";
// Compile the source code
compileAndRunDynamicClass("DynamicClass", sourceCode);
}
private static void compileAndRunDynamicClass(String className, String sourceCode) throws Exception {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
// StringWriter compilerOutput = new StringWriter();
OutputStream compilerOutput = new FileOutputStream("D:\\testout.txt"); ;
int compilationResult = compiler.run(null, null, compilerOutput, "-d", "./out", "-sourcepath", "./src", "-classpath",
System.getProperty("java.class.path"), "-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:rawtypes",
"-Xlint:cast", "-Xlint:path", "-Xlint:processing", "-Xlint:-processing");
if (compilationResult == 0) {
try {
// Load the dynamically compiled class
Class<?> dynamicClass = Class.forName(className);
Object instance = dynamicClass.getDeclaredConstructor().newInstance();
// Call a method on the dynamically compiled class
dynamicClass.getMethod("printMessage").invoke(instance);
} catch (Exception e) {
System.out.println("exception: "+ e);
e.printStackTrace();
}
} else {
// Print compilation errors
System.out.println("Compilation failed:");
System.err.println(compilerOutput.toString());
}
}
}
\ No newline at end of file
package com.practice.migration.nov_13_23.customParser;
public enum Constansts {
}
package com.practice.migration.nov_13_23.customParser.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.practice.migration.nov_13_23.customParser.model.common.MainTemplate;
import com.practice.migration.nov_13_23.customParser.model.request_and_response_body.FTLRequestBody;
import com.practice.migration.nov_13_23.customParser.model.request_and_response_body.JsonResponse;
import com.practice.migration.nov_13_23.customParser.service.HomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/v1/api/")
public class HomeController {
@Autowired
private HomeService homeService;
@GetMapping("ftl-to-json")
public ResponseEntity<JsonResponse> getResponse(@RequestBody FTLRequestBody ftlRequestBody) {
JsonResponse jsonResponse = null;
try {
jsonResponse = homeService.convertFTLtoJson(ftlRequestBody);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return new ResponseEntity<>(jsonResponse, HttpStatus.OK);
}
}
package com.practice.migration.nov_13_23.customParser.model.assign;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Data
@Setter
@Getter
public class AssignmentBlock {
// private String assignmentId = String.valueOf(UUID.randomUUID());
private String type; // assignment
private String variable; // variable name
private String value; // actual value
}
package com.practice.migration.nov_13_23.customParser.model.common;
import com.practice.migration.nov_13_23.customParser.model.assign.AssignmentBlock;
import com.practice.migration.nov_13_23.customParser.model.if_else_block.IfElseBlock;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Data
@Setter
@Getter
//@Builder
public class Children {
// private String childrenId = String.valueOf(UUID.randomUUID());
private AssignmentBlock assignment;
public List<IfElseBlock> ifElseBlockList;
}
package com.practice.migration.nov_13_23.customParser.model.common;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.UUID;
@Data
@Setter
@Getter
@ToString
public class LittleChild {
// private String littleChildId = String.valueOf(UUID.randomUUID());
private String type;
private String content;
}
package com.practice.migration.nov_13_23.customParser.model.common;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.UUID;
@Data
@Getter
@Setter
//@Builder
public class MainTemplate {
// private final String templateId = String.valueOf(UUID.randomUUID());
private String TemplateName;
private List<Children> childrenList;
}
package com.practice.migration.nov_13_23.customParser.model.if_else_block;
import com.practice.migration.nov_13_23.customParser.model.common.LittleChild;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
import java.util.UUID;
@Data
@Getter
@Setter
@ToString
public class IfElseBlock {
// private String ifElseBlockId = String.valueOf(UUID.randomUUID());
private String type;
private String condition;
private List<LittleChild> trueBranch;
private List<LittleChild> falseBranch;
}
package com.practice.migration.nov_13_23.customParser.model.request_and_response_body;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Data
@Getter
@Setter
public class FTLRequestBody {
private String ftlString;
}
package com.practice.migration.nov_13_23.customParser.model.request_and_response_body;
import com.practice.migration.nov_13_23.customParser.model.common.MainTemplate;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
@Data
@Setter
@Getter
public class JsonResponse {
private MainTemplate mainTemplate;
}
package com.practice.migration.nov_13_23.customParser.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.practice.migration.nov_13_23.customParser.model.common.Children;
import com.practice.migration.nov_13_23.customParser.model.common.LittleChild;
import com.practice.migration.nov_13_23.customParser.model.common.MainTemplate;
import com.practice.migration.nov_13_23.customParser.model.if_else_block.IfElseBlock;
import com.practice.migration.nov_13_23.customParser.model.request_and_response_body.FTLRequestBody;
import com.practice.migration.nov_13_23.customParser.model.request_and_response_body.JsonResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Service
public class HomeService {
public JsonResponse convertFTLtoJson(FTLRequestBody ftlRequestBody) throws JsonProcessingException {
String ftlString = ftlRequestBody.getFtlString();
IfElseBlock ifBlockFromFTL = getIfBlockFromFTL(ftlString);
// getAssigment
// System.out.println("result: "+ ifBlockFromFTL);
// Children children = Children.builder()
// .assignment(null)
// .ifElseBlockList(Arrays.asList(ifBlockFromFTL))
// .build();
// MainTemplate template = MainTemplate.builder()
// .TemplateName("template")
// .childrenList(Arrays.asList(children))
// .build();
JsonResponse jsonResponse = new JsonResponse();
// jsonResponse.setMainTemplate(template);
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(jsonResponse);
System.out.println("Response: "+ json);
return jsonResponse;
}
private static IfElseBlock getIfBlockFromFTL(String ftlString) {
int startIndex = ftlString.indexOf("[#if");
int endIndex = ftlString.indexOf("/#if]", startIndex );
String result = ftlString.substring(startIndex, endIndex - 1); //+ 5
String[] ifElseWords = result.split("\n");
String substring = StringUtils.substring(ftlString, startIndex, endIndex + 1);
// StringUtils.countMatches()
// StringUtils.
// System.out.println("words length from FTL: "+ ifElseWords.length);
IfElseBlock ifElseBlock = new IfElseBlock();
ifElseBlock.setType("conditional");
Arrays.stream(ifElseWords)
.filter(s -> (!s.equals(" ") || !s.equals(" ")))
.forEach(s -> {
// System.out.println("words from FTL: "+ s);
buildIfElseBlockObject(s, ifElseBlock);
});
// System.out.println("---> main block ---> "+ ifElseBlock);
return ifElseBlock;
}
private static void buildIfElseBlockObject(String linesDividedBy_N, IfElseBlock ifElseBlock) {
if (linesDividedBy_N.contains("if"))
ifElseBlock.setCondition(getCondition(linesDividedBy_N));
ifElseBlock.setTrueBranch(getTrueBranch(linesDividedBy_N));
}
private static List<LittleChild> getTrueBranch(String value) {
ArrayList<LittleChild> littleChildren = new ArrayList<>();
Arrays
.stream(value.split(" "))
.forEach(data -> {
LittleChild littleChild = new LittleChild();
littleChild.setType(data.startsWith("${") ? "variable" : "text");
littleChild.setContent(data);
littleChildren.add(littleChild);
});
return littleChildren;
}
private static String getCondition(String value) {
// int startIndex = value.indexOf("[#if");
// int endIndex = value.indexOf("]");
return value.substring(4, value.length() - 1); //+
}
}
package com.practice.migration.nov_13_23.customParser.service;
import freemarker.cache.StringTemplateLoader;
import freemarker.ext.beans.BeansWrapperBuilder;
import freemarker.template.Configuration;
import freemarker.template.Template;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Map;
public class TestService {
private Configuration freemarkerConfig;
private static final String TEMPLATE_DIRECTORY = "src/main/resources/templates/";
public TestService() {
freemarkerConfig = new Configuration(Configuration.VERSION_2_3_23);
freemarkerConfig.setTagSyntax(Configuration.ANGLE_BRACKET_TAG_SYNTAX);
freemarkerConfig.setDefaultEncoding("UTF-8");
freemarkerConfig.setNumberFormat("computer");
freemarkerConfig.setObjectWrapper(new BeansWrapperBuilder(Configuration.VERSION_2_3_23).build());
freemarkerConfig.setTemplateLoader(new StringTemplateLoader());
}
public String processTemplate(String templateName, Map<String, Object> data) {
Template template = loadTemplate(templateName, TEMPLATE_DIRECTORY + templateName + ".ftl");
System.out.println("--> Template"+ template);
try (StringWriter writer = new StringWriter()) {
template.process(data, writer);
return writer.toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private Template loadTemplate(String templateName, String templatePath) {
try {
String templateContent = new String(Files.readAllBytes(Paths.get(templatePath)));
((StringTemplateLoader) freemarkerConfig.getTemplateLoader()).putTemplate(templateName, templateContent);
return freemarkerConfig.getTemplate(templateName);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
package com.practice.migration.nov_13_23.customParser.util;
public class MetaData {
public static final String SAMPLE_LIST_OBJECT = "{\n" +
" \"type\": \"foreach\",\n" +
" \"variable\": \"system\",\n" +
" \"list\": \"systems\",\n" +
" \"body\": [\n" +
" {\n" +
" \"type\": \"text\",\n" +
" \"content\": \"<li>\"\n" +
" },\n" +
" {\n" +
" \"type\": \"text\",\n" +
" \"content\": \"${system_index + 1}. \"\n" +
" },\n" +
" {\n" +
" \"type\": \"variable\",\n" +
" \"name\": \"system.name\"\n" +
" },\n" +
" {\n" +
" \"type\": \"text\",\n" +
" \"content\": \" from \"\n" +
" },\n" +
" {\n" +
" \"type\": \"variable\",\n" +
" \"name\": \"system.developer\"\n" +
" },\n" +
" {\n" +
" \"type\": \"text\",\n" +
" \"content\": \"</li>\"\n" +
" }\n" +
" ]\n" +
" },";
}
\ No newline at end of file
//package com.practice.migration.siva_work;
//
//import com.fasterxml.jackson.databind.ObjectMapper;
////import org.junit.Test;
//import java.io.IOException;
//import java.util.ArrayList;
//import java.util.List;
//
//public class NestedPOJOTest {
//
// @Test
// public void createNestedPOJO() throws IOException {
//
// NestedPOJO demo = new NestedPOJO();
// demo.setType("template");
//
// // Children
// Children chil1 = new Children();
// chil1.setType("assignment");
// chil1.setVariable("name");
// chil1.setValue("John");
//
// Children chil2 = new Children();
// chil2.setType("conditional");
// chil2.setCondition("age > 18");
//
// // Creating a List of Children
// List<Children> childrenList = new ArrayList<Children>();
// childrenList.add(chil1);
// childrenList.add(chil2);
// demo.setChildren(childrenList);
//
// // TrueBranch
// TrueBranch true1 = new TrueBranch();
// true1.setType("Text");
// true1.setContent("Welcome");
//
// TrueBranch true2 = new TrueBranch();
// true2.setType("variable");
// true2.setName("name");
//
// TrueBranch true3 = new TrueBranch();
// true3.setType("Text");
// true3.setContent("!");
//
// // Creating a List of TrueBranch
// List<FalseBranch> trueBranchList = new ArrayList<FalseBranch>();
// trueBranchList.add(true1);
// trueBranchList.add(true2);
// trueBranchList.add(true3);
// demo.setTrueBranchsetTrueBranch(trueBranchList);
//
// // FalseBranch
// FalseBranch false1 = new FalseBranch();
// false1.setType("Text");
// false1.setContent("You are too young, ");
//
// FalseBranch false2 = new FalseBranch();
// false2.setType("variable");
// false2.setName("name");
//
// FalseBranch false3 = new FalseBranch();
// false3.setType("Text");
// false3.setContent("!");
//
// // Creating a List of FalseBranch
// List<FalseBranch> falseBranchList = new ArrayList<FalseBranch>();
// falseBranchList.add(false1);
// falseBranchList.add(false2);
// falseBranchList.add(false3);
// demo.setFalseBranch(falseBranchList);
//
//
// ObjectMapper mapper = new ObjectMapper();
// String nestedJsonPayload = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(demo);
// System.out.println(nestedJsonPayload);
//
// }
//
//}
\ No newline at end of file
//package com.practice.migration.siva_work;
//
//public class NestedPOJO {
//
// // private variables or data members of pojo class
// //
// private String type;
// //
//
// private List<Children> children;
// List<TrueBranch> trueBranch;
// List<FalseBranch> falseBranch;
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
//
// public List<Children> getChildren() {
// return children;
// }
//
// public void setChildren(List<Children> children) {
// this.children = children;
// }
//
// public List<TrueBranch> getTrueBranch() {
// return trueBranch;
// }
//
// public void setTrueBranch(List<TrueBranch> trueBranch) {
// this.trueBranch = trueBranch;
// }
// public List<FalseBranch> getFalseBranch() {
// return falseBranch;
// }
//
// public void setFalseBranch(List<FalseBranch> falseBranch) {
// this.falseBranch = falseBranch;
// }
//
//}
\ No newline at end of file
//package com.practice.migration.siva_work;
//
//public class Children {
//
// // private variables or data members of pojo class
// private String type;
// private String variable;
// private String value;
// private String condition;
//
// // Getter and setter methods
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
//
// public String getVariable() {
// return variable;
// }
// public void setVariable(String variable) {
// this.variable = variable;
// }
//
// public String getValue() {
// return value;
// }
// public void setValue(String value) {
// this.value = value;
// }
//
// public String getCondition() {
// return condition;
// }
// public void setCondition(String condition) {
// this.condition = condition;
// }
//}
\ No newline at end of file
//package com.practice.migration.siva_work;
//
//public class falseBranch {
//
// // private variables or data members of pojo class
// private String type;
// private String content;
// private String name;
//
// // Getter and setter methods
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
//
// public String getContent() {
// return content;
// }
// public void setContent(String content) {
// this.content = content;
// }
//
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
//
//
//}
\ No newline at end of file
//package com.practice.migration.siva_work;
//
//public class trueBranch {
//
// // private variables or data members of pojo class
// private String type;
// private String content;
// private String name;
//
// // Getter and setter methods
// public String getType() {
// return type;
// }
// public void setType(String type) {
// this.type = type;
// }
//
// public String getContent() {
// return content;
// }
// public void setContent(String content) {
// this.content = content;
// }
//
// public String getName() {
// return name;
// }
// public void setName(String name) {
// this.name = name;
// }
//
//
//}
\ No newline at end of file
//package com.practice.migration.siva_work;
//
//public class Employee {
//
// // private variables or data members of pojo class
// private String firstName;
// private String lastName;
// private int age;
// private double salary;
// private String designation;
// private String contactNumber;
// private String emailId;
//
// // Getter and setter methods
// public String getFirstName() {
// return firstName;
// }
//
// public void setFirstName(String firstName) {
// this.firstName = firstName;
// }
//
// public String getLastName() {
// return lastName;
// }
//
// public void setLastName(String lastName) {
// this.lastName = lastName;
// }
//
// public int getAge() {
// return age;
// }
//
// public void setAge(int age) {
// this.age = age;
// }
//
// public double getSalary() {
// return salary;
// }
//
// public void setSalary(double salary) {
// this.salary = salary;
// }
//
// public String getDesignation() {
// return designation;
// }
//
// public void setDesignation(String designation) {
// this.designation = designation;
// }
//
// public String getContactNumber() {
// return contactNumber;
// }
//
// public void setContactNumber(String contactNumber) {
// this.contactNumber = contactNumber;
// }
//
// public String getEmailId() {
// return emailId;
// }
//
// public void setEmailId(String emailId) {
// this.emailId = emailId;
// }
//
//}
\ No newline at end of file
package com.practice.migration.stringconvertion;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;
import freemarker.template.Version;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
public class FTLProcessor {
public static void main(String[] args) {
// Initialize FreeMarker configuration
Configuration cfg = new Configuration(new Version("2.3.31"));
cfg.setClassForTemplateLoading(FTLProcessor.class, "/templates");
cfg.setDefaultEncoding("UTF-8");
cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
// Data model (replace this with your data)
Map<String, Object> data = new HashMap<>();
data.put("name", "John");
// data.put("age", 25);
// Process FTL template
try {
Template template = cfg.getTemplate("example.ftl");
// Create a StringWriter to capture the output
try (Writer out = new StringWriter()) {
// Process the template with the data model and write to the StringWriter
template.process(data, out);
// Get the content from the StringWriter
String content = out.toString();
System.out.println("FTL Template Output:\n" + content);
// Here you can convert 'content' into an intermediate representation (IR)
// This may involve parsing the content and converting it into a structured format.
// For simplicity, we'll just print the content in this example.
// Your actual logic for IR conversion would depend on your requirements.
// ...
} catch (TemplateException | IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
\ No newline at end of file
package com.practice.migration.stringconvertion;
import org.objectweb.asm.*;
import java.net.MalformedURLException;
public class IRGenerator {
// public static byte[] generateIRClass(String className, String code) {
// boolean b = ClassWriter.COMPUTE_FRAMES;
// ClassWriter cw = new ClassWriter(true);
// cw.visit(Opcodes.V1_6, Opcodes.ACC_PUBLIC, className, null, "java/lang/Object", null);
// Generate default constructor
// MethodVisitor constructor = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
// constructor.visitCode();
// constructor.visitVarInsn(Opcodes.ALOAD, 0);
// constructor.visitMethodInsn(Opcodes.INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
// constructor.visitInsn(Opcodes.RETURN);
// constructor.visitMaxs(1, 1);
// constructor.visitEnd();
//
// // Generate printIR method
// MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, "printIR", "()V", null, null);
// mv.visitCode();
// Here, you would need to parse your string code and generate bytecode for your IR logic.
// For demonstration purposes, let's just print "Hello, IR!" to the console.
// mv.visitFieldInsn(Opcodes.GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
// mv.visitLdcInsn("Hello, IR!");
// mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V");
//
// mv.visitInsn(Opcodes.RETURN);
// mv.visitMaxs(2, 0);
// mv.visitEnd();
//
// cw.visitEnd();
//
// return cw.toByteArray();
// }
// public static void main(String[] args) throws MalformedURLException {
// String className = "GeneratedIRClass";
// String code = "/* Your IR code here */";
//
// byte[] classBytes = generateIRClass(className, code);
//
// // Saving the generated class to a .class file (optional)
// try (java.io.FileOutputStream fos = new java.io.FileOutputStream(className + ".class")) {
// fos.write(classBytes);
// System.out.println("Generated class file: " + className + ".class");
// } catch (java.io.IOException e) {
// e.printStackTrace();
// }
//
// // Load and instantiate the generated class
// ClassLoader classLoader = new java.net.URLClassLoader(
// new java.net.URL[]{new java.io.File(".").toURI().toURL()}
// );
//
// try {
// Class<?> generatedClass = Class.forName(className, true, classLoader);
// generatedClass.getDeclaredMethod("printIR").invoke(null);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
}
\ No newline at end of file
[#import '/components/common/_abtest-assignment.ftl' as abTest/]
[#import '/macros/products/pipElements.ftl' as pipElements/]
[#import '/macros/products/subsets.ftl' as subsets/]
[#import '/macros/config.ftl' as config/]
[#import '/macros/products/addToCart.ftl' as addToCart/]
[#macro setBuying pipInfo isOptimizedLoadEnabled sectionType isPersistent showSurcharge persistents]
[#-- eCM MESSAGING ON PIP --]
<div class="pip-set-buying">
[@subsets.displaySubsetGroups groups=persistents showExtended=true showSurcharge=showSurcharge isOptimizedLoadEnabled=isOptimizedLoadEnabled sectionType='persistents' isPersistent=true/]
</div>
[#if (isSetBuyingAddAllItemsEnabled && isSetBuyingAddLineItemEnabled) || isSetBuyingAddAllBelowEnabled]
<div class="add-all-atc">
[@addToCart.display suppressRegistry=pipInfo.isRegistrySuppressed() sectionType=sectionType addAll=true /]
</div>
[@wsgc.dojoaddonloadNested]
wsgc.js.AddToCart.attach("#pip", {mainPip: true});
[/@wsgc.dojoaddonloadNested]
[/#if]
[/#macro]
[#--Returns true if pip type is complex/multi buy --]
[#function isPipTypeComplex pipInfo='' pipElements='']
[#if pipInfo?? && pipInfo?is_hash]
[#if config.id != "we"]
[#if pipInfo.isMultiBuy()]
[#return true]
[#else]
[#return false]
[/#if]
[#else]
[#assign isMultiBuy = pipInfo.isMultiBuy()?string('multi','') /]
[#if isMultiBuy == 'multi']
[#return true]
[#else ]
[#return false]
[/#if]
[/#if]
[#else ]
[#return false]
[/#if]
[/#function]
[#assign setbuyingBehaviorByFlag = info.getSetting("pip","setbuying_desktop_behavior")!"" /]
[#assign isSetBuyingAbTestDesktopEnabled = wsgc.ison("pip","is_setBuying_abtest_desktop_enabled")/]
[#global isComplexPip = isPipTypeComplex(pipInfo,pipElements)]
[#global isSetBuyingEnabled = false]
[#global isSetBuyingAddLineItemEnabled = false]
[#global isSetBuyingAddAllItemsEnabled = false]
[#global isSetBuyingAddAllBelowEnabled = false]
[#assign setbuyingExperience = isSetBuyingAbTestDesktopEnabled?then(abTest.getAbTestVariationAssignment("setBuyingDesktop")!"", "") /]
[#if (setbuyingExperience?has_content || setbuyingBehaviorByFlag?has_content) && isComplexPip]
[#global isSetBuyingEnabled = true]
[/#if]
[#if setbuyingExperience?has_content && isComplexPip]
[#if setbuyingExperience == 'inline-add-item']
[#global isSetBuyingAddLineItemEnabled = true]
[#global isSetBuyingAddAllItemsEnabled = false]
[#elseif setbuyingExperience == 'inline-add-all']
[#global isSetBuyingAddAllItemsEnabled = true]
[#global isSetBuyingAddLineItemEnabled = false]
[#elseif setbuyingExperience == 'inline-add-item-add-all-below']
[#global isSetBuyingAddAllItemsEnabled = true]
[#global isSetBuyingAddLineItemEnabled = true]
[#elseif setbuyingExperience == 'add-all-below']
[#global isSetBuyingAddAllBelowEnabled = true]
[#else]
[#global isSetBuyingEnabled = false]
[/#if]
[#elseif setbuyingBehaviorByFlag?has_content && isComplexPip]
[#if setbuyingBehaviorByFlag == 'inline-add-item']
[#global isSetBuyingAddLineItemEnabled = true]
[#global isSetBuyingAddAllItemsEnabled = false]
[#elseif setbuyingBehaviorByFlag == 'inline-add-all']
[#global isSetBuyingAddAllItemsEnabled = true]
[#global isSetBuyingAddLineItemEnabled = false]
[#elseif setbuyingBehaviorByFlag == 'inline-add-item-add-all-below']
[#global isSetBuyingAddAllItemsEnabled = true]
[#global isSetBuyingAddLineItemEnabled = true]
[#elseif setbuyingBehaviorByFlag == 'add-all-below']
[#global isSetBuyingAddAllBelowEnabled = true]
[#else]
[#global isSetBuyingEnabled = false]
[/#if]
[/#if]
[#import '/macros/widgets.ftl' as widgets/]
[#import '/macros/config.ftl' as config/]
[#import '/components/common/_abtest-assignment.ftl' as abTest/]
[#import '/macros/productImage.ftl' as productImage/]
[#import '/macros/pricedisplay.ftl' as priceDisplay/]
[#import '/macros/model.ftl' as model/]
[#--
Determines if Smart Bundling is currently enabled for the Desktop RAC.
If so, UtilityNeeds information should be displayed there.
@return true if Smart Bundling is enabled for the Desktop RAC, otherwise false
--]
[#function isDesktopEnabled]
[#if isSmartBundlingDesktopEnabledRac??]
[#return isSmartBundlingDesktopEnabledRac /]
[/#if]
[#assign isSmartBundlingDesktopEnabledRac = false /]
[#if smartBundlingRacConfiguration?? && smartBundlingRacConfiguration.isDesktopEnabledRac()]
[#if smartBundlingRacConfiguration.isAbTestDesktopEnabledRac()]
[#local variationId = smartBundlingRacConfiguration.getDesktopAbTestVariationIdRac() /]
[#local variationAssignment = abTest.getAbTestVariationAssignment(smartBundlingRacConfiguration.getDesktopAbTestIdRac()) /]
[#assign isSmartBundlingDesktopEnabledRac = variationAssignment == variationId /]
[#else]
[#assign isSmartBundlingDesktopEnabledRac = true /]
[/#if]
[/#if]
[#return isSmartBundlingDesktopEnabledRac /]
[/#function]
[#function isDesktopCartEnabled]
[#if isSmartBundlingDesktopEnabledCart??]
[#return isSmartBundlingDesktopEnabledCart /]
[/#if]
[#assign isSmartBundlingDesktopEnabledCart = false /]
[#if smartBundlingCartConfiguration?? && smartBundlingCartConfiguration.isDesktopEnabledCartPage()]
[#if smartBundlingCartConfiguration.isAbTestDesktopEnabledCartPage()]
[#local variationId = smartBundlingCartConfiguration.getDesktopAbTestVariationIdCartPage() /]
[#local variationAssignment = abTest.getAbTestVariationAssignment(smartBundlingCartConfiguration.getDesktopAbTestIdCartPage()) /]
[#assign isSmartBundlingDesktopEnabledCart = variationAssignment == variationId /]
[#else]
[#assign isSmartBundlingDesktopEnabledCart = true /]
[/#if]
[/#if]
[#return isSmartBundlingDesktopEnabledCart /]
[/#function]
[#function shouldHideUtilitySkuCopy]
[#if hideUtilitySkuCopy??]
[#return hideUtilitySkuCopy /]
[/#if]
[#assign hideUtilitySkuCopy = false /]
[#if smartBundlingCartConfiguration?? && smartBundlingCartConfiguration.isDesktopCopyHiddenEnabled()]
[#if smartBundlingCartConfiguration.isAbTestDesktopCopyHiddenEnabled()]
[#local variationAssignment = abTest.getAbTestVariationAssignment("smartBundlingCartCopy") /]
[#if variationAssignment?? && variationAssignment == "showCopy"]
[#assign hideUtilitySkuCopy = false]
[#return hideUtilitySkuCopy]
[/#if]
[/#if]
[#assign hideUtilitySkuCopy = true]
[/#if]
[#return hideUtilitySkuCopy]
[/#function]
[#macro richCartSmartBundlingItems]
[#assign smartBundlingLinkSuffix = "&cm_src=smartbundlerac" /]
[@widgets.jstemplate id="richCartSmartBundlingItemTemplate"]
<div class="content-scroller-item">
<div class="smart-bundling-item [%= isFirstElement %]">
<div class="smart-bundling-copy">[%= copy %]</div>
<div class="smart-bundling-content">
<div class="smart-bundling-image-container">
<a class="smart-bundling-link" href="/products/[%= groupId %]/?sku=[%= sku %]${smartBundlingLinkSuffix}">
[% if(productImageSrc) { %]
[#-- src is intentionally omitted as an attribute below as an empty src creates a second call to the PIP on construction --]
[#local imgSrc = "[%= productImageSrc %]"/]
<img src="${imgSrc}" alt="[%= productImageAlt %]"/>
[% } %]
</a>
</div>
<div class="subset-pricing info">
<a class="smart-bundling-link" href="/products/[%= groupId %]/?sku=[%= sku %]${smartBundlingLinkSuffix}">
<h4 class="dynamic-text" id="title">[%= title %]</h4>
</a>
<div class="product-price">
[% if(isSaleOrSpecial) { %]
[%= price %]
[% } %]
[% if(!isSaleOrSpecial) { %]
<span>Price:</span> [%= price %]
[% } %]
</div>
[%if(storeName !== "") { %]
<div class="bopis-store-info">
<span>Also Available in [%= storeName %] Store</span>
</div>
[% } %]
<div class="smart-bundling-add-to-cart" id="smart-bundling-atc-[%= sku %]">
<div class="subset-selection">
<div class="subset-qty quantity-selector">
<input class="qty" id="rac_qty_[%= sku %]" aria-label="Quantity" type="number" inputmode="numeric"
min="0" max="99" maxlength="2" placeholder="${config.quantityPlaceholder}"
value="[%= itemQuantity %]" autocomplete="none"
data-addtocart="{&quot;sku&quot;:&quot;[%= sku %]&quot;,&quot;groupId&quot;:&quot;[%= groupId %]&quot;,&quot;catalog&quot;:&quot;[%= catalog %]&quot;,&quot;intlIneligibility&quot;:false[%if (pickupLocationCode !== undefined) { %],&quot;pickupLocationCode&quot;:&quot;[%= pickupLocationCode %]&quot;[% } %][%if (pickupServiceLevel !== undefined) { %],&quot;pickupServiceLevel&quot;:&quot;[%= pickupServiceLevel %]&quot;[% } %]}"/>
</div>
</div>
<div tabindex="0">
<button aria-label="Add to Cart" class="btn_addtobasket btn-add-to-cart btn-pip" sku="[%= sku %]">
<span>Add to Cart</span>
</button>
</div>
</div>
<div class="smart-bundling-error">
<div class="general-error hidden"></div>
<div class="specific-error hidden"></div>
</div>
</div>
</div>
[% if(memberCopy) { %]
<div class="utility-member-copy">[%= memberCopy %]</div>
[% } %]
</div>
</div>
[/@widgets.jstemplate]
[/#macro]
[#macro cartSmartBundlingItems]
[#assign smartBundlingLinkSuffix = "&cm_src=smartbundlecart" /]
[@widgets.jstemplate id="cartSmartBundlingItemTemplate"]
<div class="smart-bundling-content" id="smartBundlingContent-[%= mainSku %]-[%= sku %]">
<div class="smart-bundling-image-container">
<a class="smart-bundling-link" href="/products/[%= groupId %]/?sku=[%= sku %]${smartBundlingLinkSuffix}">
[% if(productImageSrc) { %]
[#local imgSrc = "[%= productImageSrc %]"/]
<img src="${imgSrc}" alt="[%= productImageAlt %]"/>
[% } %]
</a>
</div>
<div class="subset-pricing info">
<a class="smart-bundling-link" href="/products/[%= groupId %]/?sku=[%= sku %]${smartBundlingLinkSuffix}">
<p class="smart-bundling-title">[%= title %]</p>
</a>
<div class="product-price">
[% if(isSaleOrSpecial) { %]
[%= price %]
[% } %]
[% if(!isSaleOrSpecial) { %]
<span>Price:</span> [%= price %]
[% } %]
</div>
<div class="smart-bundling-add-to-cart" id="smart-bundling-atc-[%= sku %]">
<div class="subset-selection">
<div class="subset-qty quantity-selector">
<input class="qty" id="rac_qty_[%= sku %]" aria-label="Quantity" type="number" inputmode="numeric"
min="0" max="99" maxlength="2" placeholder="${config.quantityPlaceholder}"
value="[%= itemQuantity %]" autocomplete="none"
data-addtocart="{&quot;sku&quot;:&quot;[%= sku %]&quot;,&quot;groupId&quot;:&quot;[%= groupId %]&quot;,&quot;catalog&quot;:&quot;[%= catalog %]&quot;,&quot;intlIneligibility&quot;:false[%if (pickupLocationCode !== undefined) { %],&quot;pickupLocationCode&quot;:&quot;[%= pickupLocationCode %]&quot;[% } %][%if (pickupServiceLevel !== undefined) { %],&quot;pickupServiceLevel&quot;:&quot;[%= pickupServiceLevel %]&quot;[% } %]}"/>
</div>
</div>
<div>
<button aria-label="Add to Cart" class="btn_addtobasket btn-add-to-cart btn-pip" sku="[%= sku %]">
<span>Add to Cart</span>
</button>
</div>
</div>
<div class="smart-bundling-error">
<div class="general-error hidden"></div>
<div class="specific-error hidden"></div>
</div>
</div>
</div>
[/@widgets.jstemplate]
[/#macro]
[#macro smartBundlingUtilityCopy mainSku="" memberCopy=""]
[#if memberCopy?? && mainSku??]
<div id="smartBundlingUtilityCopy-${mainSku}">
<div class="smart-bundling-utility-member-copy"><p>${memberCopy}</p></div>
</div>
[/#if]
[/#macro]
[#macro smartBundlingOneLine utilityNeed]
<div class="smart-bundling-one-line" id="smartBundlingOneLine-${utilityNeed.mainSku}">
<div class="smart-bundling-cart-icon">
<img src="[@wsgc.docurl url='images/checkout/svg/cartDesktop.svg'/]"/>
</div>
[#if utilityNeed.data.copy??]
<div class="smart-bundling-copy">${utilityNeed.data.copy}</div>
[/#if]
[#if smartBundlingCartConfiguration.isDesktopDismissProductRecommendationEnabledCartPage()]
<div class="smart-bundling-close">
<a><img src="[@wsgc.docurl url='images/svg/close.svg'/]" class="smartBundlingClose"/></a>
</div>
[/#if]
</div>
[/#macro]
[#macro cartLineItem utilityNeeds = [] mainSkuGroupId = ""]
[#list utilityNeeds as utilityNeed]
<div class="smart-bundling-container hidden" id="smartBundlingContainer-${utilityNeed.mainSku}">
<div class="smart-bundling-atc-success smart-bundling-hidden" id="smartBundlingAtcSuccess-${utilityNeed.mainSku}">
<img src="[@wsgc.docurl url='images/shop/loading.gif'/]"/>
<p>Adding to cart....</p>
</div>
[@smartBundlingOneLine utilityNeed=utilityNeed /]
<div class="smart-bundling-items" id="smartBundlingItems-${utilityNeed.mainSku}">
[#local utilityNeedObjectJson = model.hashOrListToJson(utilityNeed) /]
[#local utilitySkus = utilityNeed.data.members]
[#list utilitySkus as utilitySku]
[#local utilitySkuJson = model.hashOrListToJson(utilitySku) /]
[#if utilitySku.copy?? && !shouldHideUtilitySkuCopy()]
[#assign flexClass = "smart-bundling-item-display-flex" /]
[#else]
[#assign flexClass = "" /]
[/#if ]
<div class="smart-bundling-item ${flexClass}" id="smartBundlingItem-${utilityNeed.mainSku}-${utilitySku.sku}">
[#if utilitySku.copy?? && utilityNeed.mainSku?? && !shouldHideUtilitySkuCopy()]
[@smartBundlingUtilityCopy mainSku=utilityNeed.mainSku memberCopy=utilitySku.copy/]
[/#if]
[@wsgc.dojoaddonloadNested]
wsgc.js.SmartBundlingCartUtils.getSmartBundlingContentCart(${utilityNeedObjectJson}, ${utilitySkuJson}, ${utilitySku.sku}, ${utilityNeed.mainSku}, "${mainSkuGroupId}")
[/@wsgc.dojoaddonloadNested]
</div>
[/#list]
</div>
</div>
[/#list]
[/#macro]
\ No newline at end of file
[#import '/macros/config.ftl' as config/]
[#import '/macros/pricedisplay.ftl' as pricedisplay/]
[#import '/macros/widgets.ftl' as widgets/]
[#assign productThumbnailSuffix = config.imageSuffixes.pipRecs /]
[#assign productSwatchThumbnailSuffix = config.imageSuffixes.guidedPipSwatchCopy /]
[#assign
overlayTitle = "Review Your Made-to-Order Item"
shipDelaySpecialMessage = "Select &quot;Accept Terms&quot; to acknowledge this policy and to continue to add this item to your cart. If you select Decline, this item will not be added."
shipDelayAcceptButtonText = "Accept &amp; Add to Cart"
shipDelayDeclineButtonText = "Decline"
/]
[#macro readyOverlay inFragment=false]
[#if !wsgc.ison('pip', 'show_ship_delay_confirmation')]
[#return]
[/#if]
[@widgets.overlay id='shipDelayConfirmation' inFragment=inFragment]
[@alertJsTemplateContent/]
[/@widgets.overlay]
[/#macro]
[#macro readyMobileOverlay]
[#if !wsgc.ison('pip', 'show_ship_delay_confirmation')]
[#return]
[/#if]
[@widgets.jstemplate id="shipDelayConfirmation"]
<div class="sliding-overlay-confirmation ship-delay-confirmation-sliding-overlay">
<div class="overlay overlay-collapsed">
<div class="headline">
<a class="close closeComponent">x</a>
</div>
[@alertJsTemplateContent/]
</div>
<div class="mask closeComponent"></div>
</div>
[/@widgets.jstemplate]
[/#macro]
[#macro alertJsTemplateContent]
<h3 class="primary-modal-header ship-delay-product-header">${overlayTitle}</h3>
<ul class="ship-delay-confirmation-product-group">
[% for (var i = 0; i ${'<'} products.length; i++) { %]
<li class="ship-delay-confirmation-product">
[#local productImgSrc = "${wsgcMacroHelper.catImageBase}/[%= products[i].image %]${productThumbnailSuffix}.jpg"/]
[#local swatchImgSrc = "${wsgcMacroHelper.catImageBase}/[%= products[i].swatch %]${productSwatchThumbnailSuffix}.jpg"/]
<h2 class="product-title">
[%= products[i].shortName %]
</h2>
<div class="ship-delay-confirmation-product-alert-message">
[%= products[i].shipDelayAlert %]
</div>
<img src="${productImgSrc}" class="ship-delay-confirmation-product-thumb" alt="Reference photo for [%= products[i].shortName %]"/>
[% if( products[i].swatch ) { %]
<img src="${swatchImgSrc}" class="ship-delay-confirmation-product-swatch-thumb" alt="Reference swatch for [%= products[i].shortName %]"/>
[% } %]
</li>
[% } %]
</ul>
<div class="ship-delay-confirmation-accept-terms">
<p class="ship-delay-confirmation-call-to-action">${shipDelaySpecialMessage}</p>
<div class="button-group">
<button class="btn btn-primary js-accept-shipping-button">${shipDelayAcceptButtonText}</button>
<button class="btn btn-secondary js-deny-shipping-button">${shipDelayDeclineButtonText}</button>
</div>
</div>
[/#macro]
\ No newline at end of file
{
"data": {
"employee": {
"empid": 2012,
"empname": "Virat",
"location": "Hyderabad"
}
}
}
\ No newline at end of file
package com.practice.migration;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.practice.migration.nov_13_23.customParser.model.request_and_response_body.FTLRequestBody;
import com.practice.migration.nov_13_23.customParser.service.HomeService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class FtlVueMigrationApplicationTests {
@Test
void contextLoads() throws JsonProcessingException {
HomeService homeService = new HomeService();
homeService.convertFTLtoJson(getStringJson());
}
private FTLRequestBody getStringJson() {
FTLRequestBody ftlRequestBody = new FTLRequestBody();
ftlRequestBody.setFtlString(FTL_String);
return ftlRequestBody;
}
private static final String FTL_String = "[#assign name='John'] \n" +
"[#if age > 18]\n" +
" Welcome, ${name}!\n" +
"[#else]\n" +
" You are too young, ${name}!\n" +
"[/#if]";
}
package com.practice.migration.nov_13_23.customParser.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.practice.migration.nov_13_23.customParser.model.assign.AssignmentBlock;
import com.practice.migration.nov_13_23.customParser.model.common.Children;
import com.practice.migration.nov_13_23.customParser.model.common.LittleChild;
import com.practice.migration.nov_13_23.customParser.model.common.MainTemplate;
import com.practice.migration.nov_13_23.customParser.model.if_else_block.IfElseBlock;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
public class HomeServiceImpl {
private static final String FTL_String = "[#assign name_value='vinil'] \n" +
"[#if age > 19]\n" +
" Welcome, ${name} to nisum family\n" +
"[#else]\n" +
" You are too nisum young, ${name}!\n" +
"[/#if]";
static IfElseBlock ifElseBlock = new IfElseBlock();
static AssignmentBlock assignmentBlock = new AssignmentBlock();
static Children children = new Children();
public static void main(String[] ar) throws JsonProcessingException {
getResponseFromIfElseBlock();
getResponseFromAssignBlock();
children.setAssignment(assignmentBlock);
children.setIfElseBlockList(List.of(ifElseBlock));
MainTemplate mainTemplate = new MainTemplate();
mainTemplate.setTemplateName("template");
mainTemplate.setChildrenList(List.of(children));
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(mainTemplate);
System.out.println("Response: "+ json);
}
private static void getResponseFromAssignBlock() {
int startIndex = FTL_String.indexOf("#assign");
int endIndex = FTL_String.indexOf("]");
String substring = FTL_String.substring(startIndex + 7, endIndex); // added 7 because of removeing the #assign from the string.
String[] variableAndName = substring.split("\n");
assignmentBlock.setType("Assignment");
String[] variableAndNameArray = variableAndName[0].split("=");
assignmentBlock.setVariable(variableAndNameArray[0]);
assignmentBlock.setValue(variableAndNameArray[1]);
}
private static void getResponseFromIfElseBlock() {
ifElseBlock.setType("template");
int startIndex = FTL_String.indexOf("[#if" );
int endIndex = FTL_String.indexOf("[#else]" );
String response = FTL_String.substring(startIndex, endIndex);
String[] split = response.split("\n");
// System.out.println("condition--> " + getCondition(split));
ifElseBlock.setCondition(getCondition(split));
ifElseBlock.setTrueBranch(getChildrenBranch(split[1]));
getChildrenBranch(split[1]);
String elseString = FTL_String.substring(endIndex);
int last = FTL_String.indexOf("[/#if]");
String[] split1 = elseString.split("\n");
getChildrenBranch(split1[1]);
ifElseBlock.setFalseBranch(getChildrenBranch(split1[1]));
// System.out.println("Final block: "+ ifElseBlock);
}
private static List <LittleChild> getChildrenBranch(String s) {
ArrayList<LittleChild> littleChildren = new ArrayList<>();
if(s.contains("${")) {
String between = StringUtils.substringBetween(s, "${", "}");
int startIndex = s.indexOf(between) - 2;
int endIndex = startIndex + between.length() + 3;
String before = s.substring(0, startIndex);
littleChildren.add(getLittleChild(before, "text"));
String inBetween = s.substring(startIndex, endIndex);
littleChildren.add( getLittleChild(inBetween, "Variable"));
String after = s.substring(endIndex);
littleChildren.add(getLittleChild(after, "text"));
// System.out.print("Final ----> Before "+ before + " Custom name "+ inBetween +" after "+ after);
} else {
littleChildren.add(getLittleChild(s.trim(), "text"));
}
return littleChildren ;
}
private static LittleChild getLittleChild(String key, String value) {
LittleChild littleChildInBetween = new LittleChild();
littleChildInBetween.setType(key);
littleChildInBetween.setContent(value);
return littleChildInBetween;
}
private static String getCondition(String[] value) {
int startIndex = value[0].indexOf("[#if");
int endIndex = value[0].indexOf("]");
String substring = value[0].substring(startIndex + 4,endIndex);
return substring;
}
}
package com.practice.migration.nov_13_23.customParser.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.practice.migration.FtlVueMigrationApplication;
import com.practice.migration.nov_13_23.customParser.model.request_and_response_body.FTLRequestBody;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.*;
@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = FtlVueMigrationApplication.class)
class HomeServiceTest {
private static final String FTL_String = "[#assign name=${obj.name}] \n" +
"[#if age > ${age}]\n" +
" Welcome, ${name}!\n" +
"[#else]\n" +
" You are too young, ${name}!\n" +
"[/#if]";
// @Test
// void contextLoads() {
public static void main(String[] ar) throws JsonProcessingException {
HomeService homeService = new HomeService();
homeService.convertFTLtoJson(getStringJson());
}
private static FTLRequestBody getStringJson() {
FTLRequestBody ftlRequestBody = new FTLRequestBody();
System.out.println("----> FTL input <-------" + FTL_String);
ftlRequestBody.setFtlString(FTL_String);
return ftlRequestBody;
}
}
\ No newline at end of file
package com.practice.migration.nov_13_23.customParser.service;
import static org.junit.jupiter.api.Assertions.*;
class TestServiceTest {
public static void main(String[] args) {
TestService testService = new TestService();
String s = testService.processTemplate("_pip-set-buying", null);
System.out.println(" final output "+s);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment