diff --git a/Test_Processing_Tool_project/.idea/.gitignore b/Test_Processing_Tool_project/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/Test_Processing_Tool_project/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/Test_Processing_Tool_project/.idea/compiler.xml b/Test_Processing_Tool_project/.idea/compiler.xml new file mode 100644 index 0000000..31364e5 --- /dev/null +++ b/Test_Processing_Tool_project/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test_Processing_Tool_project/.idea/encodings.xml b/Test_Processing_Tool_project/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/Test_Processing_Tool_project/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Test_Processing_Tool_project/.idea/jarRepositories.xml b/Test_Processing_Tool_project/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/Test_Processing_Tool_project/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Test_Processing_Tool_project/.idea/misc.xml b/Test_Processing_Tool_project/.idea/misc.xml new file mode 100644 index 0000000..e122dea --- /dev/null +++ b/Test_Processing_Tool_project/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Test_Processing_Tool_project/.idea/uiDesigner.xml b/Test_Processing_Tool_project/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/Test_Processing_Tool_project/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test_Processing_Tool_project/.mvn/wrapper/maven-wrapper.jar b/Test_Processing_Tool_project/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..c1dd12f Binary files /dev/null and b/Test_Processing_Tool_project/.mvn/wrapper/maven-wrapper.jar differ diff --git a/Test_Processing_Tool_project/.mvn/wrapper/maven-wrapper.properties b/Test_Processing_Tool_project/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..40ca015 --- /dev/null +++ b/Test_Processing_Tool_project/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.5/apache-maven-3.8.5-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar \ No newline at end of file diff --git a/Test_Processing_Tool_project/README.md b/Test_Processing_Tool_project/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Test_Processing_Tool_project/mvnw b/Test_Processing_Tool_project/mvnw new file mode 100644 index 0000000..8a8fb22 --- /dev/null +++ b/Test_Processing_Tool_project/mvnw @@ -0,0 +1,316 @@ +#!/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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# 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 + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -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 "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; 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; \\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 + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# 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/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# 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. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +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 "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -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 + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + $MAVEN_DEBUG_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" \ + "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/Test_Processing_Tool_project/mvnw.cmd b/Test_Processing_Tool_project/mvnw.cmd new file mode 100644 index 0000000..1d8ab01 --- /dev/null +++ b/Test_Processing_Tool_project/mvnw.cmd @@ -0,0 +1,188 @@ +@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 Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@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 DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + +FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_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 DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_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('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@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% diff --git a/Test_Processing_Tool_project/pom.xml b/Test_Processing_Tool_project/pom.xml new file mode 100644 index 0000000..da551b9 --- /dev/null +++ b/Test_Processing_Tool_project/pom.xml @@ -0,0 +1,77 @@ + + + 4.0.0 + + com.labs + Test_Processing_Tool + 1.0-SNAPSHOT + Test_Processing_Tool + + + UTF-8 + 5.10.2 + + + + + org.openjfx + javafx-controls + 17.0.6 + + + org.openjfx + javafx-fxml + 17.0.6 + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 23 + 23 + + + + org.openjfx + javafx-maven-plugin + 0.0.8 + + + + default-cli + + com.labs.test_processing_tool/com.labs.test_processing_tool.HelloApplication + + app + app + app + true + true + true + + + + + + + \ No newline at end of file diff --git a/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/DataManager.java b/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/DataManager.java new file mode 100644 index 0000000..64eadcc --- /dev/null +++ b/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/DataManager.java @@ -0,0 +1,27 @@ +package com.labs.test_processing_tool; + +public class DataManager { + private String key; + private String value; + + public DataManager(String key, String value) { + this.key = key; + this.value = value; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/DataManagerController.java b/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/DataManagerController.java new file mode 100644 index 0000000..6171fb8 --- /dev/null +++ b/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/DataManagerController.java @@ -0,0 +1,185 @@ +package com.labs.test_processing_tool; + + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; +import javafx.scene.layout.AnchorPane; +import javafx.stage.Stage; + +import javax.swing.*; +import java.io.IOException; + +public class DataManagerController { + + @FXML + private Button bttn_add; + + @FXML + private Button bttn_back; + + @FXML + private Button bttn_delete; + + @FXML + private Button bttn_update; + + @FXML + private TableView table_data; + + @FXML + private TableColumn table_key; + + @FXML + private TableColumn table_value; + + + @FXML + private TextField txt_key; + + @FXML + private TextField txt_value; + + private ObservableList dataList; + + + /** + * Initializes the controller. + * Sets up the TableView columns and binds the data list to the TableView. + */ + @FXML + public void initialize() { + + dataList = FXCollections.observableArrayList(); + table_key.setCellValueFactory(cellData -> new javafx.beans.property.SimpleStringProperty(cellData.getValue().getKey())); + table_value.setCellValueFactory(cellData -> new javafx.beans.property.SimpleStringProperty(cellData.getValue().getValue())); + + // Set data to the table + table_data.setItems(dataList); + } + + + + + /** + * + * Adds a new entry to the TableView based on the values provided in the text fields. + * Clears the input fields after adding. + * + * @param event the ActionEvent triggered by clicking the "Add" button + */ + @FXML + void handleAddDAta(ActionEvent event) { + String key = txt_key.getText(); + String value = txt_value.getText(); + if (key.isEmpty() || value.isEmpty()) { + JOptionPane.showMessageDialog(null, "Both key and value must be provided."); + return; + } + + DataManager newData = new DataManager(key, value); + dataList.add(newData); + + // Clear input fields + txt_key.clear(); + txt_value.clear(); + } + + /** + * Handles the "Back" button click event. + * Navigates back to the main UI by loading the "MainUI.fxml" file. + * + * @param event the ActionEvent triggered by clicking the "Back" button + */ + @FXML + void handleBackAction(ActionEvent event) { + try { + // Load the Transaction FXML + FXMLLoader loader = new FXMLLoader(MainController.class.getResource("MainUI.fxml")); + Parent root = loader.load(); + + // Get the current stage + Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); + + // Set the new scene + Scene scene = new Scene(root); + stage.setScene(scene); + stage.setTitle("Text Processing"); + stage.show(); + + } catch (IOException e) { + JOptionPane.showMessageDialog(null, e); + } + + } + + + + /** + * Handles the "Delete" button click event. + * Deletes the selected entry from the TableView. + * + * @param event the ActionEvent triggered by clicking the "Delete" button + */ + @FXML + void handleDeleteData(ActionEvent event) { + DataManager selected = table_data.getSelectionModel().getSelectedItem(); + + if (selected == null) { + JOptionPane.showMessageDialog(null, "Please select an item to delete."); + return; + } + + dataList.remove(selected); + + + } + + /** + * Handles the "Update" button click event. + * Updates the selected entry in the TableView with the values provided in the text fields. + * Refreshes the TableView to display updated data and clears the input fields. + * + * @param event the ActionEvent triggered by clicking the "Update" button + */ + @FXML + void handleUpdateData(ActionEvent event) { + DataManager selected = table_data.getSelectionModel().getSelectedItem(); + + if (selected == null) { + JOptionPane.showMessageDialog(null,"Please select an item to update."); + return; + } + + String key = txt_key.getText(); + String value = txt_value.getText(); + + if (key.isEmpty() || value.isEmpty()) { + JOptionPane.showMessageDialog(null, "Both key and value must be provided."); + return; + } + + // Update selected data + selected.setKey(key); + selected.setValue(value); + + // Refresh table to show updated data + table_data.refresh(); + + // Clear input fields + txt_key.clear(); + txt_value.clear(); + + } + +} + diff --git a/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/HelloApplication.java b/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/HelloApplication.java new file mode 100644 index 0000000..0c76047 --- /dev/null +++ b/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/HelloApplication.java @@ -0,0 +1,23 @@ +package com.labs.test_processing_tool; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.stage.Stage; + +import java.io.IOException; + +public class HelloApplication extends Application { + @Override + public void start(Stage stage) throws IOException { + FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("MainUI.fxml")); + Scene scene = new Scene(fxmlLoader.load(), 668, 542); + stage.setTitle("Hello!"); + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) { + launch(); + } +} \ No newline at end of file diff --git a/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/MainController.java b/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/MainController.java new file mode 100644 index 0000000..794faf8 --- /dev/null +++ b/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/MainController.java @@ -0,0 +1,88 @@ +package com.labs.test_processing_tool; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; +import com.labs.test_processing_tool.RegexUtil; + +import javax.swing.*; + +public class MainController { + + + @FXML + private Button bttn_clear; + + @FXML + private Button bttn_match; + + @FXML + private Button bttn_replace; + + @FXML + private Button bttn_search; + + @FXML + private TextArea txtA_input_text; + + @FXML + private TextArea txtA_result; + + @FXML + private TextField txt_regular_expres; + + @FXML + private TextField txt_replace_text; + + + + @FXML + void handleClear(ActionEvent event) { + txt_replace_text.clear(); + txtA_result.clear(); + txt_regular_expres.clear(); + txtA_input_text.clear(); + txtA_result.setDisable(true); + } + + @FXML + void handleMatchPattern(ActionEvent event) { + String pattern = txt_regular_expres.getText(); + String text = txtA_input_text.getText(); + boolean is_match = RegexUtil.isMatch(pattern, text); + String result = is_match ? "The text matches the pattern" : "The text does not match the pattern"; + txtA_result.setText(result); + txtA_result.setDisable(true); + + } + + @FXML + void handleReplace(ActionEvent event) { + if(txt_replace_text.getText() == null){ + JOptionPane.showMessageDialog(null, "Replace text can't be null");} + String textToReplace = txt_replace_text.getText(); + String text = txtA_input_text.getText(); + String pattern = txt_regular_expres.getText(); + String matches = RegexUtil.replaceText(pattern, text, textToReplace); + txtA_result.setText(matches); + txtA_result.setDisable(true); + + + } + + @FXML + void handleSearch(ActionEvent event) { + + String pattern = txt_regular_expres.getText(); + String text = txtA_input_text.getText(); + RegexUtil RegexUtils = null; + String matches = RegexUtils.findMatches(pattern, text); + txtA_result.setText(matches); + txtA_result.setDisable(true); + + } + +} \ No newline at end of file diff --git a/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/RegexUtil.java b/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/RegexUtil.java new file mode 100644 index 0000000..7a902bc --- /dev/null +++ b/Test_Processing_Tool_project/src/main/java/com/labs/test_processing_tool/RegexUtil.java @@ -0,0 +1,41 @@ +package com.labs.test_processing_tool; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class RegexUtil { + + public static String findMatches(String pattern, String text){ + StringBuilder results = new StringBuilder(); + Pattern regex = Pattern.compile(pattern); + Matcher matcher = regex.matcher(text); + + while (matcher.find()){ + results.append("Match: ").append(matcher.group()).append(" at position ").append(matcher.start()).append("\n"); + } + return results.length() > 0 ? results.toString() : "No matches found"; + } + + public static String replaceText(String pattern, String text, String replacement){ + Pattern regex = Pattern.compile(pattern); + Matcher matcher = regex.matcher(text); + return matcher.replaceAll(replacement); + } + + // for finding match + public static boolean isMatch(String pattern, String text) + { + if(pattern == null || text == null){ + return false; + } + return Pattern.matches(pattern, text); + } + + public static void main(String[] args){ + String retunString = findMatches("xbx","texbx"); + + String replace = replaceText("[^abc]", "Are you back", "cba"); + System.out.println(replace); + } + + +} diff --git a/Test_Processing_Tool_project/src/main/java/module-info.java b/Test_Processing_Tool_project/src/main/java/module-info.java new file mode 100644 index 0000000..678aa4a --- /dev/null +++ b/Test_Processing_Tool_project/src/main/java/module-info.java @@ -0,0 +1,9 @@ +module com.labs.test_processing_tool { + requires javafx.controls; + requires javafx.fxml; + requires java.desktop; + + + opens com.labs.test_processing_tool to javafx.fxml; + exports com.labs.test_processing_tool; +} \ No newline at end of file diff --git a/Test_Processing_Tool_project/src/main/resources/com/labs/test_processing_tool/MainUI.fxml b/Test_Processing_Tool_project/src/main/resources/com/labs/test_processing_tool/MainUI.fxml new file mode 100644 index 0000000..730fa41 --- /dev/null +++ b/Test_Processing_Tool_project/src/main/resources/com/labs/test_processing_tool/MainUI.fxml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Test_Processing_Tool_project/src/main/resources/com/labs/test_processing_tool/data-manager.fxml b/Test_Processing_Tool_project/src/main/resources/com/labs/test_processing_tool/data-manager.fxml new file mode 100644 index 0000000..f38220f --- /dev/null +++ b/Test_Processing_Tool_project/src/main/resources/com/labs/test_processing_tool/data-manager.fxml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/HelloApplication.class b/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/HelloApplication.class new file mode 100644 index 0000000..9a17fb3 Binary files /dev/null and b/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/HelloApplication.class differ diff --git a/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/MainController.class b/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/MainController.class new file mode 100644 index 0000000..03506a4 Binary files /dev/null and b/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/MainController.class differ diff --git a/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/MainUI.fxml b/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/MainUI.fxml new file mode 100644 index 0000000..730fa41 --- /dev/null +++ b/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/MainUI.fxml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/RegexUtil.class b/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/RegexUtil.class new file mode 100644 index 0000000..b064e3a Binary files /dev/null and b/Test_Processing_Tool_project/target/classes/com/labs/test_processing_tool/RegexUtil.class differ diff --git a/Test_Processing_Tool_project/target/classes/module-info.class b/Test_Processing_Tool_project/target/classes/module-info.class new file mode 100644 index 0000000..3eff251 Binary files /dev/null and b/Test_Processing_Tool_project/target/classes/module-info.class differ diff --git a/WebSortingAlgo/.gitignore b/WebSortingAlgo/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/WebSortingAlgo/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/WebSortingAlgo/.idea/.gitignore b/WebSortingAlgo/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/WebSortingAlgo/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/WebSortingAlgo/.idea/encodings.xml b/WebSortingAlgo/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/WebSortingAlgo/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/WebSortingAlgo/.idea/misc.xml b/WebSortingAlgo/.idea/misc.xml new file mode 100644 index 0000000..001e756 --- /dev/null +++ b/WebSortingAlgo/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/WebSortingAlgo/.mvn/jvm.config b/WebSortingAlgo/.mvn/jvm.config new file mode 100644 index 0000000..e69de29 diff --git a/WebSortingAlgo/.mvn/maven.config b/WebSortingAlgo/.mvn/maven.config new file mode 100644 index 0000000..e69de29 diff --git a/WebSortingAlgo/README.md b/WebSortingAlgo/README.md new file mode 100644 index 0000000..de6fe38 --- /dev/null +++ b/WebSortingAlgo/README.md @@ -0,0 +1,2 @@ +This project is a Spring-based RESTful API for sorting data using algorithms like Heap Sort, Quick Sort, Merge Sort, Radix Sort, and Bucket Sort. The API accepts three parameters: the sorting algorithm, an array of integers, and the desired sort order (ascending/descending). It processes the data using the specified algorithm and returns the sorted array. Built with Spring Framework, the application uses dependency injection, autowiring, and beans for modularity. It is deployed on Apache Tomcat, ensuring robust HTTP request handling. Although HATEOAS was not implemented, the API demonstrates efficient algorithm integration and provides a foundation for future enhancements. + \ No newline at end of file diff --git a/WebSortingAlgo/pom.xml b/WebSortingAlgo/pom.xml new file mode 100644 index 0000000..934bd8e --- /dev/null +++ b/WebSortingAlgo/pom.xml @@ -0,0 +1,141 @@ + + + + 4.0.0 + + org.example + WebSortingAlgo + 1.0-SNAPSHOT + war + + WebSortingAlgo Maven Webapp + + http://www.example.com + + + UTF-8 + 8 + 8 + + + + + junit + junit + 4.13.1 + test + + + + + jakarta.servlet + jakarta.servlet-api + 6.1.0 + provided + + + + + com.fasterxml.jackson.core + jackson-databind + 2.18.2 + + + + + org.springframework + spring-webmvc + 6.2.0 + + + + + org.springframework + spring-web + 6.2.0 + + + + + org.springframework + spring-context + 6.2.0 + + + + + org.springframework.hateoas + spring-hateoas + 2.4.0 + + + + + org.apache.tomcat + tomcat-jasper + 9.0.62 + + + + + javax.persistence + persistence-api + 1.0.2 + + + + org.springframework.data + spring-data-jpa + 3.4.0 + + + + jakarta.servlet + jakarta.servlet-api + 6.1.0 + provided + + + + + + WebSortingAlgo + + + + maven-clean-plugin + 3.4.0 + + + + maven-resources-plugin + 3.3.1 + + + maven-compiler-plugin + 3.13.0 + + + maven-surefire-plugin + 3.3.0 + + + maven-war-plugin + 3.4.0 + + + maven-install-plugin + 3.1.2 + + + maven-deploy-plugin + 3.1.2 + + + + + + + + diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/Main.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/Main.java new file mode 100644 index 0000000..03368e9 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/Main.java @@ -0,0 +1,22 @@ +package org.example.websortingalgo; + +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRegistration; +import org.example.websortingalgo.config.AppConfig; +import org.springframework.web.WebApplicationInitializer; +import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; +import org.springframework.web.servlet.DispatcherServlet; + +public class Main implements WebApplicationInitializer { + @Override + public void onStartup(ServletContext servletContext) throws ServletException { + AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext(); + context.setServletContext(servletContext); + context.register(AppConfig.class); + + ServletRegistration.Dynamic dispatcher = servletContext.addServlet("SpringDispatcher", new DispatcherServlet(context)); + dispatcher.setLoadOnStartup(1); + dispatcher.addMapping("/"); + } +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/config/AppConfig.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/config/AppConfig.java new file mode 100644 index 0000000..b7bb393 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/config/AppConfig.java @@ -0,0 +1,43 @@ +package org.example.websortingalgo.config; + +import org.example.websortingalgo.controller.Controller; +import org.example.websortingalgo.service.BucketSortService; +import org.example.websortingalgo.service.Greeting; +import org.example.websortingalgo.service.MergeSortService; +import org.example.websortingalgo.service.QuickSort; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; + +@EnableWebMvc +@Configuration +@ComponentScan(basePackages = "org.example.websortingalgo.controller, org.example.websortingalgo.service") +public class AppConfig { +// @Bean +// public Controller controller(BucketSortService bucketSortService, Greeting greeting, MergeSortService mergeSortService, QuickSort quickSort) { +// return new Controller(bucketSortService,greeting, mergeSortService, quickSort); +// } + + @Bean + public QuickSort quickSort() { + return new QuickSort(); + } + + @Bean + public MergeSortService mergeSortService() { + return new MergeSortService(); + } + + @Bean + public BucketSortService bucketSortService() { + return new BucketSortService(); + } + + @Bean + public Greeting greeting() { + return new Greeting(); + } + + +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/controller/Controller.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/controller/Controller.java new file mode 100644 index 0000000..2c65702 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/controller/Controller.java @@ -0,0 +1,56 @@ +package org.example.websortingalgo.controller; + +import org.example.websortingalgo.dto.InputRequest; +import org.example.websortingalgo.dto.SortingRequest; +import org.example.websortingalgo.service.*; +import org.springframework.beans.factory.annotation.Autowired; +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; +import org.springframework.web.bind.annotation.*; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/api") +public class Controller { + private final Greeting greeting; + private final SortingService sortingService; + + + @Autowired + public Controller(Greeting greeting, SortingService sortingService) { + this.greeting = greeting; + this.sortingService = sortingService; + + + } + + + + @GetMapping("/welcome") + public String sort() { + return "Hello World"; + } + + @PostMapping("/sort") + public ResponseEntity> sortData(@RequestBody SortingRequest sortingRequest) { + // retrieving values from the DTO + Map response = sortingService.handleSorting(sortingRequest); + return ResponseEntity.ok(response); + } + + + //for testing + @PostMapping("/greeting") + public ResponseEntity algorithm(@RequestBody InputRequest inputRequest) { + String result = greeting.greet(inputRequest.getData()); + return ResponseEntity.ok(result); + } +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/dto/InputRequest.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/dto/InputRequest.java new file mode 100644 index 0000000..568a9d3 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/dto/InputRequest.java @@ -0,0 +1,13 @@ +package org.example.websortingalgo.dto; + +public class InputRequest { + String data; + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/dto/SortingRequest.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/dto/SortingRequest.java new file mode 100644 index 0000000..9420512 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/dto/SortingRequest.java @@ -0,0 +1,35 @@ +package org.example.websortingalgo.dto; + +import java.util.List; + +public class SortingRequest { + String algorithm; + String order; + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getAlgorithm() { + return algorithm; + } + + public void setAlgorithm(String algorithm) { + this.algorithm = algorithm; + } + + List data; + +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/entity/SortedData.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/entity/SortedData.java new file mode 100644 index 0000000..2aead54 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/entity/SortedData.java @@ -0,0 +1,49 @@ +package org.example.websortingalgo.entity; + + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Entity +public class SortedData { + + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private String algorithm; + private String order; + private String sortedData; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getAlgorithm() { + return algorithm; + } + + public void setAlgorithm(String algorithm) { + this.algorithm = algorithm; + } + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + + public String getSortedData() { + return sortedData; + } + + public void setSortedData(String sortedData) { + this.sortedData = sortedData; + } +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/BucketSortService.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/BucketSortService.java new file mode 100644 index 0000000..a3fd7ae --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/BucketSortService.java @@ -0,0 +1,50 @@ +package org.example.websortingalgo.service; + + +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +@Service +public class BucketSortService { + public int[] sort(String algorithm, int[] arr) { + if (arr == null || arr.length <= 1) return arr; + + if(algorithm == null) + throw new NullPointerException("algorithm is null"); + + int maxValue = Arrays.stream(arr).max().orElse(0); + int minValue = Arrays.stream(arr).min().orElse(0); + + int bucketCount = (maxValue - minValue) / arr.length + 1; + List> buckets = new ArrayList<>(bucketCount); + + for (int i = 0; i < bucketCount; i++) { + buckets.add(new ArrayList<>()); + } + + // Distribute input into buckets + for (int value : arr) { + int bucketIndex = (value - minValue) / arr.length; + buckets.get(bucketIndex).add(value); + } + + // Sort individual buckets + for (List bucket : buckets) { + Collections.sort(bucket); + } + + // Concatenate all buckets + int index = 0; + for (List bucket : buckets) { + for (int value : bucket) { + arr[index++] = value; + } + } + + return arr; + } +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/Greeting.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/Greeting.java new file mode 100644 index 0000000..7247ce3 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/Greeting.java @@ -0,0 +1,11 @@ +package org.example.websortingalgo.service; + +import org.springframework.stereotype.Service; + +@Service +public class Greeting { + public String greet(String name) { + return "Hello, " + name + "!"; + } + +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/HeapSortService.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/HeapSortService.java new file mode 100644 index 0000000..fa35625 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/HeapSortService.java @@ -0,0 +1,48 @@ +package org.example.websortingalgo.service; + +import org.springframework.stereotype.Service; + +@Service +public class HeapSortService { + + public int[] sort(String algorithm, int[] array){ + int n = array.length; + + // Build heap (rearrange array) + for (int i = n / 2 - 1; i >= 0; i--) + heapify(array, n, i); + + // One by one extract an element from heap + for (int i = n - 1; i > 0; i--) { + // Move current root to end + int temp = array[0]; + array[0] = array[i]; + array[i] = temp; + + // Call max heapify on the reduced heap + heapify(array, i, 0); + } + return array; + } + + private void heapify(int[] arr, int n, int i) { + int largest = i; + int left = 2 * i + 1; + int right = 2 * i + 2; + + if (left < n && arr[left] > arr[largest]) + largest = left; + + if (right < n && arr[right] > arr[largest]) + largest = right; + + if (largest != i) { + int swap = arr[i]; + arr[i] = arr[largest]; + arr[largest] = swap; + + heapify(arr, n, largest); + } + } + +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/MergeSortService.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/MergeSortService.java new file mode 100644 index 0000000..32d7fc5 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/MergeSortService.java @@ -0,0 +1,46 @@ +package org.example.websortingalgo.service; +import org.springframework.stereotype.Service; + + +@Service +public class MergeSortService { + + public int[] sort(String algorithm, int[] arr) { + mergeSort(arr, 0, arr.length - 1); + return arr; + } + + private void mergeSort(int[] arr, int left, int right) { + if (left < right) { + int mid = (left + right) / 2; + + mergeSort(arr, left, mid); + mergeSort(arr, mid + 1, right); + + merge(arr, left, mid, right); + } + } + + private void merge(int[] arr, int left, int mid, int right) { + int[] temp = new int[right - left + 1]; + int i = left, j = mid + 1, k = 0; + + while (i <= mid && j <= right) { + if (arr[i] <= arr[j]) { + temp[k++] = arr[i++]; + } else { + temp[k++] = arr[j++]; + } + } + + while (i <= mid) { + temp[k++] = arr[i++]; + } + + while (j <= right) { + temp[k++] = arr[j++]; + } + + System.arraycopy(temp, 0, arr, left, temp.length); + } +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/QuickSort.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/QuickSort.java new file mode 100644 index 0000000..43fd29d --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/QuickSort.java @@ -0,0 +1,41 @@ +package org.example.websortingalgo.service; + +import org.springframework.stereotype.Service; + +@Service +public class QuickSort { + + public int[] sort(String algorithm, int[] arr) { + quickSort(arr, 0, arr.length - 1); + return arr; + } + + private void quickSort(int[] arr, int low, int high) { + if (low < high) { + int partitionIndex = partition(arr, low, high); + + quickSort(arr, low, partitionIndex - 1); + quickSort(arr, partitionIndex + 1, high); + } + } + + private int partition(int[] arr, int low, int high) { + int pivot = arr[high]; + int i = (low - 1); + + for (int j = low; j < high; j++) { + if (arr[j] < pivot) { + i++; + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + + int temp = arr[i + 1]; + arr[i + 1] = arr[high]; + arr[high] = temp; + + return i + 1; + } +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/RadixSortService.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/RadixSortService.java new file mode 100644 index 0000000..2191fb5 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/RadixSortService.java @@ -0,0 +1,60 @@ +package org.example.websortingalgo.service; + +import org.springframework.stereotype.Service; + +import java.util.Arrays; + + +/** + * Service that provides functionality to perform Radix Sort on an array of integers. + * Radix Sort is a non-comparative sorting algorithm that processes each digit of the numbers. + * It uses a stable intermediate sorting algorithm (Counting Sort) for each digit in the numbers. + */ +@Service +public class RadixSortService { + + /** + * Sorts the given array of integers using the Radix Sort algorithm. + * The sorting is done by processing each digit of the numbers starting from the least significant digit (LSD). + * + * @param algorithm The name of the algorithm (not used in this implementation, but could be for logging or future enhancements). + * @param arr The array of integers to be sorted. + * @return The sorted array of integers. + * @throws IllegalArgumentException If the input array is null or empty. + */ + public int[] sort(String algorithm, int[] arr) { + + if (algorithm.isEmpty() || arr == null || arr.length == 0) { + throw new IllegalArgumentException("Input array must not be null or empty."); + } + int max = Arrays.stream(arr).max().orElse(0); + + for (int exp = 1; max / exp > 0; exp *= 10) { + countingSort(arr, exp); + } + return arr; + } + + private void countingSort(int[] arr, int exp) { + int n = arr.length; + int[] output = new int[n]; + int[] count = new int[10]; + + Arrays.fill(count, 0); + + for (int j : arr) { + count[(j / exp) % 10]++; + } + + for (int i = 1; i < 10; i++) { + count[i] += count[i - 1]; + } + + for (int i = n - 1; i >= 0; i--) { + output[count[(arr[i] / exp) % 10] - 1] = arr[i]; + count[(arr[i] / exp) % 10]--; + } + + System.arraycopy(output, 0, arr, 0, n); + } +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/SortingService.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/SortingService.java new file mode 100644 index 0000000..229583c --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/service/SortingService.java @@ -0,0 +1,93 @@ +package org.example.websortingalgo.service; + +import org.example.websortingalgo.dto.SortingRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + + +/** + * Service class that handles sorting requests and delegates sorting to appropriate sorting algorithm services. + *

