Compare commits
162
Commits
main
...
eb996dd004
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb996dd004 | ||
|
|
f599aa1954 | ||
|
|
145aa5083c | ||
|
|
35e2fd44a5 | ||
|
|
ba68057c0f | ||
|
|
b411f5d57f | ||
|
|
29f00f39aa | ||
|
|
23cef6f545 | ||
|
|
2acc6acafe | ||
|
|
cbc4b4ff76 | ||
|
|
fbca245326 | ||
|
|
2514200eeb | ||
|
|
7c90434f0f | ||
|
|
d2ed44cc9a | ||
|
|
04f0188c3f | ||
|
|
a06efd5355 | ||
|
|
9cf286db39 | ||
|
|
4dcd994ac9 | ||
|
|
98b9321c12 | ||
|
|
7b721a5592 | ||
|
|
10c90e7d04 | ||
|
|
b1c95784ef | ||
|
|
d30ec92bb5 | ||
|
|
6ac9203fa1 | ||
|
|
b96b34e1a1 | ||
|
|
ee7a3004b3 | ||
|
|
4a024c4476 | ||
|
|
4c3f18f852 | ||
|
|
12164c03ae | ||
|
|
d078a182a1 | ||
|
|
ed69935657 | ||
|
|
3d4fd84a0a | ||
|
|
6e82e05298 | ||
|
|
3b3f8e7162 | ||
|
|
19e928e723 | ||
|
|
ef7f36982a | ||
|
|
7c869b8410 | ||
|
|
79d41f0f8a | ||
|
|
7516d802ca | ||
|
|
76adb595d5 | ||
|
|
102f2b8ba3 | ||
|
|
12aec6c37f | ||
|
|
5ea6511a48 | ||
|
|
95d71fa813 | ||
|
|
4220fd06cb | ||
|
|
632a39cd5d | ||
|
|
decf60fb0a | ||
|
|
7c5bbe65e5 | ||
|
|
3f10de8225 | ||
|
|
dac3f31a37 | ||
|
|
87c3dd21c6 | ||
|
|
d7296a5634 | ||
|
|
a9fcf76a85 | ||
|
|
37e5317d72 | ||
|
|
c301923c24 | ||
|
|
752b3253d9 | ||
|
|
3095dbd0e5 | ||
|
|
e286d1029c | ||
|
|
26b7545517 | ||
|
|
63ff6838de | ||
|
|
f5ef53aefd | ||
|
|
6ca8693258 | ||
|
|
b5fb2d6842 | ||
|
|
0c63d45dd6 | ||
|
|
61d6597578 | ||
|
|
c76a972286 | ||
|
|
34f906f622 | ||
|
|
e7a74694ba | ||
|
|
13effb5d59 | ||
|
|
ea2697e114 | ||
|
|
8ba07bab8e | ||
|
|
6099b55f6c | ||
|
|
363dd073e8 | ||
|
|
d9616956ee | ||
|
|
71546bd499 | ||
|
|
67ea5c7d97 | ||
|
|
f349b92973 | ||
|
|
f9c06971f0 | ||
|
|
c833f373bd | ||
|
|
54f1129021 | ||
|
|
0d640bd61d | ||
|
|
b76e125d31 | ||
|
|
2f0385f1f5 | ||
|
|
1c99d0a468 | ||
|
|
952f869f59 | ||
|
|
c959d62116 | ||
|
|
089b8eba08 | ||
|
|
af28e5cb6f | ||
|
|
287b96f03b | ||
|
|
76db3ba9d3 | ||
|
|
5ef306c853 | ||
|
|
3945b471b2 | ||
|
|
f8b53cfe52 | ||
|
|
824e0f35be | ||
|
|
d54a7089c8 | ||
|
|
14b45f638d | ||
|
|
70db634f10 | ||
|
|
cbcaeda25f | ||
|
|
23ad175f98 | ||
|
|
6fe026ee74 | ||
|
|
4f638c3111 | ||
|
|
0578c6ecbc | ||
|
|
221a2157cf | ||
|
|
50ba1198c7 | ||
|
|
4bd7af39a8 | ||
|
|
37030a67ec | ||
|
|
b100e4e2e8 | ||
|
|
a6145eed64 | ||
|
|
dbd2eb1737 | ||
|
|
27193999fc | ||
|
|
87c0383db8 | ||
|
|
dd9c8cc0af | ||
|
|
c1e8c901cd | ||
|
|
780bcf0c98 | ||
|
|
341f914b35 | ||
|
|
10e6348dcf | ||
|
|
f1ce35dcdf | ||
|
|
c53511939d | ||
|
|
5474e2a4d1 | ||
|
|
7367c5c86f | ||
|
|
2fcee30597 | ||
|
|
8cfb2a325a | ||
|
|
5862a99d73 | ||
|
|
fbbac7fdb0 | ||
|
|
7e09e96cb1 | ||
|
|
d42edcf01c | ||
|
|
2f411aae67 | ||
|
|
d54e8991d7 | ||
|
|
7f98b928bd | ||
|
|
7d9fc5aac1 | ||
|
|
53af82a429 | ||
|
|
3a5df3cae6 | ||
|
|
57baee27bd | ||
|
|
1e9ee8127c | ||
|
|
306bf69107 | ||
|
|
d8e70fb1b0 | ||
|
|
6579d3c003 | ||
|
|
72a6140925 | ||
|
|
81b68b27f7 | ||
|
|
2f66771b0d | ||
|
|
c7e9cd092f | ||
|
|
b09d7ed474 | ||
|
|
cdb1f92893 | ||
|
|
1b7bcbf9b0 | ||
|
|
93cbcb75a4 | ||
|
|
16d5baabef | ||
|
|
91e5ed50b7 | ||
|
|
126b9778c0 | ||
|
|
cb01b7bcb7 | ||
|
|
e4186457e2 | ||
|
|
ae2be9c425 | ||
|
|
d8af0b3d6c | ||
|
|
f22f9a929b | ||
|
|
bce0f3800c | ||
|
|
8828f4477a | ||
|
|
5b4667e8ae | ||
|
|
557cd59c8f | ||
|
|
e57f79c18b | ||
|
|
babfe66872 | ||
|
|
9c88c28151 | ||
|
|
a484010285 | ||
|
|
283efc775b |
+3
-2
@@ -1,6 +1,7 @@
|
||||
/.gradle/
|
||||
/.gradle
|
||||
/.idea/
|
||||
/.settings/
|
||||
/build/
|
||||
/gradle/
|
||||
/target/
|
||||
src/main/main.iml
|
||||
src/test/test.iml
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'application'
|
||||
|
||||
mainClassName = 'App'
|
||||
sourceCompatibility = 11
|
||||
targetCompatibility = 11
|
||||
version = '1.0'
|
||||
compileJava.options.encoding = 'UTF-8'
|
||||
compileTestJava.options.encoding = 'UTF-8'
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'mysql:mysql-connector-java:8.0.32'
|
||||
implementation 'org.apache.httpcomponents:httpclient:4.5.14'
|
||||
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
|
||||
implementation 'com.google.code.gson:gson:2.10.1'
|
||||
implementation platform('com.amazonaws:aws-java-sdk-bom:1.12.429')
|
||||
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.429'
|
||||
implementation 'com.google.auth:google-auth-library-oauth2-http:1.16.0'
|
||||
implementation 'com.google.api-client:google-api-client:2.2.0'
|
||||
implementation 'com.google.apis:google-api-services-calendar:v3-rev20220715-2.0.0'
|
||||
implementation 'com.google.guava:guava:31.1-jre'
|
||||
implementation 'commons-cli:commons-cli:1.5.0'
|
||||
implementation 'net.sourceforge.argparse4j:argparse4j:0.9.0'
|
||||
implementation 'org.apache.logging.log4j:log4j-api:2.20.0'
|
||||
implementation 'org.apache.logging.log4j:log4j-core:2.20.0'
|
||||
implementation 'javax.xml.bind:jaxb-api:2.3.1'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation 'org.testng:testng:7.7.0'
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes(
|
||||
'Main-Class': 'de.jeyp91.App'
|
||||
)
|
||||
}
|
||||
manifest.attributes(
|
||||
'Multi-Release': 'true'
|
||||
)
|
||||
from {
|
||||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
+6
@@ -0,0 +1,6 @@
|
||||
#Tue May 26 17:58:07 CEST 2020
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStorePath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
@@ -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" "$@"
|
||||
Vendored
+104
@@ -0,0 +1,104 @@
|
||||
@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 init
|
||||
|
||||
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 init
|
||||
|
||||
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
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
: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 %CMD_LINE_ARGS%
|
||||
|
||||
: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
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Restore tlw-database-tool') {
|
||||
steps {
|
||||
copyArtifacts filter: '**/tlw-database-tool-1.0.jar', fingerprintArtifacts: true, projectName: 'build tlw-database-tool', selector: lastSuccessful(), target: '.'
|
||||
}
|
||||
}
|
||||
stage('Execute') {
|
||||
steps {
|
||||
script {
|
||||
String jdkPath = tool name: 'OpenJDK19', type: 'jdk'
|
||||
withCredentials([
|
||||
usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_KEY'),
|
||||
usernamePassword(credentialsId: 'forum_database', usernameVariable: 'TLW_DATABASE_USERNAME', passwordVariable: 'TLW_DATABASE_PASSWORD'),
|
||||
usernamePassword(credentialsId: 'forum_user', usernameVariable: 'FORUM_USERNAME', passwordVariable: 'FORUM_PASSWORD')
|
||||
]) {
|
||||
withEnv([
|
||||
"JAVA_HOME=${jdkPath}/jdk-19.0.2"
|
||||
]) {
|
||||
try {
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode APIFootballUpdater --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesListGistUpdater --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
|
||||
} catch (Exception e) {
|
||||
telegramSendManual("TLW-Database-Tool crashed!")
|
||||
}
|
||||
String outputString = readFile 'log.txt'
|
||||
if(outputString != "") {
|
||||
ArrayList<String> outputList = outputString.replace("\n\n", "\n").split('\n').toList()
|
||||
outputList = clean(outputList)
|
||||
outputList.each {
|
||||
telegramSendManual(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Trigger Tool') {
|
||||
steps {
|
||||
echo 'Trigger jobs'
|
||||
build wait: false, job: 'TippligaUpdater'
|
||||
build wait: false, job: 'WTLPokalUpdater'
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
deleteDir()
|
||||
}
|
||||
failure {
|
||||
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> clean(ArrayList<String> orig) {
|
||||
ArrayList<String> cleaned = new ArrayList<String>()
|
||||
orig.each{line ->
|
||||
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
|
||||
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
cleaned.add(line)
|
||||
}
|
||||
return cleaned.unique()
|
||||
}
|
||||
|
||||
def telegramSendManual(String text) {
|
||||
def encodedMessage = URLEncoder.encode(text, "UTF-8")
|
||||
println encodedMessage
|
||||
httpRequest(
|
||||
httpMode: 'GET',
|
||||
contentType: 'APPLICATION_JSON',
|
||||
responseHandle: 'NONE',
|
||||
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
|
||||
wrapAsMultipart: false,
|
||||
consoleLogResponseBody: true
|
||||
)
|
||||
sleep 1
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Restore tlw-database-tool') {
|
||||
steps {
|
||||
copyArtifacts filter: '**/tlw-database-tool-1.0.jar', fingerprintArtifacts: true, projectName: 'build tlw-database-tool', selector: lastSuccessful(), target: '.'
|
||||
}
|
||||
}
|
||||
stage('GetAndWriteChecksum') {
|
||||
steps {
|
||||
script {
|
||||
String jdkPath = tool name: 'OpenJDK19', type: 'jdk'
|
||||
withCredentials([
|
||||
usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_KEY'),
|
||||
usernamePassword(credentialsId: 'forum_database', usernameVariable: 'TLW_DATABASE_USERNAME', passwordVariable: 'TLW_DATABASE_PASSWORD'),
|
||||
usernamePassword(credentialsId: 'forum_user', usernameVariable: 'FORUM_USERNAME', passwordVariable: 'FORUM_PASSWORD')
|
||||
]) {
|
||||
withEnv([
|
||||
"JAVA_HOME=${jdkPath}/jdk-19.0.2"
|
||||
]) {
|
||||
String checksum_tippliga = sh returnStdout: true, script: "java -jar build/libs/tlw-database-tool-1.0.jar --mode PostChecksum --season ${season} --league 1 --configFile Tippliga 2>&1"
|
||||
writeFile file: 'checksum_tippliga.txt', text: checksum_tippliga
|
||||
archiveArtifacts artifacts: 'checksum_tippliga.txt', followSymlinks: false
|
||||
String checksum_wtlpokal = sh returnStdout: true, script: "java -jar build/libs/tlw-database-tool-1.0.jar --mode PostChecksum --season ${season} --league 1 --configFile WTL-Pokal 2>&1"
|
||||
writeFile file: 'checksum_wtlpokal.txt', text: checksum_wtlpokal
|
||||
archiveArtifacts artifacts: 'checksum_wtlpokal.txt', followSymlinks: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('CompareChecksums') {
|
||||
steps {
|
||||
copyArtifacts filter: 'checksum*', fingerprintArtifacts: true, projectName: 'CheckGistUpdates', selector: lastWithArtifacts(), target: 'last'
|
||||
script {
|
||||
String checksumTippliga = readFile 'checksum_tippliga.txt'
|
||||
String lastChecksumTippliga = readFile 'last/checksum_tippliga.txt'
|
||||
String checksumWTLPokal = readFile 'checksum_wtlpokal.txt'
|
||||
String lastChecksumWTLPokal = readFile 'last/checksum_wtlpokal.txt'
|
||||
if(!checksumTippliga.equals(lastChecksumTippliga)){
|
||||
telegramSendManual('Tippliga Update')
|
||||
build wait: false, job: 'TippligaUpdater'
|
||||
}
|
||||
if(!checksumWTLPokal.equals(lastChecksumWTLPokal)){
|
||||
telegramSendManual('WTL-Pokal Update')
|
||||
build wait: false, job: 'WTLPokalUpdater'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
failure {
|
||||
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def telegramSendManual(String text) {
|
||||
sleep 1
|
||||
def encodedMessage = URLEncoder.encode(text, "UTF-8")
|
||||
println encodedMessage
|
||||
httpRequest(
|
||||
httpMode: 'GET',
|
||||
contentType: 'APPLICATION_JSON',
|
||||
responseHandle: 'NONE',
|
||||
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
|
||||
wrapAsMultipart: false,
|
||||
consoleLogResponseBody: true
|
||||
)
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Restore tlw-database-tool') {
|
||||
steps {
|
||||
copyArtifacts filter: '**/tlw-database-tool-1.0.jar', fingerprintArtifacts: true, projectName: 'build tlw-database-tool', selector: lastSuccessful(), target: '.'
|
||||
}
|
||||
}
|
||||
stage('Execute') {
|
||||
steps {
|
||||
script {
|
||||
String jdkPath = tool name: 'OpenJDK', type: 'jdk'
|
||||
withCredentials([
|
||||
usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_KEY'),
|
||||
usernamePassword(credentialsId: 'forum_database', usernameVariable: 'TLW_DATABASE_USERNAME', passwordVariable: 'TLW_DATABASE_PASSWORD'),
|
||||
usernamePassword(credentialsId: 'forum_user', usernameVariable: 'FORUM_USERNAME', passwordVariable: 'FORUM_PASSWORD')
|
||||
]) {
|
||||
withEnv([
|
||||
"JAVA_HOME=${jdkPath}/jdk-19.0.2"
|
||||
]) {
|
||||
try {
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesUpdaterFootball --season ${season} --league 45 --configFile Supercup 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchdaysUpdater --season ${season} --league 45 --configFile Supercup 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode TeamsUpdater --season ${season} --league 45 --configFile Supercup 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesResultsUpdater --season ${season} --league 45 --configFile Supercup 2>&1 >> log.txt"
|
||||
} catch (Exception e) {
|
||||
telegramSendManual("TLW-Database-Tool crashed!")
|
||||
}
|
||||
String outputString = readFile 'log.txt'
|
||||
if(outputString != "") {
|
||||
ArrayList<String> outputList = outputString.replace("\n\n", "\n").split('\n').toList()
|
||||
outputList = clean(outputList)
|
||||
outputList.each {
|
||||
telegramSendManual(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
deleteDir()
|
||||
}
|
||||
failure {
|
||||
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> clean(ArrayList<String> orig) {
|
||||
ArrayList<String> cleaned = new ArrayList<String>()
|
||||
orig.each{line ->
|
||||
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
|
||||
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
cleaned.add(line)
|
||||
}
|
||||
return cleaned.unique()
|
||||
}
|
||||
|
||||
def telegramSendManual(String text) {
|
||||
def encodedMessage = URLEncoder.encode(text, "UTF-8")
|
||||
println encodedMessage
|
||||
httpRequest(
|
||||
httpMode: 'GET',
|
||||
contentType: 'APPLICATION_JSON',
|
||||
responseHandle: 'NONE',
|
||||
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
|
||||
wrapAsMultipart: false,
|
||||
consoleLogResponseBody: true
|
||||
)
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Restore tlw-database-tool') {
|
||||
steps {
|
||||
copyArtifacts filter: '**/tlw-database-tool-1.0.jar', fingerprintArtifacts: true, projectName: 'build tlw-database-tool', selector: lastSuccessful(), target: '.'
|
||||
}
|
||||
}
|
||||
stage('Execute') {
|
||||
steps {
|
||||
script {
|
||||
String jdkPath = tool name: 'OpenJDK19', type: 'jdk'
|
||||
withCredentials([
|
||||
usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_KEY'),
|
||||
usernamePassword(credentialsId: 'forum_database', usernameVariable: 'TLW_DATABASE_USERNAME', passwordVariable: 'TLW_DATABASE_PASSWORD'),
|
||||
usernamePassword(credentialsId: 'forum_user', usernameVariable: 'FORUM_USERNAME', passwordVariable: 'FORUM_PASSWORD')
|
||||
]) {
|
||||
withEnv([
|
||||
"JAVA_HOME=${jdkPath}/jdk-19.0.2"
|
||||
]) {
|
||||
try {
|
||||
sh "ls build/libs"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesUpdaterFootball --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchdaysUpdater --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode TeamsUpdater --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesResultsUpdater --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesUpdaterFootball --season ${season} --league 2 --configFile Tippliga 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchdaysUpdater --season ${season} --league 2 --configFile Tippliga 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode TeamsUpdater --season ${season} --league 2 --configFile Tippliga 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesResultsUpdater --season ${season} --league 2 --configFile Tippliga 2>&1 >> log.txt"
|
||||
} catch (Exception e) {
|
||||
telegramSendManual("TLW-Database-Tool crashed!")
|
||||
}
|
||||
String outputString = readFile 'log.txt'
|
||||
if(outputString != "") {
|
||||
ArrayList<String> outputList = outputString.replace("\n\n", "\n").split('\n').toList()
|
||||
outputList = clean(outputList)
|
||||
outputList.each {
|
||||
telegramSendManual(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
deleteDir()
|
||||
}
|
||||
failure {
|
||||
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> clean(ArrayList<String> orig) {
|
||||
ArrayList<String> cleaned = new ArrayList<String>()
|
||||
orig.each{line ->
|
||||
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
|
||||
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
cleaned.add(line)
|
||||
}
|
||||
return cleaned.unique()
|
||||
}
|
||||
|
||||
def telegramSendManual(String text) {
|
||||
sleep 1
|
||||
if(text) {
|
||||
def encodedMessage = URLEncoder.encode(text, "UTF-8")
|
||||
println encodedMessage
|
||||
httpRequest(
|
||||
httpMode: 'GET',
|
||||
contentType: 'APPLICATION_JSON',
|
||||
responseHandle: 'NONE',
|
||||
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
|
||||
wrapAsMultipart: false,
|
||||
consoleLogResponseBody: true
|
||||
)
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Restore tlw-database-tool') {
|
||||
steps {
|
||||
copyArtifacts filter: '**/tlw-database-tool-1.0.jar', fingerprintArtifacts: true, projectName: 'build tlw-database-tool', selector: lastSuccessful(), target: '.'
|
||||
}
|
||||
}
|
||||
stage('Execute') {
|
||||
steps {
|
||||
script {
|
||||
String jdkPath = tool name: 'OpenJDK19', type: 'jdk'
|
||||
withCredentials([
|
||||
usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_KEY'),
|
||||
usernamePassword(credentialsId: 'forum_database', usernameVariable: 'TLW_DATABASE_USERNAME', passwordVariable: 'TLW_DATABASE_PASSWORD'),
|
||||
usernamePassword(credentialsId: 'forum_user', usernameVariable: 'FORUM_USERNAME', passwordVariable: 'FORUM_PASSWORD')
|
||||
]) {
|
||||
withEnv([
|
||||
"JAVA_HOME=${jdkPath}/jdk-19.0.2"
|
||||
]) {
|
||||
try {
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesUpdaterFootball --season ${season} --league 48 --configFile WTL-Pokal 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchdaysUpdater --season ${season} --league 48 --configFile WTL-Pokal 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode TeamsUpdater --season ${season} --league 48 --configFile WTL-Pokal 2>&1 >> log.txt"
|
||||
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesResultsUpdater --season ${season} --league 48 --configFile WTL-Pokal 2>&1 >> log.txt"
|
||||
} catch (Exception e) {
|
||||
telegramSendManual("TLW-Database-Tool crashed!")
|
||||
}
|
||||
String outputString = readFile 'log.txt'
|
||||
if(outputString != "") {
|
||||
ArrayList<String> outputList = outputString.replace("\n\n", "\n").split('\n').toList()
|
||||
outputList = clean(outputList)
|
||||
outputList.each {
|
||||
telegramSendManual(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
deleteDir()
|
||||
}
|
||||
failure {
|
||||
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> clean(ArrayList<String> orig) {
|
||||
ArrayList<String> cleaned = new ArrayList<String>()
|
||||
orig.each{line ->
|
||||
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
|
||||
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
cleaned.add(line)
|
||||
}
|
||||
return cleaned.unique()
|
||||
}
|
||||
|
||||
def telegramSendManual(String text) {
|
||||
def encodedMessage = URLEncoder.encode(text, "UTF-8")
|
||||
println encodedMessage
|
||||
httpRequest(
|
||||
httpMode: 'GET',
|
||||
contentType: 'APPLICATION_JSON',
|
||||
responseHandle: 'NONE',
|
||||
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
|
||||
wrapAsMultipart: false,
|
||||
consoleLogResponseBody: true
|
||||
)
|
||||
}
|
||||
Vendored
+78
@@ -0,0 +1,78 @@
|
||||
pipeline {
|
||||
agent any
|
||||
|
||||
stages {
|
||||
stage('Checkout') {
|
||||
steps {
|
||||
git branch: 'main', credentialsId: 'gitea', url: 'https://git.codeam.io/Julian/tlw-database-tool.git'
|
||||
}
|
||||
}
|
||||
stage('Build') {
|
||||
steps {
|
||||
script {
|
||||
String jdkPath = tool name: 'OpenJDK19', type: 'jdk'
|
||||
withCredentials([
|
||||
usernamePassword(credentialsId: 'aws', usernameVariable: 'AWS_ACCESS_KEY_ID', passwordVariable: 'AWS_SECRET_KEY'),
|
||||
usernamePassword(credentialsId: 'forum_database', usernameVariable: 'TLW_DATABASE_USERNAME', passwordVariable: 'TLW_DATABASE_PASSWORD'),
|
||||
usernamePassword(credentialsId: 'forum_user', usernameVariable: 'FORUM_USERNAME', passwordVariable: 'FORUM_PASSWORD')
|
||||
]) {
|
||||
withEnv([
|
||||
"JAVA_HOME=${jdkPath}/jdk-19.0.2"
|
||||
]) {
|
||||
sh returnStdout: false, script: "./gradlew build -x test"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Archive') {
|
||||
steps {
|
||||
archiveArtifacts artifacts: 'build/libs/tlw-database-tool-1.0.jar', followSymlinks: false
|
||||
}
|
||||
}
|
||||
stage('Trigger') {
|
||||
steps {
|
||||
echo 'Trigger jobs'
|
||||
build wait: false, job: 'TippligaUpdater'
|
||||
build wait: false, job: 'WTLPokalUpdater'
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
deleteDir()
|
||||
}
|
||||
failure {
|
||||
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> clean(ArrayList<String> orig) {
|
||||
ArrayList<String> cleaned = new ArrayList<String>()
|
||||
orig.each{line ->
|
||||
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
|
||||
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
cleaned.add(line)
|
||||
}
|
||||
return cleaned.unique()
|
||||
}
|
||||
|
||||
def telegramSendManual(String text) {
|
||||
def encodedMessage = URLEncoder.encode(text, "UTF-8")
|
||||
println encodedMessage
|
||||
httpRequest(
|
||||
httpMode: 'GET',
|
||||
contentType: 'APPLICATION_JSON',
|
||||
responseHandle: 'NONE',
|
||||
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
|
||||
wrapAsMultipart: false,
|
||||
consoleLogResponseBody: true
|
||||
)
|
||||
sleep 1
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*/
|
||||
|
||||
rootProject.name = 'tlw-database-tool'
|
||||
@@ -0,0 +1,134 @@
|
||||
package de.jeyp91;
|
||||
import de.jeyp91.apifootball.APIFootballUpdater;
|
||||
import de.jeyp91.googlecalendar.TippligaGoogleEventManager;
|
||||
import de.jeyp91.tippligaforum.MatchesListForumUpdater;
|
||||
import de.jeyp91.tippliga.*;
|
||||
import de.jeyp91.tippligaforum.TippligaConfigProvider;
|
||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||
import net.sourceforge.argparse4j.ArgumentParsers;
|
||||
import net.sourceforge.argparse4j.inf.ArgumentParser;
|
||||
import net.sourceforge.argparse4j.inf.ArgumentParserException;
|
||||
import net.sourceforge.argparse4j.inf.Namespace;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.core.config.Configurator;
|
||||
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
|
||||
import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
|
||||
import org.apache.logging.log4j.core.config.builder.api.RootLoggerComponentBuilder;
|
||||
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App {
|
||||
|
||||
private static String mode;
|
||||
private static int season;
|
||||
private static int league;
|
||||
private static String configFile;
|
||||
private static final Logger logger = LogManager.getLogger(App.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurationBuilder<BuiltConfiguration> builder
|
||||
= ConfigurationBuilderFactory.newConfigurationBuilder();
|
||||
|
||||
RootLoggerComponentBuilder rootLogger
|
||||
= builder.newRootLogger(Level.ERROR);
|
||||
|
||||
builder.add(rootLogger);
|
||||
Configurator.initialize(builder.build());
|
||||
Configurator.setRootLevel(Level.INFO);
|
||||
initOptions(args);
|
||||
String sql = "";
|
||||
String beautifulInfo = "";
|
||||
switch(mode) {
|
||||
case "MatchdaysUpdater":
|
||||
TLWMatchdaysUpdater matchdaysUpdater = new TLWMatchdaysUpdater(season, league, configFile);
|
||||
sql = matchdaysUpdater.getUpdateSql();
|
||||
beautifulInfo = matchdaysUpdater.getBeautifulInfo();
|
||||
matchdaysUpdater.updateGoogleCalendar();
|
||||
break;
|
||||
case "MatchesCreatorFootball":
|
||||
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(season, league, configFile);
|
||||
sql = creator.getSQLInsertString();
|
||||
break;
|
||||
case "MatchesUpdaterFootball":
|
||||
TLWMatchesUpdaterFootball tlwMatchesUpdaterFootball = new TLWMatchesUpdaterFootball(season, league, configFile);
|
||||
sql = tlwMatchesUpdaterFootball.getUpdateSQL();
|
||||
beautifulInfo = tlwMatchesUpdaterFootball.getBeautifulInfo();
|
||||
break;
|
||||
case "MatchesResultsUpdater":
|
||||
TLWMatchesResultsUpdater tlwMatchesResultsUpdater = new TLWMatchesResultsUpdater(season, league, configFile);
|
||||
beautifulInfo = tlwMatchesResultsUpdater.getBeautifulInfo();
|
||||
break;
|
||||
case "TeamsUpdater":
|
||||
TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(season, league, configFile);
|
||||
sql = teamsUpdater.getInsertSQL();
|
||||
break;
|
||||
case "APIFootballUpdater":
|
||||
APIFootballUpdater apiFootballUpdater = new APIFootballUpdater();
|
||||
apiFootballUpdater.updateAllFixtures(season);
|
||||
apiFootballUpdater.updateAllRounds(season);
|
||||
break;
|
||||
case "MatchesListGistUpdater":
|
||||
MatchesListForumUpdater matchesListForumUpdater = new MatchesListForumUpdater(season);
|
||||
matchesListForumUpdater.updateAllLeagues(season);
|
||||
break;
|
||||
case "PostChecksum":
|
||||
TippligaConfigProvider configProvider = new TippligaConfigProvider(season);
|
||||
String checksum = configProvider.getChecksumOfConfigPost(configFile);
|
||||
System.out.println(checksum);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if(!StatusHolder.getError() && !sql.equals("")) {
|
||||
TippligaSQLConnector con = TippligaSQLConnector.getInstance();
|
||||
con.executeUpdate(sql);
|
||||
}
|
||||
if(!StatusHolder.getError() && !beautifulInfo.equals(""))
|
||||
logger.info(beautifulInfo);
|
||||
}
|
||||
|
||||
private static void initOptions(String[] args) {
|
||||
ArgumentParser parser = ArgumentParsers.newFor("tlw").build()
|
||||
.defaultHelp(true)
|
||||
.description("Test");
|
||||
|
||||
parser.addArgument("-m", "--mode")
|
||||
.dest("mode")
|
||||
.choices("MatchdaysUpdater", "MatchesCreatorFootball", "MatchesUpdaterFootball", "MatchesResultsUpdater", "TeamsUpdater", "APIFootballUpdater", "MatchesListGistUpdater", "PostChecksum")
|
||||
.help("")
|
||||
.required(true)
|
||||
.type(String.class);
|
||||
|
||||
parser.addArgument("-s", "--season")
|
||||
.dest("season")
|
||||
.required(true)
|
||||
.type(Integer.class);
|
||||
|
||||
parser.addArgument("-l", "--league")
|
||||
.dest("league")
|
||||
.required(true)
|
||||
.type(Integer.class);
|
||||
|
||||
parser.addArgument("-c", "--configFile")
|
||||
.dest("configFile")
|
||||
.required(true)
|
||||
.type(String.class);
|
||||
|
||||
Namespace res = null;
|
||||
try {
|
||||
res = parser.parseArgs(args);
|
||||
} catch (ArgumentParserException e) {
|
||||
parser.printHelp();
|
||||
System.exit(1);
|
||||
}
|
||||
mode = res.get("mode");
|
||||
season = res.get("season");
|
||||
league = res.get("league");
|
||||
configFile = res.get("configFile");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package de.jeyp91;
|
||||
|
||||
public abstract class BaseMatch {
|
||||
|
||||
public static final Integer STATUS_NOTSTARTED = 0;
|
||||
public static final Integer STATUS_STARTED = 1;
|
||||
public static final Integer STATUS_PROVISIONAL_RESULT_AVAILABLE = 2;
|
||||
public static final Integer STATUS_FINISHED = 3;
|
||||
public static final Integer STATUS_NOT_EVALUATED = 4;
|
||||
|
||||
public enum COMPARISON {
|
||||
IDENTICAL,
|
||||
DIFFERENT,
|
||||
DIFFERENT_DATETIME,
|
||||
DIFFERENT_RESULT
|
||||
}
|
||||
|
||||
protected Integer teamIdHome;
|
||||
protected Integer teamIdGuest;
|
||||
protected String teamNameHome = null;
|
||||
protected String teamNameGuest = null;
|
||||
protected Integer goalsHome = null;
|
||||
protected Integer goalsGuest = null;
|
||||
protected Integer goalsOvertimeHome = null;
|
||||
protected Integer goalsOvertimeGuest = null;
|
||||
protected Integer goalsPenaltyHome = null;
|
||||
protected Integer goalsPenaltyGuest = null;
|
||||
protected Integer matchday = null;
|
||||
protected String matchDatetime = null;
|
||||
protected Integer status = null;
|
||||
protected COMPARISON updateStatus = COMPARISON.IDENTICAL;
|
||||
|
||||
public Integer getMatchday() {
|
||||
return this.matchday;
|
||||
}
|
||||
|
||||
public Integer getTeamIdHome() {
|
||||
return this.teamIdHome;
|
||||
}
|
||||
|
||||
public Integer getTeamIdGuest() {
|
||||
return this.teamIdGuest;
|
||||
}
|
||||
|
||||
public String getMatchDateTime() {
|
||||
return this.matchDatetime;
|
||||
}
|
||||
|
||||
public Integer getGoalsHome() {
|
||||
return this.goalsHome;
|
||||
}
|
||||
|
||||
public Integer getGoalsGuest() {
|
||||
return this.goalsGuest;
|
||||
}
|
||||
|
||||
public Integer getGoalsOvertimeHome() {
|
||||
return this.goalsOvertimeHome;
|
||||
}
|
||||
|
||||
public Integer getGoalsOvertimeGuest() {
|
||||
return this.goalsOvertimeGuest;
|
||||
}
|
||||
|
||||
public Integer getGoalsPenaltyHome() {
|
||||
return this.goalsPenaltyHome;
|
||||
}
|
||||
|
||||
public Integer getGoalsPenaltyGuest() {
|
||||
return this.goalsPenaltyGuest;
|
||||
}
|
||||
|
||||
public String getTeamNameHome() {
|
||||
return this.teamNameHome;
|
||||
}
|
||||
|
||||
public String getTeamNameGuest() {
|
||||
return this.teamNameGuest;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public void setUpdateStatus(COMPARISON newStatus) { this.updateStatus = newStatus; }
|
||||
|
||||
public COMPARISON getUpdateStatus() {
|
||||
return this.updateStatus;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package de.jeyp91;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class ResourceProvider {
|
||||
|
||||
private static JSONArray getJSONArrayFromResource(String path) {
|
||||
URL url = Resources.getResource(path);
|
||||
String jsonConfig;
|
||||
JSONArray array = null;
|
||||
|
||||
try {
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||
array = (JSONArray) jsonParser.parse(jsonConfig);
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static JSONArray getLigenConfig(int season) {
|
||||
return getJSONArrayFromResource("Tippliga/" + season + "_Ligen.json");
|
||||
}
|
||||
|
||||
public static JSONArray getTeamIDMatcherConfig() {
|
||||
return getJSONArrayFromResource("Tippliga/Team_ID_Matcher_Config.json");
|
||||
}
|
||||
|
||||
public static JSONArray getTipperMatchPairConfig() {
|
||||
return getJSONArrayFromResource("Tippliga/Tipper_Match_Pair_Config.json");
|
||||
}
|
||||
|
||||
public static JSONArray getTipperTeamConfig() {
|
||||
return getJSONArrayFromResource("Tippliga/Tipper_Team_Config.json");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package de.jeyp91;
|
||||
|
||||
import com.amazonaws.AmazonServiceException;
|
||||
import com.amazonaws.SdkClientException;
|
||||
import com.amazonaws.regions.Regions;
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
||||
import com.amazonaws.services.s3.model.S3Object;
|
||||
import com.amazonaws.services.s3.model.S3ObjectInputStream;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class S3Provider {
|
||||
private static final Regions AWS_DEFAULT_REGION = Regions.EU_CENTRAL_1;
|
||||
private static final String BUCKET_NAME = "tlw-database-tool-api-football-data";
|
||||
|
||||
private void writeToS3(String filename, String content) {
|
||||
final AmazonS3 s3 = AmazonS3ClientBuilder
|
||||
.standard()
|
||||
.withRegion(AWS_DEFAULT_REGION)
|
||||
.build();
|
||||
try {
|
||||
s3.putObject(BUCKET_NAME, filename, content);
|
||||
} catch (AmazonServiceException e) {
|
||||
System.err.println(e.getErrorMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void writeFixturesToS3(int league, String content) {
|
||||
writeToS3("fixtures/" + league + ".json", content);
|
||||
}
|
||||
|
||||
public void writeRoundsToS3(int league, String content) {
|
||||
writeToS3("rounds/" + league + ".json", content);
|
||||
}
|
||||
|
||||
private String getFileFromS3(String filename) {
|
||||
final AmazonS3 s3 = AmazonS3ClientBuilder
|
||||
.standard()
|
||||
.withRegion(AWS_DEFAULT_REGION)
|
||||
.build();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
try {
|
||||
S3Object o = s3.getObject(BUCKET_NAME, filename);
|
||||
S3ObjectInputStream s3is = o.getObjectContent();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(s3is));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
} catch (SdkClientException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
String getFixturesStringFromS3(int league) {
|
||||
return getFileFromS3("fixtures/" + league + ".json");
|
||||
}
|
||||
|
||||
public JSONObject getFixturesJSONFromS3(int league) {
|
||||
String fixturesString = getFixturesStringFromS3(league);
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject jsonObject = null;
|
||||
try {
|
||||
jsonObject = (JSONObject) parser.parse(fixturesString);
|
||||
} catch (ParseException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
private String getRoundsStringFromS3(int league) {
|
||||
return getFileFromS3("rounds/" + league + ".json");
|
||||
}
|
||||
|
||||
public JSONObject getRoundsJSONFromS3(int league) {
|
||||
String fixturesString = getRoundsStringFromS3(league);
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject jsonObject = null;
|
||||
try {
|
||||
jsonObject = (JSONObject) parser.parse(fixturesString);
|
||||
} catch (ParseException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package de.jeyp91;
|
||||
|
||||
public class StatusHolder {
|
||||
private static boolean error = false;
|
||||
public static void setError() {
|
||||
error = true;
|
||||
}
|
||||
public static boolean getError() {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package de.jeyp91.apifootball;
|
||||
|
||||
import de.jeyp91.S3Provider;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class APIFootballConnector {
|
||||
|
||||
private static APIFootballConnector conn = null;
|
||||
private final int season;
|
||||
private final HashMap<Integer, JSONObject> rounds = new HashMap<>();
|
||||
private final HashMap<Integer, JSONObject> matches = new HashMap<>();
|
||||
private static final Logger logger = LogManager.getLogger(APIFootballConnector.class);
|
||||
|
||||
private APIFootballConnector(int season) {
|
||||
this.season = season;
|
||||
}
|
||||
|
||||
public static APIFootballConnector getAPIFootballConnectorInstance(int season) {
|
||||
if(conn == null) {
|
||||
conn = new APIFootballConnector(season);
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
|
||||
public APIFootballMatch getMatchDataByLeagueAndMatchID(int league, int id) {
|
||||
|
||||
APIFootballMatch matchWithID = null;
|
||||
|
||||
ArrayList<APIFootballMatch> allMatches = getMatchesFromLeagueFromFile(league);
|
||||
for (APIFootballMatch singleMatch : allMatches) {
|
||||
if (singleMatch.getAPIFootBallMatchID() == id) {
|
||||
matchWithID = singleMatch;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return matchWithID;
|
||||
}
|
||||
|
||||
public ArrayList<APIFootballMatch> getMatchDataByLeagueAndMatchday(int league, int matchday) {
|
||||
|
||||
ArrayList<APIFootballMatch> matchesOfMatchday = new ArrayList<>();
|
||||
|
||||
ArrayList<APIFootballMatch> allMatches = getMatchesFromLeagueFromFile(league);
|
||||
for (APIFootballMatch singleMatch : allMatches) {
|
||||
if (singleMatch.getMatchday() == matchday) {
|
||||
matchesOfMatchday.add(singleMatch);
|
||||
}
|
||||
}
|
||||
|
||||
return matchesOfMatchday;
|
||||
}
|
||||
|
||||
public ArrayList<APIFootballMatch> getMatchesFromLeagueFromFile(int leagueId) {
|
||||
ArrayList<APIFootballMatch> matchesList = new ArrayList<>();
|
||||
S3Provider prov = new S3Provider();
|
||||
|
||||
if(!this.matches.containsKey(leagueId)) {
|
||||
this.matches.put(leagueId, prov.getFixturesJSONFromS3(leagueId));
|
||||
}
|
||||
JSONObject matches = this.matches.get(leagueId);
|
||||
JSONArray matchArray = (JSONArray) (((JSONObject)matches.get("api")).get("fixtures"));
|
||||
|
||||
for(int i = 0; i < matchArray.size(); i++) {
|
||||
try {
|
||||
APIFootballMatch match = new APIFootballMatch((JSONObject) matchArray.get(i), this.season);
|
||||
matchesList.add(match);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return matchesList;
|
||||
}
|
||||
|
||||
public JSONObject getMatchdays(int leagueId) {
|
||||
S3Provider prov = new S3Provider();
|
||||
if(!this.rounds.containsKey(leagueId)) {
|
||||
this.rounds.put(leagueId, prov.getRoundsJSONFromS3(leagueId));
|
||||
}
|
||||
return this.rounds.get(leagueId);
|
||||
}
|
||||
|
||||
public JSONObject getTeamsForLeague(int league) throws Exception {
|
||||
String url = "https://v2.api-football.com/teams/league/" + league;
|
||||
String content = new APIFootballUpdater().getRawData(url);
|
||||
return stringToJSONObject(content);
|
||||
}
|
||||
|
||||
public static JSONObject stringToJSONObject(String rawData) {
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject data = null;
|
||||
try {
|
||||
data = (JSONObject) parser.parse(rawData);
|
||||
} catch (Exception e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package de.jeyp91.apifootball;
|
||||
|
||||
import de.jeyp91.BaseMatch;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class APIFootballMatch extends BaseMatch {
|
||||
|
||||
private int matchId;
|
||||
private int leagueId;
|
||||
private String teamNameHome;
|
||||
private String teamNameGuest;
|
||||
private String round;
|
||||
private Boolean showTable = null;
|
||||
|
||||
public APIFootballMatch(JSONObject json, int season) throws Exception {
|
||||
this.matchId = Integer.parseInt(json.get("fixture_id").toString());
|
||||
// TODO
|
||||
this.leagueId = Integer.parseInt(json.get("league_id").toString());
|
||||
this.teamIdHome = Integer.parseInt(((JSONObject) json.get("homeTeam")).get("team_id").toString());
|
||||
this.teamIdGuest = Integer.parseInt(((JSONObject) json.get("awayTeam")).get("team_id").toString());
|
||||
this.teamNameHome = ((JSONObject) json.get("homeTeam")).get("team_name").toString();
|
||||
this.teamNameGuest = ((JSONObject) json.get("awayTeam")).get("team_name").toString();
|
||||
this.goalsHome = getNumberOrNull(json.get("goalsHomeTeam"));
|
||||
this.goalsGuest = getNumberOrNull(json.get("goalsAwayTeam"));
|
||||
this.round = json.get("round").toString();
|
||||
try {
|
||||
this.matchday = getMatchdayFromRoundString(season, this.round, this.leagueId);
|
||||
} catch (Exception e) {
|
||||
throw new Exception("Did not find matchday for league '" + this.leagueId + "': '" + json.get("round").toString() + "'");
|
||||
}
|
||||
this.matchDatetime = (String) json.get("event_date");
|
||||
this.status = parseStatus(json.get("statusShort").toString());
|
||||
this.parseResult(json);
|
||||
}
|
||||
|
||||
public int getAPIFootBallMatchID() {
|
||||
return this.matchId;
|
||||
}
|
||||
|
||||
public static int getMatchdayFromRoundString(int season, String round, int leagueId) {
|
||||
round = round.replace(" ", "_");
|
||||
Integer matchday = null;
|
||||
if (round.startsWith("Regular_Season_-_")) {
|
||||
matchday = Integer.parseInt(round.replace("Regular_Season_-_", ""));
|
||||
} else {
|
||||
APIFootballConnector con = APIFootballConnector.getAPIFootballConnectorInstance(season);
|
||||
JSONObject roundsObject = con.getMatchdays(leagueId);
|
||||
JSONArray roundsArray = (JSONArray)(((JSONObject) roundsObject.get("api")).get("fixtures"));
|
||||
for (int i = 0; i < roundsArray.size(); i++) {
|
||||
if(roundsArray.get(i).toString().equals(round)) {
|
||||
matchday = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return matchday;
|
||||
}
|
||||
|
||||
private Integer getNumberOrNull(Object object) {
|
||||
return object != null ? Integer.parseInt(object.toString()) : null;
|
||||
}
|
||||
|
||||
public String getTeamNameHome() {
|
||||
return this.teamNameHome;
|
||||
}
|
||||
|
||||
public String getTeamNameGuest() {
|
||||
return this.teamNameGuest;
|
||||
}
|
||||
|
||||
public String getRound() {
|
||||
return this.round;
|
||||
}
|
||||
|
||||
public void setShowTable(boolean showTable) {
|
||||
this.showTable = showTable;
|
||||
}
|
||||
|
||||
public Boolean getShowTable() {
|
||||
return this.showTable;
|
||||
}
|
||||
|
||||
private int parseStatus(String statusShort) {
|
||||
switch (statusShort) {
|
||||
case "TBD":
|
||||
case "NS": return 0;
|
||||
case "FT":
|
||||
case "AET":
|
||||
case "PEN": return 3;
|
||||
default: return 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void parseResult(JSONObject json) {
|
||||
Object resultFulltime = ((JSONObject) json.get("score")).get("fulltime");
|
||||
if(resultFulltime != null) {
|
||||
String[] result = resultFulltime.toString().split("-");
|
||||
this.goalsHome = Integer.parseInt(result[0]);
|
||||
this.goalsGuest = Integer.parseInt(result[1]);
|
||||
}
|
||||
|
||||
Object resultExtratime = ((JSONObject) json.get("score")).get("extratime");
|
||||
if(resultExtratime != null) {
|
||||
String[] result = resultExtratime.toString().split("-");
|
||||
this.goalsOvertimeHome = this.goalsHome + Integer.parseInt(result[0]);
|
||||
this.goalsOvertimeGuest = this.goalsGuest + Integer.parseInt(result[1]);
|
||||
}
|
||||
|
||||
Object resultPenalty = ((JSONObject) json.get("score")).get("penalty");
|
||||
if(resultPenalty != null) {
|
||||
String[] result = resultPenalty.toString().split("-");
|
||||
this.goalsPenaltyHome = this.goalsOvertimeHome + Integer.parseInt(result[0]);
|
||||
this.goalsPenaltyGuest = this.goalsOvertimeGuest + Integer.parseInt(result[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package de.jeyp91.apifootball;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class APIFootballMatchesProvider {
|
||||
|
||||
APIFootballConnector conn;
|
||||
public APIFootballMatchesProvider(int season) {
|
||||
this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1);
|
||||
}
|
||||
|
||||
public ArrayList<APIFootballMatch> getAPIFootballMatchesFromConfig(JSONArray config) {
|
||||
ArrayList<APIFootballMatch> apiFootballMatches = new ArrayList<>();
|
||||
for (Object singleConfigObject : config) {
|
||||
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
||||
String type = (String) singleConfig.get("type");
|
||||
boolean showTable = false;
|
||||
switch (type) {
|
||||
case "AllMatchesOfMatchday":
|
||||
int matchesLeague = ((Long) singleConfig.get("matchesLeague")).intValue();
|
||||
int leagueMatchday = ((Long) singleConfig.get("leagueMatchday")).intValue();
|
||||
ArrayList<APIFootballMatch> matches = conn.getMatchDataByLeagueAndMatchday(matchesLeague, leagueMatchday);
|
||||
try {
|
||||
showTable = (boolean) singleConfig.get("showTable");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
boolean finalShowTable = showTable;
|
||||
matches.forEach(apiFootballMatch -> apiFootballMatch.setShowTable(finalShowTable));
|
||||
apiFootballMatches.addAll(matches);
|
||||
break;
|
||||
case "SingleMatch":
|
||||
int matchLeague = ((Long) singleConfig.get("matchLeague")).intValue();
|
||||
int matchId = ((Long) singleConfig.get("matchId")).intValue();
|
||||
APIFootballMatch match = conn.getMatchDataByLeagueAndMatchID(matchLeague, matchId);
|
||||
showTable = (boolean) singleConfig.get("showTable");
|
||||
match.setShowTable(showTable);
|
||||
apiFootballMatches.add(match);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return apiFootballMatches;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package de.jeyp91.apifootball;
|
||||
|
||||
import de.jeyp91.ResourceProvider;
|
||||
import de.jeyp91.S3Provider;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class APIFootballUpdater {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(APIFootballUpdater.class);
|
||||
|
||||
public APIFootballUpdater() {
|
||||
|
||||
}
|
||||
|
||||
public void updateFixtures(int league) {
|
||||
String apiFootballUrl = "https://v2.api-football.com/fixtures/league/" + league + "?timezone=Europe/Berlin";
|
||||
S3Provider prov = new S3Provider();
|
||||
try {
|
||||
String content = getRawData(apiFootballUrl);
|
||||
prov.writeFixturesToS3(league, content);
|
||||
} catch (Exception e) {
|
||||
if(e.getMessage().toLowerCase().contains("rate limit'")) {
|
||||
try {
|
||||
Thread.sleep(1000 * 60);
|
||||
String content = getRawData(apiFootballUrl);
|
||||
prov.writeFixturesToS3(league, content);
|
||||
} catch (InterruptedException interruptedException) {
|
||||
interruptedException.printStackTrace();
|
||||
} catch (Exception exception) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
} else {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAllFixtures(int season) {
|
||||
HashSet<Integer> leagues = getLeagues(season);
|
||||
for (Integer league : leagues) {
|
||||
updateFixtures(league);
|
||||
try {
|
||||
Thread.sleep(1000*6);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAllRounds(int season) {
|
||||
HashSet<Integer> leagues = getLeagues(season);
|
||||
for (Integer league : leagues) {
|
||||
updateRounds(league);
|
||||
try {
|
||||
Thread.sleep(1000*6);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRounds(int league) {
|
||||
String apiFootballUrl = "https://v2.api-football.com/fixtures/rounds/" + league;
|
||||
S3Provider prov = new S3Provider();
|
||||
try {
|
||||
String content = getRawData(apiFootballUrl);
|
||||
prov.writeRoundsToS3(league, content);
|
||||
} catch (Exception e) {
|
||||
if(e.getMessage().toLowerCase().contains("rate limit'")) {
|
||||
try {
|
||||
Thread.sleep(1000 * 60);
|
||||
String content = getRawData(apiFootballUrl);
|
||||
prov.writeRoundsToS3(league, content);
|
||||
} catch (InterruptedException interruptedException) {
|
||||
interruptedException.printStackTrace();
|
||||
} catch (Exception exception) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
} else {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getRawData(String requestUrl) throws Exception {
|
||||
|
||||
HttpClient client = HttpClientBuilder.create().build();
|
||||
HttpGet request = new HttpGet(requestUrl);
|
||||
|
||||
// add request header
|
||||
request.addHeader("X-RapidAPI-Key", "a607e6a7437d9d52f3ac73e0b2704d0b");
|
||||
|
||||
HttpResponse response = null;
|
||||
try {
|
||||
response = client.execute(request);
|
||||
} catch (IOException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
BufferedReader rd = null;
|
||||
try {
|
||||
assert response != null;
|
||||
rd = new BufferedReader(
|
||||
new InputStreamReader(response.getEntity().getContent())
|
||||
);
|
||||
} catch (IOException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line = "";
|
||||
while (true) {
|
||||
try {
|
||||
line = rd.readLine();
|
||||
} catch (Exception e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Stop reading if last line was found.
|
||||
if (line == null) break;
|
||||
|
||||
result.append(line);
|
||||
}
|
||||
checkErrors(requestUrl, result.toString());
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public HashSet<Integer> getLeagues(int season) {
|
||||
JSONArray leaguesArray = ResourceProvider.getLigenConfig(season);
|
||||
HashSet<Integer> leagues = new HashSet<>();
|
||||
for (Object leagueObject : leaguesArray) {
|
||||
JSONObject leagueJSONObject = (JSONObject) leagueObject;
|
||||
Integer leagueId = ((Long) leagueJSONObject.get("league_id")).intValue();
|
||||
leagues.add(leagueId);
|
||||
}
|
||||
return leagues;
|
||||
}
|
||||
|
||||
public void checkErrors(String requestUrl, String result) throws Exception {
|
||||
JSONObject resultObject = stringToJSONObject(result);
|
||||
boolean containsError = ((JSONObject) resultObject.get("api")).containsKey("error");
|
||||
int results = Integer.parseInt(((JSONObject) resultObject.get("api")).get("results").toString());
|
||||
if(containsError) {
|
||||
String errorMessage = ((JSONObject) resultObject.get("api")).get("error").toString();
|
||||
throw new Exception(requestUrl + " returned error: '" + errorMessage + "'");
|
||||
} else if (results == 0) {
|
||||
String statusMessage = ((JSONObject) resultObject.get("api")).get("status").toString();
|
||||
throw new Exception(requestUrl + " did not have any results with status: '" + statusMessage + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private JSONObject stringToJSONObject(String rawData) {
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject data = null;
|
||||
try {
|
||||
data = (JSONObject) parser.parse(rawData);
|
||||
} catch (Exception e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package de.jeyp91.googlecalendar;
|
||||
|
||||
import com.google.common.io.Resources;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class CalendarConfigProvider {
|
||||
|
||||
private static JSONObject googleCalendarConfig = null;
|
||||
|
||||
private static JSONObject getGoogleCalendarConfig() {
|
||||
if(googleCalendarConfig == null) {
|
||||
//JSON parser object to parse read file
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
URL url = Resources.getResource("Google_Calendar_Config.json");
|
||||
String jsonConfig = null;
|
||||
|
||||
try {
|
||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||
//Read JSON file
|
||||
googleCalendarConfig = (JSONObject) jsonParser.parse(jsonConfig);
|
||||
|
||||
} catch (IOException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
return googleCalendarConfig;
|
||||
}
|
||||
|
||||
public static String getCalendarUrl() {
|
||||
JSONObject leagueConfig = (JSONObject) getGoogleCalendarConfig().get(String.valueOf(1));
|
||||
return (String) leagueConfig.get("url");
|
||||
}
|
||||
|
||||
public static String getCalendarId() {
|
||||
JSONObject leagueConfig = (JSONObject) getGoogleCalendarConfig().get(String.valueOf(1));
|
||||
return (String) leagueConfig.get("id");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package de.jeyp91.googlecalendar;
|
||||
|
||||
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
||||
import com.google.api.client.http.javanet.NetHttpTransport;
|
||||
import com.google.api.client.json.JsonFactory;
|
||||
import com.google.api.client.json.gson.GsonFactory;
|
||||
import com.google.api.services.calendar.Calendar;
|
||||
import com.google.api.services.calendar.CalendarScopes;
|
||||
import com.google.auth.http.HttpCredentialsAdapter;
|
||||
import com.google.auth.oauth2.GoogleCredentials;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class GoogleCalendarConnector {
|
||||
private static final String APPLICATION_NAME = "Google Calendar API Java Quickstart";
|
||||
private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
|
||||
|
||||
/**
|
||||
* Global instance of the scopes required by this quickstart.
|
||||
* If modifying these scopes, delete your previously saved tokens/ folder.
|
||||
*/
|
||||
private static final String SERVICE_CREDENTIALS_FILE_PATH = "/tippliga-4e0def9ef447.json";
|
||||
|
||||
/**
|
||||
* Creates an authorized Credential object.
|
||||
* @return An authorized Credential object.
|
||||
* @throws IOException If the Google_Credentials.json file cannot be found.
|
||||
*/
|
||||
private static GoogleCredentials getGoogleCredentials() throws IOException {
|
||||
InputStream in = GoogleCalendarConnector.class.getResourceAsStream(SERVICE_CREDENTIALS_FILE_PATH);
|
||||
GoogleCredentials credentials = GoogleCredentials.fromStream(in)
|
||||
.createScoped(Collections.singleton(CalendarScopes.CALENDAR));
|
||||
credentials.refreshIfExpired();
|
||||
return credentials;
|
||||
}
|
||||
|
||||
public static com.google.api.services.calendar.Calendar getSerivce() {
|
||||
Calendar service = null;
|
||||
|
||||
final NetHttpTransport HTTP_TRANSPORT;
|
||||
try {
|
||||
// Build a new authorized API client service.
|
||||
HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
|
||||
service = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, null)
|
||||
.setHttpRequestInitializer(new HttpCredentialsAdapter(getGoogleCredentials()))
|
||||
.setApplicationName(APPLICATION_NAME)
|
||||
.build();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return service;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package de.jeyp91.googlecalendar;
|
||||
|
||||
import com.google.api.client.util.DateTime;
|
||||
import com.google.api.services.calendar.Calendar;
|
||||
import com.google.api.services.calendar.model.Event;
|
||||
import com.google.api.services.calendar.model.EventDateTime;
|
||||
import com.google.api.services.calendar.model.EventReminder;
|
||||
import com.google.api.services.calendar.model.Events;
|
||||
import de.jeyp91.tippliga.TLWLeague;
|
||||
import de.jeyp91.tippliga.TLWMatchday;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static de.jeyp91.googlecalendar.GoogleCalendarConnector.getSerivce;
|
||||
|
||||
public class TippligaGoogleEventManager {
|
||||
|
||||
private static List<Event> allEvents = null;
|
||||
private static final Logger logger = LogManager.getLogger(TippligaGoogleEventManager.class);
|
||||
|
||||
public static List<Event> getAllEvents(Integer season) {
|
||||
if(allEvents == null) {
|
||||
allEvents = getAllEventsStartingFromDateTime(new DateTime(season-1 + "-07-01T00:00:00Z"));
|
||||
}
|
||||
return allEvents;
|
||||
}
|
||||
|
||||
public static List<Event> getAllEventsStartingFromDateTime(DateTime dateTime) {
|
||||
|
||||
Calendar service = getSerivce();
|
||||
Events events = null;
|
||||
|
||||
String calendarUrl = CalendarConfigProvider.getCalendarUrl();
|
||||
|
||||
// Build a new authorized API client service.
|
||||
try {
|
||||
events = service.events().list(calendarUrl)
|
||||
.setMaxResults(500)
|
||||
.setTimeMin(dateTime)
|
||||
.setOrderBy("startTime")
|
||||
.setSingleEvents(true)
|
||||
.execute();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
assert events != null;
|
||||
return events.getItems();
|
||||
}
|
||||
|
||||
public static Event findEvent(List<Event> allEvents, Integer season, Integer league, Integer matchday, Integer deliveryDateNumber) {
|
||||
String description = getDescription(season, league, matchday, deliveryDateNumber);
|
||||
String descriptionHtml = getDescriptionHTML(season, league, matchday, deliveryDateNumber);
|
||||
for (Event event : allEvents) {
|
||||
String eventDescription = event.getDescription();
|
||||
if (
|
||||
(eventDescription.replaceAll("\\s+","").equals(description.replaceAll("\\s+","")))
|
||||
|| eventDescription.equals(descriptionHtml)
|
||||
) {
|
||||
return event;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void createOrUpdateEventsForMatchday(TLWMatchday matchday) {
|
||||
createOrUpdateEvent(matchday, matchday.getDeliveryDate(), 1);
|
||||
if(!matchday.getDeliveryDate2().equals("")) createOrUpdateEvent(matchday, matchday.getDeliveryDate2(), 2);
|
||||
if(!matchday.getDeliveryDate3().equals("")) createOrUpdateEvent(matchday, matchday.getDeliveryDate3(), 3);
|
||||
}
|
||||
|
||||
public static void createOrUpdateEvent(TLWMatchday matchday, String deliveryDateString, Integer deliverDateNumber) {
|
||||
List<Event> allEvents = getAllEvents(matchday.getSeason());
|
||||
Event event = findEvent(allEvents, matchday.getSeason(), matchday.getLeague(), matchday.getMatchday(), deliverDateNumber);
|
||||
if(event == null) {
|
||||
createNewEvent(matchday, deliveryDateString, deliverDateNumber);
|
||||
}
|
||||
else {
|
||||
String googleEventStart = event.getStart().getDateTime().toString();
|
||||
String googleEventStartBeautified = googleEventStart.substring(0, 19).replace("T", " ");
|
||||
if(!googleEventStartBeautified.equals(deliveryDateString)) {
|
||||
updateEvent(event, matchday, deliveryDateString, deliverDateNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void createNewEvent(TLWMatchday matchday, String deliveryDateString, Integer deliverDateNumber) {
|
||||
String calendarUrl = CalendarConfigProvider.getCalendarUrl();
|
||||
|
||||
Event event = getEvent(matchday, deliveryDateString, deliverDateNumber);
|
||||
|
||||
try {
|
||||
logger.info("Create new google calendar event for " + matchday.getSeason() + ", " + matchday.getLeague() + ", " + matchday.getMatchday() + ", " + deliverDateNumber);
|
||||
getSerivce().events().insert(calendarUrl, event).execute();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateEvent(Event oldEvent, TLWMatchday matchday, String deliveryDateString, Integer deliverDateNumber) {
|
||||
String calendarUrl = CalendarConfigProvider.getCalendarUrl();
|
||||
|
||||
Event event = getEvent(matchday, deliveryDateString, deliverDateNumber);
|
||||
|
||||
try {
|
||||
logger.info("Update google calendar event for " + matchday.getSeason() + ", " + matchday.getLeague() + ", " + matchday.getMatchday() + ", " + deliverDateNumber);
|
||||
Calendar.Events events = getSerivce().events();
|
||||
events.update(calendarUrl, oldEvent.getId(), event).execute();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteEvent(TLWMatchday matchday, Integer deliverDateNumber) {
|
||||
String calendarUrl = CalendarConfigProvider.getCalendarUrl();
|
||||
|
||||
Event event = findEvent(getAllEvents(matchday.getSeason()), matchday.getSeason(), matchday.getLeague(), matchday.getMatchday(), deliverDateNumber);
|
||||
if(event != null) {
|
||||
try {
|
||||
logger.info("Delete google calendar event for " + matchday.getSeason() + ", " + matchday.getLeague() + ", " + matchday.getMatchday() + ", " + deliverDateNumber);
|
||||
getSerivce().events().delete(calendarUrl, event.getId()).execute();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteAllEvents(int season) throws IOException {
|
||||
String calendarUrl = CalendarConfigProvider.getCalendarUrl();
|
||||
List<Event> events = getAllEvents(season);
|
||||
for(Event event : events ) {
|
||||
getSerivce().events().delete(calendarUrl, event.getId()).execute();
|
||||
}
|
||||
}
|
||||
|
||||
private static Event getEvent(TLWMatchday matchday, String deliveryDateString, Integer deliverDateNumber) {
|
||||
String matchdayName = matchday.getMatchdayName().equals("") ? matchday.getMatchday().toString() + ". Spieltag" : matchday.getMatchdayName();
|
||||
String summary = TLWLeague.getLeagueNameCalendar(matchday.getLeague()) + " " + matchdayName + " tippen!";
|
||||
if(deliverDateNumber > 1) summary += " " + deliverDateNumber + ". Chance \uD83D\uDE43";
|
||||
String description = getDescription(matchday.getSeason(), matchday.getLeague(), matchday.getMatchday(), deliverDateNumber);
|
||||
String location = "https://tippliga-wuerzburg.de/app.php/football/bet";
|
||||
|
||||
LocalDateTime deliveryLocalDateTime = LocalDateTime.parse(deliveryDateString.replace(" ", "T"));
|
||||
ZonedDateTime zdtBerlin = ZonedDateTime.of(deliveryLocalDateTime, ZoneId.of("Europe/Berlin"));
|
||||
DateTime deliveryDateTime = new DateTime(zdtBerlin.toInstant().toEpochMilli());
|
||||
EventDateTime date = new EventDateTime()
|
||||
.setDateTime(deliveryDateTime)
|
||||
.setTimeZone("Europe/Berlin");
|
||||
|
||||
// Set reminder to 12 hours before
|
||||
Event.Reminders reminders = new Event.Reminders();
|
||||
reminders.setUseDefault(true);
|
||||
|
||||
return new Event()
|
||||
.setSummary(summary)
|
||||
.setLocation(location)
|
||||
.setDescription(description)
|
||||
.setStart(date)
|
||||
.setEnd(date)
|
||||
.setReminders(reminders);
|
||||
}
|
||||
|
||||
private static String getDescription(Integer season, Integer league, Integer matchday, Integer deliverDateNumber) {
|
||||
league = league == 2 ? 1 : league;
|
||||
return "Saison: " + season + "\n" + "Liga: " + league + "\n" + "Spieltag: " + matchday + "\n" + "Abgabeschluss: " + deliverDateNumber;
|
||||
}
|
||||
|
||||
|
||||
private static String getDescriptionHTML(Integer season, Integer league, Integer matchday, Integer deliverDateNumber) {
|
||||
league = league == 2 ? 1 : league;
|
||||
return "Saison: " + season + "<br>" + "Liga: " + league + "<br>" + "Spieltag: " + matchday + "<br>" + "Abgabeschluss: " + deliverDateNumber;
|
||||
}
|
||||
|
||||
public static void updateAllMatchdays(ArrayList<TLWMatchday> matchdays) {
|
||||
matchdays.forEach(tlwMatchday -> {
|
||||
createOrUpdateEvent(tlwMatchday, tlwMatchday.getDeliveryDate(), 1);
|
||||
if(tlwMatchday.getDeliveryDate2().equals("")) {
|
||||
deleteEvent(tlwMatchday, 2);
|
||||
} else {
|
||||
createOrUpdateEvent(tlwMatchday, tlwMatchday.getDeliveryDate2(), 2);
|
||||
}
|
||||
if(tlwMatchday.getDeliveryDate3().equals("")) {
|
||||
deleteEvent(tlwMatchday, 3);
|
||||
} else {
|
||||
createOrUpdateEvent(tlwMatchday, tlwMatchday.getDeliveryDate3(), 3);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package de.jeyp91.openligadb;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class OpenLigaDBConnector {
|
||||
|
||||
private final String OPENLIGADB_API_URL = "http://www.openligadb.de/api/";
|
||||
|
||||
public OpenLigaDBConnector() {}
|
||||
|
||||
public OpenLigaDBMatch getMatchDataOfSingleMatch(int id) {
|
||||
String url = OPENLIGADB_API_URL + "getmatchdata/" + id;
|
||||
JSONObject matchAsJson = getDataAsJSONObject(url);
|
||||
return new OpenLigaDBMatch(matchAsJson);
|
||||
}
|
||||
|
||||
public ArrayList<OpenLigaDBMatch> getMatchDataOfMatchday(int season, String league, int matchday) {
|
||||
|
||||
String url = OPENLIGADB_API_URL + "getmatchdata/" + league + "/" + (season - 1) + "/" + matchday;
|
||||
|
||||
JSONArray matches = getDataAsJSONArray(url);
|
||||
ArrayList<OpenLigaDBMatch> matchesList = new ArrayList<>();
|
||||
|
||||
for(Object match: matches) {
|
||||
matchesList.add(new OpenLigaDBMatch((JSONObject) match));
|
||||
}
|
||||
|
||||
return matchesList;
|
||||
}
|
||||
|
||||
public ArrayList<OpenLigaDBMatch> getMatchDataOfCurrentMatchday(String league) {
|
||||
|
||||
String url = OPENLIGADB_API_URL + "getmatchdata/" + league;
|
||||
|
||||
JSONArray matches = getDataAsJSONArray(url);
|
||||
ArrayList<OpenLigaDBMatch> matchesList = new ArrayList<>();
|
||||
|
||||
for(Object match: matches) {
|
||||
matchesList.add(new OpenLigaDBMatch((JSONObject) match));
|
||||
}
|
||||
|
||||
return matchesList;
|
||||
}
|
||||
|
||||
public OpenLigaDBMatch getMatchDataByMatchId(int id) {
|
||||
String url = OPENLIGADB_API_URL + "getmatchdata/" + id;
|
||||
JSONObject match = getDataAsJSONObject(url);
|
||||
return new OpenLigaDBMatch(match);
|
||||
}
|
||||
|
||||
private JSONArray getDataAsJSONArray(String requestUrl) {
|
||||
|
||||
String rawData = getRawData(requestUrl);
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONArray data = null;
|
||||
try {
|
||||
data = (JSONArray) parser.parse(rawData);
|
||||
} catch (ParseException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private JSONObject getDataAsJSONObject(String requestUrl) {
|
||||
|
||||
String rawData = getRawData(requestUrl);
|
||||
JSONParser parser = new JSONParser();
|
||||
JSONObject data = null;
|
||||
try {
|
||||
data = (JSONObject) parser.parse(rawData);
|
||||
} catch (ParseException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private String getRawData(String requestUrl) {
|
||||
|
||||
HttpClient client = HttpClientBuilder.create().build();
|
||||
HttpGet request = new HttpGet(requestUrl);
|
||||
|
||||
// add request header
|
||||
request.addHeader("Content-Type", "application/json");
|
||||
|
||||
HttpResponse response = null;
|
||||
try {
|
||||
response = client.execute(request);
|
||||
} catch (ClientProtocolException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
BufferedReader rd = null;
|
||||
try {
|
||||
rd = new BufferedReader(
|
||||
new InputStreamReader(response.getEntity().getContent())
|
||||
);
|
||||
} catch (IOException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
String line = "";
|
||||
while (true) {
|
||||
try {
|
||||
line = rd.readLine();
|
||||
} catch (IOException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Stop reading if last line was found.
|
||||
if (line == null) break;
|
||||
|
||||
result.append(line);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package de.jeyp91.openligadb;
|
||||
|
||||
import de.jeyp91.BaseMatch;
|
||||
import de.jeyp91.tippliga.TLWMatch;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import java.util.regex.*;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class OpenLigaDBMatch extends BaseMatch {
|
||||
|
||||
private final int RESULT_TYPE_ENDRESULT = 2;
|
||||
|
||||
private Integer season = null;
|
||||
private int matchId;
|
||||
private int leagueId;
|
||||
private boolean matchIsFinished;
|
||||
|
||||
public OpenLigaDBMatch(JSONObject json) {
|
||||
this.matchId = Integer.parseInt(json.get("MatchID").toString());
|
||||
this.season = getSeasonFromLeageName(json.get("LeagueName").toString());
|
||||
this.leagueId = Integer.parseInt(json.get("LeagueId").toString());
|
||||
this.teamIdHome = Integer.parseInt(((JSONObject) json.get("Team1")).get("TeamId").toString());
|
||||
this.teamIdGuest = Integer.parseInt(((JSONObject) json.get("Team2")).get("TeamId").toString());
|
||||
for(int i = 0; i < ((JSONArray) json.get("MatchResults")).size(); i++) {
|
||||
if(Integer.parseInt((((JSONObject) ((JSONArray) json.get("MatchResults")).get(i)).get("ResultTypeID")).toString()) == RESULT_TYPE_ENDRESULT) {
|
||||
this.goalsHome = Integer.parseInt(((JSONObject) ((JSONArray) json.get("MatchResults")).get(i)).get("PointsTeam1").toString());
|
||||
this.goalsGuest = Integer.parseInt(((JSONObject) ((JSONArray) json.get("MatchResults")).get(i)).get("PointsTeam2").toString());
|
||||
}
|
||||
}
|
||||
this.matchday = Integer.parseInt(((JSONObject) json.get("Group")).get("GroupOrderID").toString());
|
||||
this.matchIsFinished = (Boolean) json.get("MatchIsFinished");
|
||||
this.matchDatetime = (String) json.get("MatchDateTime");
|
||||
}
|
||||
|
||||
private int getSeasonFromLeageName(String leagueName) {
|
||||
Pattern p = Pattern.compile("\\d*/\\d*");
|
||||
Matcher m = p.matcher(leagueName);
|
||||
m.find();
|
||||
String seasonString = m.group();
|
||||
p = Pattern.compile("\\d+");
|
||||
m = p.matcher(seasonString);
|
||||
Integer season = null;
|
||||
while(m.find()) {
|
||||
season = Integer.parseInt(m.group());
|
||||
}
|
||||
return season < 100 ? season + 2000 : season;
|
||||
}
|
||||
|
||||
public boolean isSameMatch(TLWMatch compareMatch) {
|
||||
if(this.getSeason()!= compareMatch.getSeason()) {
|
||||
return false;
|
||||
}
|
||||
if(this.getMatchday() != compareMatch.getMatchday()) {
|
||||
return false;
|
||||
}
|
||||
if(this.getTeamIdHome() != compareMatch.getTeamIdHome()) {
|
||||
return false;
|
||||
}
|
||||
if(this.getTeamIdGuest() != compareMatch.getTeamIdGuest()) {
|
||||
return false;
|
||||
}
|
||||
String thisDateTime = this.getMatchDateTime().replace("T", " ");
|
||||
String tempDateTime = compareMatch.getMatchDateTime().replace("T", " ");
|
||||
if(!tempDateTime.equals(thisDateTime)) {
|
||||
return false;
|
||||
}
|
||||
if(this.goalsHome != compareMatch.getGoalsHome() ||
|
||||
this.goalsGuest != compareMatch.getGoalsGuest()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Integer getSeason() {
|
||||
return this.season;
|
||||
}
|
||||
|
||||
public Integer getMatchId() {
|
||||
return this.matchId;
|
||||
}
|
||||
|
||||
public boolean getMatchIsFinished() {
|
||||
return this.matchIsFinished;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package de.jeyp91.teamidmatcher;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import de.jeyp91.ResourceProvider;
|
||||
import de.jeyp91.StatusHolder;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import org.apache.logging.log4j.*;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class TeamIDMatcher {
|
||||
|
||||
private static HashBiMap<Integer, Integer> ids = null;
|
||||
private static final Logger logger = LogManager.getLogger(TeamIDMatcher.class);
|
||||
private static JSONArray teams;
|
||||
private static boolean init = false;
|
||||
public static final int HOME = 0;
|
||||
public static final int GUEST = 1;
|
||||
|
||||
private static void initBiMap() {
|
||||
if(!init) {
|
||||
ids = HashBiMap.create();
|
||||
|
||||
teams = ResourceProvider.getTeamIDMatcherConfig();
|
||||
|
||||
for (Object team : teams) {
|
||||
int tippligaID = ((Long) ((JSONObject) team).get("tippligaID")).intValue();
|
||||
int apiFootballID = ((Long) ((JSONObject) team).get("apiFootballID")).intValue();
|
||||
ids.put(tippligaID, apiFootballID);
|
||||
}
|
||||
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer getApiFootballIdFromTippligaId(int id) {
|
||||
initBiMap();
|
||||
if(ids.containsKey(id)) {
|
||||
return ids.get(id);
|
||||
} else {
|
||||
logger.error("Tippliga ID: " + id + " not in ID Matcher.");
|
||||
StatusHolder.setError();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Integer getTippligaIdFromApiFootballId(APIFootballMatch match, int homeguest) {
|
||||
Integer apiFootballId = homeguest == HOME ? match.getTeamIdHome() : match.getTeamIdGuest();
|
||||
Integer tlwId = null;
|
||||
if(apiFootballId == null) return null;
|
||||
initBiMap();
|
||||
if(ids.inverse().containsKey(apiFootballId)) {
|
||||
tlwId = ids.inverse().get(apiFootballId);
|
||||
} else {
|
||||
String teamname = homeguest == HOME ? match.getTeamNameHome() : match.getTeamNameGuest();
|
||||
logger.error("Could not find id " + apiFootballId + " for " + teamname);
|
||||
StatusHolder.setError();
|
||||
}
|
||||
return tlwId;
|
||||
}
|
||||
|
||||
public static String getTeamNameFromTippligaId(Integer id) {
|
||||
initBiMap();
|
||||
String name = "";
|
||||
for(Object team : teams) {
|
||||
int tippligaID = ((Long)((JSONObject) team).get("tippligaID")).intValue();
|
||||
if(id == tippligaID) {
|
||||
name = (((JSONObject) team).get("teamname")).toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.jeyp91.teamidmatcher;
|
||||
|
||||
import de.jeyp91.apifootball.APIFootballConnector;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class TeamIDMatcherTemplateCreator {
|
||||
APIFootballConnector con;
|
||||
JSONArray teams;
|
||||
|
||||
public TeamIDMatcherTemplateCreator(int season, int league) throws Exception {
|
||||
this.con = APIFootballConnector.getAPIFootballConnectorInstance(season);
|
||||
JSONObject apiObject = con.getTeamsForLeague(league);
|
||||
JSONObject teamsObject = (JSONObject) apiObject.get("api");
|
||||
this.teams = (JSONArray) teamsObject.get("teams");
|
||||
}
|
||||
|
||||
public String getTeamsTemplate() {
|
||||
String teamsTemplate = "";
|
||||
for (Object team : this.teams) {
|
||||
JSONObject teamObject = (JSONObject) team;
|
||||
teamsTemplate += ",\n";
|
||||
teamsTemplate += " {\n";
|
||||
teamsTemplate += " \"teamname\": \"" + teamObject.get("name") + "\",\n";
|
||||
teamsTemplate += " \"tippligaID\": " + ",\n";
|
||||
teamsTemplate += " \"apiFootballID\": " + teamObject.get("team_id") + "\n";
|
||||
teamsTemplate += " }";
|
||||
}
|
||||
return teamsTemplate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
public class TLWLeague {
|
||||
public static String getLeagueName(int id) {
|
||||
String leagueName = "";
|
||||
switch (id) {
|
||||
case 1:
|
||||
leagueName = "Tippliga";
|
||||
break;
|
||||
case 46:
|
||||
leagueName = "Elfmeter";
|
||||
break;
|
||||
case 47:
|
||||
leagueName = "Relegation";
|
||||
break;
|
||||
case 48:
|
||||
leagueName = "WTL-Pokal";
|
||||
break;
|
||||
case 49:
|
||||
leagueName = "Liga-Cup";
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
return leagueName;
|
||||
}
|
||||
|
||||
public static String getLeagueNameShort(int id) {
|
||||
String leagueName = "";
|
||||
switch (id) {
|
||||
case 1:
|
||||
leagueName = "1. TLW";
|
||||
break;
|
||||
case 2:
|
||||
leagueName = "2. TLW";
|
||||
break;
|
||||
case 46:
|
||||
leagueName = "ELF";
|
||||
break;
|
||||
case 47:
|
||||
leagueName = "REL";
|
||||
break;
|
||||
case 48:
|
||||
leagueName = "WTL";
|
||||
break;
|
||||
case 49:
|
||||
leagueName = "LC";
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
return leagueName;
|
||||
}
|
||||
|
||||
public static String getLeagueNameCalendar(int id) {
|
||||
String leagueName = "";
|
||||
switch (id) {
|
||||
case 1:
|
||||
case 2:
|
||||
leagueName = "Tippliga";
|
||||
break;
|
||||
case 46:
|
||||
leagueName = "Elfmeter";
|
||||
break;
|
||||
case 47:
|
||||
leagueName = "Relegation";
|
||||
break;
|
||||
case 48:
|
||||
leagueName = "WTL-Pokal";
|
||||
break;
|
||||
case 49:
|
||||
leagueName = "Liga Cup";
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
return leagueName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,284 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import de.jeyp91.BaseMatch;
|
||||
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TLWMatch extends BaseMatch{
|
||||
|
||||
private Integer season = null;
|
||||
private Integer league = null;
|
||||
private Integer matchNo = null;
|
||||
private String groupId = null;
|
||||
private String formulaHome = null;
|
||||
private String formulaGuest = null;
|
||||
private Integer koMatch = 0;
|
||||
private Integer showTable = null;
|
||||
private String trend = null;
|
||||
private Float odd1 = null;
|
||||
private Float oddX = null;
|
||||
private Float odd2 = null;
|
||||
private Float rating = null;
|
||||
|
||||
public TLWMatch(ResultSet rset) {
|
||||
|
||||
final int SEASON = 1;
|
||||
final int LEAGUE = 2;
|
||||
final int MATCH_NO = 3;
|
||||
final int TEAM_ID_HOME = 4;
|
||||
final int TEAM_ID_GUEST = 5;
|
||||
final int GOALS_HOME = 6;
|
||||
final int GOALS_GUEST = 7;
|
||||
final int MATCHDAY = 8;
|
||||
final int STATUS = 9;
|
||||
final int MATCH_DATETIME = 10;
|
||||
final int GROUP_ID = 11;
|
||||
final int FORMULA_HOME = 12;
|
||||
final int FORMULA_GUEST = 13;
|
||||
final int KO_MATCH = 14;
|
||||
final int GOALS_OVERTIME_HOME = 15;
|
||||
final int GOALS_OVERTIME_GUEST = 16;
|
||||
final int SHOW_TABLE = 17;
|
||||
final int TREND = 18;
|
||||
final int ODD1 = 19;
|
||||
final int ODDX = 20;
|
||||
final int ODD2 = 21;
|
||||
final int RATING = 22;
|
||||
|
||||
try {
|
||||
this.season = Integer.parseInt(rset.getString(SEASON));
|
||||
this.league = Integer.parseInt(rset.getString(LEAGUE));
|
||||
this.matchNo = Integer.parseInt(rset.getString(MATCH_NO));
|
||||
this.teamIdHome = Integer.parseInt(rset.getString(TEAM_ID_HOME));
|
||||
this.teamIdGuest = Integer.parseInt(rset.getString(TEAM_ID_GUEST));
|
||||
this.goalsHome = rset.getString(GOALS_HOME).isEmpty()?null:Integer.parseInt(rset.getString(GOALS_HOME));
|
||||
this.goalsGuest = rset.getString(GOALS_GUEST).isEmpty()?null:Integer.parseInt(rset.getString(GOALS_GUEST));
|
||||
this.matchday = Integer.parseInt(rset.getString(MATCHDAY));
|
||||
this.status = Integer.parseInt(rset.getString(STATUS));
|
||||
this.matchDatetime = rset.getString(MATCH_DATETIME);
|
||||
this.groupId = rset.getString(GROUP_ID);
|
||||
this.formulaHome = rset.getString(FORMULA_HOME);
|
||||
this.formulaGuest = rset.getString(FORMULA_GUEST);
|
||||
this.koMatch = Integer.parseInt(rset.getString(KO_MATCH));
|
||||
this.goalsOvertimeHome = rset.getString(GOALS_OVERTIME_HOME).isEmpty()?null:Integer.parseInt(rset.getString(GOALS_OVERTIME_HOME));
|
||||
this.goalsOvertimeGuest = rset.getString(GOALS_OVERTIME_GUEST).isEmpty()?null:Integer.parseInt(rset.getString(GOALS_OVERTIME_GUEST));
|
||||
this.showTable = Integer.parseInt(rset.getString(SHOW_TABLE));
|
||||
this.trend = rset.getString(TREND);
|
||||
this.odd1 = Float.parseFloat(rset.getString(ODD1));
|
||||
this.oddX = Float.parseFloat(rset.getString(ODDX));
|
||||
this.odd2 = Float.parseFloat(rset.getString(ODD2));
|
||||
this.rating = Float.parseFloat(rset.getString(RATING));
|
||||
} catch (SQLException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public TLWMatch(APIFootballMatch apiFootballMatch, int season, int league, int matchday, int matchNo, int status, int koMatch, boolean showTable) {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.matchday = matchday;
|
||||
this.matchNo = matchNo;
|
||||
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
|
||||
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.GUEST);
|
||||
this.goalsHome = apiFootballMatch.getGoalsHome();
|
||||
this.goalsOvertimeHome = apiFootballMatch.getGoalsOvertimeHome();
|
||||
this.goalsOvertimeGuest = apiFootballMatch.getGoalsOvertimeGuest();
|
||||
this.goalsGuest = apiFootballMatch.getGoalsGuest();
|
||||
this.goalsHome = apiFootballMatch.getGoalsHome();
|
||||
this.goalsGuest = apiFootballMatch.getGoalsGuest();
|
||||
this.matchDatetime = apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19);
|
||||
this.groupId = this.getGroupFromMatchdayString(apiFootballMatch.getRound());
|
||||
this.formulaHome = "";
|
||||
this.formulaGuest = "";
|
||||
this.status = status;
|
||||
this.koMatch = koMatch;
|
||||
this.showTable = showTable ? 0 : 1;
|
||||
this.teamNameHome = apiFootballMatch.getTeamNameHome();
|
||||
this.teamNameGuest = apiFootballMatch.getTeamNameGuest();
|
||||
}
|
||||
|
||||
public TLWMatch(int season, int league, int matchday, int matchNo, String matchDatetime, int status, int koMatch) {
|
||||
this.season = season;
|
||||
this.matchday = matchday;
|
||||
this.league = league;
|
||||
this.matchNo = matchNo;
|
||||
this.status = status;
|
||||
this.koMatch = koMatch;
|
||||
this.matchDatetime = matchDatetime;
|
||||
}
|
||||
|
||||
public TLWMatch(int season, int league, int matchday, int matchNo, int teamIdHome, int teamIdGuest, String matchDatetime, int koMatch) {
|
||||
this.season = season;
|
||||
this.matchday = matchday;
|
||||
this.league = league;
|
||||
this.matchNo = matchNo;
|
||||
this.teamIdHome = teamIdHome;
|
||||
this.teamIdGuest = teamIdGuest;
|
||||
this.matchDatetime = matchDatetime;
|
||||
this.status = 0;
|
||||
this.koMatch = koMatch;
|
||||
}
|
||||
|
||||
public TLWMatch(TLWMatch referenceMatch) {
|
||||
this.season = referenceMatch.season;
|
||||
this.league = referenceMatch.league;
|
||||
this.matchday = referenceMatch.matchday;
|
||||
this.teamIdHome = referenceMatch.teamIdHome;
|
||||
this.teamIdGuest = referenceMatch.teamIdGuest;
|
||||
this.goalsHome = referenceMatch.goalsHome;
|
||||
this.goalsGuest = referenceMatch.goalsGuest;
|
||||
this.matchDatetime = referenceMatch.matchDatetime;
|
||||
this.matchNo = referenceMatch.matchNo;
|
||||
this.groupId = referenceMatch.groupId;
|
||||
this.formulaHome = referenceMatch.formulaHome;
|
||||
this.formulaGuest = referenceMatch.formulaGuest;
|
||||
this.status = referenceMatch.status;
|
||||
this.koMatch = referenceMatch.koMatch;
|
||||
this.goalsOvertimeHome = referenceMatch.goalsOvertimeHome;
|
||||
this.goalsOvertimeGuest = referenceMatch.goalsOvertimeGuest;
|
||||
this.showTable = referenceMatch.showTable;
|
||||
this.trend = referenceMatch.trend;
|
||||
this.odd1 = referenceMatch.odd1;
|
||||
this.oddX = referenceMatch.oddX;
|
||||
this.odd2 = referenceMatch.odd2;
|
||||
this.rating = referenceMatch.rating;
|
||||
}
|
||||
|
||||
public Integer getSeason() {
|
||||
return this.season;
|
||||
}
|
||||
|
||||
public Integer getLeague() {
|
||||
return this.league;
|
||||
}
|
||||
|
||||
public Integer getMatchNo() {
|
||||
return this.matchNo;
|
||||
}
|
||||
|
||||
public Integer getKoMatch() {
|
||||
return this.koMatch;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public Integer getShowTable() {
|
||||
return this.showTable;
|
||||
}
|
||||
|
||||
public String getFormulaHome() {
|
||||
String formula = "'D'";
|
||||
if(this.teamIdHome != null) {
|
||||
return "''";
|
||||
}
|
||||
else if (this.formulaHome != null) {
|
||||
formula = this.formulaHome;
|
||||
}
|
||||
return formula;
|
||||
}
|
||||
|
||||
public String getFormulaGuest() {
|
||||
String formula = "'D'";
|
||||
if(this.teamIdGuest != null) {
|
||||
return "''";
|
||||
}
|
||||
else if (this.formulaGuest != null) {
|
||||
formula = this.formulaGuest;
|
||||
}
|
||||
return formula;
|
||||
}
|
||||
|
||||
public String getSQLQueryInsert() {
|
||||
return "INSERT INTO phpbb_footb_matches VALUES (" +
|
||||
getSQLQueryValues()
|
||||
+ ");";
|
||||
}
|
||||
|
||||
public String getSQLQueryReplace() {
|
||||
return "REPLACE INTO phpbb_footb_matches VALUES (" +
|
||||
getSQLQueryValues()
|
||||
+ ");";
|
||||
}
|
||||
|
||||
public String getSQLQueryValues() {
|
||||
return this.season + ", " +
|
||||
this.league + ", " +
|
||||
this.matchNo + ", " +
|
||||
nullToSqlEmptyString(this.teamIdHome) + ", " +
|
||||
nullToSqlEmptyString(this.teamIdGuest) + ", " +
|
||||
nullToSqlEmptyString(this.goalsHome) + ", " +
|
||||
nullToSqlEmptyString(this.goalsGuest) + ", " +
|
||||
this.matchday + ", " +
|
||||
this.status + ", " +
|
||||
nullToSqlEmptyString(this.matchDatetime) + ", " +
|
||||
nullToSqlEmptyString(this.groupId) + ", " +
|
||||
getFormulaHome() + ", " +
|
||||
getFormulaGuest() + ", " +
|
||||
nullToSqlEmptyString(this.koMatch) + ", " +
|
||||
nullToSqlEmptyString(this.goalsOvertimeHome) + ", " +
|
||||
nullToSqlEmptyString(this.goalsOvertimeGuest) + ", " +
|
||||
nullToSqlEmptyString(this.showTable) + ", " +
|
||||
"'','0.00','0.00','0.00','0.00'";
|
||||
}
|
||||
|
||||
private String nullToSqlEmptyString(Integer number) {
|
||||
return number != null ? number.toString() : "''";
|
||||
}
|
||||
|
||||
private String nullToSqlEmptyString(String string) {
|
||||
return string != null ? "'"+string+"'" : "''";
|
||||
}
|
||||
|
||||
public void setGoalsHome(int goals) {
|
||||
this.goalsHome = goals;
|
||||
}
|
||||
|
||||
public void setGoalsGuest(int goals) {
|
||||
this.goalsGuest = goals;
|
||||
}
|
||||
|
||||
public void setGoalsOvertimeHome(int goals) {
|
||||
this.goalsOvertimeHome = goals;
|
||||
}
|
||||
|
||||
public void setGoalsOvertimeGuest(int goals) {
|
||||
this.goalsOvertimeGuest = goals;
|
||||
}
|
||||
|
||||
public void setMatchDateTime(String matchDateTime) {
|
||||
this.matchDatetime = matchDateTime;
|
||||
}
|
||||
|
||||
public void setShowTable(Boolean showTable) {
|
||||
this.showTable = showTable ? 0 : 1;
|
||||
}
|
||||
|
||||
public void updateMatch(APIFootballMatch apiFootballMatch) {
|
||||
this.teamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
|
||||
this.teamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.GUEST);
|
||||
this.teamNameHome = apiFootballMatch.getTeamNameHome();
|
||||
this.teamNameGuest = apiFootballMatch.getTeamNameGuest();
|
||||
this.goalsHome = apiFootballMatch.getGoalsHome();
|
||||
this.goalsGuest = apiFootballMatch.getGoalsGuest();
|
||||
this.matchDatetime = apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19);
|
||||
}
|
||||
|
||||
private String getGroupFromMatchdayString(String matchdayString) {
|
||||
if(matchdayString.startsWith("Group ")) {
|
||||
return matchdayString.substring(6, 7);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class TLWMatchday {
|
||||
|
||||
final Integer STATUS_NOTSTARTED = 0;
|
||||
final Integer STATUS_STARTED = 1;
|
||||
final Integer STATUS_PROVISIONAL_RESULT_AVAILABLE = 2;
|
||||
final Integer STATUS_FINISHED = 3;
|
||||
|
||||
private Integer season = null;
|
||||
private Integer league = null;
|
||||
private Integer matchday = null;
|
||||
private Integer status = null;
|
||||
private String deliveryDate = null;
|
||||
private String deliveryDate2 = null;
|
||||
private String deliveryDate3 = null;
|
||||
private String matchdayName = null;
|
||||
private Integer matches = null;
|
||||
|
||||
public TLWMatchday(ResultSet rset) {
|
||||
|
||||
final int SEASON = 1;
|
||||
final int LEAGUE = 2;
|
||||
final int MATCHDAY = 3;
|
||||
final int STATUS = 4;
|
||||
final int DELIVERY_DATE = 5;
|
||||
final int DELIVERY_DATE_2 = 6;
|
||||
final int DELIVERY_DATE_3 = 7;
|
||||
final int MATCHDAY_NAME = 8;
|
||||
final int MATCHES = 9;
|
||||
|
||||
try {
|
||||
this.season = Integer.parseInt(rset.getString(SEASON));
|
||||
this.league = Integer.parseInt(rset.getString(LEAGUE));
|
||||
this.matchday = Integer.parseInt(rset.getString(MATCHDAY));
|
||||
this.status = Integer.parseInt(rset.getString(STATUS));
|
||||
this.deliveryDate = rset.getString(DELIVERY_DATE);
|
||||
this.deliveryDate2 = rset.getString(DELIVERY_DATE_2);
|
||||
this.deliveryDate3 = rset.getString(DELIVERY_DATE_3);
|
||||
this.matchdayName = rset.getString(MATCHDAY_NAME);
|
||||
this.matches = Integer.parseInt(rset.getString(MATCHES));
|
||||
} catch (SQLException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public TLWMatchday(int season, int league, int matchday, int status, String deliveryDate1, String deliveryDate2, String deliveryDate3, String matchdayName, int numberOfMatches) {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.matchday = matchday;
|
||||
this.status = status;
|
||||
this.deliveryDate = deliveryDate1;
|
||||
this.deliveryDate2 = deliveryDate2;
|
||||
this.deliveryDate3 = deliveryDate3;
|
||||
this.matchdayName = matchdayName;
|
||||
this.matches = numberOfMatches;
|
||||
}
|
||||
|
||||
public Integer getSeason() {
|
||||
return this.season;
|
||||
}
|
||||
|
||||
public Integer getLeague() {
|
||||
return this.league;
|
||||
}
|
||||
|
||||
public Integer getMatchday() {
|
||||
return this.matchday;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public String getDeliveryDate() {
|
||||
return this.deliveryDate == null ? "" : this.deliveryDate;
|
||||
}
|
||||
|
||||
public String getDeliveryDate2() {
|
||||
return this.deliveryDate2 == null ? "" : this.deliveryDate2;
|
||||
}
|
||||
|
||||
public String getDeliveryDate3() {
|
||||
return this.deliveryDate3 == null ? "" : this.deliveryDate3;
|
||||
}
|
||||
|
||||
public String getMatchdayName() {
|
||||
return this.matchdayName;
|
||||
}
|
||||
|
||||
public Integer getMatches() {
|
||||
return this.matches;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.apifootball.APIFootballConnector;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import de.jeyp91.tippligaforum.TippligaConfigProvider;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TLWMatchdaysCreator {
|
||||
|
||||
int season;
|
||||
int league;
|
||||
ArrayList<TLWMatch> matches;
|
||||
int matchesPerMatchday;
|
||||
JSONObject configObject;
|
||||
|
||||
public TLWMatchdaysCreator(int season, int league, String configPath){
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
|
||||
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(season, 1, configPath);
|
||||
this.matches = matchesCreator.getMatches();
|
||||
|
||||
TippligaConfigProvider prov = new TippligaConfigProvider(season);
|
||||
this.configObject = prov.getTippligaConfig(configPath);
|
||||
|
||||
//Read JSON file
|
||||
this.matchesPerMatchday = ((Long) this.configObject.get("matchesPerMatchday")).intValue();
|
||||
}
|
||||
|
||||
public ArrayList<TLWMatchday> getMatchdays() {
|
||||
ArrayList<TLWMatchday> matchdays = new ArrayList<>();
|
||||
|
||||
JSONArray matchdaysConfig = (JSONArray) this.configObject.get("matchdayConfig");
|
||||
String deliveryDateMode = this.configObject.containsKey("deliveryDateMode") ? this.configObject.get("deliveryDateMode").toString() : "";
|
||||
for (Object matchdayConfig : matchdaysConfig) {
|
||||
JSONObject matchdayConfigJson = (JSONObject) matchdayConfig;
|
||||
|
||||
int matchdayNumber = Integer.parseInt(matchdayConfigJson.get("TLWMatchday").toString());
|
||||
String matchdayName = matchdayConfigJson.containsKey("matchdayName") ? matchdayConfigJson.get("matchdayName").toString() : "";
|
||||
|
||||
int numberOfMatches = this.matchesPerMatchday;
|
||||
if(numberOfMatches == 0){
|
||||
numberOfMatches = Integer.parseInt(matchdayConfigJson.get("numberOfMatches").toString());
|
||||
}
|
||||
|
||||
ArrayList<String> deliveryDates = getDeliveryDates(matchdayConfigJson, matchdayNumber, deliveryDateMode);
|
||||
|
||||
TLWMatchday matchday = new TLWMatchday(this.season, this.league, matchdayNumber, 0, deliveryDates.get(0), deliveryDates.get(1), deliveryDates.get(2), matchdayName, numberOfMatches);
|
||||
matchdays.add(matchday);
|
||||
}
|
||||
|
||||
return matchdays;
|
||||
}
|
||||
|
||||
private ArrayList<TLWMatch> getMatchesForMatchday(ArrayList<TLWMatch> matches, int matchday) {
|
||||
ArrayList<TLWMatch> matchesOfMatchday = new ArrayList<>();
|
||||
for(TLWMatch match : matches) {
|
||||
if(match.getMatchday() == matchday) {
|
||||
matchesOfMatchday.add(match);
|
||||
}
|
||||
}
|
||||
return matchesOfMatchday;
|
||||
}
|
||||
|
||||
private String getMatchdayNameFromConfig(int matchday) {
|
||||
String matchdayName = "";
|
||||
JSONArray matchdaysConfig = (JSONArray) this.configObject.get("matchdayConfig");
|
||||
for (Object matchdayConfig : matchdaysConfig) {
|
||||
if(((JSONObject) matchdayConfig).get("TLWMatchday").toString().equals(String.valueOf(matchday))
|
||||
&& ((JSONObject) matchdayConfig).containsKey("matchdayName")) {
|
||||
matchdayName = ((JSONObject) matchdayConfig).get("matchdayName").toString();
|
||||
}
|
||||
}
|
||||
return matchdayName;
|
||||
}
|
||||
|
||||
private ArrayList<String> getDeliveryDates(JSONObject matchdayConfigJson, int matchdayNumber, String deliveryDateMode) {
|
||||
ArrayList<String> deliveryDates;
|
||||
switch(deliveryDateMode) {
|
||||
case "single":
|
||||
deliveryDates = getDefaultSingleDeliveryDate(matchdayConfigJson, matchdayNumber);
|
||||
break;
|
||||
case "multiple":
|
||||
default:
|
||||
deliveryDates = getDefaultMultipleDeliveryDates(matchdayConfigJson, matchdayNumber);
|
||||
deliveryDates.addAll(getAdditionalDeliveryDates(matchdayConfigJson, matchdayNumber));
|
||||
deliveryDates = removeDuplicates(deliveryDates);
|
||||
break;
|
||||
}
|
||||
while(deliveryDates.size() < 3) {
|
||||
deliveryDates.add("");
|
||||
}
|
||||
return deliveryDates;
|
||||
}
|
||||
|
||||
private ArrayList<String> getDefaultSingleDeliveryDate(JSONObject matchdayConfigJson, int matchdayNumber) {
|
||||
ArrayList<String> deliveryDates = new ArrayList<>();
|
||||
|
||||
JSONArray matchesConfig = (JSONArray) matchdayConfigJson.get("matchesConfig");
|
||||
JSONObject matchesConfigPlaceholder = (JSONObject) matchesConfig.get(matchesConfig.size() - 1);
|
||||
ArrayList<TLWMatch> matchesOfMatchday = getMatchesForMatchday(matches, matchdayNumber);
|
||||
if(matchesOfMatchday.size() == 0) {
|
||||
deliveryDates.add(matchesConfigPlaceholder.get("placeholderDatetime").toString());
|
||||
}
|
||||
else {
|
||||
LocalDateTime firstMatchDate = TLWMatchesManagerBase.getFirstMatchtimeTLW(matchesOfMatchday);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
deliveryDates.add(firstMatchDate.format(formatter));
|
||||
}
|
||||
|
||||
return deliveryDates;
|
||||
}
|
||||
|
||||
private ArrayList<String> getDefaultMultipleDeliveryDates(JSONObject matchdayConfigJson, int matchdayNumber) {
|
||||
ArrayList<String> deliveryDates = new ArrayList<>();
|
||||
|
||||
JSONArray matchesConfig = (JSONArray) matchdayConfigJson.get("matchesConfig");
|
||||
JSONObject matchesConfigPlaceholder = (JSONObject) matchesConfig.get(matchesConfig.size() - 1);
|
||||
ArrayList<TLWMatch> matchesOfMatchday = getMatchesForMatchday(matches, matchdayNumber);
|
||||
if(matchesOfMatchday.size() == 0) {
|
||||
deliveryDates.add(matchesConfigPlaceholder.get("placeholderDatetime").toString());
|
||||
}
|
||||
else {
|
||||
LocalDateTime firstMatchDate = TLWMatchesManagerBase.getFirstMatchtimeTLW(matchesOfMatchday);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
deliveryDates.add(firstMatchDate.format(formatter));
|
||||
|
||||
ArrayList<TLWMatch> matchesSecondDay = TLWMatchesManagerBase.getMatchesStartingFromSecondDay(matchesOfMatchday);
|
||||
if(matchesSecondDay.size() > 0) {
|
||||
firstMatchDate = TLWMatchesManagerBase.getFirstMatchtimeTLW(matchesSecondDay);
|
||||
deliveryDates.add(firstMatchDate.format(formatter));
|
||||
}
|
||||
|
||||
ArrayList<TLWMatch> matchesSecondWeek = TLWMatchesManagerBase.getMatchesStartingFromSecondWeek(matchesOfMatchday);
|
||||
if(matchesSecondWeek.size() > 0) {
|
||||
firstMatchDate = TLWMatchesManagerBase.getFirstMatchtimeTLW(matchesSecondWeek);
|
||||
deliveryDates.add(firstMatchDate.format(formatter));
|
||||
}
|
||||
}
|
||||
|
||||
return deliveryDates;
|
||||
}
|
||||
|
||||
private ArrayList<String> getAdditionalDeliveryDates(JSONObject matchdayConfigJson, int matchdayNumber) {
|
||||
ArrayList<String> deliveryDates = new ArrayList<>();
|
||||
JSONArray matchesConfig = (JSONArray) matchdayConfigJson.get("matchesConfig");
|
||||
|
||||
APIFootballConnector conn = APIFootballConnector.getAPIFootballConnectorInstance(this.season);
|
||||
for(Object config: matchesConfig) {
|
||||
JSONObject jsonConfig = (JSONObject) config;
|
||||
if(jsonConfig.containsKey("additionalDeliveryDate") &&
|
||||
((Boolean) jsonConfig.get("additionalDeliveryDate"))) {
|
||||
ArrayList<APIFootballMatch> matches = TLWMatchesCreatorFootball.getAPIFootballMatchesForConfig(conn, jsonConfig);
|
||||
if(matches.size() > 0) {
|
||||
LocalDateTime firstDate = TLWMatchesManagerBase.getFirstMatchtimeAPIFootball(matches);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
deliveryDates.add(firstDate.format(formatter));
|
||||
}
|
||||
}
|
||||
}
|
||||
return deliveryDates;
|
||||
}
|
||||
|
||||
public String getMatchdaysSQL() {
|
||||
String matchdaySql = "";
|
||||
for (TLWMatchday matchday : getMatchdays()) {
|
||||
matchdaySql += "REPLACE INTO phpbb_footb_matchdays VALUES('";
|
||||
matchdaySql += matchday.getSeason().toString();
|
||||
matchdaySql += "', '";
|
||||
matchdaySql += matchday.getLeague().toString();
|
||||
matchdaySql += "', '";
|
||||
matchdaySql += matchday.getMatchday().toString();
|
||||
matchdaySql += "', '";
|
||||
matchdaySql += matchday.getStatus().toString();
|
||||
matchdaySql += "', '";
|
||||
matchdaySql += matchday.getDeliveryDate();
|
||||
matchdaySql += "', '";
|
||||
matchdaySql += matchday.getDeliveryDate2();
|
||||
matchdaySql += "', '";
|
||||
matchdaySql += matchday.getDeliveryDate3();
|
||||
matchdaySql += "', '";
|
||||
matchdaySql += matchday.getMatchdayName();
|
||||
matchdaySql += "', '";
|
||||
matchdaySql += matchday.getMatches().toString();
|
||||
matchdaySql += "');\n";
|
||||
}
|
||||
return matchdaySql;
|
||||
}
|
||||
|
||||
public static <T> ArrayList<T> removeDuplicates(ArrayList<T> list)
|
||||
{
|
||||
ArrayList<T> newList = new ArrayList<T>();
|
||||
for (T element : list) {
|
||||
if (!newList.contains(element)) {
|
||||
newList.add(element);
|
||||
}
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
|
||||
import static de.jeyp91.googlecalendar.TippligaGoogleEventManager.*;
|
||||
|
||||
public class TLWMatchdaysUpdater {
|
||||
|
||||
private final Logger logger = LogManager.getLogger(TLWMatch.class);
|
||||
|
||||
int season;
|
||||
int league;
|
||||
ArrayList<TLWMatchday> matchdaysOriginal;
|
||||
ArrayList<TLWMatchday> matchdaysUpdated;
|
||||
String beautifulInfo = "";
|
||||
|
||||
public TLWMatchdaysUpdater(int season, int league, String configPath) {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
|
||||
TippligaSQLConnector conn = TippligaSQLConnector.getInstance();
|
||||
this.matchdaysOriginal = conn.getMatchdays(String.valueOf(season), String.valueOf(league));
|
||||
this.matchdaysOriginal.sort(Comparator.comparing(TLWMatchday::getMatchday));
|
||||
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(season, league, configPath);
|
||||
this.matchdaysUpdated = creator.getMatchdays();
|
||||
this.matchdaysUpdated.sort(Comparator.comparing(TLWMatchday::getMatchday));
|
||||
}
|
||||
|
||||
public String getUpdateSql() {
|
||||
String updateSql = "";
|
||||
|
||||
if(this.matchdaysUpdated.size() != this.matchdaysOriginal.size()) {
|
||||
this.logger.error("Wrong matchdays config!");
|
||||
} else {
|
||||
|
||||
for (int i = 0; i < this.matchdaysUpdated.size(); i++) {
|
||||
TLWMatchday matchdayOriginal = this.matchdaysOriginal.get(i);
|
||||
TLWMatchday matchdayUpdated = this.matchdaysUpdated.get(i);
|
||||
|
||||
if (matchdayOriginal.getMatchday() != matchdayUpdated.getMatchday()) {
|
||||
this.logger.error("BUUUUG!");
|
||||
} else {
|
||||
|
||||
Date now = new Date(System.currentTimeMillis());
|
||||
|
||||
Date earliestDate = null;
|
||||
try {
|
||||
earliestDate = new SimpleDateFormat("yyyy-MM-dd").parse(matchdayUpdated.getDeliveryDate().substring(0, 10));
|
||||
} catch (java.text.ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (earliestDate.after(now)) {
|
||||
|
||||
String updateStart = "UPDATE phpbb_footb_matchdays SET ";
|
||||
String condition = "WHERE season = " + matchdayOriginal.getSeason() + " " +
|
||||
"AND league = " + matchdayOriginal.getLeague() + " " +
|
||||
"AND matchday = " + matchdayOriginal.getMatchday() + ";\n";
|
||||
String beautifulInfoStart = "Aktualisiere Saison " + matchdayOriginal.getSeason() + ", " +
|
||||
"Liga " + matchdayOriginal.getLeague() + ", " +
|
||||
"Spieltag " + matchdayOriginal.getMatchday() + ", ";
|
||||
|
||||
if (!matchdayOriginal.getDeliveryDate().equals(matchdayUpdated.getDeliveryDate())) {
|
||||
updateSql += updateStart +
|
||||
"delivery_date = '" + matchdayUpdated.getDeliveryDate() + "' " +
|
||||
condition;
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Tippabgabeschluss 1 zu '" + matchdayUpdated.getDeliveryDate() + "'.\n";
|
||||
}
|
||||
|
||||
if (!matchdayOriginal.getDeliveryDate2().equals(matchdayUpdated.getDeliveryDate2())) {
|
||||
updateSql += updateStart +
|
||||
"delivery_date_2 = '" + matchdayUpdated.getDeliveryDate2() + "' " +
|
||||
condition;
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Tippabgabeschluss 2 zu '" + matchdayUpdated.getDeliveryDate2() + "'.\n";
|
||||
}
|
||||
|
||||
if (!matchdayOriginal.getDeliveryDate3().equals(matchdayUpdated.getDeliveryDate3())) {
|
||||
updateSql += updateStart +
|
||||
"delivery_date_3 = '" + matchdayUpdated.getDeliveryDate3() + "' " +
|
||||
condition;
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Tippabgabeschluss 3 zu '" + matchdayUpdated.getDeliveryDate3() + "'.\n";
|
||||
}
|
||||
|
||||
if (!matchdayOriginal.getMatchdayName().equals(matchdayUpdated.getMatchdayName())) {
|
||||
updateSql += updateStart +
|
||||
"matchday_name = '" + matchdayUpdated.getMatchdayName() + "' " +
|
||||
condition;
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Spieltagsname zu '" + matchdayUpdated.getMatchdayName() + "'.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return updateSql;
|
||||
}
|
||||
|
||||
public void updateGoogleCalendar() {
|
||||
updateAllMatchdays(matchdaysUpdated);
|
||||
}
|
||||
|
||||
public String getBeautifulInfo() {
|
||||
return this.beautifulInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.apifootball.APIFootballConnector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class TLWMatchesCreatorBase {
|
||||
|
||||
ArrayList<TLWMatch> TLWMatches;
|
||||
APIFootballConnector conn;
|
||||
|
||||
public TLWMatchesCreatorBase() {
|
||||
this.TLWMatches = new ArrayList<>();
|
||||
}
|
||||
|
||||
public ArrayList<TLWMatch> getMatches() {
|
||||
return this.TLWMatches;
|
||||
}
|
||||
|
||||
public String getSQLInsertString() {
|
||||
String sql = "";
|
||||
|
||||
ArrayList<TLWMatch> tlwMatches = getMatches();
|
||||
|
||||
// Add matches from config
|
||||
for(TLWMatch match : tlwMatches) {
|
||||
sql += match.getSQLQueryReplace() + "\n";
|
||||
}
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
public int getNumberOfMatchdays() {
|
||||
int matchday = 0;
|
||||
for(TLWMatch match : this.TLWMatches) {
|
||||
if(match.getMatchday() > matchday) {
|
||||
matchday = match.getMatchday();
|
||||
}
|
||||
}
|
||||
return matchday;
|
||||
}
|
||||
|
||||
public ArrayList<TLWMatch> getMatchesForMatchday(int matchday) {
|
||||
ArrayList<TLWMatch> matches = new ArrayList<>();
|
||||
|
||||
for(TLWMatch match : this.TLWMatches) {
|
||||
if (match.getMatchday() == matchday) {
|
||||
matches.add(match);
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.apifootball.APIFootballConnector;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import de.jeyp91.tippligaforum.TippligaConfigProvider;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
|
||||
|
||||
int season;
|
||||
int league;
|
||||
int numberOfMatchdays;
|
||||
int matchesPerMatchday;
|
||||
int ko;
|
||||
int nextMatchNo = 1;
|
||||
JSONArray matchdayConfig;
|
||||
JSONObject config;
|
||||
|
||||
public TLWMatchesCreatorFootball(int season, int league, String configFileName) {
|
||||
|
||||
super();
|
||||
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1);
|
||||
|
||||
TippligaConfigProvider prov = new TippligaConfigProvider(season);
|
||||
this.config = prov.getTippligaConfig(configFileName);
|
||||
|
||||
this.numberOfMatchdays = ((Long) this.config.get("numberOfMatchdays")).intValue();
|
||||
this.matchesPerMatchday = ((Long) this.config.get("matchesPerMatchday")).intValue();
|
||||
this.matchdayConfig = (JSONArray) this.config.get("matchdayConfig");
|
||||
this.ko = ((Long) this.config.get("ko")).intValue();
|
||||
String deliveryDateMode = this.config.containsKey("deliveryDateMode") ? this.config.get("deliveryDateMode").toString() : "";
|
||||
|
||||
this.publicateMatchObjects(deliveryDateMode);
|
||||
}
|
||||
|
||||
private void publicateMatchObjects(String deliveryDateMode) {
|
||||
for(int i = 0; i < this.matchdayConfig.size(); i++) {
|
||||
int TLWMatchday = ((Long) ((JSONObject) this.matchdayConfig.get(i)).get("TLWMatchday")).intValue();
|
||||
|
||||
JSONArray matchesConfig = (JSONArray)((JSONObject) this.matchdayConfig.get(i)).get("matchesConfig");
|
||||
ArrayList<APIFootballMatch> apiFootballMatchesForMatchday = getAPIFootballMatchesForMatchday(matchesConfig);
|
||||
|
||||
int matchdayMatchCounter = 0;
|
||||
|
||||
// Use first matchtime because API Football always returns matches sorted by date
|
||||
LocalDateTime firstDate = TLWMatchesManagerBase.getFirstMatchtimeAPIFootball(apiFootballMatchesForMatchday);
|
||||
|
||||
for(APIFootballMatch match : apiFootballMatchesForMatchday) {
|
||||
int matchNo = this.nextMatchNo;
|
||||
this.nextMatchNo++;
|
||||
int status = 0;
|
||||
LocalDateTime matchDateTime = TLWMatchesManagerBase.getDate(match);
|
||||
if(!deliveryDateMode.equals("single")
|
||||
&& firstDate != null
|
||||
&& TLWMatchesManagerBase.getDaysDifference(firstDate, matchDateTime) >= 1) {
|
||||
status = -1;
|
||||
}
|
||||
this.TLWMatches.add(new TLWMatch(match, this.season, this.league, TLWMatchday, matchNo, status, this.ko, true));
|
||||
matchdayMatchCounter++;
|
||||
if(firstDate == null) {
|
||||
firstDate = matchDateTime;
|
||||
}
|
||||
}
|
||||
|
||||
// Add empty missing matches
|
||||
int matchesPerMatchdayTemp = 0;
|
||||
if(this.matchesPerMatchday != 0) {
|
||||
matchesPerMatchdayTemp = this.matchesPerMatchday;
|
||||
} else {
|
||||
if(((JSONObject) this.matchdayConfig.get(i)).containsKey("numberOfMatches")) {
|
||||
matchesPerMatchdayTemp = ((Long) ((JSONObject) this.matchdayConfig.get(i)).get("numberOfMatches")).intValue();
|
||||
}
|
||||
}
|
||||
for(int j = matchdayMatchCounter; j < matchesPerMatchdayTemp; j++) {
|
||||
String matchDatetime = "";
|
||||
if(apiFootballMatchesForMatchday.size() > 0) {
|
||||
matchDatetime = this.TLWMatches.get(this.TLWMatches.size() - 1).getMatchDateTime();
|
||||
}
|
||||
else {
|
||||
matchDatetime = ((JSONObject) matchesConfig.get(matchesConfig.size() - 1)).get("placeholderDatetime").toString();
|
||||
}
|
||||
int matchNo = this.nextMatchNo;
|
||||
this.nextMatchNo++;
|
||||
this.TLWMatches.add(new TLWMatch(this.season, this.league, TLWMatchday, matchNo, matchDatetime, 0, this.ko));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<APIFootballMatch> getAPIFootballMatchesForMatchday(JSONArray config) {
|
||||
ArrayList<APIFootballMatch> apiFootballMatches = new ArrayList<>();
|
||||
for (Object singleConfigObject : config) {
|
||||
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
||||
apiFootballMatches.addAll(getAPIFootballMatchesForConfig(this.conn, singleConfig));
|
||||
}
|
||||
return apiFootballMatches;
|
||||
}
|
||||
|
||||
public static ArrayList<APIFootballMatch> getAPIFootballMatchesForConfig(APIFootballConnector conn, JSONObject singleConfig) {
|
||||
ArrayList<APIFootballMatch> apiFootballMatches = new ArrayList<>();
|
||||
String type = (String) singleConfig.get("type");
|
||||
switch (type) {
|
||||
case "AllMatchesOfMatchday":
|
||||
int matchesLeague = ((Long) singleConfig.get("matchesLeague")).intValue();
|
||||
int leagueMatchday = ((Long) singleConfig.get("leagueMatchday")).intValue();
|
||||
apiFootballMatches.addAll(conn.getMatchDataByLeagueAndMatchday(matchesLeague, leagueMatchday));
|
||||
break;
|
||||
case "SingleMatch":
|
||||
int matchLeague = ((Long) singleConfig.get("matchLeague")).intValue();
|
||||
int matchId = ((Long) singleConfig.get("matchId")).intValue();
|
||||
apiFootballMatches.add(conn.getMatchDataByLeagueAndMatchID(matchLeague, matchId));
|
||||
break;
|
||||
}
|
||||
return apiFootballMatches;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.ResourceProvider;
|
||||
import de.jeyp91.StatusHolder;
|
||||
import de.jeyp91.tippligaforum.TippligaConfigProvider;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase {
|
||||
|
||||
private final Logger logger = LogManager.getLogger(TLWMatchesCreatorTipperLeague.class);
|
||||
|
||||
int season;
|
||||
int league;
|
||||
|
||||
JSONArray matchPairingConfig;
|
||||
JSONObject tipperList;
|
||||
JSONArray tipperTeamConfig;
|
||||
ArrayList<TLWMatchday> matchdays;
|
||||
|
||||
public TLWMatchesCreatorTipperLeague(int season, int league, String configFileName, ArrayList<TLWMatchday> matchdays) {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.matchdays = matchdays;
|
||||
|
||||
|
||||
this.matchPairingConfig = ResourceProvider.getTipperMatchPairConfig();
|
||||
this.tipperTeamConfig = ResourceProvider.getTipperTeamConfig();
|
||||
|
||||
TippligaConfigProvider prov = new TippligaConfigProvider(season);
|
||||
this.tipperList = prov.getTippligaConfig(configFileName);
|
||||
|
||||
this.publicateMatchObjects();
|
||||
}
|
||||
|
||||
private void publicateMatchObjects() {
|
||||
|
||||
for(Object matchdayConfig : this.matchPairingConfig) {
|
||||
|
||||
int matchday = ((Long) ((JSONObject) matchdayConfig).get("matchday")).intValue();
|
||||
JSONArray matchesConfig = (JSONArray)((JSONObject) matchdayConfig).get("matches");
|
||||
|
||||
for(int i = 0; i < matchesConfig.size(); i++) {
|
||||
int homeTipperNumber = ((Long) ((JSONObject) matchesConfig.get(i)).get("home")).intValue();
|
||||
int guestTipperNumber = ((Long) ((JSONObject) matchesConfig.get(i)).get("guest")).intValue();
|
||||
|
||||
String homeName = this.tipperList.get(String.valueOf(homeTipperNumber)).toString();
|
||||
String guestName = this.tipperList.get(String.valueOf(guestTipperNumber)).toString();
|
||||
|
||||
int teamIdHome = getTeamIdFromTipperName(homeName);
|
||||
int teamIdGuest = getTeamIdFromTipperName(guestName);
|
||||
|
||||
int matchNo = (matchday - 1) * matchesConfig.size() + i + 1;
|
||||
|
||||
String matchDatetime = getDeliveryDateForMatchday(matchday);
|
||||
|
||||
TLWMatch tlwMatch = new TLWMatch(this.season, this.league, matchday, matchNo, teamIdHome, teamIdGuest, matchDatetime, 0);
|
||||
this.TLWMatches.add(tlwMatch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getTeamIdFromTipperName(String name) {
|
||||
int teamId = 0;
|
||||
for(Object config : tipperTeamConfig) {
|
||||
if (((JSONObject) config).get("team_name").toString().equals(name)) {
|
||||
teamId = ((Long) (((JSONObject) config).get("team_id"))).intValue();
|
||||
}
|
||||
}
|
||||
if(teamId == 0) {
|
||||
logger.error("ERROR! Did not find Tipper ID for " + name);
|
||||
StatusHolder.setError();
|
||||
}
|
||||
return teamId;
|
||||
}
|
||||
|
||||
private String getDeliveryDateForMatchday(int matchday) {
|
||||
String deliveryDate = "";
|
||||
for (TLWMatchday matchdayObject : this.matchdays) {
|
||||
if(matchdayObject.getMatchday() == matchday) {
|
||||
deliveryDate = matchdayObject.getDeliveryDate();
|
||||
}
|
||||
}
|
||||
return deliveryDate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.ResourceProvider;
|
||||
import de.jeyp91.tippligaforum.TippligaConfigProvider;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{
|
||||
|
||||
Logger logger = LogManager.getLogger(TLWMatchesCreatorTipperPokal.class);
|
||||
|
||||
int season;
|
||||
int league;
|
||||
|
||||
ArrayList<TLWMatch> TLWMatches;
|
||||
JSONObject tipperList;
|
||||
JSONArray tipperTeamConfig;
|
||||
ArrayList<TLWMatchday> matchdays;
|
||||
|
||||
public TLWMatchesCreatorTipperPokal(int season, int league, String configFileName, ArrayList<TLWMatchday> matchdays) {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.matchdays = matchdays;
|
||||
|
||||
TippligaConfigProvider prov = new TippligaConfigProvider(season);
|
||||
this.tipperList = prov.getTippligaConfig(configFileName);
|
||||
|
||||
this.tipperTeamConfig = ResourceProvider.getTipperTeamConfig();
|
||||
|
||||
this.TLWMatches = new ArrayList<>();
|
||||
|
||||
this.publicateMatchObjects();
|
||||
}
|
||||
|
||||
private void publicateMatchObjects() {
|
||||
|
||||
int matchday = 1;
|
||||
|
||||
for(int matchNo = 1; matchNo <= this.tipperList.size() / 2; matchNo++) {
|
||||
|
||||
String homeName = this.tipperList.get(String.valueOf(2 * matchNo - 1)).toString();
|
||||
String guestName = this.tipperList.get(String.valueOf(2 * matchNo)).toString();
|
||||
|
||||
int teamIdHome = getTeamIdFromTipperName(homeName);
|
||||
int teamIdGuest = getTeamIdFromTipperName(guestName);
|
||||
|
||||
String matchDatetime = getDeliveryDateForMatchday(matchday);
|
||||
|
||||
TLWMatch tlwMatch = new TLWMatch(this.season, this.league, matchday, matchNo, teamIdHome, teamIdGuest, matchDatetime, 1);
|
||||
tlwMatch.setShowTable(false);
|
||||
this.TLWMatches.add(tlwMatch);
|
||||
}
|
||||
}
|
||||
|
||||
private int getTeamIdFromTipperName(String name) {
|
||||
int teamId = 0;
|
||||
for(Object config : tipperTeamConfig) {
|
||||
if (((JSONObject) config).get("team_name").toString().equals(name)) {
|
||||
teamId = ((Long) (((JSONObject) config).get("team_id"))).intValue();
|
||||
}
|
||||
}
|
||||
if(teamId == 0) {
|
||||
logger.error("Did not find Tipper ID for " + name);
|
||||
}
|
||||
return teamId;
|
||||
}
|
||||
|
||||
public ArrayList<TLWMatch> getMatches() {
|
||||
return this.TLWMatches;
|
||||
}
|
||||
|
||||
private String getDeliveryDateForMatchday(int matchday) {
|
||||
String deliveryDate = "";
|
||||
for (TLWMatchday matchdayObject : this.matchdays) {
|
||||
if(matchdayObject.getMatchday() == matchday) {
|
||||
deliveryDate = matchdayObject.getDeliveryDate();
|
||||
}
|
||||
}
|
||||
return deliveryDate;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
||||
import de.jeyp91.tippligaforum.TippligaConfigProvider;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TLWMatchesManagerBase {
|
||||
|
||||
protected int season;
|
||||
protected int league;
|
||||
protected int numberOfMatchdays;
|
||||
protected int matchesPerMatchday;
|
||||
protected int ko;
|
||||
protected int betKOType;
|
||||
|
||||
protected JSONArray matchdayConfig;
|
||||
|
||||
protected void initConfigParamsFromFile(String configFileName) {
|
||||
|
||||
TippligaConfigProvider prov = new TippligaConfigProvider(this.season);
|
||||
JSONObject config = prov.getTippligaConfig(configFileName);
|
||||
this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue();
|
||||
this.matchdayConfig = (JSONArray) config.get("matchdayConfig");
|
||||
this.ko = ((Long) config.get("ko")).intValue();
|
||||
Long parsedBetKOType = (Long) config.get("betKOType");
|
||||
this.betKOType = parsedBetKOType == null ? 1 : parsedBetKOType.intValue();
|
||||
}
|
||||
|
||||
public static ArrayList<TLWMatch> getMatchesStartingFromSecondDay(ArrayList<TLWMatch> matches) {
|
||||
LocalDateTime firstMatchtime = getFirstMatchtimeTLW(matches);
|
||||
ArrayList<TLWMatch> filteredMatches = new ArrayList<>();
|
||||
for(TLWMatch match : matches) {
|
||||
LocalDateTime matchDateTime = getDate(match);
|
||||
if(getDaysDifference(matchDateTime, firstMatchtime) != 0) {
|
||||
filteredMatches.add(match);
|
||||
}
|
||||
}
|
||||
return filteredMatches;
|
||||
}
|
||||
|
||||
public static ArrayList<TLWMatch> getMatchesStartingFromSecondWeek(ArrayList<TLWMatch> matches) {
|
||||
LocalDateTime firstMatchtime = getFirstMatchtimeTLW(matches);
|
||||
ArrayList<TLWMatch> filteredMatches = new ArrayList<>();
|
||||
for(TLWMatch match : matches) {
|
||||
LocalDateTime matchDateTime = getDate(match);
|
||||
if(getDaysDifference(matchDateTime, firstMatchtime) > 6) {
|
||||
filteredMatches.add(match);
|
||||
}
|
||||
}
|
||||
return filteredMatches;
|
||||
}
|
||||
|
||||
public static LocalDateTime getFirstMatchtimeTLW(ArrayList<TLWMatch> matches) {
|
||||
LocalDateTime matchtime = null;
|
||||
for(TLWMatch match : matches) {
|
||||
LocalDateTime matchtimeTemp = getDate(match);
|
||||
if(matchtime == null) {
|
||||
matchtime = matchtimeTemp;
|
||||
} else {
|
||||
if(matchtimeTemp.isBefore(matchtime)) {
|
||||
matchtime = matchtimeTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return matchtime;
|
||||
}
|
||||
|
||||
public static LocalDateTime getFirstMatchtimeAPIFootball(ArrayList<APIFootballMatch> matches) {
|
||||
LocalDateTime matchtime = null;
|
||||
for(APIFootballMatch match : matches) {
|
||||
LocalDateTime matchtimeTemp = getDate(match);
|
||||
if(matchtime == null) {
|
||||
matchtime = matchtimeTemp;
|
||||
} else {
|
||||
if(matchtimeTemp.isBefore(matchtime)) {
|
||||
matchtime = matchtimeTemp;
|
||||
}
|
||||
}
|
||||
}
|
||||
return matchtime;
|
||||
}
|
||||
|
||||
public static LocalDateTime getDate(TLWMatch match) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime dateTime = LocalDateTime.parse(match.getMatchDateTime(), formatter);
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public static LocalDateTime getDate(APIFootballMatch match) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
||||
LocalDateTime dateTime = LocalDateTime.parse(match.getMatchDateTime().substring(0, 19), formatter);
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
public static int getDaysDifference(LocalDateTime date1, LocalDateTime date2) {
|
||||
date1 = date1.toLocalDate().atTime(0, 0, 0);
|
||||
date2 = date2.toLocalDate().atTime(0, 0, 0);
|
||||
return (int) date1.until(date2, ChronoUnit.DAYS);
|
||||
}
|
||||
|
||||
protected TLWMatch getMatchingMatch(APIFootballMatch apiFootballMatch, ArrayList<TLWMatch> tlwMatches) throws NullPointerException{
|
||||
int foundMatches = 0;
|
||||
TLWMatch matchingMatch = null;
|
||||
for(TLWMatch match : tlwMatches) {
|
||||
Integer apiTeamIdHome = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.HOME);
|
||||
Integer apiTeamIdGuest = TeamIDMatcher.getTippligaIdFromApiFootballId(apiFootballMatch, TeamIDMatcher.GUEST);
|
||||
int tlwTeamIdHome = match.getTeamIdHome();
|
||||
int tlwTeamIdGuest = match.getTeamIdGuest();
|
||||
|
||||
if(apiTeamIdHome == null
|
||||
|| apiTeamIdGuest == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
if(
|
||||
apiTeamIdHome.equals(tlwTeamIdHome)
|
||||
&& apiTeamIdGuest.equals(tlwTeamIdGuest)
|
||||
) {
|
||||
foundMatches++;
|
||||
matchingMatch = match;
|
||||
}
|
||||
}
|
||||
return matchingMatch;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import de.jeyp91.apifootball.APIFootballMatchesProvider;
|
||||
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||
import de.jeyp91.tippligaforum.TippligaWebsiteConnector;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
|
||||
public class TLWMatchesResultsUpdater extends TLWMatchesManagerBase {
|
||||
private static final Logger logger = LogManager.getLogger(TLWMatchesResultsUpdater.class);
|
||||
|
||||
|
||||
ArrayList<ArrayList<TLWMatch>> tlwMatchesUpdated = new ArrayList<>();
|
||||
|
||||
String beautifulInfo = "";
|
||||
|
||||
public TLWMatchesResultsUpdater(int season, int league, String configFileName) {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
|
||||
super.initConfigParamsFromFile(configFileName);
|
||||
initUpdates();
|
||||
applyUpdates();
|
||||
}
|
||||
|
||||
private void initUpdates() {
|
||||
|
||||
APIFootballMatchesProvider apiFootballMatchesProvider = new APIFootballMatchesProvider(this.season);
|
||||
TippligaSQLConnector tippligaSQLConnector = TippligaSQLConnector.getInstance();
|
||||
for (Object singleMatchdayConfig : this.matchdayConfig) {
|
||||
int tlwMatchday = ((Long) ((JSONObject) singleMatchdayConfig).get("TLWMatchday")).intValue();
|
||||
JSONArray matchesConfig = (JSONArray) ((JSONObject) singleMatchdayConfig).get("matchesConfig");
|
||||
|
||||
ArrayList<APIFootballMatch> apiFootballMatches = apiFootballMatchesProvider.getAPIFootballMatchesFromConfig(matchesConfig);
|
||||
|
||||
ArrayList<TLWMatch> tlwMatchesOriginalMatchday = tippligaSQLConnector.getMatches(String.valueOf(this.season), String.valueOf(this.league), String.valueOf(tlwMatchday));
|
||||
ArrayList<TLWMatch> tlwMatchesUpdatedMatchday = new ArrayList<>();
|
||||
for (TLWMatch match : tlwMatchesOriginalMatchday) {
|
||||
tlwMatchesUpdatedMatchday.add(new TLWMatch(match));
|
||||
}
|
||||
|
||||
if (apiFootballMatches.size() > tlwMatchesOriginalMatchday.size()) {
|
||||
logger.error("Not matching config!");
|
||||
}
|
||||
|
||||
if(apiFootballMatches.size() > 0) {
|
||||
updateResults(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||
}
|
||||
|
||||
updateBeautifulInfo(tlwMatchesOriginalMatchday, tlwMatchesUpdatedMatchday);
|
||||
tlwMatchesUpdatedMatchday.removeIf(tlwMatch -> tlwMatch.getUpdateStatus() != TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||
if(tlwMatchesUpdatedMatchday.size() > 0) this.tlwMatchesUpdated.add(tlwMatchesUpdatedMatchday);
|
||||
}
|
||||
}
|
||||
|
||||
public void applyUpdates() {
|
||||
TippligaWebsiteConnector con;
|
||||
try {
|
||||
con = new TippligaWebsiteConnector();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
this.tlwMatchesUpdated.forEach(tlwMatches -> {
|
||||
con.updateResultsAdmin(this.season, this.league, tlwMatches.get(0).getMatchday(), tlwMatches);
|
||||
});
|
||||
}
|
||||
|
||||
private void updateResults(
|
||||
ArrayList<TLWMatch> tlwMatchesUpdated,
|
||||
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||
{
|
||||
ArrayList<TLWMatch> tlwMatchesCopy = new ArrayList<>(tlwMatchesUpdated);
|
||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||
try {
|
||||
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatchesCopy);
|
||||
tlwMatchesCopy.remove(tlwMatch);
|
||||
if(Objects.equals(apiFootballMatch.getStatus(), TLWMatch.STATUS_FINISHED)) {
|
||||
if(!Objects.equals(tlwMatch.getGoalsHome(), apiFootballMatch.getGoalsHome())
|
||||
|| !Objects.equals(tlwMatch.getGoalsGuest(), apiFootballMatch.getGoalsGuest())
|
||||
) {
|
||||
tlwMatch.setGoalsHome(apiFootballMatch.getGoalsHome());
|
||||
tlwMatch.setGoalsGuest(apiFootballMatch.getGoalsGuest());
|
||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||
}
|
||||
if(tlwMatch.getKoMatch() == 1 &&
|
||||
this.betKOType == 2 &&
|
||||
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsOvertimeHome())
|
||||
|| !Objects.equals(tlwMatch.getGoalsOvertimeGuest(), apiFootballMatch.getGoalsOvertimeGuest()))
|
||||
) {
|
||||
tlwMatch.setGoalsOvertimeHome(apiFootballMatch.getGoalsOvertimeHome());
|
||||
tlwMatch.setGoalsOvertimeGuest(apiFootballMatch.getGoalsOvertimeGuest());
|
||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||
}
|
||||
if(tlwMatch.getKoMatch() == 1 &&
|
||||
(this.betKOType == 1 || this.betKOType == 3) &&
|
||||
(apiFootballMatch.getGoalsPenaltyHome() != null) &&
|
||||
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsPenaltyHome())
|
||||
|| !Objects.equals(tlwMatch.getGoalsOvertimeGuest(), apiFootballMatch.getGoalsPenaltyGuest()))
|
||||
) {
|
||||
tlwMatch.setGoalsOvertimeHome(apiFootballMatch.getGoalsPenaltyHome());
|
||||
tlwMatch.setGoalsOvertimeGuest(apiFootballMatch.getGoalsPenaltyGuest());
|
||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||
}
|
||||
if(tlwMatch.getKoMatch() == 1 &&
|
||||
(this.betKOType == 1 || this.betKOType == 3) &&
|
||||
(apiFootballMatch.getGoalsPenaltyHome() == null) &&
|
||||
(!Objects.equals(tlwMatch.getGoalsOvertimeHome(), apiFootballMatch.getGoalsOvertimeHome())
|
||||
|| !Objects.equals(tlwMatch.getGoalsOvertimeGuest(), apiFootballMatch.getGoalsOvertimeGuest()))
|
||||
) {
|
||||
tlwMatch.setGoalsOvertimeHome(apiFootballMatch.getGoalsOvertimeHome());
|
||||
tlwMatch.setGoalsOvertimeGuest(apiFootballMatch.getGoalsOvertimeGuest());
|
||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||
}
|
||||
if(Objects.equals(tlwMatch.getStatus(), TLWMatch.STATUS_PROVISIONAL_RESULT_AVAILABLE)) {
|
||||
tlwMatch.setUpdateStatus(TLWMatch.COMPARISON.DIFFERENT_RESULT);
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBeautifulInfo(ArrayList<TLWMatch> matchesOriginal, ArrayList<TLWMatch> matchesUpdated) {
|
||||
for (int i = 0; i < matchesOriginal.size(); i++) {
|
||||
updateBeautifulInfo(matchesOriginal.get(i), matchesUpdated.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBeautifulInfo(TLWMatch matchOriginal, TLWMatch matchUpdated) {
|
||||
String beautifulInfoStart = "Aktualisiere Saison " + matchOriginal.getSeason() + ", " +
|
||||
"Liga " + matchOriginal.getLeague() + ", " +
|
||||
"Spieltag " + matchOriginal.getMatchday() + ", " +
|
||||
"Spielnummer " + matchOriginal.getMatchNo() + ", " +
|
||||
"Spiel '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdHome()) + "' - '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdGuest()) + "', ";
|
||||
|
||||
if(!Objects.equals(matchOriginal.getGoalsHome(), matchUpdated.getGoalsHome())
|
||||
|| !Objects.equals(matchOriginal.getGoalsGuest(), matchUpdated.getGoalsGuest())) {
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Ergebnis zu '" + matchUpdated.getGoalsHome() + ":" + matchUpdated.getGoalsGuest() + "'.\n";
|
||||
}
|
||||
|
||||
if(matchOriginal.getKoMatch() == 1 && (!Objects.equals(matchOriginal.getGoalsOvertimeHome(), matchUpdated.getGoalsOvertimeHome())
|
||||
|| !Objects.equals(matchOriginal.getGoalsOvertimeGuest(), matchUpdated.getGoalsOvertimeGuest()))) {
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Ergebnis Nachspielzeit zu '" + matchUpdated.getGoalsOvertimeHome() + ":" + matchUpdated.getGoalsOvertimeGuest() + "'.\n";
|
||||
}
|
||||
|
||||
if(matchOriginal.getStatus().equals(TLWMatch.STATUS_PROVISIONAL_RESULT_AVAILABLE)
|
||||
&& Objects.equals(matchOriginal.getGoalsHome(), matchUpdated.getGoalsHome())
|
||||
&& Objects.equals(matchOriginal.getGoalsGuest(), matchUpdated.getGoalsGuest())
|
||||
&& (matchOriginal.getKoMatch() == 0 || (
|
||||
matchOriginal.getKoMatch() == 1
|
||||
&& Objects.equals(matchOriginal.getGoalsOvertimeHome(), matchUpdated.getGoalsOvertimeHome())
|
||||
&& Objects.equals(matchOriginal.getGoalsOvertimeGuest(), matchUpdated.getGoalsOvertimeGuest())
|
||||
))
|
||||
) {
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Ergebnis gespeichert.\n";
|
||||
}
|
||||
}
|
||||
|
||||
public String getBeautifulInfo() {
|
||||
return this.beautifulInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.StatusHolder;
|
||||
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import de.jeyp91.apifootball.APIFootballMatchesProvider;
|
||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.time.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase {
|
||||
private static final Logger logger = LogManager.getLogger(TLWMatchesUpdaterFootball.class);
|
||||
|
||||
ArrayList<TLWMatch> tlwMatchesOriginal;
|
||||
ArrayList<TLWMatch> tlwMatchesUpdated;
|
||||
|
||||
String beautifulInfo = "";
|
||||
|
||||
public TLWMatchesUpdaterFootball(int season, int league, String configFileName) {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
|
||||
tlwMatchesOriginal = new ArrayList<>();
|
||||
tlwMatchesUpdated = new ArrayList<>();
|
||||
|
||||
super.initConfigParamsFromFile(configFileName);
|
||||
this.initUpdates();
|
||||
}
|
||||
|
||||
private void initUpdates() {
|
||||
|
||||
APIFootballMatchesProvider apiFootballMatchesProvider = new APIFootballMatchesProvider(this.season);
|
||||
TippligaSQLConnector tippligaSQLConnector = TippligaSQLConnector.getInstance();
|
||||
for (Object singleMatchdayConfig : this.matchdayConfig) {
|
||||
int tlwMatchday = ((Long) ((JSONObject) singleMatchdayConfig).get("TLWMatchday")).intValue();
|
||||
JSONArray matchesConfig = (JSONArray) ((JSONObject) singleMatchdayConfig).get("matchesConfig");
|
||||
|
||||
ArrayList<APIFootballMatch> apiFootballMatches = apiFootballMatchesProvider.getAPIFootballMatchesFromConfig(matchesConfig);
|
||||
|
||||
ArrayList<TLWMatch> tlwMatchesOriginalMatchday = tippligaSQLConnector.getMatches(String.valueOf(this.season), String.valueOf(this.league), String.valueOf(tlwMatchday));
|
||||
ArrayList<TLWMatch> tlwMatchesUpdatedMatchday = new ArrayList<>();
|
||||
for (TLWMatch match : tlwMatchesOriginalMatchday) {
|
||||
tlwMatchesUpdatedMatchday.add(new TLWMatch(match));
|
||||
}
|
||||
|
||||
if (apiFootballMatches.size() > tlwMatchesUpdatedMatchday.size()) {
|
||||
logger.error("Not matching config!");
|
||||
}
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime firstMatchOriginal = TLWMatchesManagerBase.getFirstMatchtimeTLW(tlwMatchesOriginalMatchday);
|
||||
LocalDateTime firstMatchUpdated = TLWMatchesManagerBase.getFirstMatchtimeAPIFootball(apiFootballMatches);
|
||||
|
||||
if(apiFootballMatches.size() > 0
|
||||
&& now.isBefore(firstMatchOriginal)
|
||||
&& now.isBefore(firstMatchUpdated)) {
|
||||
addMissingMatches(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||
updateMatchDateTimes(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||
updateShowTable(tlwMatchesUpdatedMatchday, apiFootballMatches);
|
||||
updateStatus(tlwMatchesUpdatedMatchday);
|
||||
}
|
||||
|
||||
this.tlwMatchesOriginal.addAll(tlwMatchesOriginalMatchday);
|
||||
this.tlwMatchesUpdated.addAll(tlwMatchesUpdatedMatchday);
|
||||
}
|
||||
}
|
||||
|
||||
public String getUpdateSQL() {
|
||||
return this.getUpdateString(tlwMatchesOriginal, tlwMatchesUpdated);
|
||||
}
|
||||
|
||||
private String getUpdateString(ArrayList<TLWMatch> matchesOriginal, ArrayList<TLWMatch> matchesUpdated) {
|
||||
String updateString = "";
|
||||
for (int i = 0; i < matchesOriginal.size(); i++) {
|
||||
updateString += getUpdateString(matchesOriginal.get(i), matchesUpdated.get(i));
|
||||
}
|
||||
return updateString;
|
||||
}
|
||||
|
||||
private String getUpdateString(TLWMatch matchOriginal, TLWMatch matchUpdated) {
|
||||
String updateString = "";
|
||||
String updateStart = "UPDATE phpbb_footb_matches SET ";
|
||||
String condition = "WHERE season = " + matchOriginal.getSeason() + " " +
|
||||
"AND league = " + matchOriginal.getLeague() + " " +
|
||||
"AND matchday = " + matchOriginal.getMatchday() + " " +
|
||||
"AND match_no = " + matchOriginal.getMatchNo() + ";\n";
|
||||
String beautifulInfoStart = "Aktualisiere Saison " + matchOriginal.getSeason() + ", " +
|
||||
"Liga " + matchOriginal.getLeague() + ", " +
|
||||
"Spieltag " + matchOriginal.getMatchday() + ", " +
|
||||
"Spielnummer " + matchOriginal.getMatchNo() + ", " +
|
||||
"Spiel '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdHome()) + "' - '" + TeamIDMatcher.getTeamNameFromTippligaId(matchOriginal.getTeamIdGuest()) + "', ";
|
||||
|
||||
if(!matchOriginal.getTeamIdHome().equals(matchUpdated.getTeamIdHome())) {
|
||||
updateString += updateStart +
|
||||
"team_id_home = " + matchUpdated.getTeamIdHome() + " " +
|
||||
condition;
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Heimteam zu '" + matchUpdated.getTeamNameHome() + "'.\n";
|
||||
}
|
||||
|
||||
if(!matchOriginal.getTeamIdGuest().equals(matchUpdated.getTeamIdGuest())) {
|
||||
updateString += updateStart +
|
||||
"team_id_guest = " + matchUpdated.getTeamIdGuest() + " " +
|
||||
condition;
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Gastteam zu '" + matchUpdated.getTeamNameGuest() + "'.\n";
|
||||
}
|
||||
|
||||
if (!matchOriginal.getMatchDateTime().equals(matchUpdated.getMatchDateTime())) {
|
||||
updateString += updateStart +
|
||||
"match_datetime = '" + matchUpdated.getMatchDateTime() + "' " +
|
||||
condition;
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Spielbeginn zu '" + matchUpdated.getMatchDateTime() + "'.\n";
|
||||
}
|
||||
|
||||
if (!matchOriginal.getStatus().equals(matchUpdated.getStatus())) {
|
||||
updateString += updateStart +
|
||||
"status = '" + matchUpdated.getStatus() + "' " +
|
||||
condition;
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Status zu '" + matchUpdated.getStatus() + "'.\n";
|
||||
}
|
||||
|
||||
if (!matchOriginal.getShowTable().equals(matchUpdated.getShowTable())) {
|
||||
updateString += updateStart +
|
||||
"show_table = '" + matchUpdated.getShowTable() + "' " +
|
||||
condition;
|
||||
this.beautifulInfo += beautifulInfoStart +
|
||||
"Spiel in Tabelle einberechnen zu '" + (matchUpdated.getShowTable() == 1 ? "falsch" : "wahr") + "'.\n";
|
||||
}
|
||||
|
||||
|
||||
return updateString;
|
||||
}
|
||||
|
||||
private void addMissingMatches(ArrayList<TLWMatch> tlwMatches,
|
||||
ArrayList<APIFootballMatch> apiFootballMatches) {
|
||||
|
||||
ArrayList<APIFootballMatch> missingMatches = new ArrayList<>();
|
||||
|
||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||
try {
|
||||
if(getMatchingMatch(apiFootballMatch, tlwMatches) == null) {
|
||||
missingMatches.add(apiFootballMatch);
|
||||
}
|
||||
} catch (NullPointerException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (APIFootballMatch missingMatch : missingMatches) {
|
||||
boolean done = false;
|
||||
for(TLWMatch tlwMatch : tlwMatches) {
|
||||
if(tlwMatch.getTeamIdHome() == 0 && tlwMatch.getTeamIdGuest() == 0) {
|
||||
tlwMatch.updateMatch(missingMatch);
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!done) {
|
||||
logger.error("Could not add missing match: " + this.season + ", " + this.league + ", " + tlwMatches.get(0).getMatchday() + ", " + missingMatch.getTeamNameHome() + " - " + missingMatch.getTeamNameGuest());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMatchDateTimes(
|
||||
ArrayList<TLWMatch> tlwMatches,
|
||||
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||
{
|
||||
ArrayList<TLWMatch> tlwMatchesCopy = new ArrayList<>(tlwMatches);
|
||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||
try {
|
||||
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatchesCopy);
|
||||
tlwMatchesCopy.remove(tlwMatch);
|
||||
if(tlwMatch == null) {
|
||||
StatusHolder.setError();
|
||||
logger.error("Did not find match to update: " + this.season + ", " + this.league + ", " + tlwMatches.get(0).getMatchday() + ", " + apiFootballMatch.getTeamNameHome() + " - " + apiFootballMatch.getTeamNameGuest());
|
||||
}
|
||||
tlwMatch.setMatchDateTime(apiFootballMatch.getMatchDateTime().replace("T", " ").substring(0, 19));
|
||||
} catch(NullPointerException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStatus(ArrayList<TLWMatch> matches) {
|
||||
LocalDateTime earliestDate = TLWMatchesManagerBase.getFirstMatchtimeTLW(matches);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if(earliestDate.isAfter(now)) {
|
||||
for(TLWMatch match : matches) {
|
||||
LocalDateTime date = TLWMatchesManagerBase.getDate(match);
|
||||
if (getDaysDifference(earliestDate, date) == 0) {
|
||||
match.setStatus(0);
|
||||
} else {
|
||||
match.setStatus(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateShowTable(
|
||||
ArrayList<TLWMatch> tlwMatches,
|
||||
ArrayList<APIFootballMatch> apiFootballMatches)
|
||||
{
|
||||
ArrayList<TLWMatch> tlwMatchesCopy = new ArrayList<>(tlwMatches);
|
||||
for(APIFootballMatch apiFootballMatch : apiFootballMatches) {
|
||||
try {
|
||||
TLWMatch tlwMatch = getMatchingMatch(apiFootballMatch, tlwMatchesCopy);
|
||||
tlwMatchesCopy.remove(tlwMatch);
|
||||
tlwMatch.setShowTable(apiFootballMatch.getShowTable());
|
||||
} catch (NullPointerException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<TLWMatch> getTLWMatchesUpdated() {
|
||||
return this.tlwMatchesUpdated;
|
||||
}
|
||||
|
||||
public String getBeautifulInfo() {
|
||||
return this.beautifulInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class TLWTeam {
|
||||
|
||||
private int season;
|
||||
private int league;
|
||||
private int teamId;
|
||||
private String teamName;
|
||||
private String teamNameShort;
|
||||
private String teamSymbol;
|
||||
private String groupId;
|
||||
private int matchday;
|
||||
|
||||
public TLWTeam(ResultSet rset) {
|
||||
final int SEASON = 1;
|
||||
final int LEAGUE = 2;
|
||||
final int TEAM_ID = 3;
|
||||
final int TEAM_NAME = 4;
|
||||
final int TEAM_NAME_SHORT = 5;
|
||||
final int TEAM_SYMBOL = 6;
|
||||
final int GROUP_ID = 7;
|
||||
final int MATCHDAY = 8;
|
||||
|
||||
try {
|
||||
this.season = Integer.parseInt(rset.getString(SEASON));
|
||||
this.league = Integer.parseInt(rset.getString(LEAGUE));
|
||||
this.teamId = Integer.parseInt(rset.getString(TEAM_ID));
|
||||
this.teamName = rset.getString(TEAM_NAME);
|
||||
this.teamNameShort = rset.getString(TEAM_NAME_SHORT);
|
||||
this.teamSymbol = rset.getString(TEAM_SYMBOL);
|
||||
this.groupId = rset.getString(GROUP_ID);
|
||||
this.matchday = Integer.parseInt(rset.getString(MATCHDAY));
|
||||
} catch (SQLException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public TLWTeam(
|
||||
int season, int league, int teamId,
|
||||
String teamName, String teamNameShort, String teamSymbol, String groupId,
|
||||
int matchday
|
||||
) {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.teamId = teamId;
|
||||
this.teamName = teamName;
|
||||
this.teamNameShort = teamNameShort;
|
||||
this.teamSymbol = teamSymbol;
|
||||
this.groupId = groupId;
|
||||
this.matchday = matchday;
|
||||
}
|
||||
|
||||
public int getSeason() {
|
||||
return this.season;
|
||||
}
|
||||
|
||||
public int getLeague() {
|
||||
return this.league;
|
||||
}
|
||||
|
||||
public int getTeamId() {
|
||||
return this.teamId;
|
||||
}
|
||||
|
||||
public String getTeamName() {
|
||||
return this.teamName;
|
||||
}
|
||||
|
||||
public String getTeamNameShort() {
|
||||
return this.teamNameShort;
|
||||
}
|
||||
|
||||
public String getTeamSymbol() {
|
||||
return this.teamSymbol;
|
||||
}
|
||||
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
public int getMatchday() {
|
||||
return this.matchday;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public class TLWTeamsCreator {
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(TLWTeamsCreator.class);
|
||||
int season;
|
||||
int league;
|
||||
ArrayList<TLWMatch> matches;
|
||||
TippligaSQLConnector connector = TippligaSQLConnector.getInstance();
|
||||
|
||||
public TLWTeamsCreator(int season, int league, ArrayList<TLWMatch> matches) {
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.matches = matches;
|
||||
}
|
||||
|
||||
public Set<Integer> getTeamIds() {
|
||||
Set<Integer> teamIds = new LinkedHashSet<>();
|
||||
for(TLWMatch match : matches) {
|
||||
if(match.getTeamIdHome() != null) {
|
||||
teamIds.add(match.getTeamIdHome());
|
||||
}
|
||||
if(match.getTeamIdGuest() != null) {
|
||||
teamIds.add(match.getTeamIdGuest());
|
||||
}
|
||||
}
|
||||
return teamIds;
|
||||
}
|
||||
|
||||
public String getSql() {
|
||||
Set<Integer> teamIds = getTeamIds();
|
||||
String sql = "";
|
||||
for (Integer id : teamIds) {
|
||||
ArrayList<TLWTeam> teams = connector.getTeams(String.valueOf(id));
|
||||
if(teams.size() == 0) {
|
||||
this.logger.error("Did not find team id " + id.toString());
|
||||
continue;
|
||||
}
|
||||
String teamName = teams.get(0).getTeamName();
|
||||
String teamNameShort = teams.get(0).getTeamNameShort();
|
||||
String teamSymbol = teams.get(0).getTeamSymbol();
|
||||
String groupId = getGroup(id);
|
||||
int matchday = getMatchday(id);
|
||||
sql += "REPLACE INTO phpbb_footb_teams VALUES ('";
|
||||
sql += this.season;
|
||||
sql += "', '";
|
||||
sql += this.league;
|
||||
sql += "', '";
|
||||
sql += id;
|
||||
sql += "', '";
|
||||
sql += teamName;
|
||||
sql += "', '";
|
||||
sql += teamNameShort;
|
||||
sql += "', '";
|
||||
sql += teamSymbol;
|
||||
sql += "', '";
|
||||
sql += groupId;
|
||||
sql += "', '";
|
||||
sql += matchday;
|
||||
sql += "');\n";
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
String getGroup(Integer teamId) {
|
||||
for(TLWMatch match: matches) {
|
||||
if(teamId.equals(match.getTeamIdHome()) || teamId.equals(match.getTeamIdGuest())) {
|
||||
return match.getGroupId() != null ? match.getGroupId() : "";
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
int getMatchday(Integer teamId) {
|
||||
int matchday = 0;
|
||||
for(TLWMatch match: matches) {
|
||||
if(teamId.equals(match.getTeamIdHome()) || teamId.equals(match.getTeamIdGuest())) {
|
||||
matchday = matchday > match.getMatchday() ? matchday : match.getMatchday();
|
||||
}
|
||||
}
|
||||
return matchday;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class TLWTeamsUpdater {
|
||||
|
||||
Integer season;
|
||||
Integer league;
|
||||
ArrayList<TLWTeam> teamsOriginal;
|
||||
ArrayList<TLWMatch> matchesUpdated;
|
||||
ArrayList<TLWTeam> missingTeams;
|
||||
|
||||
public TLWTeamsUpdater(int season, int league, String configFileName) {
|
||||
|
||||
TippligaSQLConnector conn = TippligaSQLConnector.getInstance();
|
||||
|
||||
this.season = season;
|
||||
this.league = league;
|
||||
this.matchesUpdated = new ArrayList<>();
|
||||
|
||||
TLWMatchesUpdaterFootball matchesUpdaterFootball = new TLWMatchesUpdaterFootball(season, league, configFileName);
|
||||
this.matchesUpdated.addAll(matchesUpdaterFootball.getTLWMatchesUpdated());
|
||||
this.matchesUpdated.addAll(conn.getMatches(String.valueOf(season), String.valueOf(league)));
|
||||
|
||||
missingTeams = new ArrayList<>();
|
||||
|
||||
teamsOriginal = conn.getTeams(String.valueOf(season), String.valueOf(league));
|
||||
|
||||
HashSet<Integer> missingIds = this.initMissingIds();
|
||||
this.initMissingTeams(missingIds);
|
||||
}
|
||||
|
||||
private HashSet<Integer> initMissingIds() {
|
||||
HashSet<Integer> missingIds = new HashSet<>();
|
||||
|
||||
for(TLWMatch match : matchesUpdated) {
|
||||
if(isTeamMissing(match.getTeamIdHome())) {
|
||||
missingIds.add(match.getTeamIdHome());
|
||||
}
|
||||
if(isTeamMissing(match.getTeamIdGuest())) {
|
||||
missingIds.add(match.getTeamIdGuest());
|
||||
}
|
||||
}
|
||||
missingIds.remove(0);
|
||||
return missingIds;
|
||||
}
|
||||
|
||||
private void initMissingTeams(HashSet<Integer> missingIds) {
|
||||
TippligaSQLConnector conn = TippligaSQLConnector.getInstance();
|
||||
for (Integer id : missingIds) {
|
||||
ArrayList<TLWTeam> teams = conn.getTeams(String.valueOf(id));
|
||||
missingTeams.add(new TLWTeam(
|
||||
this.season,
|
||||
this.league,
|
||||
id,
|
||||
teams.get(0).getTeamName(),
|
||||
teams.get(0).getTeamNameShort(),
|
||||
teams.get(0).getTeamSymbol(),
|
||||
"",
|
||||
0
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isTeamMissing(int id) {
|
||||
boolean teamMissing = true;
|
||||
for(TLWTeam team : teamsOriginal) {
|
||||
if(team.getTeamId() == id) {
|
||||
teamMissing = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return teamMissing;
|
||||
}
|
||||
|
||||
public String getInsertSQL() {
|
||||
String updateSql = "";
|
||||
|
||||
for(TLWTeam team : missingTeams) {
|
||||
|
||||
updateSql += "INSERT INTO phpbb_footb_teams VALUES (" +
|
||||
team.getSeason() + ", " +
|
||||
team.getLeague() + ", " +
|
||||
team.getTeamId() + ", " +
|
||||
"'" + team.getTeamName() + "', " +
|
||||
"'" + team.getTeamNameShort() + "', " +
|
||||
"'" + team.getTeamSymbol() + "', " +
|
||||
"'" + team.getGroupId() + "', " +
|
||||
team.getMatchday() +
|
||||
");\n";
|
||||
}
|
||||
|
||||
return updateSql;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package de.jeyp91.tippligaforum;
|
||||
|
||||
import com.google.gson.*;
|
||||
import de.jeyp91.S3Provider;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class MatchesListCreator {
|
||||
|
||||
private final JSONObject mainObject = new JSONObject();
|
||||
private final String country;
|
||||
private final String leagueName;
|
||||
|
||||
public MatchesListCreator(int league) {
|
||||
S3Provider prov = new S3Provider();
|
||||
JSONObject leagueConfig = prov.getFixturesJSONFromS3(league);
|
||||
JSONObject api = (JSONObject) leagueConfig.get("api");
|
||||
JSONArray matchesAPIFootball = (JSONArray) api.get("fixtures");
|
||||
|
||||
JSONObject firstMatchAPIFootball = (JSONObject) matchesAPIFootball.get(0);
|
||||
JSONObject leagueObject = (JSONObject) firstMatchAPIFootball.get("league");
|
||||
this.country = leagueObject.get("country").toString();
|
||||
this.leagueName = leagueObject.get("name").toString();
|
||||
|
||||
JSONArray matchesConfig = populateMatches(matchesAPIFootball);
|
||||
|
||||
JSONObject matchdayConfigObject = new JSONObject();
|
||||
matchdayConfigObject.put("matchesConfig", matchesConfig);
|
||||
|
||||
JSONArray matchdayConfig = new JSONArray();
|
||||
matchdayConfig.add(matchdayConfigObject);
|
||||
|
||||
this.mainObject.put("matchdayConfig", matchdayConfig);
|
||||
}
|
||||
|
||||
private JSONArray populateMatches(JSONArray matchesAPIFootball) {
|
||||
JSONArray matches = new JSONArray();
|
||||
for(Object matchAPIFootballObject : matchesAPIFootball) {
|
||||
JSONObject matchAPIFootball = (JSONObject) matchAPIFootballObject;
|
||||
JSONObject match = new JSONObject();
|
||||
|
||||
Long leagueId = (Long) matchAPIFootball.get("league_id");
|
||||
String matchdayString = matchAPIFootball.get("round").toString();
|
||||
int matchday = APIFootballMatch.getMatchdayFromRoundString(2021, matchdayString, leagueId.intValue());
|
||||
String matchtime = matchAPIFootball.get("event_date").toString().replace("T", " ").substring(0, 16);
|
||||
Long fixtureId = (Long) matchAPIFootball.get("fixture_id");
|
||||
|
||||
JSONObject teamHome = (JSONObject) matchAPIFootball.get("homeTeam");
|
||||
String teamNameHome = teamHome.get("team_name").toString();
|
||||
JSONObject teamGuest = (JSONObject) matchAPIFootball.get("awayTeam");
|
||||
String teamNameGuest = teamGuest.get("team_name").toString();
|
||||
|
||||
match.put("match", teamNameHome + " - " + teamNameGuest);
|
||||
match.put("matchday", matchday);
|
||||
match.put("matchtime", matchtime);
|
||||
match.put("type", "SingleMatch");
|
||||
match.put("matchLeague", leagueId);
|
||||
match.put("matchId", fixtureId);
|
||||
match.put("showTable", false);
|
||||
matches.add(match);
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
|
||||
public JSONObject getMatches() {
|
||||
return this.mainObject;
|
||||
}
|
||||
|
||||
public String getMatchesBeautiful() {
|
||||
JsonElement jelement = JsonParser.parseString(this.mainObject.toString());
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
return gson.toJson(jelement);
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public String getLeagueName() {
|
||||
return leagueName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package de.jeyp91.tippligaforum;
|
||||
|
||||
import de.jeyp91.App;
|
||||
import de.jeyp91.apifootball.APIFootballUpdater;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class MatchesListForumUpdater {
|
||||
private HashSet<Integer> leagues;
|
||||
private static final Logger logger = LogManager.getLogger(MatchesListForumUpdater.class);
|
||||
|
||||
public MatchesListForumUpdater(int season) {
|
||||
this.leagues = new APIFootballUpdater().getLeagues(season);
|
||||
}
|
||||
|
||||
public void updateAllLeagues(int season) {
|
||||
for(Integer league : this.leagues) {
|
||||
updateLeague(season, league);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLeague(int season, int league) {
|
||||
MatchesListCreator creator = new MatchesListCreator(league);
|
||||
String content = creator.getMatchesBeautiful();
|
||||
String contentWithCodeBBCode = "<r><CODE><s>[code]</s>" + content + "<e>[/code]</e></CODE></r>";
|
||||
Integer postId = getPostId(season, creator.getCountry(), creator.getLeagueName());
|
||||
if(postId != null) {
|
||||
TippligaSQLConnector con = TippligaSQLConnector.getInstance();
|
||||
con.updatePost(postId, contentWithCodeBBCode);
|
||||
}
|
||||
}
|
||||
|
||||
private Integer getPostId(int season, String country, String league) {
|
||||
TippligaSQLConnector con = TippligaSQLConnector.getInstance();
|
||||
Integer adminForumId = con.getForumId("Admin");
|
||||
Integer tippligaConfigForumId = con.getForumId("Tippliga-Config", adminForumId);
|
||||
Integer seasonForumId = con.getForumId(String.valueOf(season), tippligaConfigForumId);
|
||||
Integer leagueForumId = con.getForumId("Ligen", seasonForumId);
|
||||
String query = "SELECT post_id FROM phpbb_posts WHERE post_subject = '" + country + " " + league + "' AND forum_id = " + leagueForumId + ";";
|
||||
ResultSet rset = con.executeQuery(query);
|
||||
Integer postId = null;
|
||||
try {
|
||||
rset.next();
|
||||
postId = Integer.parseInt(rset.getString(1));
|
||||
} catch (SQLException e) {
|
||||
logger.error("Could not find post for " + country + " - " + league + ".");
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
return postId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package de.jeyp91.tippligaforum;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
public class TippligaConfigProvider {
|
||||
TippligaSQLConnector con;
|
||||
Integer seasonForumId;
|
||||
|
||||
public TippligaConfigProvider(int season) {
|
||||
this.con = TippligaSQLConnector.getInstance();
|
||||
Integer adminForumId = con.getForumId("Admin");
|
||||
Integer tippligaConfigForumId = con.getForumId("Tippliga-Config", adminForumId);
|
||||
this.seasonForumId = con.getForumId(String.valueOf(season), tippligaConfigForumId);
|
||||
}
|
||||
|
||||
public JSONObject getTippligaConfig(String config) {
|
||||
String post = this.con.getPost(config, this.seasonForumId);
|
||||
int postLength = post.length();
|
||||
post = post.substring(22, postLength - 25);
|
||||
|
||||
JSONObject tippligaConfig = null;
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
try {
|
||||
tippligaConfig = (JSONObject) jsonParser.parse(post);
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return tippligaConfig;
|
||||
}
|
||||
|
||||
public String getChecksumOfConfigPost(String configFile) {
|
||||
return con.getChecksumOfPost(this.seasonForumId, configFile);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package de.jeyp91.tippligaforum;
|
||||
|
||||
import de.jeyp91.StatusHolder;
|
||||
import de.jeyp91.tippliga.TLWMatch;
|
||||
import de.jeyp91.tippliga.TLWMatchday;
|
||||
import de.jeyp91.tippliga.TLWTeam;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class TippligaSQLConnector {
|
||||
|
||||
Connection con;
|
||||
|
||||
private static final Logger logger = LogManager.getLogger(TippligaSQLConnector.class);
|
||||
private static TippligaSQLConnector tlwSqlCon = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
} catch (ClassNotFoundException ex) {
|
||||
logger.error("Unable to load MySQL Driver");
|
||||
StatusHolder.setError();
|
||||
}
|
||||
}
|
||||
|
||||
private TippligaSQLConnector() {
|
||||
String databaseUsername = System.getenv("TLW_DATABASE_USERNAME");
|
||||
String databasePassword = System.getenv("TLW_DATABASE_PASSWORD");
|
||||
String jdbcUrlLocalhost = "jdbc:mysql://localhost:3306/d0144ddb" +
|
||||
"?user=root" +
|
||||
"&password=" +
|
||||
"&useUnicode=true" +
|
||||
"&useJDBCCompliantTimezoneShift=true" +
|
||||
"&useLegacyDatetimeCode=false" +
|
||||
"&serverTimezone=UTC" +
|
||||
"&allowMultiQueries=true";
|
||||
String jdbcUrlProd = "jdbc:mysql://w00f4eaf.kasserver.com:3306/d0144ddb" +
|
||||
"?user=" + databaseUsername +
|
||||
"&password=" + databasePassword +
|
||||
"&useUnicode=true" +
|
||||
"&useJDBCCompliantTimezoneShift=true" +
|
||||
"&useLegacyDatetimeCode=false" +
|
||||
"&serverTimezone=UTC" +
|
||||
"&allowMultiQueries=true" +
|
||||
"&useSSL=false";
|
||||
try {
|
||||
con = DriverManager.getConnection(jdbcUrlProd);
|
||||
} catch (SQLException e) {
|
||||
/* TODO */
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static TippligaSQLConnector getInstance() {
|
||||
if(tlwSqlCon == null) {
|
||||
tlwSqlCon = new TippligaSQLConnector();
|
||||
}
|
||||
return tlwSqlCon;
|
||||
}
|
||||
|
||||
public ArrayList<TLWTeam> getTeams(String season, String league) {
|
||||
String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `season` = " + season + " AND `league` = " + league + ";";
|
||||
|
||||
ArrayList<TLWTeam> teams = new ArrayList<>();
|
||||
ResultSet rset = executeQuery(queryString);
|
||||
try {
|
||||
while (rset.next()) {
|
||||
teams.add(new TLWTeam(rset));
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
|
||||
return teams;
|
||||
}
|
||||
|
||||
public ArrayList<TLWTeam> getTeams(String id) {
|
||||
String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `team_id` = " + id + " ORDER BY `season` DESC, `league` ASC;";
|
||||
|
||||
ArrayList<TLWTeam> teams = new ArrayList<>();
|
||||
ResultSet rset = executeQuery(queryString);
|
||||
try {
|
||||
while (rset.next()) {
|
||||
teams.add(new TLWTeam(rset));
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
|
||||
return teams;
|
||||
}
|
||||
|
||||
private ArrayList<TLWMatch> getMatches(String queryString) {
|
||||
|
||||
ArrayList<TLWMatch> matches = new ArrayList<>();
|
||||
ResultSet rset = executeQuery(queryString);
|
||||
try {
|
||||
while (rset.next()) {
|
||||
matches.add(new TLWMatch(rset));
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
return matches;
|
||||
}
|
||||
|
||||
public ArrayList<TLWMatch> getMatches(String season, String league) {
|
||||
String queryString = "SELECT * FROM `phpbb_footb_matches` WHERE `season` = " + season + " AND `league` = " + league + " ORDER BY match_no ASC;";
|
||||
return getMatches(queryString);
|
||||
}
|
||||
|
||||
public ArrayList<TLWMatch> getMatches(String season, String league, String matchday) {
|
||||
String queryString = "SELECT * FROM `phpbb_footb_matches` WHERE `season` = " + season + " AND `league` = " + league + " AND `matchday` = " + matchday + " ORDER BY match_no ASC;";
|
||||
return getMatches(queryString);
|
||||
}
|
||||
|
||||
public ArrayList<TLWMatchday> getMatchdays(String season, String league) {
|
||||
String queryString = "SELECT * FROM `phpbb_footb_matchdays` WHERE `season` = " + season + " AND `league` = " + league + ";";
|
||||
|
||||
ArrayList<TLWMatchday> matchdays = new ArrayList<>();
|
||||
ResultSet rset = executeQuery(queryString);
|
||||
try {
|
||||
while (rset.next()) {
|
||||
matchdays.add(new TLWMatchday(rset));
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
return matchdays;
|
||||
}
|
||||
|
||||
public Integer getForumId(String forumName, int parentId) {
|
||||
String queryString = "SELECT forum_id FROM phpbb_forums WHERE forum_name = \"" + forumName + "\" AND parent_id = " + parentId + ";";
|
||||
ResultSet rset = executeQuery(queryString);
|
||||
Integer id = null;
|
||||
try {
|
||||
while (rset.next()) {
|
||||
id = Integer.parseInt(rset.getString(1));
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public Integer getForumId(String forumName) {
|
||||
String queryString = "SELECT forum_id FROM phpbb_forums WHERE forum_name = \"" + forumName + "\";";
|
||||
ResultSet rset = executeQuery(queryString);
|
||||
Integer id = null;
|
||||
try {
|
||||
while (rset.next()) {
|
||||
id = Integer.parseInt(rset.getString(1));
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getPost(String subject, int forum_id) {
|
||||
String queryString = "SELECT post_text FROM phpbb_posts WHERE post_subject = \"" + subject + "\" AND forum_id = \"" + forum_id + "\";";
|
||||
ResultSet rset = executeQuery(queryString);
|
||||
String post = null;
|
||||
try {
|
||||
while (rset.next()) {
|
||||
post = rset.getString(1);
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
return post;
|
||||
}
|
||||
|
||||
public ResultSet executeQuery (String queryString){
|
||||
Statement stmt;
|
||||
ResultSet rset = null;
|
||||
try {
|
||||
stmt = con.createStatement();
|
||||
rset = stmt.executeQuery(queryString);
|
||||
} catch (SQLException e) {
|
||||
logger.error(e.getStackTrace());
|
||||
}
|
||||
return rset;
|
||||
}
|
||||
|
||||
public void executeUpdate (String queryString){
|
||||
Statement stmt;
|
||||
try {
|
||||
stmt = con.createStatement();
|
||||
stmt.executeUpdate(queryString);
|
||||
} catch (SQLException e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePost(int postId, String postText) {
|
||||
String postChecksum = getChecksum(postText);
|
||||
final long postEditTime = Instant.now().getEpochSecond();;
|
||||
final String postEditReason = "Update by tool.";
|
||||
int postEditUser = 2;
|
||||
String query = getPostUpdateQuery(postId, postText, postChecksum, postEditTime, postEditReason, postEditUser);
|
||||
executeUpdate(query);
|
||||
}
|
||||
|
||||
public String getChecksumOfPost(int forum_id, String subject) {
|
||||
String queryString = "SELECT post_checksum FROM phpbb_posts WHERE forum_id = " + forum_id + " AND post_subject = '" + subject + "'";
|
||||
ResultSet rset = executeQuery(queryString);
|
||||
String checksum = null;
|
||||
try {
|
||||
while (rset.next()) {
|
||||
checksum = rset.getString(1);
|
||||
}
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
return checksum;
|
||||
}
|
||||
|
||||
public String getPostUpdateQuery(int postId, String postText, String postChecksum, long postEditTime, String postEditReason, int postEditUser) {
|
||||
return "UPDATE phpbb_posts SET " +
|
||||
"post_text = '" + postText + "', " +
|
||||
"post_checksum = '" + postChecksum + "', " +
|
||||
"post_edit_time = " + postEditTime + ", " +
|
||||
"post_edit_reason = '" + postEditReason + "', " +
|
||||
"post_edit_user = " + postEditUser + ", " +
|
||||
"post_edit_count = post_edit_count + 1 " +
|
||||
"WHERE post_id = " + postId + ";";
|
||||
}
|
||||
|
||||
public String getChecksum(String postText) {
|
||||
String postTextForMd5 = replaceXmlMetacharacters(postText);
|
||||
MessageDigest md = null;
|
||||
try {
|
||||
md = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
assert md != null;
|
||||
md.update(postTextForMd5.getBytes());
|
||||
byte[] digest = md.digest();
|
||||
return DatatypeConverter.printHexBinary(digest).toLowerCase();
|
||||
}
|
||||
|
||||
public String replaceXmlMetacharacters(String post) {
|
||||
post = post.replace("&", "&");
|
||||
post = post.replace("<", "<");
|
||||
post = post.replace(">", ">");
|
||||
post = post.replace("\"", """);
|
||||
post = post.replace("'", "'");
|
||||
return post;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
package de.jeyp91.tippligaforum;
|
||||
|
||||
import de.jeyp91.tippliga.TLWMatch;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.*;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TippligaWebsiteConnector {
|
||||
CookieManager cm = new CookieManager(null, CookiePolicy.ACCEPT_ALL);
|
||||
|
||||
CookieStore cookieStore = cm.getCookieStore();
|
||||
private static final Logger logger = LogManager.getLogger(TippligaWebsiteConnector.class);
|
||||
private final HttpClient client;
|
||||
private final String username = System.getenv("FORUM_USERNAME");
|
||||
private final String password = System.getenv("FORUM_PASSWORD");
|
||||
private String lastCreationTime = "";
|
||||
private String lastFormToken = "";
|
||||
|
||||
public TippligaWebsiteConnector() throws IOException {
|
||||
CookieHandler.setDefault(cm);
|
||||
|
||||
client = HttpClient.newBuilder()
|
||||
.cookieHandler(CookieHandler.getDefault())
|
||||
.connectTimeout(Duration.ofSeconds(10))
|
||||
.build();
|
||||
login();
|
||||
adminLogin();
|
||||
}
|
||||
|
||||
private void login() throws IOException {
|
||||
HttpRequest req = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://tippliga-wuerzburg.de/ucp.php?mode=login"))
|
||||
.GET().build();
|
||||
|
||||
String reqBody = "";
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
reqBody = client.send(req, HttpResponse.BodyHandlers.ofString()).body();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile("^[\\s\\S]*<input type=\"hidden\" name=\"creation_time\" value=\"([\\d]{10})\" \\/>[\\s\\S]*<input type=\"hidden\" name=\"form_token\" value=\"([\\d\\w]{40})\" \\/>[\\s\\S]*<input type=\"hidden\" name=\"sid\" value=\"([\\d\\w]{32})\" \\/>[\\s\\S]*$");
|
||||
Matcher matcher = pattern.matcher(reqBody);
|
||||
matcher.find();
|
||||
|
||||
this.lastCreationTime = matcher.group(1);
|
||||
this.lastFormToken = matcher.group(2);
|
||||
String sid = matcher.group(3);
|
||||
|
||||
Map<String, String> loginParameters = new HashMap<>();
|
||||
loginParameters.put("login", "Anmelden");
|
||||
loginParameters.put("redirect", "index.php");
|
||||
loginParameters.put("autologin", "on");
|
||||
loginParameters.put("viewonline", "on");
|
||||
loginParameters.put("username", username);
|
||||
loginParameters.put("password", password);
|
||||
loginParameters.put("creation_time", this.lastCreationTime);
|
||||
loginParameters.put("form_token", this.lastFormToken);
|
||||
loginParameters.put("sid", sid);
|
||||
|
||||
String loginForm = loginParameters.entrySet()
|
||||
.stream()
|
||||
.map(e -> e.getKey() + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
|
||||
.collect(Collectors.joining("&"));
|
||||
|
||||
HttpRequest loginReq = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://tippliga-wuerzburg.de/ucp.php?mode=login"))
|
||||
.headers("Content-Type", "application/x-www-form-urlencoded")
|
||||
.POST(HttpRequest.BodyPublishers.ofString(loginForm))
|
||||
.build();
|
||||
|
||||
String loginReqBody = "";
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
loginReqBody = client.send(loginReq, HttpResponse.BodyHandlers.ofString()).body();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<HttpCookie> loginReqCookieList = cookieStore.getCookies();
|
||||
}
|
||||
|
||||
private void adminLogin() throws IOException {
|
||||
String sid = getSidFromCookie();
|
||||
String url = "https://tippliga-wuerzburg.de/adm/index.php?sid=" + sid;
|
||||
HttpRequest req = HttpRequest.newBuilder()
|
||||
.uri(URI.create(url))
|
||||
.headers("referer", "https://tippliga-wuerzburg.de/index.php?sid=" + sid)
|
||||
.GET().build();
|
||||
|
||||
String reqBody = "";
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
reqBody = client.send(req, HttpResponse.BodyHandlers.ofString()).body();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile("^[\\s\\S]*<input type=\"hidden\" name=\"creation_time\" value=\"([\\d]{10})\" \\/>[\\s\\S]*<input type=\"hidden\" name=\"form_token\" value=\"([\\d\\w]{40})\" \\/>[\\s\\S]*<input type=\"hidden\" name=\"sid\" value=\"([\\d\\w]{32})\" \\/>[\\s\\S]*<input type=\"hidden\" name=\"credential\" value=\"([\\d\\w]{32})\" \\/>[\\s\\S]*$");
|
||||
Matcher matcher = pattern.matcher(reqBody);
|
||||
matcher.find();
|
||||
|
||||
this.lastCreationTime = matcher.group(1);
|
||||
this.lastFormToken = matcher.group(2);
|
||||
sid = matcher.group(3);
|
||||
String credential = matcher.group(4);
|
||||
|
||||
Map<String, String> loginParameters = new HashMap<>();
|
||||
loginParameters.put("login", "Anmelden");
|
||||
loginParameters.put("redirect", "./../adm/index.php?sid=" + sid);
|
||||
loginParameters.put("username", username);
|
||||
loginParameters.put("password_" + credential, password);
|
||||
loginParameters.put("creation_time", this.lastCreationTime);
|
||||
loginParameters.put("form_token", this.lastFormToken);
|
||||
loginParameters.put("sid", sid);
|
||||
loginParameters.put("credential", credential);
|
||||
|
||||
String loginForm = loginParameters.entrySet()
|
||||
.stream()
|
||||
.map(e -> e.getKey() + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
|
||||
.collect(Collectors.joining("&"));
|
||||
|
||||
HttpRequest loginReq = HttpRequest.newBuilder()
|
||||
.uri(URI.create(url))
|
||||
.headers("Content-Type", "application/x-www-form-urlencoded")
|
||||
.POST(HttpRequest.BodyPublishers.ofString(loginForm))
|
||||
.build();
|
||||
|
||||
String loginReqBody = "";
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
HttpResponse<String> loginReqResponse = client.send(loginReq, HttpResponse.BodyHandlers.ofString()); // Response 302
|
||||
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
List<HttpCookie> loginReqCookieList = cookieStore.getCookies();
|
||||
}
|
||||
|
||||
public void updateResultsAdmin(int season, int league, int matchday, List<TLWMatch> matches) {
|
||||
String sid = getSidFromCookie();
|
||||
String url = "https://tippliga-wuerzburg.de/adm/index.php?i=-football-football-acp-results_module&mode=manage&sid=" + sid;
|
||||
|
||||
HttpRequest req = HttpRequest.newBuilder()
|
||||
.uri(URI.create(url))
|
||||
.GET().build();
|
||||
|
||||
String reqBody = "";
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
reqBody = client.send(req, HttpResponse.BodyHandlers.ofString()).body();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Pattern pattern = Pattern.compile("^[\\s\\S]*<input type=\"hidden\" name=\"creation_time\" value=\"([\\d]{10})\" \\/>[\\s\\S]*<input type=\"hidden\" name=\"form_token\" value=\"([\\d\\w]{40})\" \\/>[\\s\\S]*$");
|
||||
Matcher matcher = pattern.matcher(reqBody);
|
||||
matcher.find();
|
||||
|
||||
this.lastCreationTime = matcher.group(1);
|
||||
this.lastFormToken = matcher.group(2);
|
||||
|
||||
Map<String, String> resultParameters = new HashMap<>();
|
||||
|
||||
resultParameters.put("s", String.valueOf(season));
|
||||
resultParameters.put("l", String.valueOf(league));
|
||||
resultParameters.put("m", String.valueOf(matchday));
|
||||
resultParameters.put("edit", "Speichern");
|
||||
resultParameters.put("creation_time", this.lastCreationTime);
|
||||
resultParameters.put("form_token", this.lastFormToken);
|
||||
matches.forEach(tlwMatch -> {
|
||||
String matchNo = String.valueOf(tlwMatch.getMatchNo());
|
||||
resultParameters.put("select_" + matchNo, "on");
|
||||
resultParameters.put("goals_home_" + matchNo, String.valueOf(tlwMatch.getGoalsHome()));
|
||||
resultParameters.put("goals_guest_" + matchNo, String.valueOf(tlwMatch.getGoalsGuest()));
|
||||
Integer goalsOverTimeHome = tlwMatch.getGoalsOvertimeHome();
|
||||
Integer goalsOvertimeGuest = tlwMatch.getGoalsOvertimeGuest();
|
||||
resultParameters.put("overtime_home_" + matchNo, goalsOverTimeHome == null ? "" : String.valueOf(goalsOverTimeHome));
|
||||
resultParameters.put("overtime_guest_" + matchNo, goalsOvertimeGuest == null ? "" : String.valueOf(goalsOvertimeGuest));
|
||||
});
|
||||
|
||||
String resultForm = resultParameters.entrySet()
|
||||
.stream()
|
||||
.map(e -> e.getKey() + "=" + URLEncoder.encode(e.getValue(), StandardCharsets.UTF_8))
|
||||
.collect(Collectors.joining("&"));
|
||||
|
||||
HttpRequest resultReq = HttpRequest.newBuilder()
|
||||
.uri(URI.create("https://tippliga-wuerzburg.de/adm/index.php?i=-football-football-acp-results_module&mode=manage&sid=" + sid))
|
||||
.headers("Content-Type", "application/x-www-form-urlencoded")
|
||||
.POST(HttpRequest.BodyPublishers.ofString(resultForm))
|
||||
.build();
|
||||
|
||||
String resultReqBody = "";
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
resultReqBody = client.send(resultReq, HttpResponse.BodyHandlers.ofString()).body();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
matcher = pattern.matcher(resultReqBody);
|
||||
matcher.find();
|
||||
|
||||
this.lastCreationTime = matcher.group(1);
|
||||
this.lastFormToken = matcher.group(2);
|
||||
}
|
||||
|
||||
private String getSidFromCookie() {
|
||||
HttpCookie sidCookie = cookieStore.getCookies().get(2);
|
||||
String sid = sidCookie.getValue();
|
||||
return sid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"username": "tippligawuerzburg",
|
||||
"password": "1154f448eae29212971cb82ca8850f54bff23629"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"1": {
|
||||
"id": "825f79shtm9n3uknj99iuu2qho",
|
||||
"url": "825f79shtm9n3uknj99iuu2qho@group.calendar.google.com"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"installed": {
|
||||
"client_id": "267204101826-2ps9m6httllrc7mrsvml50rsfb661k87.apps.googleusercontent.com",
|
||||
"project_id": "tippliga",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_secret": "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",
|
||||
"redirect_uris": [
|
||||
"urn:ietf:wg:oauth:2.0:oob",
|
||||
"http://localhost"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
[
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Bundesliga 1",
|
||||
"league_id": 2755
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Bundesliga 2",
|
||||
"league_id": 2743
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Liga 3",
|
||||
"league_id": 2795
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Regionalliga - SudWest",
|
||||
"league_id": 2823
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Regionalliga - Bayern",
|
||||
"league_id": 1240
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "DFB Pokal",
|
||||
"league_id": 2677
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "U19 Bundesliga",
|
||||
"league_id": 2692
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Women Bundesliga",
|
||||
"league_id": 2681
|
||||
},
|
||||
{
|
||||
"country": "England",
|
||||
"name": "Premier League",
|
||||
"league_id": 2790
|
||||
},
|
||||
{
|
||||
"country": "Spain",
|
||||
"name": "Primera Division",
|
||||
"league_id": 2833
|
||||
},
|
||||
{
|
||||
"country": "Italy",
|
||||
"name": "Serie A",
|
||||
"league_id": 2857
|
||||
},
|
||||
{
|
||||
"country": "France",
|
||||
"name": "Ligue 1",
|
||||
"league_id": 2664
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Champions League",
|
||||
"league_id": 2771
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Europa League",
|
||||
"league_id": 2777
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "Euro Championship",
|
||||
"league_id": 403
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,77 @@
|
||||
[
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Bundesliga 1",
|
||||
"league_id": 3510
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Bundesliga 2",
|
||||
"league_id": 3509
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Liga 3",
|
||||
"league_id": 3520
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Regionalliga - SudWest",
|
||||
"league_id": 3582
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Regionalliga - Bayern",
|
||||
"league_id": 3584
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "DFB Pokal",
|
||||
"league_id": 3532
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "U19 Bundesliga",
|
||||
"league_id": 3555
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Women Bundesliga",
|
||||
"league_id": 3541
|
||||
},
|
||||
{
|
||||
"country": "England",
|
||||
"name": "Premier League",
|
||||
"league_id": 3456
|
||||
},
|
||||
{
|
||||
"country": "Spain",
|
||||
"name": "Primera Division",
|
||||
"league_id": 3513
|
||||
},
|
||||
{
|
||||
"country": "Italy",
|
||||
"name": "Serie A",
|
||||
"league_id": 3576
|
||||
},
|
||||
{
|
||||
"country": "France",
|
||||
"name": "Ligue 1",
|
||||
"league_id": 3506
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Champions League",
|
||||
"league_id": 3431
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Europa League",
|
||||
"league_id": 3632
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Europa Conference League",
|
||||
"league_id": 3490
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,97 @@
|
||||
[
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Bundesliga 1",
|
||||
"league_id": 4346
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Bundesliga 2",
|
||||
"league_id": 4352
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Liga 3",
|
||||
"league_id": 4383
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Regionalliga - SudWest",
|
||||
"league_id": 4509
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Regionalliga - Bayern",
|
||||
"league_id": 4507
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "DFB Pokal",
|
||||
"league_id": 4303
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "U19 Bundesliga",
|
||||
"league_id": 4489
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Women Bundesliga",
|
||||
"league_id": 4428
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Super Cup",
|
||||
"league_id": 4293
|
||||
},
|
||||
{
|
||||
"country": "England",
|
||||
"name": "Premier League",
|
||||
"league_id": 4335
|
||||
},
|
||||
{
|
||||
"country": "Spain",
|
||||
"name": "La Liga",
|
||||
"league_id": 4378
|
||||
},
|
||||
{
|
||||
"country": "Italy",
|
||||
"name": "Serie A",
|
||||
"league_id": 4399
|
||||
},
|
||||
{
|
||||
"country": "France",
|
||||
"name": "Ligue 1",
|
||||
"league_id": 4347
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Champions League",
|
||||
"league_id": 4314
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Europa League",
|
||||
"league_id": 4584
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Europa Conference League",
|
||||
"league_id": 4331
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Super Cup",
|
||||
"league_id": 4306
|
||||
},
|
||||
{
|
||||
"country": "Turkey",
|
||||
"name": "Süper Lig",
|
||||
"league_id": 4418
|
||||
},
|
||||
{
|
||||
"country": "Netherlands",
|
||||
"name": "Eredivisie",
|
||||
"league_id": 4349
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,97 @@
|
||||
[
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Bundesliga",
|
||||
"league_id": 5348
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "2. Bundesliga",
|
||||
"league_id": 5347
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "3. Liga",
|
||||
"league_id": 5399
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Regionalliga - Bayern",
|
||||
"league_id": 5518
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Regionalliga - SudWest",
|
||||
"league_id": 5519
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "U19 Bundesliga",
|
||||
"league_id": 5436
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Frauen Bundesliga",
|
||||
"league_id": 5464
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "DFB Pokal",
|
||||
"league_id": 5275
|
||||
},
|
||||
{
|
||||
"country": "Germany",
|
||||
"name": "Super Cup",
|
||||
"league_id": 5223
|
||||
},
|
||||
{
|
||||
"country": "England",
|
||||
"name": "Premier League",
|
||||
"league_id": 5267
|
||||
},
|
||||
{
|
||||
"country": "Spain",
|
||||
"name": "La Liga",
|
||||
"league_id": 5284
|
||||
},
|
||||
{
|
||||
"country": "Italy",
|
||||
"name": "Serie A",
|
||||
"league_id": 5367
|
||||
},
|
||||
{
|
||||
"country": "France",
|
||||
"name": "Ligue 1",
|
||||
"league_id": 5322
|
||||
},
|
||||
{
|
||||
"country": "Turkey",
|
||||
"name": "Süper Lig",
|
||||
"league_id": 5476
|
||||
},
|
||||
{
|
||||
"country": "Netherlands",
|
||||
"name": "Eredivisie",
|
||||
"league_id": 5389
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Champions League",
|
||||
"league_id": 5262
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Europa League",
|
||||
"league_id": 5607
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Europa Conference League",
|
||||
"league_id": 5277
|
||||
},
|
||||
{
|
||||
"country": "World",
|
||||
"name": "UEFA Super Cup",
|
||||
"league_id": 5235
|
||||
}
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,282 @@
|
||||
[
|
||||
{
|
||||
"team_id": 2002,
|
||||
"team_name": "Julian",
|
||||
"team_name_short": "Julian"
|
||||
},
|
||||
{
|
||||
"team_id": 2053,
|
||||
"team_name": "Demian",
|
||||
"team_name_short": "Demian"
|
||||
},
|
||||
{
|
||||
"team_id": 2054,
|
||||
"team_name": "Hilde",
|
||||
"team_name_short": "Hilde"
|
||||
},
|
||||
{
|
||||
"team_id": 2055,
|
||||
"team_name": "Oliver",
|
||||
"team_name_short": "Oliver"
|
||||
},
|
||||
{
|
||||
"team_id": 2056,
|
||||
"team_name": "Martin",
|
||||
"team_name_short": "Martin"
|
||||
},
|
||||
{
|
||||
"team_id": 2057,
|
||||
"team_name": "Matthias",
|
||||
"team_name_short": "Matthias"
|
||||
},
|
||||
{
|
||||
"team_id": 2058,
|
||||
"team_name": "Nicole (TG Rhön)",
|
||||
"team_name_short": "Nicole"
|
||||
},
|
||||
{
|
||||
"team_id": 2059,
|
||||
"team_name": "Sascha",
|
||||
"team_name_short": "Sascha"
|
||||
},
|
||||
{
|
||||
"team_id": 2060,
|
||||
"team_name": "TG Nürnberg",
|
||||
"team_name_short": "TG Nürnb."
|
||||
},
|
||||
{
|
||||
"team_id": 2061,
|
||||
"team_name": "Friedrich",
|
||||
"team_name_short": "Friedrich"
|
||||
},
|
||||
{
|
||||
"team_id": 2062,
|
||||
"team_name": "Jimmy",
|
||||
"team_name_short": "Jimmy"
|
||||
},
|
||||
{
|
||||
"team_id": 2063,
|
||||
"team_name": "Flo",
|
||||
"team_name_short": "Flo"
|
||||
},
|
||||
{
|
||||
"team_id": 2064,
|
||||
"team_name": "Max",
|
||||
"team_name_short": "Max"
|
||||
},
|
||||
{
|
||||
"team_id": 2065,
|
||||
"team_name": "Fabian",
|
||||
"team_name_short": "Fabian"
|
||||
},
|
||||
{
|
||||
"team_id": 2066,
|
||||
"team_name": "Bastian",
|
||||
"team_name_short": "Bastian"
|
||||
},
|
||||
{
|
||||
"team_id": 2067,
|
||||
"team_name": "Kevin",
|
||||
"team_name_short": "Kevin"
|
||||
},
|
||||
{
|
||||
"team_id": 2068,
|
||||
"team_name": "Tristan",
|
||||
"team_name_short": "Tristan"
|
||||
},
|
||||
{
|
||||
"team_id": 2069,
|
||||
"team_name": "Werner",
|
||||
"team_name_short": "Werner"
|
||||
},
|
||||
{
|
||||
"team_id": 2070,
|
||||
"team_name": "Johnny",
|
||||
"team_name_short": "Werner"
|
||||
},
|
||||
{
|
||||
"team_id": 2071,
|
||||
"team_name": "Marcel",
|
||||
"team_name_short": "Marcel"
|
||||
},
|
||||
{
|
||||
"team_id": 2072,
|
||||
"team_name": "TG Sportbild/Fifa",
|
||||
"team_name_short": "TG Sportb."
|
||||
},
|
||||
{
|
||||
"team_id": 2073,
|
||||
"team_name": "Marcel U.",
|
||||
"team_name_short": "Marcel U."
|
||||
},
|
||||
{
|
||||
"team_id": 2074,
|
||||
"team_name": "Kay",
|
||||
"team_name_short": "Kay"
|
||||
},
|
||||
{
|
||||
"team_id": 2075,
|
||||
"team_name": "Maxi H.",
|
||||
"team_name_short": "Maxi H."
|
||||
},
|
||||
{
|
||||
"team_id": 2076,
|
||||
"team_name": "Frank",
|
||||
"team_name_short": "Frank"
|
||||
},
|
||||
{
|
||||
"team_id": 2077,
|
||||
"team_name": "Stefanie",
|
||||
"team_name_short": "Stefanie"
|
||||
},
|
||||
{
|
||||
"team_id": 2078,
|
||||
"team_name": "Jaron",
|
||||
"team_name_short": "Jaron"
|
||||
},
|
||||
{
|
||||
"team_id": 2079,
|
||||
"team_name": "Jonas",
|
||||
"team_name_short": "Jonas"
|
||||
},
|
||||
{
|
||||
"team_id": 2082,
|
||||
"team_name": "Klaus",
|
||||
"team_name_short": "Klaus"
|
||||
},
|
||||
{
|
||||
"team_id": 2083,
|
||||
"team_name": "Eduard",
|
||||
"team_name_short": "Eduard"
|
||||
},
|
||||
{
|
||||
"team_id": 2084,
|
||||
"team_name": "Kristina",
|
||||
"team_name_short": "Kristina"
|
||||
},
|
||||
{
|
||||
"team_id": 2085,
|
||||
"team_name": "Andreas",
|
||||
"team_name_short": "Andreas"
|
||||
},
|
||||
{
|
||||
"team_id": 2086,
|
||||
"team_name": "Maxi U.",
|
||||
"team_name_short": "Maxi U."
|
||||
},
|
||||
{
|
||||
"team_id": 2087,
|
||||
"team_name": "Franz",
|
||||
"team_name_short": "Franz"
|
||||
},
|
||||
{
|
||||
"team_id": 2088,
|
||||
"team_name": "Vincent",
|
||||
"team_name_short": "Vincent"
|
||||
},
|
||||
{
|
||||
"team_id": 2089,
|
||||
"team_name": "Martin H.",
|
||||
"team_name_short": "Martin H."
|
||||
},
|
||||
{
|
||||
"team_id": 2090,
|
||||
"team_name": "Dome",
|
||||
"team_name_short": "Dome"
|
||||
},
|
||||
{
|
||||
"team_id": 2091,
|
||||
"team_name": "Dom",
|
||||
"team_name_short": "Dom"
|
||||
},
|
||||
{
|
||||
"team_id": 2096,
|
||||
"team_name": "Jan",
|
||||
"team_name_short": "Jan"
|
||||
},
|
||||
{
|
||||
"team_id": 2102,
|
||||
"team_name": "Maxi Z.",
|
||||
"team_name_short": "Maxi Z."
|
||||
},
|
||||
{
|
||||
"team_id": 2103,
|
||||
"team_name": "Patrick",
|
||||
"team_name_short": "Patrick"
|
||||
},
|
||||
{
|
||||
"team_id": 2104,
|
||||
"team_name": "Jan K.",
|
||||
"team_name_short": "Jan K."
|
||||
},
|
||||
{
|
||||
"team_id": 2105,
|
||||
"team_name": "Muck",
|
||||
"team_name_short": "Muck"
|
||||
},
|
||||
{
|
||||
"team_id": 2106,
|
||||
"team_name": "Philipp",
|
||||
"team_name_short": "Philipp"
|
||||
},
|
||||
{
|
||||
"team_id": 2108,
|
||||
"team_name": "Lukas",
|
||||
"team_name_short": "Lukas"
|
||||
},
|
||||
{
|
||||
"team_id": 2109,
|
||||
"team_name": "Sandro",
|
||||
"team_name_short": "Sandro"
|
||||
},
|
||||
{
|
||||
"team_id": 2110,
|
||||
"team_name": "Bernd",
|
||||
"team_name_short": "Bernd"
|
||||
},
|
||||
{
|
||||
"team_id": 2112,
|
||||
"team_name": "Arno",
|
||||
"team_name_short": "Arno"
|
||||
},
|
||||
{
|
||||
"team_id": 2113,
|
||||
"team_name": "Stefan",
|
||||
"team_name_short": "Stefan"
|
||||
},
|
||||
{
|
||||
"team_id": 2114,
|
||||
"team_name": "Armin",
|
||||
"team_name_short": "Armin"
|
||||
},
|
||||
{
|
||||
"team_id": 2119,
|
||||
"team_name": "Dominik",
|
||||
"team_name_short": "Dominik"
|
||||
},
|
||||
{
|
||||
"team_id": 2123,
|
||||
"team_name": "Michael",
|
||||
"team_name_short": "Michael"
|
||||
},
|
||||
{
|
||||
"team_id": 2124,
|
||||
"team_name": "Olli L.",
|
||||
"team_name_short": "Olli L."
|
||||
},
|
||||
{
|
||||
"team_id": 2131,
|
||||
"team_name": "Adrian",
|
||||
"team_name_short": "Adrian"
|
||||
},
|
||||
{
|
||||
"team_id": 2133,
|
||||
"team_name": "Barb",
|
||||
"team_name_short": "Barb"
|
||||
},
|
||||
{
|
||||
"team_id": 2137,
|
||||
"team_name": "Johannes",
|
||||
"team_name_short": "Johannes"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "tippliga",
|
||||
"private_key_id": "4e0def9ef4474114744a1fcaffae9e75689a8909",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDaJeiT0eCLSq6l\nfjvNxE9EnHtFxvWdJOx2CsIXvBJKA7u1b95uHSNQmmunJPMstMLvTRYYYVpJWUm0\njqLd4VGUDqjXuWcNQpn62TFLSGQs8bTwIYoYsAnTWC+kuG5iSaKKzw9UiKFx0Mxv\nLAm5CjqYb87E2pz+7ihCYfaMkpppwPhz8bUbQ+iHdo85cQBcZeVpjuL+W4KT89yV\nZxsV4dGJNabLLEznA1WyhS+pGz+3N9edfANyREthrxm1cyytd3omQ/pfIl7KpGlU\nIq4eDMzlPftn+Nq9S7UfTXzxcv9Ez2cdlGMSSSbpjQBYXNEewnzXutFqfK9h2STD\nM0XaqGh9AgMBAAECggEAAzMrOWAmI8zsUmcPYANG6WMgp6NVhcV46zEP/iTroVRg\nwr+r8bJWOJj+IjCgq4hQ09a3KyYGtlXwRrrH5HPyQyTAnqLjZtZ/3lzblm2TYJmJ\nwzwcbO1+skJCAF2Dxmxh35jgTafQIQJNhxheqtrwBStVQhUIIbosPBQvkven+tUv\n4lRn494VXNxWZSGevL+3iJoNtJbjjQ8FVLafx6/vKP4mShB0UxKHqSBRtzZ5g4/n\nB8d4Vw4Ma0eEBUMDD9vOqreMdKCUoMnZIKuQwWeyiug77mBxgfmCRnsefOdyEKne\nRvalPBKEpD2PH/iud+qkuNNITFCr0I1iF6f4NElciQKBgQD/q68TvMOUE2tlgdU6\n6o6d7b+Sm4yp19f1euR0fe7+5as6Pz4KWy0zwSXAczVNDXLq44hQ4eeJMALwKvQ+\nXqCrtjc3NkVtiPXIjnqEQ/t56WBZtsrLxlNAE9yxHQPEmyRMKjGOJTRpoNZzGBsS\naEqTiKinO7AY5xOWzXz+HVLDRQKBgQDabdmrKLJaHhboPBa5B7HJ8WCL5P5+97P6\n4WuDT7vQvyJqb3KhltdRAgMszFXsfYwyeidncQ3fxUlmMWtWlHROfjhyWQZ0jIJg\nwpTAvNqQ3HuXM2fRvM7d6Z69xE2RxVpRaAbvGUHvNohAW7Vwmoi/GV9NR6irV/ny\n1suS6SIH2QKBgHnJXEJ4nmlAvt3BdML1zC2qfKDne5/D81k5yu06t8evu1qpmXHx\ncJzAmq0LtA4aI+2DqQFuOo580kl5DJNRHBPvXmnsbjH5FasNQ4sRnw65fm39xqg+\ntpVFYND1U0Ap7qZhSu29BzRxqvV0PCEOkMeqRzwyEHYsTIZ/J9UcPrpJAoGAcNQ/\nlN8vycczNAEeB7QGzXbG1VyTbYiMSrK4c5rzPHAO2gX5o6ikTm8IrtJaLA/qJITe\n59sJPKbPNF+gv5dtwMIIbGC6KegOzOaWKj0jdaK+oKroHPo3rX+pBQNqwjq8XcKr\nmkRkv6lelkgJIEJjEruLdALpCKEoNp1niNquPnkCgYAVAkaF/8xYQ4UaBuJEJPOW\nDNXAmRrvaazU8GTv70t03VHKjhcv7b83L+n8yU3VuaqaO3bgyGIELJ2VRzVn16EH\nkUwh1W2fB1ZAmMK6V5JB7b8LCPdpCJSbQvNZAOZj4aodoNtGKM0j36rTSZJi2Rdz\nqtOSw0pEvALI62ufuNRUzA==\n-----END PRIVATE KEY-----\n",
|
||||
"client_email": "tlw-707@tippliga.iam.gserviceaccount.com",
|
||||
"client_id": "101590566618120833710",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/tlw-707%40tippliga.iam.gserviceaccount.com"
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
{
|
||||
"numberOfMatchdays": 39,
|
||||
"matchesPerMatchday": 12,
|
||||
"pointMode": 4,
|
||||
"pointsTendency": 1,
|
||||
"pointsDifference": 2,
|
||||
"pointsDirectHit": 3,
|
||||
"ko": 0,
|
||||
"matchdayConfig": [
|
||||
{
|
||||
"TLWMatchday": 1,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 2,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 3,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 4,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 5,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 6,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 7,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 8,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 9,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 10,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 11,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 12,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 13,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 14,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 15,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 16,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 17,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 18,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 19,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 20,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 21,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 22,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 23,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 24,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 25,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 26,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 27,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 28,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 29,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 30,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 31,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 32,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 33,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 34,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 35,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 36,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 37,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 38,
|
||||
"matchesConfig": []
|
||||
},
|
||||
{
|
||||
"TLWMatchday": 39,
|
||||
"matchesConfig": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package de.jeyp91;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class S3ProviderTest {
|
||||
|
||||
@Test
|
||||
public void getFixturesFromS3Test() {
|
||||
S3Provider prov = new S3Provider();
|
||||
String rounds = prov.getFixturesStringFromS3(1240);
|
||||
System.out.println(rounds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package de.jeyp91;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import de.jeyp91.teamidmatcher.TeamIDMatcher;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TeamIDMatcherTest {
|
||||
|
||||
@Test
|
||||
public void getOpenLigaDbIdFromTippligaIdTest() {
|
||||
int apiFootballId;
|
||||
|
||||
apiFootballId = TeamIDMatcher.getApiFootballIdFromTippligaId(505);
|
||||
assertEquals(80, apiFootballId);
|
||||
apiFootballId = TeamIDMatcher.getApiFootballIdFromTippligaId(160);
|
||||
assertEquals(91, apiFootballId);
|
||||
apiFootballId = TeamIDMatcher.getApiFootballIdFromTippligaId(182);
|
||||
assertEquals(12754, apiFootballId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTippligaIdFromOpenLigaDbIdTest() throws Exception {
|
||||
int tlwId;
|
||||
String jsonMatch = "{" +
|
||||
"\"fixture_id\":1," +
|
||||
"\"league_id\":1240," +
|
||||
"\"league\":{" +
|
||||
"\"name\":\"Testliga\"" +
|
||||
"}," +
|
||||
"\"event_date\":\"2020-01-01T00:00:00+02:00\"" +
|
||||
"\"round\":\"Bayern - 1\"," +
|
||||
"\"statusShort\":\"FT\"" +
|
||||
"\"homeTeam\":{" +
|
||||
"\"team_id\":9330," +
|
||||
"\"team_name\":\"TestHome\"" +
|
||||
"}," +
|
||||
"\"awayTeam\":{" +
|
||||
"\"team_id\":9331," +
|
||||
"\"team_name\":\"TestGuest\"" +
|
||||
"}" +
|
||||
"}";
|
||||
JSONObject matchObject;
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
matchObject = (JSONObject) jsonParser.parse(jsonMatch);
|
||||
APIFootballMatch match = new APIFootballMatch(matchObject, 2021);
|
||||
|
||||
match.teamIdHome = 80;
|
||||
tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(match, TeamIDMatcher.HOME);
|
||||
assertEquals(505, tlwId);
|
||||
match.teamIdHome = 91;
|
||||
tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(match, TeamIDMatcher.HOME);
|
||||
assertEquals(160, tlwId);
|
||||
match.teamIdHome = 12754;
|
||||
tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(match, TeamIDMatcher.HOME);
|
||||
assertEquals(182, tlwId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package de.jeyp91.apifootball;
|
||||
|
||||
import de.jeyp91.openligadb.OpenLigaDBConnector;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class APIFootballConnectorTest {
|
||||
|
||||
@Test
|
||||
public void APITestGetMatchDataOfMatchdayBundesliga() {
|
||||
APIFootballConnector apiFootballConnector = APIFootballConnector.getAPIFootballConnectorInstance(2020);
|
||||
ArrayList<APIFootballMatch> matchesOfMatchday = apiFootballConnector.getMatchDataByLeagueAndMatchday(2677, 1);
|
||||
assert matchesOfMatchday.get(0).getTeamIdHome() == 744;
|
||||
assert matchesOfMatchday.get(0).getTeamIdGuest() == 159;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package de.jeyp91.apifootball;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.junit.Test;
|
||||
|
||||
import static de.jeyp91.apifootball.APIFootballConnector.stringToJSONObject;
|
||||
|
||||
public class APIFootballMatchTest {
|
||||
|
||||
@Test
|
||||
public void withExtratime() throws Exception {
|
||||
String matchString = "{\"fixture_id\":958530,\"league_id\":4303,\"league\":{\"name\":\"DFB Pokal\",\"country\":\"Germany\",\"logo\":\"https:\\/\\/media-3.api-sports.io\\/football\\/leagues\\/81.png\",\"flag\":\"https:\\/\\/media-1.api-sports.io\\/flags\\/de.svg\"},\"event_date\":\"2022-10-19T18:00:00+02:00\",\"event_timestamp\":1666195200,\"firstHalfStart\":1666195200,\"secondHalfStart\":1666198800,\"round\":\"2nd Round\",\"status\":\"Match Finished\",\"statusShort\":\"PEN\",\"elapsed\":120,\"venue\":\"Home Deluxe Arena\",\"referee\":\"Frank Willenborg, Germany\",\"homeTeam\":{\"team_id\":185,\"team_name\":\"SC Paderborn 07\",\"logo\":\"https:\\/\\/media-2.api-sports.io\\/football\\/teams\\/185.png\"},\"awayTeam\":{\"team_id\":162,\"team_name\":\"Werder Bremen\",\"logo\":\"https:\\/\\/media-3.api-sports.io\\/football\\/teams\\/162.png\"},\"goalsHomeTeam\":2,\"goalsAwayTeam\":2,\"score\":{\"halftime\":\"2-0\",\"fulltime\":\"2-2\",\"extratime\":\"0-0\",\"penalty\":\"5-4\"}}";
|
||||
JSONObject matchJson = stringToJSONObject(matchString);
|
||||
APIFootballMatch match = new APIFootballMatch(matchJson, 2023);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void withoutExtratime() throws Exception {
|
||||
String matchString = "{\"fixture_id\":958530,\"league_id\":4303,\"league\":{\"name\":\"DFB Pokal\",\"country\":\"Germany\",\"logo\":\"https:\\/\\/media-3.api-sports.io\\/football\\/leagues\\/81.png\",\"flag\":\"https:\\/\\/media-1.api-sports.io\\/flags\\/de.svg\"},\"event_date\":\"2022-10-19T18:00:00+02:00\",\"event_timestamp\":1666195200,\"firstHalfStart\":1666195200,\"secondHalfStart\":1666198800,\"round\":\"2nd Round\",\"status\":\"Match Finished\",\"statusShort\":\"PEN\",\"elapsed\":120,\"venue\":\"Home Deluxe Arena\",\"referee\":\"Frank Willenborg, Germany\",\"homeTeam\":{\"team_id\":185,\"team_name\":\"SC Paderborn 07\",\"logo\":\"https:\\/\\/media-2.api-sports.io\\/football\\/teams\\/185.png\"},\"awayTeam\":{\"team_id\":162,\"team_name\":\"Werder Bremen\",\"logo\":\"https:\\/\\/media-3.api-sports.io\\/football\\/teams\\/162.png\"},\"goalsHomeTeam\":2,\"goalsAwayTeam\":2,\"score\":{\"halftime\":\"2-0\",\"fulltime\":\"2-2\",\"extratime\":null,\"penalty\":null}}";
|
||||
JSONObject matchJson = stringToJSONObject(matchString);
|
||||
APIFootballMatch match = new APIFootballMatch(matchJson, 2023);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package de.jeyp91.apifootball;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class APIFootballUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void checkErrorsTest() {
|
||||
String exceededLimitDayError = "{\"api\":{\"results\":0,\"error\":\"You have reached the request limit for the day\"}}";
|
||||
APIFootballUpdater updater = new APIFootballUpdater();
|
||||
try {
|
||||
updater.checkErrors("https://test.url/api", exceededLimitDayError);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
assert e.getMessage().equals("https://test.url/api returned error: 'You have reached the request limit for the day'");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateFixturesTest() {
|
||||
APIFootballUpdater updater = new APIFootballUpdater();
|
||||
// updater.updateFixtures(1240);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateAllFixturesTest() {
|
||||
APIFootballUpdater updater = new APIFootballUpdater();
|
||||
// updater.updateAllFixtures();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateRoundsTest() {
|
||||
APIFootballUpdater updater = new APIFootballUpdater();
|
||||
// updater.updateRounds(2777);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateAllRoundsTest() {
|
||||
APIFootballUpdater updater = new APIFootballUpdater();
|
||||
// updater.updateAllRounds();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package de.jeyp91.googlecalendar;
|
||||
|
||||
import com.google.api.client.util.DateTime;
|
||||
import com.google.api.services.calendar.model.Event;
|
||||
import de.jeyp91.tippliga.TLWMatchday;
|
||||
import de.jeyp91.tippliga.TLWMatchdaysCreator;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.jeyp91.googlecalendar.TippligaGoogleEventManager.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TippligaGoogleEventManagerTest {
|
||||
|
||||
@Test
|
||||
public void getAllEventsStartingFromDateTimeTest()
|
||||
{
|
||||
DateTime dateTime = new DateTime("2020-01-01T00:00:00");
|
||||
|
||||
List<Event> events = getAllEventsStartingFromDateTime(dateTime);
|
||||
|
||||
assertEquals("Tippliga 20. Spieltag tippen!", events.get(0).getSummary());
|
||||
DateTime startExpected = new DateTime("2020-01-17T20:30:00+01:00");
|
||||
DateTime startActual = events.get(0).getStart().getDateTime();
|
||||
assertEquals(startExpected, startActual);
|
||||
|
||||
assertEquals("Tippliga 21. Spieltag tippen!", events.get(1).getSummary());
|
||||
startExpected = new DateTime("2020-01-24T20:30:00+01:00");
|
||||
startActual = events.get(1).getStart().getDateTime();
|
||||
assertEquals(startExpected, startActual);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createOrUpdateEventsForMatchdayTippligaTest() {
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2024, 1, "Tippliga");
|
||||
ArrayList<TLWMatchday> matchdays = creator.getMatchdays();
|
||||
|
||||
matchdays.forEach(TippligaGoogleEventManager::createOrUpdateEventsForMatchday);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createOrUpdateEventsForMatchdaySupercupTest() {
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2024, 45, "Supercup");
|
||||
ArrayList<TLWMatchday> matchdays = creator.getMatchdays();
|
||||
|
||||
matchdays.forEach(TippligaGoogleEventManager::createOrUpdateEventsForMatchday);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findEventTest() {
|
||||
List<Event> allEvents = getAllEvents(2023);
|
||||
Event event = findEvent(allEvents, 2023, 1, 1, 2);
|
||||
assert event != null;
|
||||
assertEquals(event.getStart().size(), 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateEventTest() {
|
||||
List<Event> allEvents = getAllEvents(2023);
|
||||
Event event = findEvent(allEvents, 2023, 1, 1, 1);
|
||||
TLWMatchday matchday = new TLWMatchday(2023, 1, 1, 0, "2022-08-06 20:30:00", "", "", "1. Spieltag", 12);
|
||||
assert event != null;
|
||||
updateEvent(event, matchday, matchday.getDeliveryDate(), 1);
|
||||
assertEquals(event.size(), 18);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createOrUpdateEventsForMatchdayWTLPokalTest() {
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2024, 48, "WTL-Pokal");
|
||||
ArrayList<TLWMatchday> matchdays = creator.getMatchdays();
|
||||
// createOrUpdateEventsForMatchday(matchdays.get(4));
|
||||
|
||||
matchdays.forEach(TippligaGoogleEventManager::createOrUpdateEventsForMatchday);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createOrUpdateEventTest() {
|
||||
TLWMatchday matchday = new TLWMatchday(2023, 1, 1, 0, "2022-08-05 20:30:00", "", "", "1. Spieltag", 12);
|
||||
createOrUpdateEvent(matchday, matchday.getDeliveryDate(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteEventTippligaTest() {
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2022, 1, "Tippliga");
|
||||
ArrayList<TLWMatchday> matchdays = creator.getMatchdays();
|
||||
|
||||
matchdays.forEach(tlwMatchday -> {
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 1);
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 2);
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 3);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteEventWTLPokalTest() {
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2022, 48, "WTL-Pokal");
|
||||
ArrayList<TLWMatchday> matchdays = creator.getMatchdays();
|
||||
|
||||
matchdays.forEach(tlwMatchday -> {
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 1);
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 2);
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 3);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteAllEventsTest() throws IOException {
|
||||
TippligaGoogleEventManager.deleteAllEvents(2023);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package de.jeyp91.openligadb;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class OpenLigaDBConnectorTest {
|
||||
|
||||
@Test
|
||||
public void APITestGetMatchDataOfMatchdayBundesliga() {
|
||||
OpenLigaDBConnector openLigaDBConnector = new OpenLigaDBConnector();
|
||||
ArrayList<OpenLigaDBMatch> matches = openLigaDBConnector.getMatchDataOfMatchday(2020, "bl1", 1);
|
||||
|
||||
assertEquals(9, matches.size());
|
||||
|
||||
OpenLigaDBMatch match;
|
||||
|
||||
match = matches.get(0);
|
||||
assertEquals((Integer) 55277, match.getMatchId());
|
||||
assertEquals((Integer) 40, match.getTeamIdHome());
|
||||
assertEquals((Integer) 54, match.getTeamIdGuest());
|
||||
assertEquals((Integer) 2020, match.getSeason());
|
||||
assertEquals("2019-08-16T20:30:00", match.getMatchDateTime());
|
||||
assertEquals((Integer) 1, match.getMatchday());
|
||||
assertEquals((Integer) 2, match.getGoalsHome());
|
||||
assertEquals((Integer) 2, match.getGoalsGuest());
|
||||
assertTrue(match.getMatchIsFinished());
|
||||
|
||||
match = matches.get(1);
|
||||
assertEquals((Integer) 55278, match.getMatchId());
|
||||
assertEquals((Integer) 7, match.getTeamIdHome());
|
||||
assertEquals((Integer) 95, match.getTeamIdGuest());
|
||||
assertEquals((Integer) 2020, match.getSeason());
|
||||
assertEquals("2019-08-17T15:30:00", match.getMatchDateTime());
|
||||
assertEquals((Integer) 1, match.getMatchday());
|
||||
assertEquals((Integer) 5, match.getGoalsHome());
|
||||
assertEquals((Integer) 1, match.getGoalsGuest());
|
||||
assertTrue(match.getMatchIsFinished());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void APITestGetMatchDataOfMatchdayDFBPokal() {
|
||||
OpenLigaDBConnector openLigaDBConnector = new OpenLigaDBConnector();
|
||||
ArrayList<OpenLigaDBMatch> matches = openLigaDBConnector.getMatchDataOfMatchday(2020, "dfb2019", 1);
|
||||
|
||||
assert matches.size() == 32;
|
||||
|
||||
OpenLigaDBMatch match = matches.get(0);
|
||||
assertEquals((Integer) 54926, match.getMatchId());
|
||||
assertEquals((Integer) 563, match.getTeamIdHome());
|
||||
assertEquals((Integer) 7, match.getTeamIdGuest());
|
||||
assertEquals((Integer) 2020, match.getSeason());
|
||||
assertEquals("2019-08-09T20:45:00", match.getMatchDateTime());
|
||||
assertEquals((Integer) 1, match.getMatchday());
|
||||
assertEquals((Integer) 0, match.getGoalsHome());
|
||||
assertEquals((Integer) 2, match.getGoalsGuest());
|
||||
assertTrue(match.getMatchIsFinished());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void APITestGetMatchDataOfSingleMatch() {
|
||||
OpenLigaDBConnector openLigaDBConnector = new OpenLigaDBConnector();
|
||||
OpenLigaDBMatch match = openLigaDBConnector.getMatchDataOfSingleMatch(55583);
|
||||
assertEquals((Integer) 55583, match.getMatchId());
|
||||
assertEquals((Integer) 16, match.getTeamIdHome());
|
||||
assertEquals((Integer) 55, match.getTeamIdGuest());
|
||||
assertEquals((Integer) 2020, match.getSeason());
|
||||
assertEquals("2019-07-26T20:30:00", match.getMatchDateTime());
|
||||
assertEquals((Integer) 1, match.getMatchday());
|
||||
assertEquals((Integer) 2, match.getGoalsHome());
|
||||
assertEquals((Integer) 1, match.getGoalsGuest());
|
||||
assertTrue(match.getMatchIsFinished());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package de.jeyp91.teamidmatcher;
|
||||
|
||||
import de.jeyp91.teamidmatcher.TeamIDMatcherTemplateCreator;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TeamIDMatcherTemplateCreatorTest {
|
||||
|
||||
@Test
|
||||
public void getTeamsTemplate() {
|
||||
// TeamIDMatcherTemplateCreator creator = new TeamIDMatcherTemplateCreator(0, 2790);
|
||||
// String template = creator.getTeamsTemplate();
|
||||
// System.out.println(template);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TLWMatchdayUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void getUpdateSqlTest1() throws Exception {
|
||||
TLWMatchdaysUpdater matchdaysUpdater = new TLWMatchdaysUpdater(2021, 1, "Tippliga");
|
||||
|
||||
String sql = matchdaysUpdater.getUpdateSql();
|
||||
|
||||
// System.out.println(sql);
|
||||
// System.out.println(matchdaysUpdater.getBeautifulInfo());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUpdateSqlTest2() throws Exception {
|
||||
TLWMatchdaysUpdater matchdaysUpdater = new TLWMatchdaysUpdater(2021, 2, "Tippliga");
|
||||
|
||||
String sql = matchdaysUpdater.getUpdateSql();
|
||||
|
||||
// System.out.println(sql);
|
||||
// System.out.println(matchdaysUpdater.getBeautifulInfo());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateGoogleCalendarTest() {
|
||||
TLWMatchdaysUpdater matchdaysUpdater = new TLWMatchdaysUpdater(2023, 1, "Tippliga");
|
||||
matchdaysUpdater.updateGoogleCalendar();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TLWMatchdaysCreatorTest {
|
||||
|
||||
int season = 2023;
|
||||
|
||||
@Test
|
||||
public void getMatchdaysTippligaTest() {
|
||||
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 1, "Tippliga");
|
||||
ArrayList<TLWMatchday> matchdays = matchdaysCreator.getMatchdays();
|
||||
|
||||
assertEquals((Integer) 1, matchdays.get(0).getMatchday());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchdaysWTLPokalTest() {
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 48, "WTL-Pokal");
|
||||
ArrayList<TLWMatchday> matchdays = matchdaysCreator.getMatchdays();
|
||||
|
||||
assertEquals((Integer) 1, matchdays.get(0).getMatchday());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchdaysTippliga1SqlTest() {
|
||||
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 1, "Tippliga");
|
||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchdaysTippliga2SqlTest() {
|
||||
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 2, "Tippliga");
|
||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchdaysTippliga51SqlTest() {
|
||||
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 51, "Tippliga");
|
||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchdaysTippliga52SqlTest() {
|
||||
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 52, "Tippliga");
|
||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchdaysWTLPokal48SqlTest() {
|
||||
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 48, "WTL-Pokal");
|
||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchdaysWTLPokal98SqlTest() {
|
||||
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 98, "WTL-Pokal");
|
||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchdaysSupercup45SqlTest() {
|
||||
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 45, "Supercup");
|
||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchdaysSupercup95SqlTest() {
|
||||
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 95, "Supercup");
|
||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchdaysEMTippspielSqlTest() {
|
||||
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 49, "EM-Tippspiel");
|
||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||
// System.out.println(sql);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TLWMatchesCreatorFootballTest {
|
||||
|
||||
int season = 2023;
|
||||
|
||||
@Test
|
||||
public void getMatchesTest() {
|
||||
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(season, 48, "WTL-Pokal");
|
||||
ArrayList<TLWMatch> matches = creator.getMatches();
|
||||
|
||||
assertEquals((Integer) 1, matches.get(0).getMatchNo());
|
||||
assertEquals((Integer) 11, matches.get(10).getMatchNo());
|
||||
// System.out.println(matches.get(0).getSQLQueryReplace());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesTippliga1SqlTest() {
|
||||
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(season, 1, "Tippliga");
|
||||
String sql = creator.getSQLInsertString();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesTippliga2SqlTest() {
|
||||
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(season, 2, "Tippliga");
|
||||
String sql = creator.getSQLInsertString();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesWTLPokalSqlTest() {
|
||||
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(season, 48, "WTL-Pokal");
|
||||
String sql = creator.getSQLInsertString();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesSupercupSqlTest() {
|
||||
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(season, 45, "Supercup");
|
||||
String sql = creator.getSQLInsertString();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesEMTippspielSqlTest() {
|
||||
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 49, "EM-Tippspiel");
|
||||
String sql = creator.getSQLInsertString();
|
||||
// System.out.println(sql);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TLWMatchesCreatorTipperPokalTest {
|
||||
|
||||
int season = 2024;
|
||||
|
||||
@Test
|
||||
public void getMatchesWTLPokalTest() {
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 48, "WTL-Pokal");
|
||||
|
||||
TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(season, 98, "WTL-Pokal Tipper", matchdaysCreator.getMatchdays());
|
||||
|
||||
String sql = creator.getSQLInsertString();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesSupercupTest() {
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 45, "Supercup");
|
||||
|
||||
TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(season, 95, "Supercup Tipper", matchdaysCreator.getMatchdays());
|
||||
|
||||
String sql = creator.getSQLInsertString();
|
||||
System.out.println(sql);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TLWMatchesCreatorTipperTest {
|
||||
|
||||
int season = 2024;
|
||||
|
||||
@Test
|
||||
public void getMatchesTippliga1Test() {
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 1, "Tippliga");
|
||||
|
||||
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(season, 51, "1. Tippliga Tipper", matchdaysCreator.getMatchdays());
|
||||
|
||||
String sql = creator.getSQLInsertString();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesTippliga2Test() {
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 2, "Tippliga");
|
||||
|
||||
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(season, 52, "2. Tippliga Tipper", matchdaysCreator.getMatchdays());
|
||||
|
||||
String sql = creator.getSQLInsertString();
|
||||
System.out.println(sql);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TLWMatchesResultsUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void updateResultsTest1() {
|
||||
TLWMatchesResultsUpdater updater = new TLWMatchesResultsUpdater(2024, 48, "WTL-Pokal");
|
||||
// updater.applyUpdates();
|
||||
System.out.println(updater.getBeautifulInfo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TLWMatchesUpdaterFootballTest {
|
||||
|
||||
int season = 2024;
|
||||
@Test
|
||||
public void getUpdateSqlTest1() {
|
||||
TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(season, 1, "Tippliga");
|
||||
String sql = updater.getUpdateSQL();
|
||||
|
||||
System.out.println(sql);
|
||||
// System.out.println(updater.getBeautifulInfo());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUpdateSqlTest2() {
|
||||
TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(season, 2, "Tippliga");
|
||||
String sql = updater.getUpdateSQL();
|
||||
|
||||
System.out.println(sql);
|
||||
// System.out.println(updater.getBeautifulInfo());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getUpdateSqlTest48() {
|
||||
TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(season, 48, "WTL-Pokal");
|
||||
String sql = updater.getUpdateSQL();
|
||||
|
||||
System.out.println(sql);
|
||||
// System.out.println(updater.getBeautifulInfo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TLWTeamsCreatorTest {
|
||||
|
||||
int season = 2024;
|
||||
|
||||
@Test
|
||||
public void getTeamsTippligaFootball1Test() {
|
||||
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(season, 1, "Tippliga");
|
||||
ArrayList<TLWMatch> matches = matchesCreator.getMatches();
|
||||
|
||||
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 1, matches);
|
||||
String sql = teamCreator.getSql();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeamsTippligaFootball2Test() {
|
||||
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(season, 2, "Tippliga");
|
||||
ArrayList<TLWMatch> matches = matchesCreator.getMatches();
|
||||
|
||||
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 2, matches);
|
||||
String sql = teamCreator.getSql();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeamsWTLPokalTest() {
|
||||
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(season, 48, "WTL-Pokal");
|
||||
ArrayList<TLWMatch> matches = matchesCreator.getMatches();
|
||||
|
||||
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 48, matches);
|
||||
String sql = teamCreator.getSql();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeamsTippligaSupercupTest() {
|
||||
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(season, 45, "Supercup");
|
||||
ArrayList<TLWMatch> matches = matchesCreator.getMatches();
|
||||
|
||||
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 45, matches);
|
||||
String sql = teamCreator.getSql();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeamsTippligaEMTippspielTest() {
|
||||
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 49, "EM-Tippspiel");
|
||||
ArrayList<TLWMatch> matches = matchesCreator.getMatches();
|
||||
|
||||
TLWTeamsCreator teamCreator = new TLWTeamsCreator(2021, 49, matches);
|
||||
String sql = teamCreator.getSql();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeamsTipper1TLTest() {
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 1, "Tippliga");
|
||||
|
||||
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(season, 51, "1. Tippliga Tipper", matchdaysCreator.getMatchdays());
|
||||
|
||||
ArrayList<TLWMatch> matches = creator.getMatches();
|
||||
|
||||
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 51, matches);
|
||||
String sql = teamCreator.getSql();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeamsTipper2TLTest() {
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 2, "Tippliga");
|
||||
|
||||
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(season, 52, "2. Tippliga Tipper", matchdaysCreator.getMatchdays());
|
||||
|
||||
ArrayList<TLWMatch> matches = creator.getMatches();
|
||||
|
||||
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 52, matches);
|
||||
String sql = teamCreator.getSql();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeamsTipperWTLTest() {
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, 48, "WTL-Pokal");
|
||||
|
||||
TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(season, 98, "WTL-Pokal Tipper", matchdaysCreator.getMatchdays());
|
||||
|
||||
ArrayList<TLWMatch> matches = creator.getMatches();
|
||||
|
||||
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, 98, matches);
|
||||
String sql = teamCreator.getSql();
|
||||
System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeamsTipperSupercupTest() {
|
||||
int leagueId = 45;
|
||||
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(season, leagueId, "Supercup");
|
||||
|
||||
TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(season, leagueId + 50, "Supercup Tipper", matchdaysCreator.getMatchdays());
|
||||
|
||||
ArrayList<TLWMatch> matches = creator.getMatches();
|
||||
|
||||
TLWTeamsCreator teamCreator = new TLWTeamsCreator(season, leagueId + 50, matches);
|
||||
String sql = teamCreator.getSql();
|
||||
System.out.println(sql);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TLWTeamsUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void getInsertSQLTest1() throws Exception {
|
||||
TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 1, "Tippliga");
|
||||
String sql = teamsUpdater.getInsertSQL();
|
||||
// System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getInsertSQLTest2() throws Exception {
|
||||
TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 2, "Tippliga");
|
||||
String sql = teamsUpdater.getInsertSQL();
|
||||
// System.out.println(sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getInsertSQLTest48() throws Exception {
|
||||
TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 48, "WTL-Pokal");
|
||||
String sql = teamsUpdater.getInsertSQL();
|
||||
// System.out.println(sql);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.tippligaforum.TippligaConfigProvider;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TippligaConfigProviderTest {
|
||||
|
||||
@Test
|
||||
public void getTippligaConfigTest() {
|
||||
TippligaConfigProvider prov = new TippligaConfigProvider(2021);
|
||||
JSONObject config = prov.getTippligaConfig("Tippliga");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package de.jeyp91.tippliga;
|
||||
|
||||
import de.jeyp91.tippligaforum.TippligaSQLConnector;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TippligaSQLConnectorTest {
|
||||
|
||||
TippligaSQLConnector con;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
con = TippligaSQLConnector.getInstance();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeamsBySeasonAndLeagueTest() {
|
||||
ArrayList<TLWTeam> teams = con.getTeams("2020", "1");
|
||||
|
||||
assertEquals(84, teams.size());
|
||||
|
||||
assertEquals(2020, teams.get(0).getSeason());
|
||||
assertEquals(1, teams.get(0).getLeague());
|
||||
assertEquals(1, teams.get(0).getTeamId());
|
||||
assertEquals("Bayern München", teams.get(0).getTeamName());
|
||||
assertEquals("Bayern", teams.get(0).getTeamNameShort());
|
||||
assertEquals("FC Bayern Muenchen.png", teams.get(0).getTeamSymbol());
|
||||
assertEquals("", teams.get(0).getGroupId());
|
||||
assertEquals(0, teams.get(0).getMatchday());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTeamsByIdTest() {
|
||||
ArrayList<TLWTeam> teams = con.getTeams("1");
|
||||
|
||||
assertEquals(2021, teams.get(0).getSeason());
|
||||
assertEquals(1, teams.get(0).getLeague());
|
||||
assertEquals(1, teams.get(0).getTeamId());
|
||||
assertEquals("Bayern München", teams.get(0).getTeamName());
|
||||
assertEquals("Bayern", teams.get(0).getTeamNameShort());
|
||||
assertEquals("FC Bayern Muenchen.png", teams.get(0).getTeamSymbol());
|
||||
assertEquals("", teams.get(0).getGroupId());
|
||||
assertEquals(0, teams.get(0).getMatchday());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesBySeasonAndLeague() {
|
||||
ArrayList<TLWMatch> matches = con.getMatches("2020", "1");
|
||||
|
||||
assertEquals(468, matches.size());
|
||||
|
||||
assertEquals((Integer) 2020, matches.get(0).getSeason());
|
||||
assertEquals((Integer) 1, matches.get(0).getLeague());
|
||||
assertEquals((Integer) 1, matches.get(0).getMatchday());
|
||||
assertEquals("", matches.get(0).getGroupId());
|
||||
assertEquals((Integer) 1, matches.get(0).getMatchNo());
|
||||
assertEquals("2019-07-26 20:30:00", matches.get(0).getMatchDateTime());
|
||||
assertEquals((Integer) 8, matches.get(0).getTeamIdHome());
|
||||
assertEquals((Integer) 15, matches.get(0).getTeamIdGuest());
|
||||
assertEquals((Integer) 2, matches.get(0).getGoalsHome());
|
||||
assertEquals((Integer) 1, matches.get(0).getGoalsGuest());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void replaceXmlMetacharactersTest() {
|
||||
String post = "[code]\n" +
|
||||
"{\"a\"}\n" +
|
||||
"[/code]";
|
||||
String replacement = con.replaceXmlMetacharacters(post);
|
||||
System.out.println(replacement);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getChecksumTest() {
|
||||
String post = "[code]\n" +
|
||||
"{\"a\"}\n" +
|
||||
"[/code]";
|
||||
String md5 = con.getChecksum(post);
|
||||
System.out.println(md5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPostUpdateQueryTest() {
|
||||
int postId = 582;
|
||||
String postText = "[code]\n" +
|
||||
"{\"a\"}\n" +
|
||||
"[/code]";
|
||||
String postTextClean = con.replaceXmlMetacharacters(postText);
|
||||
String postChecksum = con.getChecksum(postText);
|
||||
long postEditTime = 1604691314;
|
||||
String postEditReason = "Update by tool.";
|
||||
int postEditUser = 2;
|
||||
|
||||
String query = con.getPostUpdateQuery(postId, postTextClean, postChecksum, postEditTime, postEditReason, postEditUser);
|
||||
System.out.println(query);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package de.jeyp91.tippligaforum;
|
||||
|
||||
import de.jeyp91.tippligaforum.MatchesListCreator;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MatchesListCreatorTest {
|
||||
|
||||
@Test
|
||||
public void getMatchesTest2664() {
|
||||
MatchesListCreator creator = new MatchesListCreator(2664);
|
||||
String matches = creator.getMatchesBeautiful();
|
||||
// System.out.println(matches);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesTest2743() {
|
||||
MatchesListCreator creator = new MatchesListCreator(2743);
|
||||
String matches = creator.getMatchesBeautiful();
|
||||
System.out.println(matches);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesTest2755() {
|
||||
MatchesListCreator creator = new MatchesListCreator(2755);
|
||||
String matches = creator.getMatchesBeautiful();
|
||||
// System.out.println(matches);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesTest2790() {
|
||||
MatchesListCreator creator = new MatchesListCreator(2790);
|
||||
String matches = creator.getMatchesBeautiful();
|
||||
// System.out.println(matches);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getMatchesTest2795() {
|
||||
MatchesListCreator creator = new MatchesListCreator(2795);
|
||||
String matches = creator.getMatchesBeautiful();
|
||||
// System.out.println(matches);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package de.jeyp91.tippligaforum;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class MatchesListForumUpdaterTest {
|
||||
|
||||
@Test
|
||||
public void updateAllLeaguesTest() {
|
||||
MatchesListForumUpdater updater = new MatchesListForumUpdater(2022);
|
||||
// updater.updateAllLeagues(2022);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateLeagueTest() {
|
||||
MatchesListForumUpdater updater = new MatchesListForumUpdater(2022);
|
||||
updater.updateLeague(2022, 3509);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package de.jeyp91.tippligaforum;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class TippligaSQLConnectorTest {
|
||||
@Test
|
||||
public void getChecksumOfPostTest() {
|
||||
TippligaSQLConnector con = TippligaSQLConnector.getInstance();
|
||||
// con.getChecksumOfPost(15, "Tippliga");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package de.jeyp91.tippligaforum;
|
||||
|
||||
import de.jeyp91.tippliga.TLWMatch;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TippligaWebsiteConnectorTest {
|
||||
@Test
|
||||
public void updateResultsAdminTest() throws IOException {
|
||||
TippligaWebsiteConnector con = new TippligaWebsiteConnector();
|
||||
List<TLWMatch> matches = new ArrayList<>();
|
||||
TLWMatch match = new TLWMatch(2023, 48, 5, 61, "0", 3, 0);
|
||||
match.setGoalsHome(1);
|
||||
match.setGoalsGuest(5);
|
||||
matches.add(match);
|
||||
con.updateResultsAdmin(2023, 48, 5, matches);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user