diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5093a42663f30e656f8cdce1e70bbcd95db02b36 Binary files /dev/null and b/.DS_Store differ diff --git a/Training_VS_TKSR2.zip b/Training_VS_TKSR2.zip deleted file mode 100644 index d66f17b355ea76e23c77b132c566cd737f1d83bb..0000000000000000000000000000000000000000 Binary files a/Training_VS_TKSR2.zip and /dev/null differ diff --git a/athlete-service/.DS_Store b/athlete-service/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9616fac8c3daa991b2c7d6a38b3903a7814aa3fa Binary files /dev/null and b/athlete-service/.DS_Store differ diff --git a/athlete-service/.idea/.gitignore b/athlete-service/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..eaf91e2ac647df635a09f01b8a2a254252aae8d7 --- /dev/null +++ b/athlete-service/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/athlete-service/.idea/athlete-service.iml b/athlete-service/.idea/athlete-service.iml new file mode 100644 index 0000000000000000000000000000000000000000..18ec59dd70c312989ec67b525207ca8514461e22 --- /dev/null +++ b/athlete-service/.idea/athlete-service.iml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$" /> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + </component> +</module> \ No newline at end of file diff --git a/athlete-service/.idea/misc.xml b/athlete-service/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..76dd4d2487374591d86d1e7441f0bf0dac0051a7 --- /dev/null +++ b/athlete-service/.idea/misc.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectRootManager" version="2" project-jdk-name="15" project-jdk-type="JavaSDK" /> +</project> \ No newline at end of file diff --git a/athlete-service/.idea/modules.xml b/athlete-service/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..f80ca92703f5813a497c43586c027e9461405651 --- /dev/null +++ b/athlete-service/.idea/modules.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="ProjectModuleManager"> + <modules> + <module fileurl="file://$PROJECT_DIR$/.idea/athlete-service.iml" filepath="$PROJECT_DIR$/.idea/athlete-service.iml" /> + </modules> + </component> +</project> \ No newline at end of file diff --git a/athlete-service/athlete-service/.DS_Store b/athlete-service/athlete-service/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9a874b5768f336915163bb88cd434575b859f936 Binary files /dev/null and b/athlete-service/athlete-service/.DS_Store differ diff --git a/athlete-service/athlete-service/.gitignore b/athlete-service/athlete-service/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..549e00a2a96fa9d7c5dbc9859664a78d980158c2 --- /dev/null +++ b/athlete-service/athlete-service/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### 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/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/athlete-service/athlete-service/mvnw b/athlete-service/athlete-service/mvnw new file mode 100644 index 0000000000000000000000000000000000000000..8a8fb2282df5b8f7263470a5a2dc0e196f35f35f --- /dev/null +++ b/athlete-service/athlete-service/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/athlete-service/athlete-service/mvnw.cmd b/athlete-service/athlete-service/mvnw.cmd new file mode 100644 index 0000000000000000000000000000000000000000..1d8ab018eaf11d9b3a4a90e7818ace373dfbb380 --- /dev/null +++ b/athlete-service/athlete-service/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/athlete-service/athlete-service/pom.xml b/athlete-service/athlete-service/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..701161384b4acad44ca4745173a3afaad72f0864 --- /dev/null +++ b/athlete-service/athlete-service/pom.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.6.7</version> + <relativePath/> <!-- lookup parent from repository --> + </parent> + <groupId>tk.sr</groupId> + <artifactId>training-service</artifactId> + <version>0.0.1-SNAPSHOT</version> + <name>training-service</name> + <description>Demo project for Spring Boot</description> + <properties> + <java.version>11</java.version> + </properties> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-thymeleaf</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + <dependency> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <excludes> + <exclude> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/athlete-service/athlete-service/src/.DS_Store b/athlete-service/athlete-service/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7b0d36729e2ee777a660f9e8c6709dd97bc2fb68 Binary files /dev/null and b/athlete-service/athlete-service/src/.DS_Store differ diff --git a/athlete-service/athlete-service/src/main/.DS_Store b/athlete-service/athlete-service/src/main/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..55c1fcbeb4ba2bef02771ea2748f3e4b0ea5c07d Binary files /dev/null and b/athlete-service/athlete-service/src/main/.DS_Store differ diff --git a/athlete-service/athlete-service/src/main/java/.DS_Store b/athlete-service/athlete-service/src/main/java/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2406a221e3fddd6dd60e917a37ed5ac167d11e64 Binary files /dev/null and b/athlete-service/athlete-service/src/main/java/.DS_Store differ diff --git a/athlete-service/athlete-service/src/main/java/tk/.DS_Store b/athlete-service/athlete-service/src/main/java/tk/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ad4ed559805ae1ed7f168781db3ec32186f1ed7e Binary files /dev/null and b/athlete-service/athlete-service/src/main/java/tk/.DS_Store differ diff --git a/athlete-service/athlete-service/src/main/java/tk/sr/.DS_Store b/athlete-service/athlete-service/src/main/java/tk/sr/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9ecd1ee21953f117054ccc3e0a734b57bad9b277 Binary files /dev/null and b/athlete-service/athlete-service/src/main/java/tk/sr/.DS_Store differ diff --git a/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/.DS_Store b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ede648faaeb569dc4da7f8c67750088655130bec Binary files /dev/null and b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/.DS_Store differ diff --git a/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/AthleteServiceApplication.java b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/AthleteServiceApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..78034588b6b2edc2d0358660f8cc08715018af9f --- /dev/null +++ b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/AthleteServiceApplication.java @@ -0,0 +1,13 @@ +package tk.sr.athleteservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class AthleteServiceApplication { + + public static void main(String[] args) { + SpringApplication.run(AthleteServiceApplication.class, args); + } + +} diff --git a/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/controller/AthleteController.java b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/controller/AthleteController.java new file mode 100644 index 0000000000000000000000000000000000000000..63d4e7d475131bbbfb5e6df76338662dce062ff8 --- /dev/null +++ b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/controller/AthleteController.java @@ -0,0 +1,35 @@ +package tk.sr.athleteservice.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import tk.sr.athleteservice.entity.Athlete; +import tk.sr.athleteservice.repository.AthleteRepository; +import tk.sr.athleteservice.service.AthleteService; + +import java.util.List; + +@RestController +public class AthleteController { + private final AthleteService athleteService; + private final AthleteRepository athleteRepository; + + + public AthleteController(AthleteService athleteService, AthleteRepository athleteRepository){ + this.athleteService = athleteService; + this.athleteRepository = athleteRepository; + } + + @GetMapping("/athletes") + public Iterable<Athlete> getAthletes(){ + + return athleteService.getAthletes(); + } + + @PostMapping(value = "/athletes") + public Athlete addAthlete(@RequestBody Athlete athlete){ + return athleteService.addAthlete(athlete); + } + +} diff --git a/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/controller/AthleteUIController.java b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/controller/AthleteUIController.java new file mode 100644 index 0000000000000000000000000000000000000000..b54d1b2c815eb60d1cf17a0b4d6d188311e6a229 --- /dev/null +++ b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/controller/AthleteUIController.java @@ -0,0 +1,57 @@ +package tk.sr.athleteservice.controller; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import tk.sr.athleteservice.entity.Athlete; +import tk.sr.athleteservice.service.AthleteService; +import tk.sr.athleteservice.service.PersistentAthleteService; + +import java.util.Optional; + +@Slf4j +@Controller +public class AthleteUIController { + /*private final AthleteService athleteService;*/ + private final PersistentAthleteService athleteService; + + public AthleteUIController(PersistentAthleteService athleteService) { + this.athleteService = athleteService; + } + + + @GetMapping("/web/athletes") + public String athletes(Model model){//Model ist Verbindung zwischen Controller und dem Frontend + var athletes = athleteService.getAthletes(); + model.addAttribute("athlete", new Athlete()); + model.addAttribute("athletes", athletes); + return "index"; + } + @PostMapping("/web/athletes") + public String saveAthlete(@ModelAttribute Athlete athlete){ + log.info("Received POST from Thymeleaf with athlete {} ", athlete); + athleteService.addAthlete(athlete); + return "redirect:/web/athletes"; + } + + @GetMapping("/web/athletesZwei") + public String athletesZwei(Model model){//Model ist Verbindung zwischen Controller und dem Frontend + var athlete = athleteService.getAthleteById(1); + log.info(athlete.toString()); + model.addAttribute("athlete", new Athlete()); + model.addAttribute("athletes", athlete); + return "index"; + } + + @GetMapping("/web/athletes/{id}") + public Optional<Athlete> getTutorialById(@PathVariable Integer athleteId) { + Optional<Athlete> athlete = athleteService.findById(athleteId); + log.info(athlete.toString()); + return athlete; + } + +} diff --git a/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/entity/Athlete.java b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/entity/Athlete.java new file mode 100644 index 0000000000000000000000000000000000000000..a1dba5ee8efb11fabec3cb4fda228b19a1547d6e --- /dev/null +++ b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/entity/Athlete.java @@ -0,0 +1,27 @@ +package tk.sr.athleteservice.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +@Data +@Entity +@NoArgsConstructor +@AllArgsConstructor +public class Athlete { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int athleteId; + private String username; + private String password; + private String firstname; + private String lastname; + private int age; + private double height; + private double weight; +} \ No newline at end of file diff --git a/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/repository/AthleteRepository.java b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/repository/AthleteRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..e92d7549037e3e8625b42dc428a80918e1971cd6 --- /dev/null +++ b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/repository/AthleteRepository.java @@ -0,0 +1,11 @@ +package tk.sr.athleteservice.repository; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; +import tk.sr.athleteservice.entity.Athlete; + + +@Repository +public interface AthleteRepository extends CrudRepository<Athlete,Integer> { + +} diff --git a/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/service/AthleteService.java b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/service/AthleteService.java new file mode 100644 index 0000000000000000000000000000000000000000..7288bd892c4bbc106146b06402b1c3b4ab273079 --- /dev/null +++ b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/service/AthleteService.java @@ -0,0 +1,16 @@ +package tk.sr.athleteservice.service; + +import org.springframework.stereotype.Service; +import tk.sr.athleteservice.entity.Athlete; + +import java.util.List; +import java.util.Optional; + +@Service +public interface AthleteService { + Iterable<Athlete> getAthletes(); + Athlete addAthlete(Athlete athlete); + Optional<Athlete> getAthleteById(Integer Id); + + Optional<Athlete> findById(long athleteId); +} diff --git a/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/service/PersistentAthleteService.java b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/service/PersistentAthleteService.java new file mode 100644 index 0000000000000000000000000000000000000000..859ae544e3ffa0cfc713d51ebdf5032bdcedd0e4 --- /dev/null +++ b/athlete-service/athlete-service/src/main/java/tk/sr/athleteservice/service/PersistentAthleteService.java @@ -0,0 +1,45 @@ +package tk.sr.athleteservice.service; + +import org.springframework.stereotype.Service; +import tk.sr.athleteservice.entity.Athlete; +import tk.sr.athleteservice.repository.AthleteRepository; + +import javax.annotation.PostConstruct; +import java.util.Optional; + +@Service +public class PersistentAthleteService implements AthleteService{ + private final AthleteRepository athleteRepository; + + public PersistentAthleteService(AthleteRepository athleteRepository){ + this.athleteRepository = athleteRepository; + } + + @PostConstruct + public void init(){ + athleteRepository.save(new Athlete(1,"theresakl", "blabla", "Theresa", "Klopfer",20, 190, 90.0)); + athleteRepository.save(new Athlete(2,"sophiari", "bliblu", "Sophia", "Rieger",21, 180, 80.0)); + athleteRepository.save(new Athlete(3,"maxi", "musteri", "Max", "Muster",30, 180, 100.0)); + } + + @Override + public Iterable<Athlete> getAthletes() { + return athleteRepository.findAll(); + } + + + public Optional<Athlete> getAthleteById(Integer Id){ + return athleteRepository.findById(Id); + } + + @Override + public Optional<Athlete> findById(long athleteId) { + return Optional.empty(); + } + + @Override + public Athlete addAthlete(Athlete athlete) { + return athleteRepository.save(athlete); + } + +} diff --git a/athlete-service/athlete-service/src/main/resources/application.properties b/athlete-service/athlete-service/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..e44af425256774c8b34b23df0438a469b2c166ab --- /dev/null +++ b/athlete-service/athlete-service/src/main/resources/application.properties @@ -0,0 +1,11 @@ +management.endpoints.web.exposure.include=* + +spring.datasource.url=jdbc:postgresql://localhost:5432/postgres +spring.datasource.username=postgres +spring.datasource.password=Hidu123 + +spring.jpa.hibernate.ddl-auto=create + +logging.level.root=INFO + +server.port=8080 \ No newline at end of file diff --git a/athlete-service/athlete-service/src/main/resources/templates/index.html b/athlete-service/athlete-service/src/main/resources/templates/index.html new file mode 100644 index 0000000000000000000000000000000000000000..eca99add962f30a7f60c8ca3dc591d58927485b7 --- /dev/null +++ b/athlete-service/athlete-service/src/main/resources/templates/index.html @@ -0,0 +1,49 @@ +<!DOCTYPE> +<html> +<head> + <title> + AthleteService + </title> +</head> +<body> +<h1> + Athletes +</h1> + +<form action="#" th:action="@{/web/athletesZwei}" method="post" th:object="${athlete}"> + <input type="submit" th:value="Speichern"> + <input th:field="*{athleteId}" placeholder="AthleteId"> + <input th:field="*{username}" placeholder="Username"> + <input th:field="*{password}" placeholder="Password"> + <input th:field="*{firstname}" placeholder="Firstname"> + <input th:field="*{lastname}" placeholder="Lastname"> + <input th:field="*{age}" placeholder="Age"> + <input th:field="*{height}" placeholder="Height"> + <input th:field="*{weight}" placeholder="Weight"> +</form> +<table> + <th>athleteId</th> + <th>username</th> + <th>password</th> + <th>firstname</th> + <th>lastname</th> + <th>age</th> + <th>height</th> + <th>weight</th> + + + <tr th:each="athlete : ${athletes}"> + <td th:text="${athlete.athleteId}"></td> + <td th:text="${athlete.username}"></td> + <td th:text="${athlete.password}"></td> + <td th:text="${athlete.firstname}"></td> + <td th:text="${athlete.lastname}"></td> + <td th:text="${athlete.age}"></td> + <td th:text="${athlete.height}"></td> + <td th:text="${athlete.weight}"></td> + </tr> +</table> + + +</body> +</html> \ No newline at end of file diff --git a/athlete-service/athlete-service/src/test/java/tk/sr/athleteservice/AthleteServiceApplicationTests.java b/athlete-service/athlete-service/src/test/java/tk/sr/athleteservice/AthleteServiceApplicationTests.java new file mode 100644 index 0000000000000000000000000000000000000000..42c92f6e9371e232d420b7f261169da0b5dde163 --- /dev/null +++ b/athlete-service/athlete-service/src/test/java/tk/sr/athleteservice/AthleteServiceApplicationTests.java @@ -0,0 +1,13 @@ +package tk.sr.athleteservice; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class AthleteServiceApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/exercise-service/exercise-service/.gitignore b/exercise-service/exercise-service/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..549e00a2a96fa9d7c5dbc9859664a78d980158c2 --- /dev/null +++ b/exercise-service/exercise-service/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### 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/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/exercise-service/exercise-service/exercise-service/.gitignore b/exercise-service/exercise-service/exercise-service/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..549e00a2a96fa9d7c5dbc9859664a78d980158c2 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### 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/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/exercise-service/exercise-service/exercise-service/mvnw b/exercise-service/exercise-service/exercise-service/mvnw new file mode 100644 index 0000000000000000000000000000000000000000..8a8fb2282df5b8f7263470a5a2dc0e196f35f35f --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/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/exercise-service/exercise-service/exercise-service/mvnw.cmd b/exercise-service/exercise-service/exercise-service/mvnw.cmd new file mode 100644 index 0000000000000000000000000000000000000000..1d8ab018eaf11d9b3a4a90e7818ace373dfbb380 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/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/exercise-service/exercise-service/exercise-service/pom.xml b/exercise-service/exercise-service/exercise-service/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..701161384b4acad44ca4745173a3afaad72f0864 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/pom.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.6.7</version> + <relativePath/> <!-- lookup parent from repository --> + </parent> + <groupId>tk.sr</groupId> + <artifactId>training-service</artifactId> + <version>0.0.1-SNAPSHOT</version> + <name>training-service</name> + <description>Demo project for Spring Boot</description> + <properties> + <java.version>11</java.version> + </properties> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-thymeleaf</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + <dependency> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <excludes> + <exclude> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/ExerciseServiceApplication.java b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/ExerciseServiceApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..8dac2f8f8b94a41661c03bc7512e8b8751840b30 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/ExerciseServiceApplication.java @@ -0,0 +1,13 @@ +package tk.sr.exerciseservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ExerciseServiceApplication { + + public static void main(String[] args) { + SpringApplication.run(ExerciseServiceApplication.class, args); + } + +} diff --git a/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/controller/ExerciseController.java b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/controller/ExerciseController.java new file mode 100644 index 0000000000000000000000000000000000000000..49db9a936388e068dc90813701db707e6e0ebed9 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/controller/ExerciseController.java @@ -0,0 +1,32 @@ +package tk.sr.exerciseservice.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import tk.sr.exerciseservice.entity.Exercise; +import tk.sr.exerciseservice.repository.ExerciseRepository; +import tk.sr.exerciseservice.service.ExerciseService; + +@RestController +public class ExerciseController { + + private final ExerciseService exerciseService; + private final ExerciseRepository exerciseRepository; + + public ExerciseController(ExerciseService exerciseService, ExerciseRepository exerciseRepository) { + this.exerciseService = exerciseService; + this.exerciseRepository = exerciseRepository; + } + + @GetMapping("/exercises") + public Iterable<Exercise> getExercises(){ + return exerciseService.getExercises(); + } + + @PostMapping("/exercises") + public Exercise addExercises(@RequestBody Exercise exercise){ + return exerciseService.addExercise(exercise); + } +} + diff --git a/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/controller/ExerciseUIController.java b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/controller/ExerciseUIController.java new file mode 100644 index 0000000000000000000000000000000000000000..99a1f94f7f6fb8e8f507cf53e6e270b246cc41fe --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/controller/ExerciseUIController.java @@ -0,0 +1,44 @@ +package tk.sr.exerciseservice.controller; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import tk.sr.exerciseservice.entity.Exercise; +import tk.sr.exerciseservice.service.ExerciseService; + +@Slf4j +@Controller +public class ExerciseUIController { + private final ExerciseService exerciseService; + + public ExerciseUIController(ExerciseService exerciseService) { + this.exerciseService = exerciseService; + } + + + @GetMapping("/web/exercises") + public String exercises(Model model){//Model ist Verbindung zwischen Controller und dem Frontend + var exercises = exerciseService.getExercises(); + model.addAttribute("exercise", new Exercise()); + model.addAttribute("exercises", exercises); + return "index"; + } + + @GetMapping("/web/exercises/1") + public String exercise(Model model){//Model ist Verbindung zwischen Controller und dem Frontend + var exercises = exerciseService.getExerciseById(1); + model.addAttribute("exercise", new Exercise()); + model.addAttribute("exercises", exercises); + return "index"; + } + + @PostMapping("/web/exercises") + public String saveExercise(@ModelAttribute Exercise exercise){ + log.info("Received POST from Thymeleaf with exercise {} ", exercise); + exerciseService.addExercise(exercise); + return "redirect:/web/exercises"; + } +} diff --git a/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/entity/Exercise.java b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/entity/Exercise.java new file mode 100644 index 0000000000000000000000000000000000000000..084c6ce25665d6d8df954abee7f5d821c776ea5e --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/entity/Exercise.java @@ -0,0 +1,33 @@ +package tk.sr.exerciseservice.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import java.text.SimpleDateFormat; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.Date; +import java.util.SimpleTimeZone; + +@Data +@Entity +@NoArgsConstructor +@AllArgsConstructor +public class Exercise { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private int exerciseId; + private String name; + private int reps; + private int sets; + private double weight; + + +} + diff --git a/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/repository/ExerciseRepository.java b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/repository/ExerciseRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..f8bab23e5f9998cc00ad7e40970aefcdd832d0e5 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/repository/ExerciseRepository.java @@ -0,0 +1,14 @@ +package tk.sr.exerciseservice.repository; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.stereotype.Repository; +import tk.sr.exerciseservice.entity.Exercise; + +import java.util.List; + +@Repository +public interface ExerciseRepository extends CrudRepository<Exercise, Integer> { + + List<Exercise> findAll(); + +} diff --git a/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/service/ExerciseService.java b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/service/ExerciseService.java new file mode 100644 index 0000000000000000000000000000000000000000..2a921ab6f6549f8e01a66d92e65d9540ea660d76 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/service/ExerciseService.java @@ -0,0 +1,12 @@ +package tk.sr.exerciseservice.service; +import org.springframework.stereotype.Service; +import tk.sr.exerciseservice.entity.Exercise; +import java.util.List; +import java.util.Optional; + +@Service +public interface ExerciseService { + Iterable<Exercise> getExercises(); + Optional<Exercise> getExerciseById(Integer ExerciseId); + Exercise addExercise(Exercise exercise); +} diff --git a/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/service/PersistentExerciseService.java b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/service/PersistentExerciseService.java new file mode 100644 index 0000000000000000000000000000000000000000..185877353999b9547945ed0c9543535d8f81f9d7 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/service/PersistentExerciseService.java @@ -0,0 +1,45 @@ +package tk.sr.exerciseservice.service; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.PathVariable; +import tk.sr.exerciseservice.entity.Exercise; +import tk.sr.exerciseservice.repository.ExerciseRepository; + +import javax.annotation.PostConstruct; +import java.util.List; +import java.util.Optional; + +@Service +public class PersistentExerciseService implements ExerciseService{ + private final ExerciseRepository exerciseRepository; + public PersistentExerciseService(ExerciseRepository exerciseRepository ){ + this.exerciseRepository = exerciseRepository; + } + + + @PostConstruct + public void init(){ + exerciseRepository.save(new Exercise(1,"Glute Kicks", 10, 3, 18.0)); + exerciseRepository.save(new Exercise(2,"Hip Thrusts", 10, 3, 30.2)); + exerciseRepository.save(new Exercise(3,"Face Pulls", 10, 3, 28.0)); + } + + @Override + public Iterable<Exercise> getExercises() { + return exerciseRepository.findAll(); + } + + @Override + public Optional<Exercise> getExerciseById(@PathVariable "exerciseId" Integer exerciseId) { + return exerciseRepository.findById(exerciseId); + } + + + @Override + public Exercise addExercise(Exercise exercise) { + return exerciseRepository.save(exercise); + } + + + +} + diff --git a/exercise-service/exercise-service/exercise-service/src/main/resources/application.properties b/exercise-service/exercise-service/exercise-service/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..9762af33abef2cc7839093842817a489505cb3f6 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/src/main/resources/application.properties @@ -0,0 +1,11 @@ +management.endpoints.web.exposure.include=* + +spring.datasource.url=jdbc:postgresql://localhost:5432/postgres +spring.datasource.username=postgres +spring.datasource.password=Hidu123 + +spring.jpa.hibernate.ddl-auto=create + +logging.level.root=INFO + +server.port=8070 diff --git a/exercise-service/exercise-service/exercise-service/src/main/resources/templates/index.html b/exercise-service/exercise-service/exercise-service/src/main/resources/templates/index.html new file mode 100644 index 0000000000000000000000000000000000000000..320e794a6974dd7641ee4a0d2d5f7ab32fae3580 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/src/main/resources/templates/index.html @@ -0,0 +1,38 @@ +<!DOCTYPE> +<html> +<head> + <title> + ExerciseService + </title> +</head> +<body> +<h1> + Training +</h1> + +<form action="#" th:action="@{/web/exercises}" method="post" th:object="${exercise}"> + <input type="submit" th:value="Speichern"> + <input th:field="*{name}" placeholder="Name"> + <input th:field="*{reps}" placeholder="Reps"> + <input th:field="*{sets}" placeholder="Sets"> + <input th:field="*{weight}" placeholder="Weight"> +</form> +<table> + <th>exerciseId</th> + <th>name</th> + <th>reps</th> + <th>sets</th> + <th>weight</th> + + <tr th:each="exercise : ${exercises}"> + <td th:text="${exercise.exerciseId}"></td> + <td th:text="${exercise.name}"></td> + <td th:text="${exercise.reps}"></td> + <td th:text="${exercise.sets}"></td> + <td th:text="${exercise.weight}"></td> + </tr> +</table> + + +</body> +</html> \ No newline at end of file diff --git a/exercise-service/exercise-service/exercise-service/src/test/java/tk/sr/exerciseservice/ExerciseServiceApplicationTests.java b/exercise-service/exercise-service/exercise-service/src/test/java/tk/sr/exerciseservice/ExerciseServiceApplicationTests.java new file mode 100644 index 0000000000000000000000000000000000000000..492b79d7cb0c24b6553ce7a5b8cc735e9ebed583 --- /dev/null +++ b/exercise-service/exercise-service/exercise-service/src/test/java/tk/sr/exerciseservice/ExerciseServiceApplicationTests.java @@ -0,0 +1,13 @@ +package tk.sr.exerciseservice; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ExerciseServiceApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/exercise-service/exercise-service/mvnw b/exercise-service/exercise-service/mvnw new file mode 100644 index 0000000000000000000000000000000000000000..8a8fb2282df5b8f7263470a5a2dc0e196f35f35f --- /dev/null +++ b/exercise-service/exercise-service/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/exercise-service/exercise-service/mvnw.cmd b/exercise-service/exercise-service/mvnw.cmd new file mode 100644 index 0000000000000000000000000000000000000000..1d8ab018eaf11d9b3a4a90e7818ace373dfbb380 --- /dev/null +++ b/exercise-service/exercise-service/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/exercise-service/exercise-service/pom.xml b/exercise-service/exercise-service/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..6617db4c404cb86b87ecf60e1ec47ece9b292ad2 --- /dev/null +++ b/exercise-service/exercise-service/pom.xml @@ -0,0 +1,58 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.7.0</version> + <relativePath/> <!-- lookup parent from repository --> + </parent> + <groupId>tk.sr</groupId> + <artifactId>exercise-service</artifactId> + <version>0.0.1-SNAPSHOT</version> + <name>exercise-service</name> + <description>Demo project for Spring Boot</description> + <properties> + <java.version>11</java.version> + </properties> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <excludes> + <exclude> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/ExerciseServiceApplication.java b/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/ExerciseServiceApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..8dac2f8f8b94a41661c03bc7512e8b8751840b30 --- /dev/null +++ b/exercise-service/exercise-service/src/main/java/tk/sr/exerciseservice/ExerciseServiceApplication.java @@ -0,0 +1,13 @@ +package tk.sr.exerciseservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ExerciseServiceApplication { + + public static void main(String[] args) { + SpringApplication.run(ExerciseServiceApplication.class, args); + } + +} diff --git a/exercise-service/exercise-service/src/main/resources/application.properties b/exercise-service/exercise-service/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /dev/null +++ b/exercise-service/exercise-service/src/main/resources/application.properties @@ -0,0 +1 @@ + diff --git a/exercise-service/exercise-service/src/test/java/tk/sr/exerciseservice/ExerciseServiceApplicationTests.java b/exercise-service/exercise-service/src/test/java/tk/sr/exerciseservice/ExerciseServiceApplicationTests.java new file mode 100644 index 0000000000000000000000000000000000000000..492b79d7cb0c24b6553ce7a5b8cc735e9ebed583 --- /dev/null +++ b/exercise-service/exercise-service/src/test/java/tk/sr/exerciseservice/ExerciseServiceApplicationTests.java @@ -0,0 +1,13 @@ +package tk.sr.exerciseservice; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ExerciseServiceApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/training-service/training-service/.gitignore b/training-service/training-service/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..549e00a2a96fa9d7c5dbc9859664a78d980158c2 --- /dev/null +++ b/training-service/training-service/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### 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/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/training-service/training-service/mvnw b/training-service/training-service/mvnw new file mode 100644 index 0000000000000000000000000000000000000000..8a8fb2282df5b8f7263470a5a2dc0e196f35f35f --- /dev/null +++ b/training-service/training-service/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/training-service/training-service/mvnw.cmd b/training-service/training-service/mvnw.cmd new file mode 100644 index 0000000000000000000000000000000000000000..1d8ab018eaf11d9b3a4a90e7818ace373dfbb380 --- /dev/null +++ b/training-service/training-service/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/training-service/training-service/pom.xml b/training-service/training-service/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..5e4a56208866e874a071a12f68d00b9eca8ee16b --- /dev/null +++ b/training-service/training-service/pom.xml @@ -0,0 +1,104 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.7.0</version> + <relativePath/> <!-- lookup parent from repository --> + </parent> + <groupId>tk.sr</groupId> + <artifactId>training-service</artifactId> + <version>0.0.1-SNAPSHOT</version> + <name>training-service</name> + <description>Demo project for Spring Boot</description> + <properties> + <java.version>11</java.version> + <spring-cloud.version>2021.0.3-SNAPSHOT</spring-cloud.version> + </properties> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-starter-openfeign</artifactId> + </dependency> + + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-thymeleaf</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-jpa</artifactId> + </dependency> + <dependency> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + </dependency> + </dependencies> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-dependencies</artifactId> + <version>${spring-cloud.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <excludes> + <exclude> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + </exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </build> + <repositories> + <repository> + <id>spring-snapshots</id> + <name>Spring Snapshots</name> + <url>https://repo.spring.io/snapshot</url> + <releases> + <enabled>false</enabled> + </releases> + </repository> + <repository> + <id>spring-milestones</id> + <name>Spring Milestones</name> + <url>https://repo.spring.io/milestone</url> + <snapshots> + <enabled>false</enabled> + </snapshots> + </repository> + </repositories> + +</project> diff --git a/training-service/training-service/src/main/java/tk/sr/trainingservice/TrainingServiceApplication.java b/training-service/training-service/src/main/java/tk/sr/trainingservice/TrainingServiceApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..cff86d2c984371c730d49e3e5a4210e4ca5a4b82 --- /dev/null +++ b/training-service/training-service/src/main/java/tk/sr/trainingservice/TrainingServiceApplication.java @@ -0,0 +1,15 @@ +package tk.sr.trainingservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@EnableFeignClients +@SpringBootApplication +public class TrainingServiceApplication { + + public static void main(String[] args) { + SpringApplication.run(TrainingServiceApplication.class, args); + } + +} diff --git a/training-service/training-service/src/main/java/tk/sr/trainingservice/controller/TrainingUIController.java b/training-service/training-service/src/main/java/tk/sr/trainingservice/controller/TrainingUIController.java new file mode 100644 index 0000000000000000000000000000000000000000..9131977cbacb4c75f32213ca25f2e56b916612a8 --- /dev/null +++ b/training-service/training-service/src/main/java/tk/sr/trainingservice/controller/TrainingUIController.java @@ -0,0 +1,58 @@ +package tk.sr.trainingservice.controller; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; +import tk.sr.trainingservice.entity.Athlete; +import tk.sr.trainingservice.entity.Exercise; +import tk.sr.trainingservice.service.AthleteService; +import tk.sr.trainingservice.service.ExerciseService; + +import java.util.List; + + +@Slf4j +@Controller +public class TrainingUIController { + private final AthleteService athleteService; + private final ExerciseService exerciseService; + + + public TrainingUIController(AthleteService athleteService, ExerciseService exerciseService) { + this.athleteService = athleteService; + this.exerciseService = exerciseService; + } + + + @GetMapping("/web/trainings") + public String trainings(Model model) {//Model ist Verbindung zwischen Controller und dem Frontend + var athletes = athleteService.getAthletes(); + model.addAttribute("athlete", new Athlete()); + model.addAttribute("athletes", athletes); + var exercises = exerciseService.getExercises(); + model.addAttribute("exercise", new Exercise()); + model.addAttribute("exercises", exercises); + return "index"; + } + + @PostMapping("/web/trainings") + public String saveTraining(@ModelAttribute Athlete athlete) { + log.info("Received POST from Thymeleaf with athletes {} ", athlete); + return "redirect:/web/trainings"; + } + + @GetMapping("/web/trainingsZwei") + public String trainingsZwei(Model model) {//Model ist Verbindung zwischen Controller und dem Frontend + var athletes = athleteService.getAthleteById(1); + model.addAttribute("athlete", new Athlete()); + model.addAttribute("athletes", athletes); + var exercises = exerciseService.getExercises(); + model.addAttribute("exercise", new Exercise()); + model.addAttribute("exercises", exercises); + return "index"; + } + +} diff --git a/training-service/training-service/src/main/java/tk/sr/trainingservice/entity/Athlete.java b/training-service/training-service/src/main/java/tk/sr/trainingservice/entity/Athlete.java new file mode 100644 index 0000000000000000000000000000000000000000..299d0a21ed925d316ec07de17951a41132d55b7a --- /dev/null +++ b/training-service/training-service/src/main/java/tk/sr/trainingservice/entity/Athlete.java @@ -0,0 +1,15 @@ +package tk.sr.trainingservice.entity; + +import lombok.Data; + +@Data +public class Athlete { + private int athleteId; + private String username; + private String password; + private String firstname; + private String lastname; + private int age; + private double height; + private double weight; +} diff --git a/training-service/training-service/src/main/java/tk/sr/trainingservice/entity/Exercise.java b/training-service/training-service/src/main/java/tk/sr/trainingservice/entity/Exercise.java new file mode 100644 index 0000000000000000000000000000000000000000..773dba44842b17abbdd52fa4596557eb8a03a5d1 --- /dev/null +++ b/training-service/training-service/src/main/java/tk/sr/trainingservice/entity/Exercise.java @@ -0,0 +1,14 @@ +package tk.sr.trainingservice.entity; + +import lombok.Data; + + +@Data + +public class Exercise { + private int exerciseId; + private String name; + private int reps; + private int sets; + private double weight; +} diff --git a/training-service/training-service/src/main/java/tk/sr/trainingservice/entity/Training.java b/training-service/training-service/src/main/java/tk/sr/trainingservice/entity/Training.java new file mode 100644 index 0000000000000000000000000000000000000000..a5e14edb04ed553bb43d4adf516b77b1ceebf121 --- /dev/null +++ b/training-service/training-service/src/main/java/tk/sr/trainingservice/entity/Training.java @@ -0,0 +1,13 @@ +package tk.sr.trainingservice.entity; + +import lombok.Data; + +import java.util.List; + +@Data +public class Training { + private Athlete athlete; + private List<Exercise> exercises; +} + + diff --git a/training-service/training-service/src/main/java/tk/sr/trainingservice/service/AthleteService.java b/training-service/training-service/src/main/java/tk/sr/trainingservice/service/AthleteService.java new file mode 100644 index 0000000000000000000000000000000000000000..dfe7135548dae4b56920203abb2f2c7c724c6939 --- /dev/null +++ b/training-service/training-service/src/main/java/tk/sr/trainingservice/service/AthleteService.java @@ -0,0 +1,21 @@ +package tk.sr.trainingservice.service; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import tk.sr.trainingservice.entity.Athlete; + + +import java.util.List; + +@FeignClient(name ="AthleteService", url = "http://localhost:8080") +public interface AthleteService { + @RequestMapping(method = RequestMethod.GET, value = "/athletes") + List<Athlete> getAthletes(); + + @RequestMapping(method = RequestMethod.GET, value = "/athletes/{id}") + Athlete getAthleteById(@PathVariable Integer id); + + +} diff --git a/training-service/training-service/src/main/java/tk/sr/trainingservice/service/ExerciseService.java b/training-service/training-service/src/main/java/tk/sr/trainingservice/service/ExerciseService.java new file mode 100644 index 0000000000000000000000000000000000000000..274486293313348e24602663c9bd18c5b4bb6c09 --- /dev/null +++ b/training-service/training-service/src/main/java/tk/sr/trainingservice/service/ExerciseService.java @@ -0,0 +1,19 @@ +package tk.sr.trainingservice.service; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import tk.sr.trainingservice.entity.Exercise; + +import java.util.List; + +@FeignClient(name ="ExerciseService", url = "http://localhost:8070") +public interface ExerciseService{ + @RequestMapping(method = RequestMethod.GET, value = "/exercises") + List<Exercise> getExercises(); + + @RequestMapping(method = RequestMethod.GET, value = "/exercises/{id}") + Exercise getExerciseById(@PathVariable Integer id); + +} diff --git a/training-service/training-service/src/main/resources/application.properties b/training-service/training-service/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..08bfe3c4ff6fe107f709c1fd8648352da3a49b6f --- /dev/null +++ b/training-service/training-service/src/main/resources/application.properties @@ -0,0 +1,11 @@ +management.endpoints.web.exposure.include=* + +spring.datasource.url=jdbc:postgresql://localhost:5432/postgres +spring.datasource.username=postgres +spring.datasource.password=Hidu123 + +spring.jpa.hibernate.ddl-auto=create + +logging.level.root=INFO + +server.port=8090 diff --git a/training-service/training-service/src/main/resources/templates/index.html b/training-service/training-service/src/main/resources/templates/index.html new file mode 100644 index 0000000000000000000000000000000000000000..e33785ab7121461b7dcc0bfa1734f4de6a5753df --- /dev/null +++ b/training-service/training-service/src/main/resources/templates/index.html @@ -0,0 +1,183 @@ +<!DOCTYPE> +<html> +<head> + <title> + TrainingService + </title> + <style> + body { + background-color: white; + } + + h1 { + color: black; + } + + table { + border-collapse: separate; + border-spacing: 0.2em; + } + th{ + background-color: lightgray; + } + + th, + td { + padding: 0.2em 0.5em; + border-radius: 0.1em; + } + + td { + font-style: italic; + text-align: right; + box-shadow: inset 1px 3px 5px -3px rgba(0, 0, 0, 0.5); + } + + tbody tr:nth-child(even) { + background-color: powderblue; + color: #000; + } + + input#button, input#button2 { + box-shadow: 0px 7px 14px -7px #276873; + background:linear-gradient(to bottom, #599bb3 5%, #408c99 100%); + background-color:powderblue; + border-radius:8px; + display:inline-block; + cursor:pointer; + color:black; + font-family:Arial; + font-size:11px; + font-weight:bold; + padding:4px 10px; + text-decoration:none; + text-shadow:0px 1px 0px #3d768a; + width: 120px; + } + input#button:hover, input#button2:hover{ + background:linear-gradient(to bottom, #408c99 5%, #599bb3 100%); + background-color:#408c99; + } + input#button:active, input#button2:active { + position:relative; + top:1px; + } + + input { + border: none; + -webkit-appearance: none; + -ms-appearance: none; + -moz-appearance: none; + appearance: none; + background: #f2f2f2; + padding: 5px; + border-radius: 3px; + width: 200px; + font-size: 14px; + } + input, label { + margin: 10px; + } + + + </style> +</head> +<body> +<h1> + Trainings +</h1> +<h2> + Athletes +</h2> + +<form action="#" th:action="@{/web/athletes}" method="post" th:object="${athlete}"> + <div> + <label for="AthleteId">AthleteID</label> + <input th:field="*{athleteId}" placeholder="AthleteId"> + <label for="Username">Username</label> + <input th:field="*{username}" placeholder="Username"> + <label for="password">Password</label> + <input th:field="*{password}" placeholder="Password"> + </div> + <div> + <label for="firstname">Firstname</label> + <input th:field="*{firstname}" placeholder="Firstname"> + <label for="lastname">Lastname</label> + <input th:field="*{lastname}" placeholder="Lastname"> + </div> + <div> + <label for="age">Age</label> + <input th:field="*{age}" placeholder="Age"> + <label for="heigth">Height</label> + <input th:field="*{height}" placeholder="Height"> + <label for="weight">Weight</label> + <input th:field="*{weight}" placeholder="Weight"> + </div> + <div> + <br></br> + <input id="button" type="submit" th:value="Speichern" > +</form> +<table> + <th>athleteId</th> + <th>username</th> + <th>password</th> + <th>firstname</th> + <th>lastname</th> + <th>age</th> + <th>height</th> + <th>weight</th> + + + <tr th:each="athlete : ${athletes}"> + <td th:text="${athlete.athleteId}"></td> + <td th:text="${athlete.username}"></td> + <td th:text="${athlete.password}"></td> + <td th:text="${athlete.firstname}"></td> + <td th:text="${athlete.lastname}"></td> + <td th:text="${athlete.age}"></td> + <td th:text="${athlete.height}"></td> + <td th:text="${athlete.weight}"></td> + </tr> +</table> +<h2> + Exercises +</h2> + +<form action="#" th:action="@{/web/exercises}" method="post" th:object="${exercise}"> + <div> + <label for="exerciseId">ExerciseId</label> + <input th:field="*{exerciseId}" placeholder="ExerciseId"> + <label for="name">Name</label> + <input th:field="*{name}" placeholder="Name"> + </div> + <div> + <label for="reps">Reps</label> + <input th:field="*{reps}" placeholder="Reps"> + <label for="sets">Sets</label> + <input th:field="*{sets}" placeholder="Sets"> + <label for="weight">Weight</label> + <input th:field="*{weight}" placeholder="Weight"> + </div> + <br></br> + <input id="button2" type="submit" th:value="Speichern"> +</form> +<table> + <th>exerciseId</th> + <th>name</th> + <th>reps</th> + <th>sets</th> + <th>weight</th> + + <tr th:each="exercise : ${exercises}"> + <td th:text="${exercise.exerciseId}"></td> + <td th:text="${exercise.name}"></td> + <td th:text="${exercise.reps}"></td> + <td th:text="${exercise.sets}"></td> + <td th:text="${exercise.weight}"></td> + </tr> +</table> + + +</body> +</html> + diff --git a/training-service/training-service/src/main/resources/templates/style.css b/training-service/training-service/src/main/resources/templates/style.css new file mode 100644 index 0000000000000000000000000000000000000000..c31aeb1e5897ffba271360c785e3464974182b82 --- /dev/null +++ b/training-service/training-service/src/main/resources/templates/style.css @@ -0,0 +1,6 @@ +body { + background-color: powderblue; +} +h1 { + color: blue; +} diff --git a/training-service/training-service/src/test/java/tk/sr/trainingservice/TrainingServiceApplicationTests.java b/training-service/training-service/src/test/java/tk/sr/trainingservice/TrainingServiceApplicationTests.java new file mode 100644 index 0000000000000000000000000000000000000000..272e80bb110fd85ebbb3599ab9d141a527161fd8 --- /dev/null +++ b/training-service/training-service/src/test/java/tk/sr/trainingservice/TrainingServiceApplicationTests.java @@ -0,0 +1,13 @@ +package tk.sr.trainingservice; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class TrainingServiceApplicationTests { + + @Test + void contextLoads() { + } + +}