diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..153c9335e --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 000000000..7f91a56ea --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,114 @@ +/* +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. +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.URL; +import java.nio.channels.Channels; +import java.nio.channels.ReadableByteChannel; +import java.util.Properties; + +public class MavenWrapperDownloader { + + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = + "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: : " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 000000000..01e679973 Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 000000000..cd0d451cc --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip diff --git a/SeedData.java b/SeedData.java index 642b3ed46..0828881aa 100644 --- a/SeedData.java +++ b/SeedData.java @@ -12,22 +12,19 @@ @Transactional @Component -public class SeedData implements CommandLineRunner -{ +public class SeedData implements CommandLineRunner { private CustomersRepository custrepos; private AgentsRepository agentrepos; private OrdersRepository ordersrepos; - public SeedData(CustomersRepository custrepos, AgentsRepository agentrepos, OrdersRepository ordersrepos) - { + public SeedData(CustomersRepository custrepos, AgentsRepository agentrepos, OrdersRepository ordersrepos) { this.custrepos = custrepos; this.agentrepos = agentrepos; this.ordersrepos = ordersrepos; } @Override - public void run(String... args) throws Exception - { + public void run(String... args) throws Exception { Agents a01 = new Agents("Ramasundar", "Bangalore", 0.15, "077-25814763", ""); Agents a02 = new Agents("Alex ", "London", 0.13, "075-12458969", ""); Agents a03 = new Agents("Alford", "New York", 0.12, "044-25874365", ""); @@ -53,7 +50,7 @@ public void run(String... args) throws Exception Customers c10 = new Customers("Yearannaidu", "Chennai", "Chennai", "India", "1", 8000.00, 7000.00, 7000.00, 8000.00, "ZZZZBFV", a10); Customers c11 = new Customers("Sasikant", "Mumbai", "Mumbai", "India", "1", 7000.00, 11000.00, 7000.00, 11000.00, "147-25896312", a02); Customers c12 = new Customers("Ramanathan", "Chennai", "Chennai", "India", "1", 7000.00, 11000.00, 9000.00, 9000.00, "GHRDWSD", a10); - Customers c13 = new Customers("Avinash", "Mumbai", "Mumbai", "India", "2", 7000.00, 11000.00, 9000.00, 9000.00, "113-12345678",a02); + Customers c13 = new Customers("Avinash", "Mumbai", "Mumbai", "India", "2", 7000.00, 11000.00, 9000.00, 9000.00, "113-12345678", a02); Customers c14 = new Customers("Winston", "Brisban", "Brisban", "Australia", "1", 5000.00, 8000.00, 7000.00, 6000.00, "AAAAAAA", a05); Customers c15 = new Customers("Karl", "London", "London", "UK", "0", 4000.00, 6000.00, 7000.00, 3000.00, "AAAABAA", a06); Customers c16 = new Customers("Shilton", "Torento", "Torento", "Canada", "1", 10000.00, 7000.00, 6000.00, 11000.00, "DDDDDDD", a04); diff --git a/mvnw b/mvnw new file mode 100644 index 000000000..8b9da3b8b --- /dev/null +++ b/mvnw @@ -0,0 +1,286 @@ +#!/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. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven2 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 /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)`" + # TODO classpath? +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="`which 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 + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" + 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 command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + wget "$jarUrl" -O "$wrapperJarPath" + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + curl -o "$wrapperJarPath" "$jarUrl" + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + 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 + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 000000000..fef5a8f7f --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,161 @@ +@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 Maven2 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 key stroke 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 my 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 "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\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/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" +FOR /F "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% ( + echo Found %WRAPPER_JAR% +) else ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" + echo Finished downloading %WRAPPER_JAR% +) +@REM End of extension + +%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 "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\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% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000..75b6ecfc9 --- /dev/null +++ b/pom.xml @@ -0,0 +1,103 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.5.RELEASE + + + com.jakeesveld + orders + 0.0.1-SNAPSHOT + orders + Demo project for Spring Boot + + + 1.8 + 1.2.71 + + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + com.fasterxml.jackson.module + jackson-module-kotlin + + + org.jetbrains.kotlin + kotlin-reflect + + + org.jetbrains.kotlin + kotlin-stdlib-jdk8 + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.h2database + h2 + + + + org.springframework.boot + spring-boot-starter-test + test + + + com.fasterxml.jackson.core + jackson-databind + 2.9.9 + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + + + org.jetbrains.kotlin + kotlin-maven-plugin + + + jpa + spring + + + -Xjsr305=strict + + + + + org.jetbrains.kotlin + kotlin-maven-noarg + ${kotlin.version} + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + + + diff --git a/src/main/kotlin/com/jakeesveld/orders/Models.kt b/src/main/kotlin/com/jakeesveld/orders/Models.kt new file mode 100644 index 000000000..c8aeae4e6 --- /dev/null +++ b/src/main/kotlin/com/jakeesveld/orders/Models.kt @@ -0,0 +1,54 @@ +package com.jakeesveld.orders + +import javax.persistence.* + +@Entity +data class Agent @JvmOverloads constructor( + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + val agentCode: Long? = null, + @Column(nullable = false) + var name: String? = null, + var workingArea: String? = null, + var commission: Double? = null, + var phone: String? = null, + var country: String? = null +) + +@Entity +data class Customer @JvmOverloads constructor( + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + val custCode: Long? = null, + @Column(nullable = false) + var name: String? = null, + var city: String? = null, + var workingArea: String? = null, + var country: String? = null, + var grade: String? = null, + var openingAmt: Double? = null, + var receiveAmt: Double? = null, + var paymentAmt: Double? = null, + var outstandingAmt: Double? = null, + var phone: String? = null, + var ordersList: List? = null, + @ManyToOne(cascade = [CascadeType.ALL]) + @JoinColumn(name = "agentCode") + var agentCode: Agent +) + +@Entity +data class Order @JvmOverloads constructor( + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + val orderNum: Long? = null, + var orderAmt: Double? = null, + var advanceAmt: Double? = null, + @ManyToOne(cascade = [CascadeType.ALL]) + @JoinColumn(name = "custCode") + val custCode: Customer, + @ManyToOne(cascade = [CascadeType.ALL]) + @JoinColumn(name = "agentCode") + val agentCode: Agent, + var orderDesc: String? = null +) diff --git a/src/main/kotlin/com/jakeesveld/orders/OrdersApplication.kt b/src/main/kotlin/com/jakeesveld/orders/OrdersApplication.kt new file mode 100644 index 000000000..1e634da49 --- /dev/null +++ b/src/main/kotlin/com/jakeesveld/orders/OrdersApplication.kt @@ -0,0 +1,11 @@ +package com.jakeesveld.orders + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +class OrdersApplication + +fun main(args: Array) { + runApplication(*args) +} diff --git a/src/main/kotlin/com/jakeesveld/orders/Repos.kt b/src/main/kotlin/com/jakeesveld/orders/Repos.kt new file mode 100644 index 000000000..be408d2f9 --- /dev/null +++ b/src/main/kotlin/com/jakeesveld/orders/Repos.kt @@ -0,0 +1,9 @@ +package com.jakeesveld.orders + +import org.springframework.data.repository.CrudRepository + +interface OrdersRepository: CrudRepository + +interface CustomersRepository: CrudRepository + +interface AgentsRepository: CrudRepository \ No newline at end of file diff --git a/src/main/kotlin/com/jakeesveld/orders/SeedData.kt b/src/main/kotlin/com/jakeesveld/orders/SeedData.kt new file mode 100644 index 000000000..d85601eb7 --- /dev/null +++ b/src/main/kotlin/com/jakeesveld/orders/SeedData.kt @@ -0,0 +1,118 @@ +package com.jakeesveld.orders + +import org.springframework.boot.CommandLineRunner +import org.springframework.stereotype.Component +import org.springframework.transaction.annotation.Transactional + + +@Transactional +@Component +class SeedData(private val custrepos: CustomersRepository, private val agentrepos: AgentsRepository, private val ordersrepos: OrdersRepository) : CommandLineRunner { + + @Throws(Exception::class) + override fun run(vararg args: String) { + val a01 = Agent(name = "Ramasundar", workingArea = "Bangalore", commission = 0.15, phone = "077-25814763", country = "") + val a02 = Agent(name = "Alex ", workingArea = "London", commission = 0.13, phone = "075-12458969", country = "") + val a03 = Agent(name = "Alford", workingArea = "New York", commission = 0.12, phone = "044-25874365", country = "") + val a04 = Agent(name = "Ravi Kumar", workingArea = "Bangalore", commission = 0.15, phone = "077-45625874", country = "") + val a05 = Agent(name = "Santakumar", workingArea = "Chennai", commission = 0.14, phone = "007-22388644", country = "") + val a06 = Agent(name = "Lucida", workingArea = "San Jose", commission = 0.12, phone = "044-52981425", country = "") + val a07 = Agent(name = "Anderson", workingArea = "Brisban", commission = 0.13, phone = "045-21447739", country = "") + val a08 = Agent(name = "Subbarao", workingArea = "Bangalore", commission = 0.14, phone = "077-12346674", country = "") + val a09 = Agent(name = "Mukesh", workingArea = "Mumbai", commission = 0.11, phone = "029-12358964", country = "") + val a10 = Agent(name = "McDen", workingArea = "London", commission = 0.15, phone = "078-22255588", country = "") + val a11 = Agent(name = "Ivan", workingArea = "Torento", commission = 0.15, phone = "008-22544166", country = "") + val a12 = Agent(name = "Benjamin", workingArea = "Hampshair", commission = 0.11, phone = "008-22536178", country = "") + + val c01 = Customer(name = "Holmes", city = "London", workingArea = "London", country = "UK", grade = "2", openingAmt = 6000.00, receiveAmt = 5000.00, paymentAmt = 7000.00, outstandingAmt = 4000.00, phone = "BBBBBBB",agentCode = a03) + val c02 = Customer(name = "Micheal", city = "New York", workingArea = "New York", country = "USA", grade = "2", openingAmt = 3000.00, receiveAmt = 5000.00, paymentAmt = 2000.00, outstandingAmt = 6000.00, phone = "CCCCCCC",agentCode = a08) + val c03 = Customer(name = "Albert", city = "New York", workingArea = "New York", country = "USA", grade = "3", openingAmt = 5000.00, receiveAmt = 7000.00, paymentAmt = 6000.00, outstandingAmt = 6000.00, phone = "BBBBSBB",agentCode = a08) + val c04 = Customer(name = "Ravindran", city = "Bangalore", workingArea = "Bangalore", country = "India", grade = "2", openingAmt = 5000.00, receiveAmt = 7000.00, paymentAmt = 4000.00, outstandingAmt = 8000.00, phone = "AVAVAVA",agentCode = a11) + val c05 = Customer(name = "Cook", city = "London", workingArea = "London", country = "UK", grade = "2", openingAmt = 4000.00, receiveAmt = 9000.00, paymentAmt = 7000.00, outstandingAmt = 6000.00, phone = "FSDDSDF",agentCode = a06) + val c06 = Customer(name = "Stuart", city = "London", workingArea = "London", country = "UK", grade = "1", openingAmt = 6000.00, receiveAmt = 8000.00, paymentAmt = 3000.00, outstandingAmt = 11000.00, phone = "GFSGERS",agentCode = a03) + val c07 = Customer(name = "Bolt", city = "New York", workingArea = "New York", country = "USA", grade = "3", openingAmt = 5000.00, receiveAmt = 7000.00, paymentAmt = 9000.00, outstandingAmt = 3000.00, phone = "DDNRDRH",agentCode = a08) + val c08 = Customer(name = "Fleming", city = "Brisban", workingArea = "Brisban", country = "Australia", grade = "2", openingAmt = 7000.00, receiveAmt = 7000.00, paymentAmt = 9000.00, outstandingAmt = 5000.00, phone = "NHBGVFC",agentCode = a05) + val c09 = Customer(name = "Jacks", city = "Brisban", workingArea = "Brisban", country = "Australia", grade = "1", openingAmt = 7000.00, receiveAmt = 7000.00, paymentAmt = 7000.00, outstandingAmt = 7000.00, phone = "WERTGDF",agentCode = a05) + val c10 = Customer(name = "Yearannaidu", city = "Chennai", workingArea = "Chennai", country = "India", grade = "1", openingAmt = 8000.00, receiveAmt = 7000.00, paymentAmt = 7000.00, outstandingAmt = 8000.00, phone = "ZZZZBFV",agentCode = a10) + val c11 = Customer(name = "Sasikant", city = "Mumbai", workingArea = "Mumbai", country = "India", grade = "1", openingAmt = 7000.00, receiveAmt = 11000.00, paymentAmt = 7000.00, outstandingAmt = 11000.00, phone = "147-25896312",agentCode = a02) + val c12 = Customer(name = "Ramanathan", city = "Chennai", workingArea = "Chennai", country = "India", grade = "1", openingAmt = 7000.00, receiveAmt = 11000.00, paymentAmt = 9000.00, outstandingAmt = 9000.00, phone = "GHRDWSD",agentCode = a10) + val c13 = Customer(name = "Avinash", city = "Mumbai", workingArea = "Mumbai", country = "India", grade = "2", openingAmt = 7000.00, receiveAmt = 11000.00, paymentAmt = 9000.00, outstandingAmt = 9000.00, phone = "113-12345678",agentCode = a02) + val c14 = Customer(name = "Winston", city = "Brisban", workingArea = "Brisban", country = "Australia", grade = "1", openingAmt = 5000.00, receiveAmt = 8000.00, paymentAmt = 7000.00, outstandingAmt = 6000.00, phone = "AAAAAAA",agentCode = a05) + val c15 = Customer(name = "Karl", city = "London", workingArea = "London", country = "UK", grade = "0", openingAmt = 4000.00, receiveAmt = 6000.00, paymentAmt = 7000.00, outstandingAmt = 3000.00, phone = "AAAABAA",agentCode = a06) + val c16 = Customer(name = "Shilton", city = "Torento", workingArea = "Torento", country = "Canada", grade = "1", openingAmt = 10000.00, receiveAmt = 7000.00, paymentAmt = 6000.00, outstandingAmt = 11000.00, phone = "DDDDDDD",agentCode = a04) + val c17 = Customer(name = "Charles", city = "Hampshair", workingArea = "Hampshair", country = "UK", grade = "3", openingAmt = 6000.00, receiveAmt = 4000.00, paymentAmt = 5000.00, outstandingAmt = 5000.00, phone = "MMMMMMM",agentCode = a09) + val c18 = Customer(name = "Srinivas", city = "Bangalore", workingArea = "Bangalore", country = "India", grade = "2", openingAmt = 8000.00, receiveAmt = 4000.00, paymentAmt = 3000.00, outstandingAmt = 9000.00, phone = "AAAAAAB",agentCode = a07) + val c19 = Customer(name = "Steven", city = "San Jose", workingArea = "San Jose", country = "USA", grade = "1", openingAmt = 5000.00, receiveAmt = 7000.00, paymentAmt = 9000.00, outstandingAmt = 3000.00, phone = "KRFYGJK",agentCode = a12) + val c20 = Customer(name = "Karolina", city = "Torento", workingArea = "Torento", country = "Canada", grade = "1", openingAmt = 7000.00, receiveAmt = 7000.00, paymentAmt = 9000.00, outstandingAmt = 5000.00, phone = "HJKORED",agentCode = a04) + val c21 = Customer(name = "Martin", city = "Torento", workingArea = "Torento", country = "Canada", grade = "2", openingAmt = 8000.00, receiveAmt = 7000.00, paymentAmt = 7000.00, outstandingAmt = 8000.00, phone = "MJYURFD",agentCode = a04) + val c22 = Customer(name = "Ramesh", city = "Mumbai", workingArea = "Mumbai", country = "India", grade = "3", openingAmt = 8000.00, receiveAmt = 7000.00, paymentAmt = 3000.00, outstandingAmt = 12000.00, phone = "Phone No",agentCode = a02) + val c23 = Customer(name = "Rangarappa", city = "Bangalore", workingArea = "Bangalore", country = "India", grade = "2", openingAmt = 8000.00, receiveAmt = 11000.00, paymentAmt = 7000.00, outstandingAmt = 12000.00, phone = "AAAATGF",agentCode = a01) + val c24 = Customer(name = "Venkatpati", city = "Bangalore", workingArea = "Bangalore", country = "India", grade = "2", openingAmt = 8000.00, receiveAmt = 11000.00, paymentAmt = 7000.00, outstandingAmt = 12000.00, phone = "JRTVFDD",agentCode = a07) + val c25 = Customer(name = "Sundariya", city = "Chennai", workingArea = "Chennai", country = "India", grade = "3", openingAmt = 7000.00, receiveAmt = 11000.00, paymentAmt = 7000.00, outstandingAmt = 11000.00, phone = "PPHGRTS",agentCode = a10) + + val o01 = Order(orderAmt = 1000.00, advanceAmt = 600.00, custCode = c13, agentCode = a03 ,orderDesc = "SOD") + val o02 = Order(orderAmt = 3000.00, advanceAmt = 500.00, custCode = c19, agentCode = a10 ,orderDesc = "SOD") + val o03 = Order(orderAmt = 4500.00, advanceAmt = 900.00, custCode = c07, agentCode = a10 ,orderDesc = "SOD") + val o04 = Order(orderAmt = 2000.00, advanceAmt = 400.00, custCode = c16, agentCode = a07 ,orderDesc = "SOD") + val o05 = Order(orderAmt = 4000.00, advanceAmt = 600.00, custCode = c22, agentCode = a02 ,orderDesc = "SOD") + val o06 = Order(orderAmt = 2000.00, advanceAmt = 300.00, custCode = c12, agentCode = a12 ,orderDesc = "SOD") + val o07 = Order(orderAmt = 3500.00, advanceAmt = 2000.00, custCode = c02, agentCode = a08 ,orderDesc = "SOD") + val o08 = Order(orderAmt = 2500.00, advanceAmt = 400.00, custCode = c03, agentCode = a04 ,orderDesc = "SOD") + val o09 = Order(orderAmt = 500.00, advanceAmt = 100.00, custCode = c23, agentCode = a06 ,orderDesc = "SOD") + val o10 = Order(orderAmt = 4000.00, advanceAmt = 700.00, custCode = c07, agentCode = a10 ,orderDesc = "SOD") + val o11 = Order(orderAmt = 1500.00, advanceAmt = 600.00, custCode = c08, agentCode = a04 ,orderDesc = "SOD") + val o12 = Order(orderAmt = 2500.00, advanceAmt = 400.00, custCode = c25, agentCode = a11 ,orderDesc = "SOD") + + agentrepos.save(a01) + agentrepos.save(a02) + agentrepos.save(a03) + agentrepos.save(a04) + agentrepos.save(a05) + agentrepos.save(a06) + agentrepos.save(a07) + agentrepos.save(a08) + agentrepos.save(a09) + agentrepos.save(a10) + agentrepos.save(a11) + agentrepos.save(a12) + + custrepos.save(c01) + custrepos.save(c02) + custrepos.save(c03) + custrepos.save(c04) + custrepos.save(c05) + custrepos.save(c06) + custrepos.save(c07) + custrepos.save(c08) + custrepos.save(c09) + custrepos.save(c10) + custrepos.save(c11) + custrepos.save(c12) + custrepos.save(c13) + custrepos.save(c14) + custrepos.save(c15) + custrepos.save(c16) + custrepos.save(c17) + custrepos.save(c18) + custrepos.save(c19) + custrepos.save(c20) + custrepos.save(c21) + custrepos.save(c22) + custrepos.save(c23) + custrepos.save(c24) + custrepos.save(c25) + + ordersrepos.save(o01) + ordersrepos.save(o02) + ordersrepos.save(o03) + ordersrepos.save(o04) + ordersrepos.save(o05) + ordersrepos.save(o06) + ordersrepos.save(o07) + ordersrepos.save(o08) + ordersrepos.save(o09) + ordersrepos.save(o10) + ordersrepos.save(o11) + ordersrepos.save(o12) + } +} diff --git a/src/main/kotlin/com/jakeesveld/orders/service/CustomerService.kt b/src/main/kotlin/com/jakeesveld/orders/service/CustomerService.kt new file mode 100644 index 000000000..661bb236a --- /dev/null +++ b/src/main/kotlin/com/jakeesveld/orders/service/CustomerService.kt @@ -0,0 +1,9 @@ +package com.jakeesveld.orders.service + +import com.jakeesveld.orders.Customer + +interface CustomerService { + fun delete(id: Long) + fun create(customer: Customer): Customer + fun update(customer: Customer, id: Long) +} \ No newline at end of file diff --git a/src/main/kotlin/com/jakeesveld/orders/service/CustomerServiceImpl.kt b/src/main/kotlin/com/jakeesveld/orders/service/CustomerServiceImpl.kt new file mode 100644 index 000000000..f3153efd8 --- /dev/null +++ b/src/main/kotlin/com/jakeesveld/orders/service/CustomerServiceImpl.kt @@ -0,0 +1,48 @@ +package com.jakeesveld.orders.service + +import com.jakeesveld.orders.Customer +import com.jakeesveld.orders.CustomersRepository +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Service +import javax.persistence.EntityNotFoundException + +@Service +class CustomerServiceImpl: CustomerService { + + @Autowired + var repo: CustomersRepository? = null + + override fun delete(id: Long) { + if(repo!!.findById(id).isPresent){ + repo!!.deleteById(id) + }else{ + throw EntityNotFoundException() + } + } + + override fun create(customer: Customer): Customer { + val newCustomer = Customer(name = customer.name, city = customer.city, workingArea = customer.workingArea, country = customer.country, + grade = customer.grade, openingAmt = customer.openingAmt, receiveAmt = customer.receiveAmt, paymentAmt = customer.paymentAmt, + outstandingAmt = customer.outstandingAmt, phone = customer.phone, agentCode = customer.agentCode) + + return repo!!.save(newCustomer) + } + + + override fun update(customer: Customer, id: Long) { + val currentCustomer: Customer = repo!!.findById(id).orElseThrow() + customer.name.let { currentCustomer.name = customer.name } + customer.city.let { currentCustomer.city = customer.city } + customer.workingArea.let { currentCustomer.workingArea = customer.workingArea } + customer.country.let { currentCustomer.country = customer.country } + customer.grade.let { currentCustomer.grade = customer.grade } + customer.openingAmt.let { currentCustomer.openingAmt = customer.openingAmt } + customer.receiveAmt.let { currentCustomer.receiveAmt = customer.receiveAmt } + customer.paymentAmt.let { currentCustomer.paymentAmt = customer.paymentAmt } + customer.outstandingAmt.let { currentCustomer.outstandingAmt = customer.outstandingAmt } + customer.phone.let { currentCustomer.phone = customer.phone } + customer.agentCode.let { currentCustomer.agentCode = customer.agentCode } + + repo!!.save(currentCustomer) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/jakeesveld/orders/service/OrderService.kt b/src/main/kotlin/com/jakeesveld/orders/service/OrderService.kt new file mode 100644 index 000000000..615830a9d --- /dev/null +++ b/src/main/kotlin/com/jakeesveld/orders/service/OrderService.kt @@ -0,0 +1,9 @@ +package com.jakeesveld.orders.service + +import com.jakeesveld.orders.Order + +interface OrderService { + fun findAll(): List + fun findByCustomer(id: Long): List + +} \ No newline at end of file diff --git a/src/main/kotlin/com/jakeesveld/orders/service/OrderServiceImpl.kt b/src/main/kotlin/com/jakeesveld/orders/service/OrderServiceImpl.kt new file mode 100644 index 000000000..e6cce332d --- /dev/null +++ b/src/main/kotlin/com/jakeesveld/orders/service/OrderServiceImpl.kt @@ -0,0 +1,25 @@ +package com.jakeesveld.orders.service + +import com.jakeesveld.orders.Order +import com.jakeesveld.orders.OrdersRepository +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Service + +@Service +class OrderServiceImpl: OrderService { + + @Autowired + var repo: OrdersRepository? = null + + override fun findAll(): List { + val orderList = mutableListOf() + repo!!.findAll().iterator().forEachRemaining { order: Order? -> order?.let { orderList.add(it) } } + return orderList + } + + override fun findByCustomer(id: Long): List { + val orderList = mutableListOf() + repo!!.findAll().iterator().forEachRemaining{order: Order? -> order?.let { orderList.add(it) }} + return orderList.filter { order -> order.custCode.custCode == id } + } +} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/src/test/kotlin/com/jakeesveld/orders/OrdersApplicationTests.kt b/src/test/kotlin/com/jakeesveld/orders/OrdersApplicationTests.kt new file mode 100644 index 000000000..77f78b261 --- /dev/null +++ b/src/test/kotlin/com/jakeesveld/orders/OrdersApplicationTests.kt @@ -0,0 +1,16 @@ +package com.jakeesveld.orders + +import org.junit.Test +import org.junit.runner.RunWith +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.junit4.SpringRunner + +@RunWith(SpringRunner::class) +@SpringBootTest +class OrdersApplicationTests { + + @Test + fun contextLoads() { + } + +}