diff --git a/countriesflex/.gitignore b/countriesflex/.gitignore new file mode 100644 index 00000000..549e00a2 --- /dev/null +++ b/countriesflex/.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/countriesflex/.mvn/wrapper/MavenWrapperDownloader.java b/countriesflex/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 00000000..a45eb6ba --- /dev/null +++ b/countriesflex/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,118 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/countriesflex/.mvn/wrapper/maven-wrapper.jar b/countriesflex/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 00000000..2cc7d4a5 Binary files /dev/null and b/countriesflex/.mvn/wrapper/maven-wrapper.jar differ diff --git a/countriesflex/.mvn/wrapper/maven-wrapper.properties b/countriesflex/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..ffdc10e5 --- /dev/null +++ b/countriesflex/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/countriesflex/mvnw b/countriesflex/mvnw new file mode 100644 index 00000000..a16b5431 --- /dev/null +++ b/countriesflex/mvnw @@ -0,0 +1,310 @@ +#!/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 /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="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.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" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$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 \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/countriesflex/mvnw.cmd b/countriesflex/mvnw.cmd new file mode 100644 index 00000000..c8d43372 --- /dev/null +++ b/countriesflex/mvnw.cmd @@ -0,0 +1,182 @@ +@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 "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.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 "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/countriesflex/pom.xml b/countriesflex/pom.xml new file mode 100644 index 00000000..d5f1b6ef --- /dev/null +++ b/countriesflex/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.8.RELEASE + + + com.example + countriesflex + 0.0.1-SNAPSHOT + countriesflex + Demo project for Spring Boot + + 11 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.h2database + h2 + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/countriesflex/src/main/java/com/example/countriesflex/CountriesflexApplication.java b/countriesflex/src/main/java/com/example/countriesflex/CountriesflexApplication.java new file mode 100644 index 00000000..7e602d85 --- /dev/null +++ b/countriesflex/src/main/java/com/example/countriesflex/CountriesflexApplication.java @@ -0,0 +1,13 @@ +package com.example.countriesflex; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CountriesflexApplication { + + public static void main(String[] args) { + SpringApplication.run(CountriesflexApplication.class, args); + } + +} diff --git a/countriesflex/src/main/java/com/example/countriesflex/controllers/CountryController.java b/countriesflex/src/main/java/com/example/countriesflex/controllers/CountryController.java new file mode 100644 index 00000000..5fd4378c --- /dev/null +++ b/countriesflex/src/main/java/com/example/countriesflex/controllers/CountryController.java @@ -0,0 +1,40 @@ +package com.example.countriesflex.controllers; + + +import com.example.countriesflex.models.Country; +import com.example.countriesflex.services.CountryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +public class CountryController { +@Autowired + CountryService countryService; + + @GetMapping(value = "/names/all", produces = "application/json") + public ResponseEntity listAllCountries() + { + List returnList = countryService.getAllCountries(); + return new ResponseEntity<>(returnList, HttpStatus.OK); + } + + @GetMapping(value = "/population/total", produces = "application/json") + public ResponseEntity listTotalPopulation() + { + + long returnTotalPop = countryService.getPopulationTotal(); + System.out.println("The Total Population is " + returnTotalPop); + return new ResponseEntity<>(HttpStatus.OK); + + + + } + + @GetMapping(value = "/") + +} diff --git a/countriesflex/src/main/java/com/example/countriesflex/models/Country.java b/countriesflex/src/main/java/com/example/countriesflex/models/Country.java new file mode 100644 index 00000000..27d4f346 --- /dev/null +++ b/countriesflex/src/main/java/com/example/countriesflex/models/Country.java @@ -0,0 +1,66 @@ +package com.example.countriesflex.models; + +import javax.persistence.*; + +@Entity +@Table(name = "countries") +public class Country { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long countryid; + private String name; + private long population; + private long landmasskm2; + private int medianage; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public long getPopulation() { + return population; + } + + public void setPopulation(long population) { + this.population = population; + } + + public long getLandmasskm2() { + return landmasskm2; + } + + public void setLandmasskm2(long landmasskm2) { + this.landmasskm2 = landmasskm2; + } + + public int getMedianage() { + return medianage; + } + + public void setMedianage(int medianage) { + this.medianage = medianage; + } + + public long getCountryid() { + return countryid; + } + + public void setCountryid(long countryid) { + this.countryid = countryid; + } + + public Country() { + } + + public Country(String name, long population, long landmasskm2, int medianage) { + this.name = name; + this.population = population; + this.landmasskm2 = landmasskm2; + this.medianage = medianage; + } +} diff --git a/countriesflex/src/main/java/com/example/countriesflex/repositories/CountryRepository.java b/countriesflex/src/main/java/com/example/countriesflex/repositories/CountryRepository.java new file mode 100644 index 00000000..68213c7f --- /dev/null +++ b/countriesflex/src/main/java/com/example/countriesflex/repositories/CountryRepository.java @@ -0,0 +1,10 @@ +package com.example.countriesflex.repositories; + +import com.example.countriesflex.models.Country; +import org.springframework.data.repository.CrudRepository; + +public interface CountryRepository extends CrudRepository { + + + +} diff --git a/countriesflex/src/main/java/com/example/countriesflex/services/CountryService.java b/countriesflex/src/main/java/com/example/countriesflex/services/CountryService.java new file mode 100644 index 00000000..d432453d --- /dev/null +++ b/countriesflex/src/main/java/com/example/countriesflex/services/CountryService.java @@ -0,0 +1,15 @@ +package com.example.countriesflex.services; + +import com.example.countriesflex.models.Country; + +import java.util.List; + +public interface CountryService { + + List getAllCountries(); + List countriesByLetter(char letter); + long getPopulationTotal(); + Country getMinPopulation(); + Country getMaxPopulation(); + +} diff --git a/countriesflex/src/main/java/com/example/countriesflex/services/CountryServiceImpl.java b/countriesflex/src/main/java/com/example/countriesflex/services/CountryServiceImpl.java new file mode 100644 index 00000000..785c72a1 --- /dev/null +++ b/countriesflex/src/main/java/com/example/countriesflex/services/CountryServiceImpl.java @@ -0,0 +1,48 @@ +package com.example.countriesflex.services; + +import com.example.countriesflex.models.Country; +import com.example.countriesflex.repositories.CountryRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service(value = "countryService") +public class CountryServiceImpl implements CountryService{ +@Autowired + CountryRepository countryRepository; + + @Override + public List getAllCountries() { + List returnList = new ArrayList<>(); + countryRepository.findAll().iterator().forEachRemaining((c) -> returnList.add(c)); + return returnList; + } + + @Override + public List countriesByLetter(char letter) { + return null; + } + + @Override + public long getPopulationTotal() { + List countryList = new ArrayList<>(); + countryRepository.findAll().iterator().forEachRemaining((c) -> countryList.add(c)); + long total = 0; + for (Country c : countryList) { + total += c.getPopulation(); + } + return total; + } + + @Override + public Country getMinPopulation() { + return null; + } + + @Override + public Country getMaxPopulation() { + return null; + } +} diff --git a/countriesflex/src/main/resources/application.properties b/countriesflex/src/main/resources/application.properties new file mode 100644 index 00000000..9a06ea3a --- /dev/null +++ b/countriesflex/src/main/resources/application.properties @@ -0,0 +1,20 @@ +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console +server.port=${PORT:2019} +# +# Feature that determines what happens when no accessors are found for a type +# (and there are no annotations to indicate it is meant to be serialized). +spring.jackson.serialization.fail-on-empty-beans=false +# Shows the generated and custom SQL but does hurt performance and the logs get full fast +# spring.jpa.show-sql=true +# spring.jpa.properties.hibernate.format_sql=true +# +# keeps a transaction inside of the same entity manager +# This property register an EntityManager to the current thread, +# so you will have the same EntityManager until the web request is finished. +spring.jpa.open-in-view=true +# +# What do with the schema +# drop n create table again, good for testing +spring.jpa.hibernate.ddl-auto=create +spring.datasource.initialization-mode=always diff --git a/countriesflex/src/main/resources/data.sql b/countriesflex/src/main/resources/data.sql new file mode 100644 index 00000000..79477590 --- /dev/null +++ b/countriesflex/src/main/resources/data.sql @@ -0,0 +1,213 @@ +DELETE +FROM countries; + +INSERT INTO countries (countryid, name, population, landmasskm2, medianage) +VALUES (1, 'China',1420062022,9388211,39), + (2, 'India',1368737513,2973190,28), + (3, 'U.S.',329093110,9147420,38), + (4, 'Indonesia',269536482,1811570,29), + (5, 'Brazil',212392717,8358140,33), + (6, 'Pakistan',204596442,770880,23), + (7, 'Nigeria',200962417,910770,18), + (8, 'Bangladesh',168065920,130170,27), + (9, 'Russia',143895551,16376870,40), + (10, 'Mexico',132328035,1943950,29), + (11, 'Japan',126854745,364555,48), + (12, 'Ethiopia',110135635,1000000,20), + (13, 'Philippines',108106310,298170,25), + (14, 'Egypt',101168745,995450,25), + (15, 'Viet Nam',97429061,310070,33), + (16, 'DR Congo',86727573,2267050,17), + (17, 'Turkey',82961805,769630,32), + (18, 'Iran',82820766,1628550,32), + (19, 'Germany',82438639,348560,47), + (20, 'Thailand',69306160,510890,40), + (21, 'U.K.',66959016,241930,41), + (22, 'France',65480710,547557,42), + (23, 'Tanzania',60913557,885800,18), + (24, 'Italy',59216525,294140,48), + (25, 'South Africa',58065097,1213090,27), + (26, 'Myanmar',54336138,653290,29), + (27, 'Kenya',52214791,569140,20), + (28, 'South Korea',51339238,97230,43), + (29, 'Colombia',49849818,1109500,32), + (30, 'Spain',46441049,498800,46), + (31, 'Uganda',45711874,199810,16), + (32, 'Argentina',45101781,2736690,32), + (33, 'Ukraine',43795220,579320,41), + (34, 'Algeria',42679018,2381740,29), + (35, 'Sudan',42514094,1765048,20), + (36, 'Iraq',40412299,434320,20), + (37, 'Poland',38028278,306230,42), + (38, 'Canada',37279811,9093510,41), + (39, 'Afghanistan',37209007,652860,19), + (40, 'Morocco',36635156,446300,30), + (41, 'Saudi Arabia',34140662,2149690,32), + (42, 'Peru',32933835,1280000,29), + (43, 'Uzbekistan',32807368,425400,28), + (44, 'Venezuela',32779868,882050,29), + (45, 'Malaysia',32454455,328550,30), + (46, 'Angola',31787566,1246700,17), + (47, 'Mozambique',31408823,786380,18), + (48, 'Ghana',30096970,227540,21), + (49, 'Nepal',29942018,143350,25), + (50, 'Yemen',29579986,527970,20), + (51, 'Madagascar',26969642,581795,20), + (52, 'North Korea',25727408,120410,35), + (53, 'Cote dIvoire',25531083,318000,19), + (54, 'Cameroon',25312993,472710,19), + (55, 'Australia',25088636,7682300,38), + (56, 'Taiwan',23758247,35410,42), + (57, 'Niger',23176691,1266700,15), + (58, 'Sri Lanka',21018859,62710,34), + (59, 'Burkina Faso',20321560,273600,18), + (60, 'Malawi',19718743,94280,18), + (61, 'Mali',19689140,1220190,16), + (62, 'Romania',19483360,230170,43), + (63, 'Kazakhstan',18592970,2699700,31), + (64, 'Syria',18499181,183630,22), + (65, 'Chile',18336653,743532,35), + (66, 'Zambia',18137369,743390,18), + (67, 'Guatemala',17577842,107160,23), + (68, 'Zimbabwe',17297495,386850,20), + (69, 'Netherlands',17132908,33720,43), + (70, 'Ecuador',17100444,248360,28), + (71, 'Senegal',16743859,192530,19), + (72, 'Cambodia',16482646,176520,26), + (73, 'Chad',15814345,1259200,17), + (74, 'Somalia',15636171,627340,17), + (75, 'Guinea',13398180,245720,19), + (76, 'South Sudan',13263184,610952,19), + (77, 'Rwanda',12794412,24670,20), + (78, 'Benin',11801595,112760,19), + (79, 'Tunisia',11783168,155360,33), + (80, 'Burundi',11575964,25680,18), + (81, 'Belgium',11562784,30280,42), + (82, 'Cuba',11492046,106440,43), + (83, 'Bolivia',11379861,1083300,25), + (84, 'Haiti',11242856,27560,24), + (85, 'Greece',11124603,128900,45), + (86, 'Dominican Republic',10996774,48320,28), + (87, 'Czech Republic',10630589,77240,43), + (88, 'Portugal',10254666,91590,46), + (89, 'Jordan',10069794,88780,23), + (90, 'Sweden',10053135,410340,41), + (91, 'Azerbaijan',10014575,82658,32), + (92, 'United Arab Emirates',9682088,83600,34), + (93, 'Hungary',9655361,90530,43), + (94, 'Honduras',9568688,111890,25), + (95, 'Belarus',9433874,202910,40), + (96, 'Tajikistan',9292000,139960,23), + (97, 'Austria',8766201,82409,44), + (98, 'Serbia',8733407,87460,41), + (99, 'Switzerland',8608259,39516,43), + (100, 'Papua New Guinea',8586525,452860,23), + (101, 'Israel',8583916,21640,31), + (102, 'Togo',8186384,54390,19), + (103, 'Sierra Leone',7883123,72180,19), + (104, 'Hong Kong',7490776,1050,45), + (105, 'Laos',7064242,230800,24), + (106, 'Bulgaria',6988739,108560,45), + (107, 'Paraguay',6981981,397300,27), + (108, 'Libya',6569864,1759540,29), + (109, 'El Salvador',6445405,20720,28), + (110, 'Nicaragua',6351157,120340,27), + (111, 'Kyrgyzstan',6218616,191800,26), + (112, 'Lebanon',6065922,10230,31), + (113, 'Turkmenistan',5942561,469930,27), + (114, 'Singapore',5868104,700,42), + (115, 'Denmark',5775224,42430,42), + (116, 'Finland',5561389,303890,43), + (117, 'Congo',5542197,341500,19), + (118, 'Slovakia',5450987,48088,41), + (119, 'Norway',5400916,365268,40), + (120, 'Eritrea',5309659,101000,19), + (121, 'State of Palestine',5186790,6020,20), + (122, 'Oman',5001875,309500,31), + (123, 'Costa Rica',4999384,51060,34), + (124, 'Liberia',4977720,96320,19), + (125, 'Ireland',4847139,68890,39), + (126, 'Central African Republic',4825711,622980,18), + (127, 'New Zealand',4792409,263310,38), + (128, 'Mauritania',4661149,1030700,20), + (129, 'Kuwait',4248974,17820,34), + (130, 'Panama',4226197,74340,30), + (131, 'Croatia',4140148,55960,44), + (132, 'Moldova',4029750,32850,38), + (133, 'Georgia',3904204,69490,39), + (134, 'Puerto Rico',3654978,8870,38), + (135, 'Bosnia & Herzegovina',3501774,51000,42), + (136, 'Uruguay',3482156,175020,36), + (137, 'Mongolia',3166244,1553560,29), + (138, 'Albania',2938428,27400,38), + (139, 'Armenia',2936706,28470,36), + (140, 'Jamaica',2906339,10830,31), + (141, 'Lithuania',2864459,62674,43), + (142, 'Qatar',2743901,11610,32), + (143, 'Namibia',2641996,823290,22), + (144, 'Botswana',2374636,566730,26), + (145, 'Lesotho',2292682,30360,22), + (146, 'Gambia',2228075,10120,18), + (147, 'Gabon',2109099,257670,23), + (148, 'TFYR Macedonia',2086720,25220,39), + (149, 'Slovenia',2081900,20140,45), + (150, 'Guinea-Bissau',1953723,28120,19), + (151, 'Latvia',1911108,62200,44), + (152, 'Bahrain',1637896,760,32), + (153, 'Swaziland',1415414,17200,21), + (154, 'Trinidad and Tobago',1375443,5130,36), + (155, 'Equatorial Guinea',1360104,28050,22), + (156, 'Timor-Leste',1352360,14870,18), + (157, 'Estonia',1303798,42390,43), + (158, 'Mauritius',1271368,2030,37), + (159, 'Cyprus',1198427,9240,37), + (160, 'Djibouti',985690,23180,25), + (161, 'Fiji',918757,18270,29), + (162, 'Reunion',889918,2500,36), + (163, 'Comoros',850910,1861,20), + (164, 'Bhutan',826229,38117,29), + (165, 'Guyana',786508,196850,26), + (166, 'Macao',642090,30,39), + (167, 'Solomon Islands',635254,27990,21), + (168, 'Montenegro',629355,13450,39), + (169, 'Luxembourg',596992,2590,40), + (170, 'Western Sahara',582478,266000,28), + (171, 'Suriname',573085,156000,30), + (172, 'Cabo Verde',560349,4030,26), + (173, 'Maldives',451738,300,31), + (174, 'Guadeloupe',448798,1690,43), + (175, 'Brunei',439336,5270,32), + (176, 'Malta',433245,320,42), + (177, 'Bahamas',403095,10010,34), + (178, 'Belize',390231,22810,25), + (179, 'Martinique',385320,1060,46), + (180, 'Iceland',340566,100250,37), + (181, 'French Guiana',296847,82200,25), + (182, 'French Polynesia',288506,3660,33), + (183, 'Vanuatu',288017,12190,23), + (184, 'Barbados',287010,430,40), + (185, 'New Caledonia',283376,18280,33), + (186, 'Mayotte',266380,375,20), + (187, 'Sao Tome & Principe',213379,960,19), + (188, 'Samoa',198909,2830,22), + (189, 'Saint Lucia',180454,610,35), + (190, 'Guam',167245,540,31), + (191, 'Channel Islands',166828,190,44), + (192, 'Curacao',162547,444,42), + (193, 'Kiribati',120428,810,23), + (194, 'St. Vincent & Grenadines',110488,390,32), + (195, 'Tonga',110041,720,22), + (196, 'Grenada',108825,340,29), + (197, 'Micronesia',106983,700,23), + (198, 'Aruba',106053,180,41), + (199, 'U.S. Virgin Islands',104909,350,42), + (200, 'Antigua and Barbuda',104084,440,32), + (201, 'Seychelles',95702,460,36); + +/* +We must tell hibernate the ids that have already been used. +The number must be larger than the last used id. +250 > 201 so we are good! + */ + +alter sequence hibernate_sequence restart with 250; \ No newline at end of file diff --git a/countriesflex/src/test/java/com/example/countriesflex/CountriesflexApplicationTests.java b/countriesflex/src/test/java/com/example/countriesflex/CountriesflexApplicationTests.java new file mode 100644 index 00000000..628cd72e --- /dev/null +++ b/countriesflex/src/test/java/com/example/countriesflex/CountriesflexApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.countriesflex; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class CountriesflexApplicationTests { + + @Test + void contextLoads() { + } + +}