parent
80c30e5bfc
commit
6cd4763d62
|
@ -1,32 +1,11 @@
|
|||
HELP.md
|
||||
/target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
/.gradle/
|
||||
/gradle/
|
||||
/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
/logs/
|
||||
/workdir/
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
https://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.channels.Channels;
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MavenWrapperDownloader {
|
||||
|
||||
/**
|
||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
||||
*/
|
||||
private static final String DEFAULT_DOWNLOAD_URL =
|
||||
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
|
||||
|
||||
/**
|
||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
||||
* use instead of the default one.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||
".mvn/wrapper/maven-wrapper.properties";
|
||||
|
||||
/**
|
||||
* Path where the maven-wrapper.jar will be saved to.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
||||
".mvn/wrapper/maven-wrapper.jar";
|
||||
|
||||
/**
|
||||
* Name of the property which should be used to override the default download url for the wrapper.
|
||||
*/
|
||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("- Downloader started");
|
||||
File baseDirectory = new File(args[0]);
|
||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||
|
||||
// If the maven-wrapper.properties existsByName, read it and check if it contains a custom
|
||||
// wrapperUrl parameter.
|
||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||
String url = DEFAULT_DOWNLOAD_URL;
|
||||
if(mavenWrapperPropertyFile.exists()) {
|
||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||
try {
|
||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||
Properties mavenWrapperProperties = new Properties();
|
||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||
} catch (IOException e) {
|
||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||
} finally {
|
||||
try {
|
||||
if(mavenWrapperPropertyFileInputStream != null) {
|
||||
mavenWrapperPropertyFileInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Ignore ...
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading from: : " + url);
|
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
if(!outputFile.getParentFile().exists()) {
|
||||
if(!outputFile.getParentFile().mkdirs()) {
|
||||
System.out.println(
|
||||
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||
try {
|
||||
downloadFileFromURL(url, outputFile);
|
||||
System.out.println("Done");
|
||||
System.exit(0);
|
||||
} catch (Throwable e) {
|
||||
System.out.println("- Error downloading");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||
URL website = new URL(urlString);
|
||||
ReadableByteChannel rbc;
|
||||
rbc = Channels.newChannel(website.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(destination);
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
fos.close();
|
||||
rbc.close();
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
|
|
@ -0,0 +1,69 @@
|
|||
group = "dev.fyloz.trial.colorrecipesexplorer"
|
||||
version = "1.3.1"
|
||||
description = "Color Recipes Explorer"
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
id("org.jetbrains.kotlin.jvm") version "1.4.0"
|
||||
id("org.jetbrains.dokka") version "1.4.0-rc"
|
||||
id("com.leobia.gradle.sassjavacompiler") version "0.2.1"
|
||||
id("io.freefair.lombok") version "5.2.1"
|
||||
id("org.springframework.boot") version "2.3.4.RELEASE"
|
||||
}
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
implementation("org.jetbrains.kotlin:kotlin-reflect")
|
||||
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.11.3")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
||||
|
||||
implementation("org.springframework.boot:spring-boot-starter-data-jpa:2.1.4.RELEASE")
|
||||
implementation("org.springframework.boot:spring-boot-starter-jdbc:2.1.4.RELEASE")
|
||||
implementation("org.springframework.boot:spring-boot-starter-thymeleaf:2.1.4.RELEASE")
|
||||
implementation("org.springframework.boot:spring-boot-starter-web:2.1.4.RELEASE")
|
||||
implementation("org.apache.poi:poi-ooxml:4.1.0")
|
||||
implementation("org.apache.pdfbox:pdfbox:2.0.4")
|
||||
implementation("org.springframework.boot:spring-boot-configuration-processor:2.1.4.RELEASE")
|
||||
implementation("org.springframework.boot:spring-boot-devtools:2.1.4.RELEASE")
|
||||
implementation("com.atlassian.commonmark:commonmark:0.13.1")
|
||||
implementation("commons-io:commons-io:2.6")
|
||||
implementation("org.springframework:spring-test:5.1.6.RELEASE")
|
||||
implementation("org.springframework.boot:spring-boot-test-autoconfigure:2.1.4.RELEASE")
|
||||
implementation("org.mockito:mockito-core:2.23.4")
|
||||
implementation("org.junit.jupiter:junit-jupiter-api:5.3.2")
|
||||
|
||||
runtimeOnly("com.h2database:h2:1.4.199")
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test:2.1.6.RELEASE")
|
||||
compileOnly("org.projectlombok:lombok:1.18.10")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
testLogging {
|
||||
events("passed", "skipped", "failed")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.compilerArgs.addAll(arrayOf("--release", "11"))
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "11"
|
||||
}
|
||||
|
||||
tasks.dokkaHtml {
|
||||
outputDirectory = "$buildDir/dokka"
|
||||
}
|
|
@ -0,0 +1,185 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
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
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
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
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
exec "$JAVACMD" "$@"
|
|
@ -0,0 +1,89 @@
|
|||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem 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, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
|
@ -0,0 +1,2 @@
|
|||
# This file is generated by the 'io.freefair.lombok' Gradle plugin
|
||||
config.stopBubbling = true
|
|
@ -1,286 +0,0 @@
|
|||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
# TODO classpath?
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
curl -o "$wrapperJarPath" "$jarUrl"
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
|
@ -1,161 +0,0 @@
|
|||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven2 Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
|
||||
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
echo Found %WRAPPER_JAR%
|
||||
) else (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
134
pom.xml
134
pom.xml
|
@ -1,134 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://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.1.4.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>dev.fyloz.trial.colorrecipesexplorer</groupId>
|
||||
<artifactId>ColorRecipesExplorer</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<name>Color Recipes Explorer</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!--spring-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>2.0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark</artifactId>
|
||||
<version>0.13.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>2.1.6.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.junit.jupiter</groupId>-->
|
||||
<!-- <artifactId>junit-jupiter</artifactId>-->
|
||||
<!-- <version>LATEST</version>-->
|
||||
<!-- <scope>compile</scope>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.19.1</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-surefire-provider</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.6.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1 @@
|
|||
rootProject.name = "ColorRecipesExplorer"
|
|
@ -1,17 +0,0 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.config.CREProperties;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.config.MaterialTypeProperties;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties({MaterialTypeProperties.class, CREProperties.class})
|
||||
public class ColorRecipesExplorerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ColorRecipesExplorerApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.config.CREProperties
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.config.MaterialTypeProperties
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.boot.runApplication
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(MaterialTypeProperties::class, CREProperties::class)
|
||||
open class ColorRecipesExplorerApplication
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<ColorRecipesExplorerApplication>(*args)
|
||||
}
|
|
@ -13,7 +13,6 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
|
|
@ -4,7 +4,7 @@ import dev.fyloz.trial.colorrecipesexplorer.core.model.Material;
|
|||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class TooLowQuantityException extends Exception {
|
||||
public class TooLowQuantityException extends RuntimeException {
|
||||
|
||||
private Long mixId;
|
||||
private Material material;
|
||||
|
|
|
@ -4,8 +4,6 @@ import dev.fyloz.trial.colorrecipesexplorer.core.model.IModel;
|
|||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
|
||||
import javax.swing.text.html.parser.Entity;
|
||||
|
||||
@Getter
|
||||
public class EntityAlreadyExistsException extends ModelException {
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.io.file;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.Preferences;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.io.file;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.Preferences;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.Recipe;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.RecipeService;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.io.response;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.Preferences;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.utils.ControllerUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.HashMap;
|
||||
|
@ -72,7 +72,7 @@ public abstract class ResponseBuilder<T extends ResponseBuilder, R> {
|
|||
return (T) this;
|
||||
}
|
||||
|
||||
public T addResponseData(ResponseDataType responseDataType, @NotNull Object data) {
|
||||
public T addResponseData(ResponseDataType responseDataType, Object data) {
|
||||
Class requiredDataTypeClass = responseDataType.getDataType();
|
||||
Class requiredListDataTypeClass = responseDataType.getListDataType();
|
||||
Class givenDataTypeClass = data.getClass();
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.model;
|
||||
|
||||
public interface IModel {
|
||||
Long getId();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.model
|
||||
|
||||
interface IModel {
|
||||
val id: Long?
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.model;
|
||||
|
||||
import lombok.*;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Material implements IModel {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.SEQUENCE)
|
||||
private Long id;
|
||||
|
||||
@NonNull
|
||||
@NotNull
|
||||
@NotEmpty
|
||||
@Column(unique = true)
|
||||
private String name;
|
||||
|
||||
@NonNull
|
||||
@NotNull
|
||||
private Float inventoryQuantity;
|
||||
|
||||
@NonNull
|
||||
@NotNull
|
||||
private boolean isMixType;
|
||||
|
||||
@NonNull
|
||||
@NotNull
|
||||
@ManyToOne
|
||||
private MaterialType materialType;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Material material = (Material) o;
|
||||
return Objects.equals(name, material.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(name);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.model
|
||||
|
||||
import org.springframework.lang.Nullable
|
||||
import javax.persistence.*
|
||||
import javax.validation.constraints.NotEmpty
|
||||
import javax.validation.constraints.NotNull
|
||||
|
||||
@Entity
|
||||
data class Material(
|
||||
@Nullable @Id @GeneratedValue(strategy = GenerationType.SEQUENCE) override val id: Long?,
|
||||
@NotNull @NotEmpty @Column(unique = true) var name: String?,
|
||||
@NotNull var inventoryQuantity: Float,
|
||||
@NotNull val isMixType: Boolean,
|
||||
@NotNull @ManyToOne var materialType: MaterialType?
|
||||
) : IModel {
|
||||
constructor(name: String, inventoryQuantity: Float, isMixType: Boolean, materialType: MaterialType) : this(null, name, inventoryQuantity, isMixType, materialType)
|
||||
constructor() : this(-1L, "", 0f, false, null)
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return other is Material && name == other.name
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return name.hashCode()
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class InventoryDto {
|
||||
|
||||
private Long mixId;
|
||||
private List<Long> materials;
|
||||
private List<Float> quantities;
|
||||
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.model.dto
|
||||
|
||||
data class InventoryDto(val mixId: Long, val materialIds: List<Long>, val quantities: List<Float>)
|
|
@ -1,80 +0,0 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.services;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.exception.TooLowQuantityException;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.Material;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.dto.InventoryDto;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MaterialService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class InventoryService {
|
||||
|
||||
private MaterialService materialService;
|
||||
|
||||
@Autowired
|
||||
public void setMaterialService(MaterialService materialService) {
|
||||
this.materialService = materialService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Utilise tous les produits demandés.
|
||||
*
|
||||
* @param mixes Tous les produits à utiliser
|
||||
* @throws TooLowQuantityException Lorsqu'il n'y a pas assez d'un produit dans l'inventaire
|
||||
*/
|
||||
@Transactional
|
||||
public void use(List<InventoryDto> mixes) throws TooLowQuantityException {
|
||||
for (InventoryDto mix : mixes) {
|
||||
List<Material> materials = convertMaterialIdsToMaterials(mix.getMaterials());
|
||||
|
||||
for (int i = 0; i < materials.size(); i++) {
|
||||
Material material = materials.get(i);
|
||||
Float quantity = mix.getQuantities().get(i);
|
||||
|
||||
if (!hasEnoughStock(material, quantity))
|
||||
throw new TooLowQuantityException(mix.getMixId(), material, material.getInventoryQuantity(), quantity);
|
||||
|
||||
useMaterial(material, quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Utilise un produit.
|
||||
*
|
||||
* @param material Le produit à utiliser
|
||||
* @param quantity La quantité à utiliser
|
||||
*/
|
||||
private void useMaterial(Material material, Float quantity) {
|
||||
material.setInventoryQuantity(material.getInventoryQuantity() - quantity);
|
||||
materialService.update(material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vérifie s'il y a assez d'un produit dans l'inventaire pour l'utiliser.
|
||||
*
|
||||
* @param material Le produit à vérifier
|
||||
* @param quantity La quantité à utiliser
|
||||
* @return S'il y a assez de produit dans l'inventaire pour l'utiliser
|
||||
*/
|
||||
private boolean hasEnoughStock(Material material, Float quantity) {
|
||||
return material.getInventoryQuantity() >= quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convertit une liste d'identifiant de produit en produits.
|
||||
*
|
||||
* @param ids Les identifiant à convertir
|
||||
* @return Les produits correspondant aux identifiants
|
||||
*/
|
||||
private List<Material> convertMaterialIdsToMaterials(List<Long> ids) {
|
||||
return ids.stream()
|
||||
.map(i -> materialService.getById(i))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.services
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.exception.TooLowQuantityException
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.Material
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.dto.InventoryDto
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MaterialService
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
@Service
|
||||
class InventoryService {
|
||||
@Autowired
|
||||
lateinit var materialService: MaterialService
|
||||
|
||||
/**
|
||||
* Use all materials in the given [mixes].
|
||||
* @throws TooLowQuantityException When there is not enough stock for a material
|
||||
*/
|
||||
fun use(mixes: List<InventoryDto>) {
|
||||
mixes.forEach { mix ->
|
||||
val materials = mix.materialIds.toMaterials()
|
||||
|
||||
materials.forEachIndexed { index, material ->
|
||||
val quantity = mix.quantities[index]
|
||||
|
||||
if (!material.hasEnoughStock(quantity))
|
||||
throw TooLowQuantityException(mix.mixId, material, material.inventoryQuantity, quantity)
|
||||
|
||||
material.use(quantity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Convert material ids to [Material]s. */
|
||||
private fun List<Long>.toMaterials(): List<Material> {
|
||||
return map { materialService.getById(it) }
|
||||
}
|
||||
|
||||
/** Check if there is at least the given [quantity] in stock for a [Material]. */
|
||||
private fun Material.hasEnoughStock(quantity: Float): Boolean {
|
||||
return inventoryQuantity >= quantity
|
||||
}
|
||||
|
||||
/** Use a given [Material], for the given [quantity]. */
|
||||
private fun Material.use(quantity: Float) {
|
||||
inventoryQuantity -= quantity
|
||||
materialService.update(this)
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.services.files;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.Preferences;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.ResourceLoader;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.services.files;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.services.files;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.exception.SimdutException;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.Material;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MaterialService;
|
||||
|
@ -125,7 +124,7 @@ public class SimdutService {
|
|||
* @return Le nom du fichier SIMDUT du produit
|
||||
*/
|
||||
public String getSimdutFileName(Material material) {
|
||||
return material.getId().toString();
|
||||
return String.valueOf(material.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.services.files;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.Preferences;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.Recipe;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.RecipeService;
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -99,6 +98,9 @@ public class MaterialService extends AbstractService<Material, MaterialDao> {
|
|||
}
|
||||
|
||||
public Material save(@NotNull Material material, MultipartFile file) {
|
||||
if (existsByName(material.getName()))
|
||||
throw new EntityAlreadyExistsException(type, ModelException.IdentifierType.NAME, material.getName());
|
||||
|
||||
Material saved = save(material);
|
||||
|
||||
if (!file.isEmpty()) simdutService.write(saved, file);
|
||||
|
@ -109,7 +111,7 @@ public class MaterialService extends AbstractService<Material, MaterialDao> {
|
|||
@Override
|
||||
public Material update(Material material) {
|
||||
Optional<Material> materialByName = dao.findByName(material.getName());
|
||||
if (materialByName.isPresent() && !material.getId().equals(materialByName.get().getId()))
|
||||
if (materialByName.isPresent() && material.getId() != materialByName.get().getId())
|
||||
throw new EntityAlreadyExistsException(type, ModelException.IdentifierType.NAME, material.getName());
|
||||
|
||||
return super.update(material);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.core.utils;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.Preferences;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.web.controller
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseCode
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.utils.ControllerUtils
|
||||
import org.springframework.web.servlet.ModelAndView
|
||||
|
||||
fun modelAndView(model: ModelAndView = ModelAndView(), op: ModelAndView.() -> Unit = {}) = model.apply {
|
||||
addObject("baseUrl", ControllerUtils.getCurrentBaseUrl())
|
||||
addObject("referer", ControllerUtils.getLatestUrl())
|
||||
apply(op)
|
||||
}
|
||||
|
||||
fun modelAndView(viewName: String, op: ModelAndView.() -> Unit = {}) = modelAndView(ModelAndView(viewName), op)
|
||||
|
||||
fun ModelAndView.message(responseCode: ResponseCode, vararg parameters: Any?) {
|
||||
addObject(if (responseCode.type == ResponseCode.ResponseCodeType.ERROR) "error" else "success", "response.${responseCode.code}")
|
||||
parameters.forEachIndexed { index, param ->
|
||||
addObject("responseArg${index + 1}", param)
|
||||
}
|
||||
}
|
|
@ -21,7 +21,6 @@ import org.springframework.web.servlet.ModelAndView;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.fyloz.trial.colorrecipesexplorer.web.StringBank.RESPONSE_REASON;
|
||||
import static dev.fyloz.trial.colorrecipesexplorer.web.WebsitePaths.INVENTORY;
|
||||
|
|
|
@ -3,7 +3,6 @@ package dev.fyloz.trial.colorrecipesexplorer.web.controller;
|
|||
import dev.fyloz.trial.colorrecipesexplorer.core.exception.model.EntityNotFoundException;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ModelResponseBuilder;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseCode;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.Material;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.files.MarkdownFilesService;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MixService;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.RecipeService;
|
||||
|
@ -17,9 +16,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static dev.fyloz.trial.colorrecipesexplorer.web.StringBank.MATERIALS;
|
||||
import static dev.fyloz.trial.colorrecipesexplorer.web.WebsitePaths.*;
|
||||
|
||||
|
|
|
@ -1,63 +1,66 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.web.controller.creators;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.exception.SimdutException;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.exception.model.EntityAlreadyExistsException;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ModelResponseBuilder;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseCode;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseDataType;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.Material;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MaterialService;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MaterialTypeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static dev.fyloz.trial.colorrecipesexplorer.web.WebsitePaths.CREATOR_MATERIAL;
|
||||
|
||||
@Controller
|
||||
public class MaterialCreatorController {
|
||||
|
||||
private MaterialService materialService;
|
||||
private MaterialTypeService materialTypeService;
|
||||
|
||||
@Autowired
|
||||
public MaterialCreatorController(MaterialService materialService, MaterialTypeService materialTypeService) {
|
||||
this.materialService = materialService;
|
||||
this.materialTypeService = materialTypeService;
|
||||
}
|
||||
|
||||
@GetMapping(CREATOR_MATERIAL)
|
||||
public ModelAndView getPage(ModelAndView model, Material material) {
|
||||
return new ModelResponseBuilder(model)
|
||||
.withView(CREATOR_MATERIAL)
|
||||
.addResponseData(ResponseDataType.MATERIAL, material != null ? material : new Material())
|
||||
.addResponseData(ResponseDataType.MATERIAL_TYPES, materialTypeService.getAll())
|
||||
.build();
|
||||
}
|
||||
|
||||
@PostMapping(value = CREATOR_MATERIAL, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public ModelAndView createMaterial(@Valid Material material, MultipartFile simdut) {
|
||||
ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder();
|
||||
|
||||
try {
|
||||
materialService.save(material, simdut);
|
||||
return getPage(
|
||||
modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_SAVING_MATERIAL, material.getName()).build(),
|
||||
null
|
||||
);
|
||||
} catch (EntityAlreadyExistsException ex) {
|
||||
modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_ALREADY_EXIST, material.getName());
|
||||
} catch (SimdutException ex) {
|
||||
modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_SAVING_MATERIAL, material.getName());
|
||||
modelResponseBuilder.addResponseCode(ResponseCode.ERROR_SAVING_SIMDUT);
|
||||
}
|
||||
|
||||
return getPage(modelResponseBuilder.build(), material);
|
||||
}
|
||||
}
|
||||
//package dev.fyloz.trial.colorrecipesexplorer.web.controller.creators;
|
||||
//
|
||||
//import dev.fyloz.trial.colorrecipesexplorer.core.exception.SimdutException;
|
||||
//import dev.fyloz.trial.colorrecipesexplorer.core.exception.model.EntityAlreadyExistsException;
|
||||
//import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ModelResponseBuilder;
|
||||
//import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseCode;
|
||||
//import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseDataType;
|
||||
//import dev.fyloz.trial.colorrecipesexplorer.core.model.Material;
|
||||
//import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MaterialService;
|
||||
//import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MaterialTypeService;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.http.MediaType;
|
||||
//import org.springframework.lang.Nullable;
|
||||
//import org.springframework.stereotype.Controller;
|
||||
//import org.springframework.web.bind.annotation.GetMapping;
|
||||
//import org.springframework.web.bind.annotation.PostMapping;
|
||||
//import org.springframework.web.multipart.MultipartFile;
|
||||
//import org.springframework.web.servlet.ModelAndView;
|
||||
//
|
||||
//import javax.validation.Valid;
|
||||
//
|
||||
//import java.util.Optional;
|
||||
//
|
||||
//import static dev.fyloz.trial.colorrecipesexplorer.web.WebsitePaths.CREATOR_MATERIAL;
|
||||
//
|
||||
//@Controller
|
||||
//public class MaterialCreatorController {
|
||||
//
|
||||
// private MaterialService materialService;
|
||||
// private MaterialTypeService materialTypeService;
|
||||
//
|
||||
// @Autowired
|
||||
// public MaterialCreatorController(MaterialService materialService, MaterialTypeService materialTypeService) {
|
||||
// this.materialService = materialService;
|
||||
// this.materialTypeService = materialTypeService;
|
||||
// }
|
||||
//
|
||||
// @GetMapping(CREATOR_MATERIAL)
|
||||
// public ModelAndView getPage(ModelAndView model, Material material) {
|
||||
// return new ModelResponseBuilder(model)
|
||||
// .withView(CREATOR_MATERIAL)
|
||||
//// .addResponseData(ResponseDataType.MATERIAL, material)
|
||||
//// .addResponseData(ResponseDataType.MATERIAL_TYPES, materialTypeService.getAll())
|
||||
// .build();
|
||||
// }
|
||||
//
|
||||
// @PostMapping(value = CREATOR_MATERIAL, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
// public ModelAndView createMaterial(@Valid Material material, MultipartFile simdut) {
|
||||
// ModelResponseBuilder modelResponseBuilder = new ModelResponseBuilder();
|
||||
//
|
||||
// try {
|
||||
// materialService.save(material, simdut);
|
||||
// return getPage(
|
||||
// modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_SAVING_MATERIAL, material.getName()).build(),
|
||||
// new Material()
|
||||
// );
|
||||
// } catch (EntityAlreadyExistsException ex) {
|
||||
// modelResponseBuilder.addResponseCode(ResponseCode.MATERIAL_ALREADY_EXIST, material.getName());
|
||||
// } catch (SimdutException ex) {
|
||||
// modelResponseBuilder.addResponseCode(ResponseCode.SUCCESS_SAVING_MATERIAL, material.getName());
|
||||
// modelResponseBuilder.addResponseCode(ResponseCode.ERROR_SAVING_SIMDUT);
|
||||
// }
|
||||
//
|
||||
// return getPage(modelResponseBuilder.build(), material);
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.web.controller.creators
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.exception.SimdutException
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.exception.model.EntityAlreadyExistsException
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.io.response.ResponseCode
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.Material
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MaterialService
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.services.model.MaterialTypeService
|
||||
import dev.fyloz.trial.colorrecipesexplorer.web.WebsitePaths.CREATOR_MATERIAL
|
||||
import dev.fyloz.trial.colorrecipesexplorer.web.controller.message
|
||||
import dev.fyloz.trial.colorrecipesexplorer.web.controller.modelAndView
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.stereotype.Controller
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import org.springframework.web.multipart.MultipartFile
|
||||
import org.springframework.web.servlet.ModelAndView
|
||||
import javax.validation.Valid
|
||||
|
||||
@Controller
|
||||
class MaterialCreatorController(val materialService: MaterialService, val materialTypeService: MaterialTypeService) {
|
||||
@GetMapping(CREATOR_MATERIAL)
|
||||
fun getPage(model: ModelAndView, @RequestParam(required = false) material: Material? = null): ModelAndView {
|
||||
return modelAndView(model) {
|
||||
viewName = CREATOR_MATERIAL
|
||||
addObject("material", material ?: Material())
|
||||
addObject("materialTypes", materialTypeService.all)
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping(value = [CREATOR_MATERIAL], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
|
||||
fun createMaterial(@Valid material: Material, simdut: MultipartFile): ModelAndView {
|
||||
return getPage(modelAndView {
|
||||
try {
|
||||
materialService.save(material, simdut)
|
||||
message(ResponseCode.SUCCESS_SAVING_MATERIAL, material.name)
|
||||
} catch (ex: EntityAlreadyExistsException) {
|
||||
message(ResponseCode.MATERIAL_ALREADY_EXIST, material.name)
|
||||
} catch (ex: SimdutException) {
|
||||
message(ResponseCode.SUCCESS_SAVING_MATERIAL, material.name)
|
||||
message(ResponseCode.ERROR_SAVING_SIMDUT)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.PathVariable;
|
|||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.fyloz.trial.colorrecipesexplorer.web.WebsitePaths.REMOVER_MATERIAL;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.xlsx;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.Preferences;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.Mix;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.model.MixQuantity;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package dev.fyloz.trial.colorrecipesexplorer.xlsx.component;
|
||||
|
||||
import dev.fyloz.trial.colorrecipesexplorer.ColorRecipesExplorerApplication;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.core.Preferences;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.xlsx.builder.SheetBuilder;
|
||||
import dev.fyloz.trial.colorrecipesexplorer.xlsx.exception.InvalidCellTypeException;
|
||||
|
|
|
@ -33,9 +33,9 @@ h1 {
|
|||
}
|
||||
|
||||
.descriptionCell {
|
||||
border-right-color: #e6e6e6;
|
||||
border-right-style: solid;
|
||||
border-right-width: 2px;
|
||||
/*border-right-color: #e6e6e6;*/
|
||||
/*border-right-style: solid;*/
|
||||
/*border-right-width: 2px;*/
|
||||
}
|
||||
|
||||
.researchEnabled .companyTab:not(.researchResult), .researchEnabled .recipeRow:not(.researchResult) {
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
$(() => {
|
||||
$(".recipeRow").each(function () {
|
||||
if (!$(this).data("approbationdate")) {
|
||||
$(this).addClass("unapproved");
|
||||
$(this).attr({title: recipeNotApproved})
|
||||
const icon = $(this).find(".icon");
|
||||
icon.removeAttr("hidden");
|
||||
icon.attr({title: recipeNotApproved})
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
<head th:fragment="head(title, styleName)">
|
||||
<title th:text="${title}"></title>
|
||||
<meta charset="UTF-8"/>
|
||||
<!-- <link rel="stylesheet" th:href="@{|${baseUrl}/css/bootstrap/bootstrap.min.css|}"/>-->
|
||||
<link rel="stylesheet" th:href="@{|${baseUrl}/css/main.css|}"/>
|
||||
<link rel="stylesheet" th:href="@{|${baseUrl}/css/menu.css|}"/>
|
||||
<link rel="stylesheet" th:href="@{|${baseUrl}/css/flex.css|}"/>
|
||||
|
@ -169,6 +170,7 @@
|
|||
th:text="#{footer.lang}"></a>
|
||||
</th:block>
|
||||
|
||||
<!-- <script th:src="@{|${baseUrl}/js/libs/bootstrap/bootstrap.min.js|}"></script>-->
|
||||
<script th:src="@{|${baseUrl}/js/libs/jquery-3.4.1.min.js|}"></script>
|
||||
<script th:src="@{|${baseUrl}/js/libs/jquery-ui-1.12.1/jquery-ui.min.js|}"></script>
|
||||
<script th:src="@{|${baseUrl}/js/libs/axios.min.js|}"></script>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
<th th:text="#{recipe.description}"></th>
|
||||
<th th:text="#{recipe.sample}"></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<tr class="recipeRow" th:each="recipe : ${recipeMap.get(company)}"
|
||||
th:data-approbationDate="${recipe.approbationDate}" th:data-recipeId="${recipe.id}">
|
||||
|
@ -39,6 +40,10 @@
|
|||
<button class="gotoRecipe" th:data-recipeid="${recipe.id}" type="button"
|
||||
th:text="#{keyword.see}"></button>
|
||||
</td>
|
||||
<td>
|
||||
<img class="icon" th:src="@{|${baseUrl}/icons/warning.svg|}" alt="warning icon"
|
||||
style="padding-top: 3px" hidden/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
<form th:action="@{/material/creator}" th:object="${material}" class="requireAuth" enctype="multipart/form-data"
|
||||
method="POST">
|
||||
<input type="hidden" name="isMixType" th:value="false" required />
|
||||
<div class="content">
|
||||
<div class="formWrap">
|
||||
<div class="formColumn">
|
||||
|
|
Loading…
Reference in New Issue