+ * This class is responsible for receiving a sorting request, choosing the appropriate sorting algorithm based on the + * user's input, and returning the sorted data. It supports multiple sorting algorithms such as Bucket Sort, Merge Sort, + * Quick Sort, Heap Sort, and Radix Sort. + *

+ */ +@Service +public class SortingService { + private final BucketSortService bucketSortService; + private final MergeSortService mergeSortService; + private final QuickSort quickSort; + private final HeapSortService heapSortService; + private RadixSortService radixSortService; + + + @Autowired + public SortingService(BucketSortService bucketSortService, + MergeSortService mergeSortService, QuickSort quickSort, + HeapSortService heapSortService, + RadixSortService radixSortService) { + this.bucketSortService = bucketSortService; + this.mergeSortService = mergeSortService; + this.quickSort = quickSort; + this.heapSortService = heapSortService; + this.radixSortService = radixSortService; + } + + /** + * Handles the sorting of data based on the user's request. + * + * @param sortingRequest the sorting request containing algorithm, order, and data to be sorted + * @return a map containing the sorted data, the algorithm used, and the order of sorting + * @throws if an unsupported sorting algorithm is requested + * @throws if the data provided is invalid or empty + */ + public Map handleSorting(SortingRequest sortingRequest) { + String algorithm = sortingRequest.getAlgorithm(); + String order = sortingRequest.getOrder(); + List data = sortingRequest.getData(); + + //validate inputs + if(data == null || data.isEmpty()){ + throw new NullPointerException("data is null or empty"); + } + + // Convert the list to an array + int[] inputArray = data.stream().mapToInt(Integer::intValue).toArray(); + + // Delegate sorting to the appropriate service + int[] sortedArray; + switch (algorithm.toLowerCase()) { + case "bucket": + sortedArray = bucketSortService.sort(algorithm, inputArray); + break; + case "merge": + sortedArray = mergeSortService.sort(algorithm, inputArray); + break; + case "quick": + sortedArray = quickSort.sort(algorithm, inputArray); + break; + case "heap": + sortedArray = heapSortService.sort(algorithm, inputArray); + break; + case "radix": + sortedArray = radixSortService.sort(algorithm, inputArray); + break; + default: + throw new IllegalArgumentException("Unsupported algorithm: " + algorithm); + } + + // Prepare the response + Map response = new HashMap<>(); + response.put("sorted_data", Arrays.stream(sortedArray).boxed().collect(Collectors.toList())); + response.put("algorithm", algorithm); + response.put("order", order); + return response; + } +} diff --git a/WebSortingAlgo/src/main/java/org/example/websortingalgo/util/HatoesClass.java b/WebSortingAlgo/src/main/java/org/example/websortingalgo/util/HatoesClass.java new file mode 100644 index 0000000..5cc2d93 --- /dev/null +++ b/WebSortingAlgo/src/main/java/org/example/websortingalgo/util/HatoesClass.java @@ -0,0 +1,35 @@ +package org.example.websortingalgo.util; + + + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.Link; +import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder; +import org.example.websortingalgo.controller.Controller; +import org.example.websortingalgo.dto.SortingRequest; + +import java.util.Map; + +public class HatoesClass { + + // Reusable helper method to add links to any sorting response + public static EntityModel> addSortingLinks( + Map response, SortingRequest sortingRequest, String algorithmType) { + + // Create the response model with the current response data + EntityModel> resource = EntityModel.of(response); + + // Add the self-link for the current sorting algorithm + Link selfLink = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(Controller.class) + .sortData(sortingRequest)) + .withSelfRel().withTitle("Sort data with " + algorithmType); + + + + // Add the links to the response + resource.add(selfLink); + + return resource; + } +} + diff --git a/WebSortingAlgo/src/main/webapp/WEB-INF/web.xml b/WebSortingAlgo/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..b9c921f --- /dev/null +++ b/WebSortingAlgo/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,10 @@ + + + Archetype Created Web Application + diff --git a/WebSortingAlgo/src/main/webapp/index.jsp b/WebSortingAlgo/src/main/webapp/index.jsp new file mode 100644 index 0000000..ee89d62 --- /dev/null +++ b/WebSortingAlgo/src/main/webapp/index.jsp @@ -0,0 +1,5 @@ + + +

<%= "Hello World!" %>

+ +