Merge branch 'android_apps' of ssh://sapsailing.com/home/trac/git into android_apps

This commit is contained in:
Lukas Zielinski committed 2015-01-15 16:41:58 +01:00
commit bde26f4f97
2327 files changed
+111973 -17459

No files matched your search

+9
View File
@@ -19,3 +19,12 @@ java/com.sap.sailing.simulator/bin/com/sap/sailing/simulator/Simulator.gwt.xml
/mobile/com.sap.sailing.racecommittee.app/res/values/keys.xml
java/com.sap.sailing.gwt.ui/SailingGWT Remote Profiling (Run-Mode only).launch
java/com.sap.sailing.gwt.ui/SailingGWT.launch
## Android Studio and Intellij and Android in general
gen/
.idea/
*.ipr
*.iws
*.iml
out/
.gradle
+19
View File
@@ -0,0 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
allprojects {
repositories {
mavenCentral()
}
version = "1.0.0-SNAPSHOT"
}
+86 -50
View File
@@ -49,8 +49,8 @@ ARCH=x86_64
START_DIR=`pwd`
# needed for maven on sapsailing.com to work correctly
if [ -f $USER_HOME/.bash_profile ]; then
source $USER_HOME/.bash_profile
if [ -f "$USER_HOME/.bash_profile" ]; then
source "$USER_HOME/.bash_profile"
fi
cd "$PROJECT_HOME"
@@ -80,19 +80,20 @@ testing=1
clean="clean"
offline=0
proxy=0
android=1
android=0
reporting=0
suppress_confirmation=0
extra=''
parallelexecution=0
p2local=0
if [ $# -eq 0 ]; then
echo "buildAndUpdateProduct [-b -u -g -t -a -o -c -m <config> -n <package> -l <port>] [build|install|all|hot-deploy|remote-deploy|local-deploy|release]"
echo "buildAndUpdateProduct [-b -u -g -t -a -r -o -c -p -v -m <config> -n <package> -l <port>] [build|install|all|hot-deploy|remote-deploy|local-deploy|release]"
echo ""
echo "-g Disable GWT compile, no gwt files will be generated, old ones will be preserved."
echo "-b Build GWT permutation only for one browser and English language."
echo "-t Disable tests"
echo "-a Disable mobile projects (RaceCommittee App, e.g., in case no AndroidSDK is installed)"
echo "-a Enable mobile projects (RaceCommittee App, e.g., in case no AndroidSDK is installed)"
echo "-r Enable generating surefire test reports"
echo "-o Enable offline mode (does not work for tycho surefire plugin)"
echo "-c Disable cleaning (use only if you are sure that no java file has changed)"
@@ -105,6 +106,7 @@ if [ $# -eq 0 ]; then
echo "-s <target server> Name of server you want to use as target for install, hot-deploy or remote-reploy. This overrides default behaviour."
echo "-w <ssh target> Target for remote-deploy and release. Must comply with the following format: user@server."
echo "-u Run without confirmation messages. Use with extreme care."
echo "-v Build local p2 respository, and use this instead of p2.sapsailing.com"
echo ""
echo "build: builds the server code using Maven to $PROJECT_HOME (log to $START_DIR/build.log)"
echo ""
@@ -141,7 +143,7 @@ echo SERVERS_HOME is $SERVERS_HOME
echo BRANCH is $active_branch
echo VERSION is $VERSION_INFO
options=':bgtocparm:n:l:s:w:u'
options=':bgtocparvm:n:l:s:w:u'
while getopts $options option
do
case $option in
@@ -151,7 +153,7 @@ do
o) offline=1;;
c) clean="";;
p) proxy=1;;
a) android=0;;
a) android=1;;
r) reporting=1;;
m) MAVEN_SETTINGS=$OPTARG;;
n) OSGI_BUNDLE_NAME=$OPTARG;;
@@ -160,6 +162,7 @@ do
HAS_OVERWRITTEN_TARGET=1;;
w) REMOTE_SERVER_LOGIN=$OPTARG;;
u) suppress_confirmation=1;;
v) p2local=1;;
\?) echo "Invalid option"
exit 4;;
esac
@@ -268,12 +271,24 @@ if [[ "$@" == "release" ]]; then
mkdir $PROJECT_HOME/dist/$SIMPLE_VERSION_INFO
echo "MONGODB_NAME=myspecificevent
REPLICATION_CHANNEL=myspecificevent
SERVER_STARTUP_NOTIFY=simon.marcel.pamies@sap.com
SERVER_NAME=MYSPECIFICEVENT
USE_ENVIRONMENT=live-server
MEMORY=4096m
INSTALL_FROM_RELEASE=$SIMPLE_VERSION_INFO
" >> $PROJECT_HOME/dist/$SIMPLE_VERSION_INFO/amazon-launch-config.txt
echo "MONGODB_NAME=myspecificevent
REPLICATION_CHANNEL=name_of_replication_channel_matching_master_config
REPLICATE_MASTER_EXCHANGE_NAME=myspecificevent_name_used_as_channel
REPLICATE_MASTER_SERVLET_HOST=ip_of_master_host
SERVER_NAME=subdomain_name_in_elb
EVENT_ID=event_uid_this_replica_is_serving
USE_ENVIRONMENT=replica
MEMORY=4096m
REPLICATE_ON_START=com.sap.sailing.server.impl.RacingEventServiceImpl
INSTALL_FROM_RELEASE=$SIMPLE_VERSION_INFO
" >> $PROJECT_HOME/dist/$SIMPLE_VERSION_INFO/amazon-launch-config_replica.txt
`which tar` cvzf $PROJECT_HOME/dist/$SIMPLE_VERSION_INFO/$SIMPLE_VERSION_INFO.tar.gz *
cp $ACDIR/env.sh $PROJECT_HOME/dist/$SIMPLE_VERSION_INFO
cp $PROJECT_HOME/build/release-notes.txt $PROJECT_HOME/dist/$SIMPLE_VERSION_INFO
@@ -496,45 +511,6 @@ echo "Starting $@ of server..."
if [[ "$@" == "build" ]] || [[ "$@" == "all" ]]; then
# yield build so that we get updated product
cd $PROJECT_HOME/java
if [ $gwtcompile -eq 1 ]; then
echo "INFO: Compiling GWT (rm -rf com.sap.$PROJECT_TYPE.gwt.ui/com.sap.$PROJECT_TYPE.*)"
rm -rf com.sap.$PROJECT_TYPE.gwt.ui/com.sap.$PROJECT_TYPE.*
if [ $onegwtpermutationonly -eq 1 ]; then
echo "INFO: Patching .gwt.xml files such that only one GWT permutation needs to be compiled"
for i in com.sap.$PROJECT_TYPE.gwt.ui/src/main/resources/com/sap/$PROJECT_TYPE/gwt/ui/*.gwt.xml; do
echo "INFO: Patching $i files such that only one GWT permutation needs to be compiled"
cp $i $i.bak
cat $i | sed -e 's/^[ ]*<extend-property *name="locale" *values="de" *\/>/<!-- <extend-property name="locale" values="de"\/> --> <set-property name="user.agent" value="gecko1_8" \/>/' >$i.sed
mv $i.sed $i
done
else
echo "INFO: Patching .gwt.xml files such that all GWT permutations are compiled"
for i in com.sap.$PROJECT_TYPE.gwt.ui/src/main/resources/com/sap/$PROJECT_TYPE/gwt/ui/*.gwt.xml; do
echo "INFO: Patching $i files such that all GWT permutations are compiled"
cp $i $i.bak
cat $i | sed -e 's/<!-- <extend-property *name="locale" *values="de" *\/> --> <set-property name="user.agent" value="gecko1_8" \/>/<extend-property name="locale" values="de"\/>/' >$i.sed
mv $i.sed $i
done
fi
else
echo "INFO: GWT Compilation disabled"
extra="-Pdebug.no-gwt-compile"
fi
# back to root!
cd $PROJECT_HOME
if [ $testing -eq 0 ]; then
echo "INFO: Skipping tests"
extra="$extra -Dmaven.test.skip=true -DskipTests=true"
else
extra="$extra -DskipTests=false"
# TODO: Think about http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html
fi
if [ $offline -eq 1 ]; then
echo "INFO: Activating offline mode"
extra="$extra -o"
@@ -548,6 +524,61 @@ if [[ "$@" == "build" ]] || [[ "$@" == "all" ]]; then
extra="$extra -P no-debug.without-proxy"
fi
cd $PROJECT_HOME/java
if [ $gwtcompile -eq 1 ]; then
echo "INFO: Compiling GWT (rm -rf com.sap.$PROJECT_TYPE.gwt.ui/com.sap.$PROJECT_TYPE.*)"
rm -rf com.sap.$PROJECT_TYPE.gwt.ui/com.sap.$PROJECT_TYPE.*
GWT_XML_FILES=`find com.sap.$PROJECT_TYPE.gwt.ui/src/main/resources -name '*.gwt.xml'`
if [ $onegwtpermutationonly -eq 1 ]; then
echo "INFO: Patching .gwt.xml files such that only one GWT permutation needs to be compiled"
for i in $GWT_XML_FILES; do
echo "INFO: Patching $i files such that only one GWT permutation needs to be compiled"
cp $i $i.bak
cat $i | sed -e 's/^[ ]*<extend-property *name="locale" *values="de" *\/>/<!-- <extend-property name="locale" values="de"\/> --> <set-property name="user.agent" value="gecko1_8" \/>/' >$i.sed
mv $i.sed $i
done
else
echo "INFO: Patching .gwt.xml files such that all GWT permutations are compiled"
for i in $GWT_XML_FILES; do
echo "INFO: Patching $i files such that all GWT permutations are compiled"
cp $i $i.bak
cat $i | sed -e 's/<!-- <extend-property *name="locale" *values="de" *\/> --> <set-property name="user.agent" value="gecko1_8" \/>/<extend-property name="locale" values="de"\/>/' >$i.sed
mv $i.sed $i
done
fi
else
echo "INFO: GWT Compilation disabled"
extra="$extra -Pdebug.no-gwt-compile"
fi
if [ $p2local -eq 1 ]; then
echo "INFO: Building and using local p2 repo"
#build local p2 repo
echo "Using following command (pwd: java/com.sap.sailing.targetplatform.base): mvn -fae -s $MAVEN_SETTINGS $clean compile"
echo "Maven version used: `mvn --version`"
(cd com.sap.$PROJECT_TYPE.targetplatform.base; mvn -fae -s $MAVEN_SETTINGS $clean compile 2>&1 | tee $START_DIR/build.log)
# now get the exit status from mvn, and not that of tee which is what $? contains now
MVN_EXIT_CODE=${PIPESTATUS[0]}
echo "Maven exit code is $MVN_EXIT_CODE"
#create local target definition
(cd com.sap.$PROJECT_TYPE.targetplatform/scripts; ./createLocalTargetDef.sh)
extra="$extra -Dp2-local" # activates the p2-target.local profile in java/pom.xml
else
echo "INFO: Using remote p2 repo (http://p2.sapsailing.com/p2/sailing/)"
fi
# back to root!
cd $PROJECT_HOME
if [ $testing -eq 0 ]; then
echo "INFO: Skipping tests"
extra="$extra -Dmaven.test.skip=true -DskipTests=true"
else
extra="$extra -DskipTests=false"
# TODO: Think about http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html
fi
if [ $android -eq 0 ] && [ $gwtcompile -eq 0 ] && [ $testing -eq 0 ]; then
parallelexecution=1
echo "INFO: Running build in parallel with 2.5*CPU threads"
@@ -565,8 +596,13 @@ if [[ "$@" == "build" ]] || [[ "$@" == "all" ]]; then
PATH=$PATH:$ANDROID_HOME/platform-tools
RC_APP_VERSION=`grep "android:versionCode=" mobile/com.sap.$PROJECT_TYPE.racecommittee.app/AndroidManifest.xml | cut -d "\"" -f 2`
echo "RC_APPVERSION=$RC_APP_VERSION"
extra="$extra -Drc-app-api-version=$RC_APP_VERSION"
echo "RC_APP_VERSION=$RC_APP_VERSION"
extra="$extra -Drc-app-version=$RC_APP_VERSION"
TRACKING_APP_VERSION=`grep "android:versionCode=" mobile/com.sap.$PROJECT_TYPE.android.tracking.app/AndroidManifest.xml | cut -d "\"" -f 2`
echo "TRACKING_APP_VERSION=$TRACKING_APP_VERSION"
extra="$extra -Dtracking-app-version=$TRACKING_APP_VERSION"
else
echo "INFO: Deactivating mobile modules"
@@ -602,7 +638,7 @@ if [[ "$@" == "build" ]] || [[ "$@" == "all" ]]; then
if [ $gwtcompile -eq 1 ]; then
# Now move back the backup .gwt.xml files before they were (maybe) patched
echo "INFO: restoring backup copies of .gwt.xml files after they has been patched before"
for i in com.sap.$PROJECT_TYPE.gwt.ui/src/main/resources/com/sap/$PROJECT_TYPE/gwt/ui/*.gwt.xml; do
for i in $GWT_XML_FILES; do
mv -v $i.bak $i
done
fi
+16 -30
View File
@@ -19,35 +19,21 @@ start_tmux() {
}
start_servers() {
launch_httpd=false
VARS=`/opt/amazon/bin/ec2-metadata -d | sed "s/user-data\: //g" | grep -v "^not available$"`
for var in $VARS; do
echo "$var" | grep -q "^SERVER_NAME="
if [ "$?" != "0" ]; then
eval "export $var"
fi
echo "$var" | grep -q "^SERVER_PORT="
if [ "$?" != "0" ]; then
eval "export $var"
fi
echo "$var" | grep -q "^EVENT_ID="
if [ "$?" != "0" ]; then
eval "export $var"
fi
echo "$var" | grep -iq "^REPLICATE_ON_START=True"
if [ "$?" != "0" ]; then
launch_httpd=true
fi
done
if [ "$launch_httpd" = "true" ]; then
launch_httpd $SERVER_NAME $SERVER_PORT $EVENT_ID
fi
NUMBER_OF_INSTANCES=`echo "$JAVA_START_INSTANCES" | wc -w`
MEMORY_PER_INSTANCE_IN_MB=`cat /proc/meminfo | grep MemTotal | awk '{printf("%i\n", ($2 / 1024 - 1500) / '$NUMBER_OF_INSTANCES' );}'`
echo "Using ${MEMORY_PER_INSTANCE_IN_MB}MB as default heap size per instance."
for conf in $JAVA_START_INSTANCES; do
echo "Checking for amazon update..."
echo "MEMORY=\"${MEMORY_PER_INSTANCE_IN_MB}m\"" >>/home/sailing/servers/$conf/env.sh
su - sailing -c "cd /home/sailing/servers/$conf && $GIT_REPOSITORY/java/target/refreshInstance.sh auto-install" 2>/var/log/sailing.err >/var/log/sailing.out
(
# execute env.sh in a subshell which now has the same set of variables that the server will see
source /home/sailing/servers/$conf/env.sh
launch_httpd
echo "Starting Java server $conf"
su - sailing -c "cd /home/sailing/servers/$conf && ./start" 2>/var/log/sailing.err >/var/log/sailing.out
# terminating the subshell will forget all the variable assignments brought in by env.sh, clearing for the next server instance
)
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
done
@@ -64,17 +50,17 @@ stop_servers() {
# launch_httpd(server_name, port, event_id)
launch_httpd() {
echo "launch_httpd($1, $2, $2)"
if [ "$REPLICATE_ON_START" != "" ]; then
echo "REPLICATE_ON_START is $REPLICATE_ON_START. Will try to launch httpd so this replica can work with an ELB easily."
if [ -x /etc/init.d/httpd ]; then
server_name="`echo $1 | tr [A-Z] [a-z]`"
port="$2"
event_id="$3"
echo "Use Event $server_name.sapsailing.com \"$event_id\" 127.0.0.1 $port" >>/etc/httpd/conf.d/001-events.conf
echo "Launching httpd to map ${server_name}.sapsailing.com to event with ID $event_id with server running on local port $port..."
server_name="`echo $SERVER_NAME | tr [A-Z] [a-z]`"
echo "Use Event $server_name.sapsailing.com \"$EVENT_ID\" 127.0.0.1 $SERVER_PORT" >>/etc/httpd/conf.d/001-events.conf
echo "Launching httpd to map ${server_name}.sapsailing.com to event with ID $EVENT_ID with server running on local port $SERVER_PORT..."
service httpd start
else
echo Can't launch httpd; start script doesn't seem to be installed at /etc/init.d/httpd
fi
fi
}
# See how we were called.
+6 -5
View File
@@ -27,11 +27,12 @@ of java classes (from a set of jars/libs) your compiler can use to
build the sources. We have defined some target-platforms for the
project which can be found inside the project
"com.sap.sailing.targetplatform" in the folder 'definitions'. There
you will find 3 definitions: race-analysis-p2-ide-local,
race-analysis-p2-maven-local and race-analysis-p2-maven-central. The
definition 'race-analysis-p2-ide-local' is intended to be used for the
IDE whereas the other definitions are used for the local and central
maven builds. The target definition contains a list of URLs to
you will find 1 definition: race-analysis-p2-remote. This is the default
to use in your IDE and the maven build. When testing changes to the
target platform, generate the race-analysis-p2-lcoal target definition
with the java/com.sap.sailing.targetplatform/scripts/createLocalTargetDef.sh
script.
The target definition contains a list of URLs to
different p2 repositories containing the actual bundles. The URLs can
be either URLs to local or remote repositories depending on your
access to those repositories. Normally you should bind your target
+18
View File
@@ -0,0 +1,18 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
Binary file not shown.
+6
View File
@@ -0,0 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
Vendored Executable
+164
View File
@@ -0,0 +1,164 @@
#!/usr/bin/env bash
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# 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
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi
# 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\"`/" >&-
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
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" ] ; 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, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
# 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=$((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
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
Vendored
+90
View File
@@ -0,0 +1,90 @@
@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
@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=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@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 Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_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=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
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
@@ -0,0 +1,7 @@
apply plugin: "java"
sourceSets {
main {
java.srcDirs = ["src"]
}
}
@@ -11,12 +11,13 @@ Import-Package: org.json.simple,
org.json.simple.parser,
org.osgi.framework;version="1.7.0",
org.osgi.util.tracker;version="1.5.1"
Require-Bundle: com.sap.sailing.gwt.ui;bundle-version="1.0.0",
com.sap.sse.common;bundle-version="1.0.0",
com.sap.sailing.domain.shared.android;bundle-version="1.0.0",
Require-Bundle: com.sap.sailing.gwt.ui,
com.sap.sse.common,
com.sap.sailing.domain.shared.android,
com.sap.sailing.domain.tractracadapter,
com.sap.sailing.server,
com.sap.sailing.domain;bundle-version="1.0.0",
com.sap.sailing.domain,
com.sap.sailing.domain.common,
com.sap.sailing.domain.persistence
com.sap.sailing.domain.persistence,
com.sap.sse.replication
Bundle-Activator: com.sap.sailing.autoload.Activator
@@ -16,8 +16,10 @@ import org.osgi.util.tracker.ServiceTracker;
import com.sap.sailing.domain.base.Regatta;
import com.sap.sailing.domain.common.RegattaIdentifier;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sailing.domain.persistence.MongoRaceLogStoreFactory;
import com.sap.sailing.domain.persistence.MongoRegattaLogStoreFactory;
import com.sap.sailing.domain.racelog.RaceLogStore;
import com.sap.sailing.domain.regattalog.RegattaLogStore;
import com.sap.sailing.domain.tracking.RaceTracker;
import com.sap.sailing.domain.tracking.TrackerManager;
import com.sap.sailing.domain.tractracadapter.RaceRecord;
@@ -27,6 +29,7 @@ import com.sap.sailing.domain.tractracadapter.TracTracConnectionConstants;
import com.sap.sailing.gwt.ui.shared.TracTracRaceRecordDTO;
import com.sap.sailing.server.RacingEventService;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.common.impl.MillisecondsTimePoint;
/**
* Auto load TracTrac races from a parameter called <code>tractrac.autoload.json_urls</code>. This
@@ -77,17 +80,27 @@ public class TracTrac {
regattaForRaceRecord = regatta.getRegattaIdentifier();
}
}
getTracTracAdapter().addTracTracRace((TrackerManager)getService(), regattaForRaceRecord,
record.getParamURL(), /*effectiveLiveURI*/ null,
record.getStoredURI(), new URI(""),
RaceLogStore raceLogStore = MongoRaceLogStoreFactory.INSTANCE.getMongoRaceLogStore(getService()
.getMongoObjectFactory(), getService().getDomainObjectFactory());
RegattaLogStore regattaLogStore = MongoRegattaLogStoreFactory.INSTANCE.getMongoRegattaLogStore(
getService().getMongoObjectFactory(), getService().getDomainObjectFactory());
getTracTracAdapter().addTracTracRace(
(TrackerManager) getService(),
regattaForRaceRecord,
record.getParamURL(), /* effectiveLiveURI */
null,
record.getStoredURI(),
new URI(""),
new MillisecondsTimePoint(record.getTrackingStartTime().asMillis()),
new MillisecondsTimePoint(record.getTrackingEndTime().asMillis()),
MongoRaceLogStoreFactory.INSTANCE.getMongoRaceLogStore(getService().getMongoObjectFactory(), getService().getDomainObjectFactory()),
RaceTracker.TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS, /*simulateWithStartTimeNow*/false,
/*tracTracUsername*/"", /*tracTracPassword*/"",
record.getRaceStatus(), record.getRaceVisibility());
raceLogStore, regattaLogStore,
RaceTracker.TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS, /* simulateWithStartTimeNow */
false,
/* tracTracUsername */"", /* tracTracPassword */"", record.getRaceStatus(),
record.getRaceVisibility());
} else {
logger.info("Ignoring race " + record.getName() + " because it is in status " + record.getRaceStatus() + " and visibility " + record.getRaceVisibility());
logger.info("Ignoring race " + record.getName() + " because it is in status "
+ record.getRaceStatus() + " and visibility " + record.getRaceVisibility());
}
}
}
@@ -26,13 +26,13 @@ import com.sap.sailing.barbados.resultimport.impl.ScoreCorrectionProviderImpl;
import com.sap.sailing.domain.common.MaxPointsReason;
import com.sap.sailing.domain.common.RegattaScoreCorrections;
import com.sap.sailing.domain.common.RegattaScoreCorrections.ScoreCorrectionsForRace;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sailing.resultimport.RegattaResults;
import com.sap.sailing.resultimport.ResultDocumentDescriptor;
import com.sap.sailing.resultimport.ResultDocumentProvider;
import com.sap.sailing.resultimport.impl.ResultDocumentDescriptorImpl;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class BarbadosResultImportTest {
private static final MillisecondsTimePoint NOW = MillisecondsTimePoint.now();
@@ -8,12 +8,12 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import com.sap.sailing.domain.common.RegattaScoreCorrections;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.resultimport.RegattaResults;
import com.sap.sailing.resultimport.ResultDocumentDescriptor;
import com.sap.sailing.resultimport.ResultDocumentProvider;
import com.sap.sailing.resultimport.impl.AbstractDocumentBasedScoreCorrectionProvider;
import com.sap.sailing.resultimport.impl.RegattaScoreCorrectionsImpl;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
public class ScoreCorrectionProviderImpl extends AbstractDocumentBasedScoreCorrectionProvider {
@@ -35,7 +35,7 @@ public class TestSailingFunctionsRegistration {
@Before
public void setUpFunctionRegistryAndProvider() {
functionRegistry = new SimpleFunctionRegistry();
functionRegistry.registerAllWithInternalFunctionPolicy(Activator.getInternalClassesWithMarkedMethods());
functionRegistry.registerAllWithInternalFunctionPolicy(Activator.getDefault().getInternalClassesWithMarkedMethods());
}
@Test
@@ -4,5 +4,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -8,8 +8,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: com.sap.sailing.server,
org.osgi.framework;version="1.7.0"
Export-Package: com.sap.sailing.datamining,
com.sap.sailing.datamining.data,
com.sap.sailing.datamining.factories
com.sap.sailing.datamining.data
Require-Bundle: com.sap.sailing.domain;bundle-version="1.0.0",
com.sap.sailing.domain.common,
com.sap.sailing.datamining.shared;bundle-version="1.0.0",
@@ -1,4 +1,5 @@
source.. = src/
source.. = src/,\
resources/
output.. = bin/
bin.includes = META-INF/,\
.
@@ -0,0 +1,24 @@
Competitor=Teilnehmer
DistanceTraveled=zurückgelegte Distanz
Boat=Boot
Team=Team
Name=Name
NationalityAcronym=Nationalität
SailID=Segelnummer
LegNumber=Nummer des Schenkels
LegType=Art des Schenkels
Year=Jahr
Regatta=Regatta
CourseArea=Regattabahn
BoatClass=Bootsklasse
Fleet=Flotte
Race=Rennen
SailingDomainRetrieverChain=Segel-Domänen Datenbeschaffer
LeaderboardGroup=Ranglisten Gruppe
RegattaLeaderboard=Regatta Rangliste
Leg=Schenkel
LegOfCompetitor=Schenkel eines Teilnehmers
GpsFix=GPS-Fix
Speed=Geschwindigkeit
InKnots=in Knoten
WindStrength=Windstärke
@@ -0,0 +1,24 @@
Speed=Speed
InKnots=in knots
DistanceTraveled=Distance Traveled
Name=Name
LegType=Leg Type
SailID=Sail Number
Year=Year
LegNumber=Leg Number
NationalityAcronym=Nationality
Regatta=Regatta
CourseArea=Course Area
BoatClass=Boat Class
Fleet=Fleet
Race=Race
Competitor=Competitor
Boat=Boat
Team=Team
SailingDomainRetrieverChain=Sailing Domain Retriever
LeaderboardGroup=Leaderboard Group
RegattaLeaderboard=Regatta Leaderboard
Leg=Leg
LegOfCompetitor=Leg of competitor
GpsFix=GPS-Fix
WindStrength=Wind Strength
@@ -1,9 +1,8 @@
package com.sap.sailing.datamining;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -13,60 +12,48 @@ import com.sap.sailing.datamining.data.HasGPSFixContext;
import com.sap.sailing.datamining.data.HasTrackedLegContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.datamining.data.HasTrackedRaceContext;
import com.sap.sse.datamining.ClassesWithFunctionsRegistrationService;
import com.sap.sse.datamining.DataMiningBundleService;
import com.sap.sse.datamining.DataRetrieverChainDefinition;
import com.sap.sse.datamining.DataRetrieverChainDefinitionRegistrationService;
import com.sap.sse.datamining.i18n.DataMiningStringMessages;
import com.sap.sse.datamining.impl.i18n.DataMiningStringMessagesImpl;
public class Activator implements BundleActivator {
public class Activator implements BundleActivator, DataMiningBundleService {
public static final String dataRetrieverGroupName = "Sailing";
private static final Logger LOGGER = Logger.getLogger(Activator.class.getSimpleName());
private static final String STRING_MESSAGES_BASE_NAME = "stringmessages/Sailing_StringMessages";
private static BundleContext context;
private static ServiceReference<ClassesWithFunctionsRegistrationService> classesWithFunctionsRegistrationServiceReference;
private static ServiceReference<DataRetrieverChainDefinitionRegistrationService> dataRetrieverChainDefinitionRegistrationServiceServiceReference;
private static Activator INSTANCE;
private final DataMiningStringMessages sailingDataMiningStringMessages;
private final SailingDataRetrieverChainDefinitions dataRetrieverChainDefinitions;
private final SailingClusterGroups clusterGroups;
private ServiceReference<DataMiningBundleService> dataMiningBundleServiceReference;
public Activator() {
dataRetrieverChainDefinitions = new SailingDataRetrieverChainDefinitions();
sailingDataMiningStringMessages = new DataMiningStringMessagesImpl(STRING_MESSAGES_BASE_NAME, Activator.class.getClassLoader());
clusterGroups = new SailingClusterGroups();
}
@Override
public void start(BundleContext context) throws Exception {
Activator.context = context;
INSTANCE = this;
classesWithFunctionsRegistrationServiceReference = Activator.context.getServiceReference(ClassesWithFunctionsRegistrationService.class);
if (classesWithFunctionsRegistrationServiceReference != null) {
Activator.context.getService(classesWithFunctionsRegistrationServiceReference)
.registerInternalClassesWithMarkedMethods(getInternalClassesWithMarkedMethods());
Activator.context.getService(classesWithFunctionsRegistrationServiceReference)
.registerExternalLibraryClasses(getExternalLibraryClasses());
} else {
LOGGER.log(Level.WARNING, "Couldn't register the sailing classes with functions. No registration service was available.");
}
dataRetrieverChainDefinitionRegistrationServiceServiceReference = Activator.context.getServiceReference(DataRetrieverChainDefinitionRegistrationService.class);
if (dataRetrieverChainDefinitionRegistrationServiceServiceReference != null) {
for (DataRetrieverChainDefinition<?> dataRetrieverChainDefinition : SailingDataRetrieverChainDefinitions.getDataRetrieverChainDefinitions()) {
Activator.context.getService(dataRetrieverChainDefinitionRegistrationServiceServiceReference).addDataRetrieverChainDefinition(dataRetrieverChainDefinition);
}
} else {
LOGGER.log(Level.WARNING, "Couldn't register the sailing data retriever chain definitions. No registration service was available.");
}
dataMiningBundleServiceReference = context.registerService(DataMiningBundleService.class, this, null).getReference();
}
@Override
public void stop(BundleContext context) throws Exception {
if (classesWithFunctionsRegistrationServiceReference != null) {
Activator.context.getService(classesWithFunctionsRegistrationServiceReference).unregisterAllFunctionsOf(
getInternalClassesWithMarkedMethods());
Activator.context.getService(classesWithFunctionsRegistrationServiceReference).unregisterAllFunctionsOf(
getExternalLibraryClasses());
context.ungetService(dataMiningBundleServiceReference);
}
if (dataRetrieverChainDefinitionRegistrationServiceServiceReference != null) {
for (DataRetrieverChainDefinition<?> dataRetrieverChainDefinition : SailingDataRetrieverChainDefinitions.getDataRetrieverChainDefinitions()) {
Activator.context.getService(dataRetrieverChainDefinitionRegistrationServiceServiceReference).removeDataRetrieverChainDefinition(dataRetrieverChainDefinition);
}
}
@Override
public DataMiningStringMessages getStringMessages() {
return sailingDataMiningStringMessages;
}
public static Set<Class<?>> getInternalClassesWithMarkedMethods() {
@Override
public Iterable<Class<?>> getInternalClassesWithMarkedMethods() {
Set<Class<?>> internalClasses = new HashSet<>();
internalClasses.add(HasTrackedRaceContext.class);
internalClasses.add(HasTrackedLegContext.class);
@@ -75,8 +62,26 @@ public class Activator implements BundleActivator {
return internalClasses;
}
public static Set<Class<?>> getExternalLibraryClasses() {
return new HashSet<>();
@Override
public Iterable<Class<?>> getExternalLibraryClasses() {
return Collections.emptySet();
}
@Override
public Iterable<DataRetrieverChainDefinition<?, ?>> getDataRetrieverChainDefinitions() {
return dataRetrieverChainDefinitions.getDataRetrieverChainDefinitions();
}
public SailingClusterGroups getClusterGroups() {
return clusterGroups;
}
public static Activator getDefault() {
if (INSTANCE == null) {
INSTANCE = new Activator(); // probably non-OSGi case, as in test execution
}
return INSTANCE;
}
}
@@ -0,0 +1,110 @@
package com.sap.sailing.datamining;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import com.sap.sailing.domain.common.Speed;
import com.sap.sailing.domain.common.impl.KnotSpeedImpl;
import com.sap.sse.datamining.data.Cluster;
import com.sap.sse.datamining.data.ClusterBoundary;
import com.sap.sse.datamining.data.ClusterGroup;
import com.sap.sse.datamining.impl.data.ClusterWithLowerAndUpperBoundaries;
import com.sap.sse.datamining.impl.data.ClusterWithSingleBoundary;
import com.sap.sse.datamining.impl.data.ComparableComparator;
import com.sap.sse.datamining.impl.data.ComparatorClusterBoundary;
import com.sap.sse.datamining.impl.data.ComparisonStrategy;
import com.sap.sse.datamining.impl.data.FixClusterGroup;
public class SailingClusterGroups {
private final ClusterGroup<Speed> windStrengthInBeaufortCluster;
public SailingClusterGroups() {
Collection<Cluster<Speed>> clusters = new ArrayList<>();
Comparator<Speed> comparableComparator = new ComparableComparator<Speed>();
Speed lowerBoundWindSpeed = new KnotSpeedImpl(0.0);
ClusterBoundary<Speed> lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
Speed upperBoundWindSpeed = new KnotSpeedImpl(1.0);
ClusterBoundary<Speed> upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Calm", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(1.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(4.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Light air", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(4.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(7.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Light breeze", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(7.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(11.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Gentle breeze", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(11.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(16.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Moderate breeze", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(16.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(22.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Fresh breeze", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(22.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(28.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Strong breeze", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(28.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(34.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("High wind", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(34.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(41.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Gale", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(41.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(48.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Strong gale", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(48.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(56.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Storm", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(56.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
upperBoundWindSpeed = new KnotSpeedImpl(64.0);
upperBound = new ComparatorClusterBoundary<Speed>(comparableComparator, upperBoundWindSpeed, ComparisonStrategy.LOWER_THAN);
clusters.add(new ClusterWithLowerAndUpperBoundaries<Speed>("Violent Storm", lowerBound, upperBound));
lowerBoundWindSpeed = new KnotSpeedImpl(64.0);
lowerBound = new ComparatorClusterBoundary<Speed>(comparableComparator, lowerBoundWindSpeed, ComparisonStrategy.GREATER_EQUALS_THAN);
clusters.add(new ClusterWithSingleBoundary<Speed>("Hurricane", lowerBound));
windStrengthInBeaufortCluster = new FixClusterGroup<Speed>("Wind Strength", clusters);
}
public ClusterGroup<Speed> getWindStrengthInBeaufortCluster() {
return windStrengthInBeaufortCluster;
}
}
@@ -22,41 +22,44 @@ import com.sap.sse.datamining.impl.SimpleDataRetrieverChainDefinition;
public class SailingDataRetrieverChainDefinitions {
private static Collection<DataRetrieverChainDefinition<?>> dataRetrieverChainDefinitions;
private final Collection<DataRetrieverChainDefinition<?, ?>> dataRetrieverChainDefinitions;
public static Collection<DataRetrieverChainDefinition<?>> getDataRetrieverChainDefinitions() {
if (dataRetrieverChainDefinitions == null) {
initializeDataRetrieverChainDefinitions();
}
return dataRetrieverChainDefinitions;
}
private static void initializeDataRetrieverChainDefinitions() {
public SailingDataRetrieverChainDefinitions() {
dataRetrieverChainDefinitions = new ArrayList<>();
DataRetrieverChainDefinition<RacingEventService> legRetrieverChainDefinition = new SimpleDataRetrieverChainDefinition<>(RacingEventService.class, "SailingDomainRetrieverChain");
DataRetrieverChainDefinition<RacingEventService, HasTrackedLegOfCompetitorContext> legOfCompetitorRetrieverChainDefinition = new SimpleDataRetrieverChainDefinition<>(
RacingEventService.class, HasTrackedLegOfCompetitorContext.class, "SailingDomainRetrieverChain");
@SuppressWarnings("unchecked")
Class<Processor<RacingEventService, LeaderboardGroup>> leaderboardGroupRetrieverType = (Class<Processor<RacingEventService, LeaderboardGroup>>)(Class<?>) LeaderboardGroupRetrievalProcessor.class;
legRetrieverChainDefinition.startWith(leaderboardGroupRetrieverType, LeaderboardGroup.class);
Class<Processor<RacingEventService, LeaderboardGroup>> leaderboardGroupRetrieverType = (Class<Processor<RacingEventService, LeaderboardGroup>>) (Class<?>) LeaderboardGroupRetrievalProcessor.class;
legOfCompetitorRetrieverChainDefinition.startWith(leaderboardGroupRetrieverType, LeaderboardGroup.class, "LeaderboardGroup");
@SuppressWarnings("unchecked")
Class<Processor<LeaderboardGroup, RegattaLeaderboard>> regattaLeaderboardRetrieverType = (Class<Processor<LeaderboardGroup, RegattaLeaderboard>>)(Class<?>) RegattaLeaderboardFilteringRetrievalProcessor.class;
legRetrieverChainDefinition.addAsLast(leaderboardGroupRetrieverType, regattaLeaderboardRetrieverType, RegattaLeaderboard.class);
Class<Processor<LeaderboardGroup, RegattaLeaderboard>> regattaLeaderboardRetrieverType = (Class<Processor<LeaderboardGroup, RegattaLeaderboard>>) (Class<?>) RegattaLeaderboardFilteringRetrievalProcessor.class;
legOfCompetitorRetrieverChainDefinition.addAfter(leaderboardGroupRetrieverType, regattaLeaderboardRetrieverType,
RegattaLeaderboard.class, "RegattaLeaderboard");
@SuppressWarnings("unchecked")
Class<Processor<RegattaLeaderboard, HasTrackedRaceContext>> raceRetrieverType = (Class<Processor<RegattaLeaderboard, HasTrackedRaceContext>>)(Class<?>) TrackedRaceFilteringRetrievalProcessor.class;
legRetrieverChainDefinition.addAsLast(regattaLeaderboardRetrieverType, raceRetrieverType, HasTrackedRaceContext.class);
Class<Processor<RegattaLeaderboard, HasTrackedRaceContext>> raceRetrieverType = (Class<Processor<RegattaLeaderboard, HasTrackedRaceContext>>) (Class<?>) TrackedRaceFilteringRetrievalProcessor.class;
legOfCompetitorRetrieverChainDefinition.addAfter(regattaLeaderboardRetrieverType, raceRetrieverType,
HasTrackedRaceContext.class, "Race");
@SuppressWarnings("unchecked")
Class<Processor<HasTrackedRaceContext, HasTrackedLegContext>> legRetrieverType = (Class<Processor<HasTrackedRaceContext, HasTrackedLegContext>>)(Class<?>) TrackedLegFilteringRetrievalProcessor.class;
legRetrieverChainDefinition.addAsLast(raceRetrieverType, legRetrieverType, HasTrackedLegContext.class);
Class<Processor<HasTrackedRaceContext, HasTrackedLegContext>> legRetrieverType = (Class<Processor<HasTrackedRaceContext, HasTrackedLegContext>>) (Class<?>) TrackedLegFilteringRetrievalProcessor.class;
legOfCompetitorRetrieverChainDefinition.addAfter(raceRetrieverType, legRetrieverType, HasTrackedLegContext.class, "Leg");
@SuppressWarnings("unchecked")
Class<Processor<HasTrackedLegContext, HasTrackedLegOfCompetitorContext>> legOfCompetitorRetrieverType = (Class<Processor<HasTrackedLegContext, HasTrackedLegOfCompetitorContext>>)(Class<?>) TrackedLegOfCompetitorFilteringRetrievalProcessor.class;
legRetrieverChainDefinition.addAsLast(legRetrieverType, legOfCompetitorRetrieverType, HasTrackedLegOfCompetitorContext.class);
dataRetrieverChainDefinitions.add(legRetrieverChainDefinition);
Class<Processor<HasTrackedLegContext, HasTrackedLegOfCompetitorContext>> legOfCompetitorRetrieverType = (Class<Processor<HasTrackedLegContext, HasTrackedLegOfCompetitorContext>>) (Class<?>) TrackedLegOfCompetitorFilteringRetrievalProcessor.class;
legOfCompetitorRetrieverChainDefinition.endWith(legRetrieverType, legOfCompetitorRetrieverType,
HasTrackedLegOfCompetitorContext.class, "LegOfCompetitor");
dataRetrieverChainDefinitions.add(legOfCompetitorRetrieverChainDefinition);
DataRetrieverChainDefinition<RacingEventService> gpsFixRetrieverChainDefinition = new SimpleDataRetrieverChainDefinition<>(legRetrieverChainDefinition, "SailingDomainRetrieverChain");
DataRetrieverChainDefinition<RacingEventService, HasGPSFixContext> gpsFixRetrieverChainDefinition = new SimpleDataRetrieverChainDefinition<>(
legOfCompetitorRetrieverChainDefinition, HasGPSFixContext.class, "SailingDomainRetrieverChain");
@SuppressWarnings("unchecked")
Class<Processor<HasTrackedLegOfCompetitorContext, HasGPSFixContext>> gpsFixRetrieverType = (Class<Processor<HasTrackedLegOfCompetitorContext, HasGPSFixContext>>)(Class<?>) GPSFixRetrievalProcessor.class;
gpsFixRetrieverChainDefinition.addAsLast(legOfCompetitorRetrieverType, gpsFixRetrieverType, HasGPSFixContext.class);
Class<Processor<HasTrackedLegOfCompetitorContext, HasGPSFixContext>> gpsFixRetrieverType = (Class<Processor<HasTrackedLegOfCompetitorContext, HasGPSFixContext>>) (Class<?>) GPSFixRetrievalProcessor.class;
gpsFixRetrieverChainDefinition.endWith(legOfCompetitorRetrieverType, gpsFixRetrieverType,
HasGPSFixContext.class, "GpsFix");
dataRetrieverChainDefinitions.add(gpsFixRetrieverChainDefinition);
}
public Collection<DataRetrieverChainDefinition<?, ?>> getDataRetrieverChainDefinitions() {
return dataRetrieverChainDefinitions;
}
}
@@ -2,6 +2,8 @@ package com.sap.sailing.datamining.data;
import com.sap.sailing.domain.tracking.GPSFixMoving;
import com.sap.sse.datamining.shared.annotations.Connector;
import com.sap.sse.datamining.shared.annotations.Dimension;
import com.sap.sse.datamining.shared.impl.dto.ClusterDTO;
public interface HasGPSFixContext {
@@ -11,4 +13,7 @@ public interface HasGPSFixContext {
@Connector
public GPSFixMoving getGPSFix();
@Dimension(messageKey="WindStrength", ordinal=10)
public ClusterDTO getWindStrength();
}
@@ -1,161 +0,0 @@
package com.sap.sailing.datamining.factories;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.sap.sailing.server.RacingEventService;
import com.sap.sse.datamining.DataRetrieverChainBuilder;
import com.sap.sse.datamining.DataRetrieverChainDefinition;
import com.sap.sse.datamining.Query;
import com.sap.sse.datamining.components.FilterCriterion;
import com.sap.sse.datamining.components.Processor;
import com.sap.sse.datamining.factories.ProcessorFactory;
import com.sap.sse.datamining.functions.Function;
import com.sap.sse.datamining.functions.FunctionProvider;
import com.sap.sse.datamining.i18n.DataMiningStringMessages;
import com.sap.sse.datamining.impl.DataMiningActivator;
import com.sap.sse.datamining.impl.DataRetrieverChainDefinitionRegistry;
import com.sap.sse.datamining.impl.ProcessorQuery;
import com.sap.sse.datamining.impl.components.GroupedDataEntry;
import com.sap.sse.datamining.impl.criterias.AndCompoundFilterCriterion;
import com.sap.sse.datamining.impl.criterias.CompoundFilterCriterion;
import com.sap.sse.datamining.impl.criterias.NullaryFunctionValuesFilterCriterion;
import com.sap.sse.datamining.shared.GroupKey;
import com.sap.sse.datamining.shared.QueryDefinition;
import com.sap.sse.datamining.shared.dto.FunctionDTO;
import com.sap.sse.datamining.shared.impl.dto.DataRetrieverChainDefinitionDTO;
public class SailingDataMiningFactory {
private final ProcessorFactory processorFactory;
private final FunctionProvider functionProvider;
private final DataRetrieverChainDefinitionRegistry dataRetrieverChainDefinitionRegistry;
public SailingDataMiningFactory(FunctionProvider functionProvider, DataRetrieverChainDefinitionRegistry dataRetrieverChainDefinitionRegistry) {
processorFactory = new ProcessorFactory(DataMiningActivator.getExecutor());
this.functionProvider = functionProvider;
this.dataRetrieverChainDefinitionRegistry = dataRetrieverChainDefinitionRegistry;
}
public <ElementType> Query<Double> createQuery(RacingEventService dataSource, final QueryDefinition queryDefinition) {
return new ProcessorQuery<Double, RacingEventService>(DataMiningActivator.getExecutor(), dataSource,
DataMiningActivator.getStringMessages(), DataMiningStringMessages.Util.getLocaleFor(queryDefinition.getLocaleInfoName())) {
@Override
protected Processor<RacingEventService, ?> createFirstProcessor() {
@SuppressWarnings("unchecked") // TODO Clean, after the deprecated components have been removed
Function<Double> extractionFunction = (Function<Double>) functionProvider.getFunctionForDTO(queryDefinition.getStatisticToCalculate());
@SuppressWarnings("unchecked")
Class<ElementType> dataTypeToRetrieve = (Class<ElementType>) extractionFunction.getDeclaringType();
Processor<GroupedDataEntry<Double>, Map<GroupKey, Double>> aggregationProcessor = processorFactory.createAggregationProcessor(/*query*/ this, queryDefinition.getAggregatorType());
Processor<GroupedDataEntry<ElementType>, GroupedDataEntry<Double>> extractionProcessor = processorFactory.createExtractionProcessor(aggregationProcessor, extractionFunction);
List<Function<?>> dimensionsToGroupBy = convertDTOsToFunctions(queryDefinition.getDimensionsToGroupBy());
Processor<ElementType, GroupedDataEntry<ElementType>> groupingProcessor = processorFactory.createGroupingProcessor(dataTypeToRetrieve, extractionProcessor, dimensionsToGroupBy);
DataRetrieverChainDefinition<RacingEventService> dataRetrieverChainDefinition = dataRetrieverChainDefinitionRegistry.getDataRetrieverChainDefinition(RacingEventService.class, queryDefinition.getDataRetrieverChainDefinition().getId());
DataRetrieverChainBuilder<RacingEventService> chainBuilder = dataRetrieverChainDefinition.startBuilding(DataMiningActivator.getExecutor());
Map<Class<?>, FilterCriterion<?>> criteriaMappedByDataType = createFilterCriteria(queryDefinition.getFilterSelection());
do {
if (criteriaMappedByDataType.containsKey(chainBuilder.getCurrentRetrievedDataType())) {
chainBuilder.setFilter(criteriaMappedByDataType.get(chainBuilder.getCurrentRetrievedDataType()));
}
chainBuilder.stepDeeper();
} while (!dataTypeToRetrieve.equals(chainBuilder.getCurrentRetrievedDataType()));
if (criteriaMappedByDataType.containsKey(chainBuilder.getCurrentRetrievedDataType())) {
chainBuilder.setFilter(criteriaMappedByDataType.get(chainBuilder.getCurrentRetrievedDataType()));
}
chainBuilder.addResultReceiver(groupingProcessor);
return chainBuilder.build();
}
};
}
private List<Function<?>> convertDTOsToFunctions(Collection<FunctionDTO> functionDTOs) {
List<Function<?>> dimensionsToGroupBy = new ArrayList<>();
for (FunctionDTO functionDTO : functionDTOs) {
dimensionsToGroupBy.add(functionProvider.getFunctionForDTO(functionDTO));
}
return dimensionsToGroupBy;
}
@SuppressWarnings("unchecked")
private <T> Map<Class<?>, FilterCriterion<?>> createFilterCriteria(Map<FunctionDTO, Iterable<? extends Serializable>> filterSelection) {
Map<Class<?>, CompoundFilterCriterion<?>> criteriaMappedByDataType = new HashMap<>();
for (Entry<FunctionDTO, Iterable<? extends Serializable>> filterSelectionEntry : filterSelection.entrySet()) {
Function<?> function = functionProvider.getFunctionForDTO(filterSelectionEntry.getKey());
Class<T> dataType = (Class<T>) function.getDeclaringType();
if (!criteriaMappedByDataType.containsKey(dataType)) {
criteriaMappedByDataType.put(dataType, new AndCompoundFilterCriterion<>(dataType));
}
Collection<Object> filterValues = new ArrayList<>();
for (Object filterValue : filterSelectionEntry.getValue()) {
filterValues.add(filterValue);
}
((CompoundFilterCriterion<T>) criteriaMappedByDataType.get(dataType)).addCriteria(new NullaryFunctionValuesFilterCriterion<>(dataType, function, filterValues));
}
return (Map<Class<?>, FilterCriterion<?>>)(Map<Class<?>, ?>) criteriaMappedByDataType;
}
public Query<Set<Object>> createDimensionValuesQuery(RacingEventService dataSource, final DataRetrieverChainDefinitionDTO dataRetrieverChainDefinitionDTO, final String localeInfoName) {
final DataMiningStringMessages stringMessages = DataMiningActivator.getStringMessages();
final Locale locale = DataMiningStringMessages.Util.getLocaleFor(localeInfoName);
return new ProcessorQuery<Set<Object>, RacingEventService>(DataMiningActivator.getExecutor(), dataSource, stringMessages, locale) {
@Override
protected Processor<RacingEventService, ?> createFirstProcessor() {
Processor<GroupedDataEntry<Object>, Map<GroupKey, Set<Object>>> valueCollector = processorFactory.createGroupedDataCollectingAsSetProcessor(/*query*/ this);
DataRetrieverChainDefinition<RacingEventService> dataRetrieverChainDefinition = dataRetrieverChainDefinitionRegistry.getDataRetrieverChainDefinition(RacingEventService.class, dataRetrieverChainDefinitionDTO.getId());
DataRetrieverChainBuilder<RacingEventService> chainBuilder = dataRetrieverChainDefinition.startBuilding(DataMiningActivator.getExecutor());
Collection<Function<?>> dimensions = functionProvider.getMinimizedDimensionsFor(dataRetrieverChainDefinition);
Map<Class<?>, Collection<Function<?>>> dimensionsMappedByDeclaringType = mapFunctionsByDeclaringType(dimensions);
while (!dimensionsMappedByDeclaringType.isEmpty()) {
Class<?> dataType = chainBuilder.getCurrentRetrievedDataType();
if (dimensionsMappedByDeclaringType.containsKey(dataType)) {
for (Processor<?, ?> resultReceiver : processorFactory.createGroupingExtractorsForDimensions(
dataType, valueCollector, dimensionsMappedByDeclaringType.get(dataType),
stringMessages, locale)) {
chainBuilder.addResultReceiver(resultReceiver);
}
dimensionsMappedByDeclaringType.remove(dataType);
}
if (!dimensionsMappedByDeclaringType.isEmpty()) {
chainBuilder.stepDeeper();
}
}
return chainBuilder.build();
}
};
}
private Map<Class<?>, Collection<Function<?>>> mapFunctionsByDeclaringType(Collection<Function<?>> functions) {
Map<Class<?>, Collection<Function<?>>> mappedFunctions = new HashMap<>();
for (Function<?> function : functions) {
Class<?> declaringType = function.getDeclaringType();
if (!mappedFunctions.containsKey(declaringType)) {
mappedFunctions.put(declaringType, new HashSet<Function<?>>());
}
mappedFunctions.get(declaringType).add(function);
}
return mappedFunctions;
}
}
@@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.ExecutorService;
import com.sap.sailing.datamining.Activator;
import com.sap.sailing.datamining.data.HasGPSFixContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.datamining.impl.data.GPSFixWithContext;
@@ -14,11 +13,7 @@ import com.sap.sailing.domain.tracking.GPSFixTrack;
import com.sap.sailing.domain.tracking.TrackedLegOfCompetitor;
import com.sap.sse.datamining.components.Processor;
import com.sap.sse.datamining.impl.components.AbstractSimpleRetrievalProcessor;
import com.sap.sse.datamining.shared.annotations.DataRetriever;
@DataRetriever(dataType=HasGPSFixContext.class,
groupName=Activator.dataRetrieverGroupName,
level=5)
public class GPSFixRetrievalProcessor extends AbstractSimpleRetrievalProcessor<HasTrackedLegOfCompetitorContext, HasGPSFixContext> {
public GPSFixRetrievalProcessor(ExecutorService executor, Collection<Processor<HasGPSFixContext, ?>> resultReceivers) {
@@ -3,16 +3,11 @@ package com.sap.sailing.datamining.impl.components;
import java.util.Collection;
import java.util.concurrent.ExecutorService;
import com.sap.sailing.datamining.Activator;
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
import com.sap.sailing.server.RacingEventService;
import com.sap.sse.datamining.components.Processor;
import com.sap.sse.datamining.impl.components.AbstractSimpleRetrievalProcessor;
import com.sap.sse.datamining.shared.annotations.DataRetriever;
@DataRetriever(dataType=LeaderboardGroup.class,
groupName=Activator.dataRetrieverGroupName,
level=0)
public class LeaderboardGroupRetrievalProcessor extends
AbstractSimpleRetrievalProcessor<RacingEventService, LeaderboardGroup> {
@@ -4,17 +4,12 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.ExecutorService;
import com.sap.sailing.datamining.Activator;
import com.sap.sailing.domain.leaderboard.Leaderboard;
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
import com.sap.sailing.domain.leaderboard.RegattaLeaderboard;
import com.sap.sse.datamining.components.Processor;
import com.sap.sse.datamining.impl.components.AbstractSimpleRetrievalProcessor;
import com.sap.sse.datamining.shared.annotations.DataRetriever;
@DataRetriever(dataType=RegattaLeaderboard.class,
groupName=Activator.dataRetrieverGroupName,
level=1)
public class RegattaLeaderboardFilteringRetrievalProcessor extends
AbstractSimpleRetrievalProcessor<LeaderboardGroup, RegattaLeaderboard> {
@@ -4,18 +4,13 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.ExecutorService;
import com.sap.sailing.datamining.Activator;
import com.sap.sailing.datamining.data.HasTrackedLegContext;
import com.sap.sailing.datamining.data.HasTrackedRaceContext;
import com.sap.sailing.datamining.impl.data.TrackedLegWithContext;
import com.sap.sailing.domain.tracking.TrackedLeg;
import com.sap.sse.datamining.components.Processor;
import com.sap.sse.datamining.impl.components.AbstractSimpleRetrievalProcessor;
import com.sap.sse.datamining.shared.annotations.DataRetriever;
@DataRetriever(dataType=HasTrackedLegContext.class,
groupName=Activator.dataRetrieverGroupName,
level=3)
public class TrackedLegFilteringRetrievalProcessor extends
AbstractSimpleRetrievalProcessor<HasTrackedRaceContext, HasTrackedLegContext> {
@@ -4,18 +4,13 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.ExecutorService;
import com.sap.sailing.datamining.Activator;
import com.sap.sailing.datamining.data.HasTrackedLegContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.datamining.impl.data.TrackedLegOfCompetitorWithContext;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sse.datamining.components.Processor;
import com.sap.sse.datamining.impl.components.AbstractSimpleRetrievalProcessor;
import com.sap.sse.datamining.shared.annotations.DataRetriever;
@DataRetriever(dataType=HasTrackedLegOfCompetitorContext.class,
groupName=Activator.dataRetrieverGroupName,
level=4)
public class TrackedLegOfCompetitorFilteringRetrievalProcessor extends
AbstractSimpleRetrievalProcessor<HasTrackedLegContext, HasTrackedLegOfCompetitorContext> {
@@ -13,11 +13,7 @@ import com.sap.sailing.domain.leaderboard.Leaderboard;
import com.sap.sailing.domain.tracking.TrackedRace;
import com.sap.sse.datamining.components.Processor;
import com.sap.sse.datamining.impl.components.AbstractSimpleRetrievalProcessor;
import com.sap.sse.datamining.shared.annotations.DataRetriever;
@DataRetriever(dataType=HasTrackedRaceContext.class,
groupName="Sailing",
level=2)
public class TrackedRaceFilteringRetrievalProcessor extends
AbstractSimpleRetrievalProcessor<Leaderboard, HasTrackedRaceContext> {
@@ -1,14 +1,19 @@
package com.sap.sailing.datamining.impl.data;
import com.sap.sailing.datamining.Activator;
import com.sap.sailing.datamining.data.HasGPSFixContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.domain.tracking.GPSFixMoving;
import com.sap.sailing.domain.tracking.Wind;
import com.sap.sse.datamining.data.Cluster;
import com.sap.sse.datamining.shared.impl.dto.ClusterDTO;
public class GPSFixWithContext implements HasGPSFixContext {
private final HasTrackedLegOfCompetitorContext trackedLegOfCompetitorContext;
private final GPSFixMoving gpsFix;
private Wind wind;
public GPSFixWithContext(HasTrackedLegOfCompetitorContext trackedLegOfCompetitorContext, GPSFixMoving gpsFix) {
this.trackedLegOfCompetitorContext = trackedLegOfCompetitorContext;
@@ -25,4 +30,19 @@ public class GPSFixWithContext implements HasGPSFixContext {
return gpsFix;
}
@Override
public ClusterDTO getWindStrength() {
Wind wind = getWind();
Cluster<?> cluster = Activator.getDefault().getClusterGroups().getWindStrengthInBeaufortCluster().getClusterFor(wind);
return new ClusterDTO(cluster.toString());
}
private Wind getWind() {
if (wind == null) {
wind = getTrackedLegOfCompetitorContext().getTrackedLegContext().getTrackedRaceContext().getTrackedRace()
.getWind(gpsFix.getPosition(), gpsFix.getTimePoint());
}
return wind;
}
}
@@ -3,8 +3,8 @@ package com.sap.sailing.datamining.impl.data;
import com.sap.sailing.datamining.data.HasTrackedLegContext;
import com.sap.sailing.datamining.data.HasTrackedLegOfCompetitorContext;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.tracking.TrackedLegOfCompetitor;
import com.sap.sse.common.TimePoint;
public class TrackedLegOfCompetitorWithContext implements HasTrackedLegOfCompetitorContext {
@@ -4,10 +4,10 @@ import com.sap.sailing.datamining.data.HasTrackedLegContext;
import com.sap.sailing.datamining.data.HasTrackedRaceContext;
import com.sap.sailing.domain.common.LegType;
import com.sap.sailing.domain.common.NoWindException;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sailing.domain.tracking.TrackedLeg;
import com.sap.sailing.domain.tracking.TrackedLegOfCompetitor;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class TrackedLegWithContext implements HasTrackedLegContext {
@@ -8,8 +8,8 @@ import com.sap.sailing.domain.base.CourseArea;
import com.sap.sailing.domain.base.Fleet;
import com.sap.sailing.domain.base.RaceDefinition;
import com.sap.sailing.domain.base.Regatta;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.tracking.TrackedRace;
import com.sap.sse.common.TimePoint;
public class TrackedRaceWithContext implements HasTrackedRaceContext {
@@ -15,7 +15,7 @@ import org.xml.sax.SAXException;
import com.sap.sailing.declination.Declination;
import com.sap.sailing.domain.common.impl.DegreePosition;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class DeclinationImportTest extends AbstractDeclinationTest {
@Test
@@ -39,25 +39,25 @@ public class DeclinationImportTest extends AbstractDeclinationTest {
@Test
public void importSimpleDeclination() throws IOException, ParseException, ParserConfigurationException, SAXException {
Declination record = importer.importRecord(new DegreePosition(53, 3),
new MillisecondsTimePoint(simpleDateFormat.parse("1920-05-27").getTime()));
assertEquals(-12.68941, record.getBearing().getDegrees(), 0.0001);
assertEquals(0.1863178, record.getAnnualChange().getDegrees(), 0.0001);
new MillisecondsTimePoint(simpleDateFormat.parse("2016-05-27").getTime()));
assertEquals(0.26307, record.getBearing().getDegrees(), 0.0001);
assertEquals(0.14795, record.getAnnualChange().getDegrees(), 0.0001);
}
@Test
public void importSouthernHemisphereDeclination() throws IOException, ParseException, ParserConfigurationException, SAXException {
long start = System.currentTimeMillis();
Declination record = importer.importRecord(new DegreePosition(-10, 3),
new MillisecondsTimePoint(simpleDateFormat.parse("2011-05-27").getTime()));
new MillisecondsTimePoint(simpleDateFormat.parse("2017-05-27").getTime()));
System.out.println("took "+(System.currentTimeMillis()-start)+"ms");
assertEquals(-9.54538, record.getBearing().getDegrees(), 0.0001);
assertEquals(0.17543, record.getAnnualChange().getDegrees(), 0.0001);
assertEquals(-8.44581, record.getBearing().getDegrees(), 0.0001);
assertEquals(0.17712, record.getAnnualChange().getDegrees(), 0.0001);
}
@Test
public void readOnlineOrFromFile() throws IOException, ClassNotFoundException, ParseException {
Declination declination = importer.getDeclination(new DegreePosition(53, 3),
new MillisecondsTimePoint(simpleDateFormat.parse("2011-05-27").getTime()),
new MillisecondsTimePoint(simpleDateFormat.parse("2018-05-27").getTime()),
/* timeoutForOnlineFetchInMilliseconds */ 10000);
assertNotNull(declination);
System.out.println(declination);
@@ -15,7 +15,7 @@ import com.sap.sailing.declination.DeclinationService;
import com.sap.sailing.declination.impl.DeclinationServiceImpl;
import com.sap.sailing.domain.common.impl.CentralAngleDistance;
import com.sap.sailing.domain.common.impl.DegreePosition;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class DeclinationServiceTest extends AbstractDeclinationTest {
private DeclinationService service;
@@ -35,11 +35,11 @@ public class DeclinationServiceTest extends AbstractDeclinationTest {
@Test
public void testDeclinationQueryNotMatchedInStore() throws IOException, ClassNotFoundException, ParseException {
Declination result = service.getDeclination(new MillisecondsTimePoint(simpleDateFormat.parse("2010-02-03").getTime()),
Declination result = service.getDeclination(new MillisecondsTimePoint(simpleDateFormat.parse("2016-02-03").getTime()),
new DegreePosition(51, -5), /* timeoutForOnlineFetchInMilliseconds */ 30000);
assertNotNull(result);
assertEquals(-3.45941, result.getBearing().getDegrees(), 0.0001);
assertEquals(0.1553643, result.getAnnualChange().getDegrees(), 0.0001);
assertEquals(-2.41498, result.getBearing().getDegrees(), 0.0001);
assertEquals(0.15318, result.getAnnualChange().getDegrees(), 0.0001);
}
@Test
@@ -32,11 +32,11 @@ import com.sap.sailing.declination.impl.DeclinationRecordImpl;
import com.sap.sailing.declination.impl.DeclinationStore;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
import com.sap.sailing.domain.common.impl.DegreePosition;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sailing.domain.common.quadtree.QuadTree;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class DeclinationStoreTest extends AbstractDeclinationTest {
private DeclinationStore store;
@@ -12,32 +12,32 @@ import org.xml.sax.SAXException;
import com.sap.sailing.declination.Declination;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.DegreePosition;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class SimpleDeclinationTest extends AbstractDeclinationTest {
@Test
public void testSimpleCorrection() throws IOException, ParseException, ParserConfigurationException, SAXException {
Declination record = importer.importRecord(new DegreePosition(53, 3),
new MillisecondsTimePoint(simpleDateFormat.parse("1920-05-27").getTime()));
assertEquals(-12.68941, record.getBearing().getDegrees(), 0.0001);
assertEquals(0.1863178, record.getAnnualChange().getDegrees(), 0.0001);
TimePoint oneYearLater = new MillisecondsTimePoint(simpleDateFormat.parse("1921-05-27").getTime());
final MillisecondsTimePoint timePoint = new MillisecondsTimePoint(simpleDateFormat.parse("2019-05-27").getTime());
Declination record = importer.importRecord(new DegreePosition(53, 3), timePoint);
assertEquals(0.70594, record.getBearing().getDegrees(), 0.0001);
assertEquals(0.14745, record.getAnnualChange().getDegrees(), 0.0001);
TimePoint oneYearLater = timePoint.plus(Duration.ONE_YEAR);
Bearing bearing = record.getBearingCorrectedTo(oneYearLater);
assertEquals(-12.68941+0.1863178, bearing.getDegrees(), 0.0001);
assertEquals(0.70594+0.14745, bearing.getDegrees(), 0.0001);
}
@Test
public void testBackwardCorrection() throws IOException, ParseException, ParserConfigurationException, SAXException {
Declination record = importer.importRecord(new DegreePosition(53, 3),
new MillisecondsTimePoint(simpleDateFormat.parse("1920-05-27").getTime()));
assertEquals(-12.68941, record.getBearing().getDegrees(), 0.0001);
assertEquals(0.1863178, record.getAnnualChange().getDegrees(), 0.0001);
// 1920 is a leap year, so add one day, otherwise it wouldn't match the 365 day assumption
TimePoint oneYearEarlier = new MillisecondsTimePoint(simpleDateFormat.parse("1919-05-28").getTime());
final MillisecondsTimePoint timePoint = new MillisecondsTimePoint(simpleDateFormat.parse("2019-05-27").getTime());
Declination record = importer.importRecord(new DegreePosition(53, 3), timePoint);
assertEquals(0.70594, record.getBearing().getDegrees(), 0.0001);
assertEquals(0.14745, record.getAnnualChange().getDegrees(), 0.0001);
TimePoint oneYearEarlier = timePoint.minus(Duration.ONE_YEAR);
Bearing bearing = record.getBearingCorrectedTo(oneYearEarlier);
assertEquals(-12.68941-0.1863178, bearing.getDegrees(), 0.0001);
assertEquals(0.70594-0.14745, bearing.getDegrees(), 0.0001);
}
}
@@ -7,7 +7,8 @@ Bundle-Vendor: SAP
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Require-Bundle: com.sap.sailing.domain,
com.sap.sailing.domain.common
com.sap.sailing.domain.common,
com.sap.sse.common
Export-Package: com.sap.sailing.declination
Import-Package: com.sap.sailing.domain.common,
com.sap.sailing.domain.common.impl,
@@ -7,7 +7,7 @@
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.sap.sailing.declination.impl.DeclinationStore"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="2014 2014 1"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="2015 2015 1"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.sap.sailing.declination"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dhttp.proxyHost=proxy.wdf.sap.corp -Dhttp.proxyPort=8080"/>
</launchConfiguration>
@@ -0,0 +1,2 @@
#!/bin/sh
java -cp bin:../com.sap.sailing.domain.common/bin/:../com.sap.sse.common/bin/:../com.sap.sailing.domain/bin/:../com.sap.sailing.domain.shared.android/bin/ com.sap.sailing.declination.impl.DeclinationStore 2015 2015 1
File diff suppressed because it is too large. Load diff
@@ -3,7 +3,7 @@ package com.sap.sailing.declination;
import com.sap.sailing.domain.base.Timed;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sse.common.TimePoint;
/**
* Tells the magnetic declination for a position and a given point in time together with an anticipated annual change.
@@ -8,8 +8,8 @@ import com.sap.sailing.declination.impl.NOAAImporter;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.Mile;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.CentralAngleDistance;
import com.sap.sse.common.TimePoint;
public interface DeclinationService {
/**
@@ -3,8 +3,8 @@ package com.sap.sailing.declination.impl;
import com.sap.sailing.declination.Declination;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
import com.sap.sse.common.TimePoint;
public class DeclinationRecordImpl implements Declination {
private static final long serialVersionUID = 6918630656182340186L;
@@ -11,8 +11,8 @@ import com.sap.sailing.declination.Declination;
import com.sap.sailing.declination.DeclinationService;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.quadtree.QuadTree;
import com.sap.sse.common.TimePoint;
public class DeclinationServiceImpl implements DeclinationService {
private final Distance defaultMaxDistance;
@@ -21,11 +21,11 @@ import org.xml.sax.SAXException;
import com.sap.sailing.declination.Declination;
import com.sap.sailing.domain.common.Bearing;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
import com.sap.sailing.domain.common.impl.DegreePosition;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sailing.domain.common.quadtree.QuadTree;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
/**
* Manages resources in which declinations can be stored for off-line look-up. Time resolution is
@@ -20,8 +20,8 @@ import org.xml.sax.SAXException;
import com.sap.sailing.declination.Declination;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
import com.sap.sse.common.TimePoint;
/**
* Imports magnetic declination data for earth from NOAA (http://www.ngdc.noaa.gov)
@@ -71,9 +71,9 @@ public class NOAAImporter {
String declinationAnnualChangeInMinutes = resultNode.getElementsByTagName("declination_sv").item(0).getTextContent().trim();
inputStream.close();
double declinationAsDouble = declination.equals("nan") ? Double.NaN : Double.valueOf(declination);
double declinationAnnualChangeInMinutesAsDouble = declinationAnnualChangeInMinutes.equals("nan") ? Double.NaN : Double.valueOf(declinationAnnualChangeInMinutes);
double declinationAnnualChangeInDegreesAsDouble = declinationAnnualChangeInMinutes.equals("nan") ? Double.NaN : Double.valueOf(declinationAnnualChangeInMinutes);
result = new DeclinationRecordImpl(position, timePoint, new DegreeBearingImpl(declinationAsDouble),
new DegreeBearingImpl(declinationAnnualChangeInMinutesAsDouble/60.));
new DegreeBearingImpl(declinationAnnualChangeInDegreesAsDouble));
return result;
}
@@ -1,2 +1,3 @@
eclipse.preferences.version=1
encoding//src/com/sap/sailing/domain/common/AbstractBearing.java=UTF-8
encoding//src/com/sap/sailing/domain/common/impl/CountryCodeFactoryImpl.java=UTF-8
@@ -20,6 +20,7 @@ Export-Package: com.sap.sailing.domain.common,
com.sap.sailing.domain.common.racelog.utils,
com.sap.sailing.domain.common.scalablevalue,
com.sap.sailing.domain.common.scalablevalue.impl,
com.sap.sailing.domain.common.trackfiles
com.sap.sailing.domain.common.trackfiles,
com.sap.sailing.domain.common.abstractlog
Require-Bundle: com.sap.sse.datamining.shared,
com.sap.sse.common
@@ -0,0 +1,13 @@
apply plugin: "java"
sourceSets {
main {
java.srcDirs = ["src"]
}
}
dependencies {
/* local dependencies */
compile project(":java:com.sap.sse.common")
compile project(":java:com.sap.sse.datamining.shared")
}
@@ -1,6 +1,7 @@
package com.sap.sailing.domain.common;
import com.sap.sailing.domain.common.impl.NauticalMileDistance;
import com.sap.sse.common.TimePoint;
public abstract class AbstractSpeedImpl implements Speed {
@@ -13,8 +13,8 @@ public interface BearingChangeAnalyzer {
BearingChangeAnalyzer INSTANCE = new BearingChangeAnalyzerImpl();
/**
* Determines whether during a maneuver a certain course was reached and crossed during a maneuver. When used with
* the wind direction, this can tell whether a boat tacked or jibed.
* Determines whether during a maneuver a certain course was reached and crossed. When used with the wind direction,
* this can tell whether a boat tacked or jibed.
*
* @param totalCourseChangeInDegrees
* tells how far and to which direction the course was changed. Positive values mean a change to
@@ -25,7 +25,12 @@ public interface BearingChangeAnalyzer {
* positive then the competitor passed the 000deg course, whereas had the
* <code>totalCourseChangeInDegrees</code> been negative and less than 370deg then the competitor would
* have passed the 180deg course but not the 000deg course.
* @return the number of times that the course identified by
* <code>wasThisCourseReachedAndCrossedDuringManeuver</code> was crossed; <code>0</code> means it was not
* crossed; any positive number tells how many times it was crossed, otherwise. Numbers greater than
* <code>1</code> require <code>totalCourseChangeInDegrees</code> to be greater than 360 degrees.
*
*/
boolean didPass(Bearing courseBeforeManeuver, double totalCourseChangeInDegrees,
int didPass(Bearing courseBeforeManeuver, double totalCourseChangeInDegrees,
Bearing courseAfterManeuver, Bearing wasThisCourseReachedAndCrossedDuringManeuver);
}
@@ -18,6 +18,7 @@ public enum BoatClassMasterdata {
DRAGON_INT ("Dragon Int.", true, 8.89, 1.96, BoatHullType.MONOHULL, true, "Drachen", "Dragon"),
EXTREME_40 ("Extreme 40", false, 12.2, 6.60, BoatHullType.CATAMARAN, true, "Extreme-40", "Extreme40", "ESS40"),
D_35 ("D35", false, 10.81, 6.89, BoatHullType.CATAMARAN, false),
ELLIOTT_6M ("Elliott 6m", true, 6.0, 2.35, BoatHullType.MONOHULL, true, "Elliott6m"),
EUROPE_INT ("Europe Int.", true, 3.35, 1.35, BoatHullType.MONOHULL, false, "Europe"),
F_18 ("Formula 18", true, 6.85, 2.25, BoatHullType.CATAMARAN, true, "F18", "F-18"),
FARR_30 ("Farr 30", true, 9.42, 3.08, BoatHullType.MONOHULL, true, "F30", "F-30", "Farr-30"),
@@ -45,7 +46,7 @@ public enum BoatClassMasterdata {
PLATU_25 ("Platu 25", true, 7.53, 2.62, BoatHullType.MONOHULL, true, "Platu", "Platu-25", "PLA", "B25"),
RS_X ("RS:X", true, 2.86, 0.93, BoatHullType.SURFERBOARD, false, "RS-X", "RSX", "RS:X"),
SONAR ("Sonar", true, 7.01, 2.39, BoatHullType.MONOHULL, true),
STAR ("Star", true, 6.92, 1.74, BoatHullType.MONOHULL, false),
STAR ("Star", true, 6.92, 1.74, BoatHullType.MONOHULL, false, "STR"),
STREAMLINE ("Streamline", true, 7.15, 2.55, BoatHullType.MONOHULL, true),
SWAN_45 ("Swan 45", true, 13.83, 3.91, BoatHullType.MONOHULL, true, "Swan", "Swan-45"),
TORNADO ("Tornado Catamaran", true, 6.10, 3.02, BoatHullType.CATAMARAN, true, "Tornado", "Tornado Cat"),
@@ -103,8 +104,8 @@ public enum BoatClassMasterdata {
return null;
}
private static String unifyBoatClassName(String boatClassName) {
return boatClassName.toUpperCase().replaceAll("\\s+","");
public static String unifyBoatClassName(String boatClassName) {
return boatClassName == null ? null : boatClassName.toUpperCase().replaceAll("\\s+","");
}
public Distance getHullLength() {
@@ -1,5 +1,7 @@
package com.sap.sailing.domain.common;
import com.sap.sse.common.Duration;
/**
* Provides methods to format a {@link Duration}.
*
@@ -1,6 +1,5 @@
package com.sap.sailing.gwt.ui.adminconsole;
package com.sap.sailing.domain.common;
import com.sap.sailing.domain.common.Color;
import com.sap.sailing.domain.common.impl.RGBColor;
public enum FleetColors {
@@ -2,9 +2,9 @@ package com.sap.sailing.domain.common;
import java.io.Serializable;
import com.sap.sailing.domain.common.impl.WindSteppingWithMaxDistance;
import com.sap.sailing.domain.common.impl.WindSpeedSteppingWithMaxDistance;
public interface PolarSheetGenerationSettings extends Serializable{
public interface PolarSheetGenerationSettings extends Serializable {
Integer getMinimumDataCountPerGraph();
@@ -26,8 +26,10 @@ public interface PolarSheetGenerationSettings extends Serializable{
boolean useOnlyEstimatedForWindDirection();
WindSteppingWithMaxDistance getWindStepping();
WindSpeedSteppingWithMaxDistance getWindSpeedStepping();
boolean splitByWindgauges();
boolean areDefault();
}
@@ -9,12 +9,16 @@ public interface PolarSheetsData extends Serializable {
int getDataCount();
boolean isComplete();
Integer[] getDataCountPerAngleForWindspeed(int windIndex);
Integer[] getDataCountPerAngleForWindspeed(int beaufort);
WindSpeedStepping getStepping();
WindStepping getStepping();
Map<Integer, Map<Integer,PolarSheetsHistogramData>> getHistogramDataMap();
/**
* @return key is a zero-based index into the wind speed range list that uses the {@link #getStepping() stepping
* configured}; value is a map whose keys are true wind angles in degrees in the range 0 &lt;= angle &lt;
* 360 and whose values are all the data points collected for this
*
*/
Map<Integer, Map<Integer, PolarSheetsHistogramData>> getHistogramDataMap();
}
@@ -0,0 +1,14 @@
package com.sap.sailing.domain.common;
import java.io.Serializable;
import java.util.List;
import com.sap.sse.common.Util.Pair;
public interface PolarSheetsXYDiagramData extends Serializable {
List<Pair<Double, Double>> getPointsForAverageSpeedMovingAverage(Tack tack, LegType legType);
List<Pair<Double, Double>> getPointsForAverageConfidence(Tack tack, LegType legType);
}
@@ -4,6 +4,7 @@ import java.util.Map;
import java.util.Set;
import com.sap.sse.common.Named;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
import com.sap.sse.common.Util.Pair;
@@ -2,11 +2,12 @@ package com.sap.sailing.domain.common;
import java.io.Serializable;
import com.sap.sse.common.TimePoint;
import com.sap.sse.datamining.shared.Unit;
import com.sap.sse.datamining.shared.annotations.Statistic;
/**
* A speed, convertable in various units of measure. Can be negative.
* A speed, convertible in various units of measure. Can be negative.
*
* @author Axel Uhl (d043530)
*
@@ -1,5 +1,7 @@
package com.sap.sailing.domain.common;
import com.sap.sse.common.TimePoint;
public interface SpeedWithBearing extends Speed {
@@ -0,0 +1,23 @@
package com.sap.sailing.domain.common;
import java.io.Serializable;
public interface WindSpeedStepping extends Serializable {
public abstract int getLevelIndexForValue(double speed);
public abstract Double getSteppedValueForValue(double speed);
double[] getRawStepping();
public abstract int getLevelIndexFloorForValue(double speed);
public abstract int getLevelIndexCeilingForValue(double speed);
double getDistanceToLevelFloor(double speed);
int hashCode();
boolean equals(Object obj);
}
@@ -1,13 +0,0 @@
package com.sap.sailing.domain.common;
import java.io.Serializable;
public interface WindStepping extends Serializable{
public abstract int getLevelIndexForValue(double speed);
public abstract int getSteppedValueForValue(double speed);
Integer[] getRawStepping();
}
@@ -1,6 +1,8 @@
package com.sap.sailing.domain.common.racelog.tracking;
package com.sap.sailing.domain.common.abstractlog;
public class NotRevokableException extends Exception {
import java.io.Serializable;
public class NotRevokableException extends Exception implements Serializable {
private static final long serialVersionUID = 6825451915706047105L;
public NotRevokableException() {
@@ -2,8 +2,8 @@ package com.sap.sailing.domain.common.confidence;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.confidence.impl.ConfidenceBasedAveragerFactoryImpl;
import com.sap.sse.common.TimePoint;
public interface ConfidenceFactory {
ConfidenceFactory INSTANCE = new ConfidenceBasedAveragerFactoryImpl();
@@ -3,8 +3,8 @@ package com.sap.sailing.domain.common.confidence;
import java.io.Serializable;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.scalablevalue.ScalableValue;
import com.sap.sse.common.TimePoint;
/**
* Some values, particularly those obtained from real-world measurements, are not always accurate. Some values are
@@ -2,10 +2,10 @@ package com.sap.sailing.domain.common.confidence.impl;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.confidence.ConfidenceBasedAverager;
import com.sap.sailing.domain.common.confidence.ConfidenceFactory;
import com.sap.sailing.domain.common.confidence.Weigher;
import com.sap.sse.common.TimePoint;
public class ConfidenceBasedAveragerFactoryImpl implements ConfidenceFactory {
@Override
@@ -1,7 +1,7 @@
package com.sap.sailing.domain.common.confidence.impl;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.confidence.Weigher;
import com.sap.sse.common.TimePoint;
/**
* The weigher computes an exponentially-decreasing weight based on the time difference of two {@link TimePoint}s.
@@ -1,7 +1,7 @@
package com.sap.sailing.domain.common.confidence.impl;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.confidence.Weigher;
import com.sap.sse.common.TimePoint;
public class HyperbolicSquaredTimeDifferenceWeigher implements Weigher<TimePoint> {
private static final long serialVersionUID = 4378168079868145134L;
@@ -1,7 +1,7 @@
package com.sap.sailing.domain.common.confidence.impl;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.confidence.Weigher;
import com.sap.sse.common.TimePoint;
public class HyperbolicTimeDifferenceWeigher implements Weigher<TimePoint> {
private static final long serialVersionUID = 4378168079868145134L;
@@ -2,9 +2,9 @@ package com.sap.sailing.domain.common.confidence.impl;
import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.confidence.ConfidenceFactory;
import com.sap.sailing.domain.common.confidence.Weigher;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util;
/**
@@ -4,6 +4,13 @@ import java.io.Serializable;
public class BoatClassDTO extends NamedDTO implements Serializable {
private static final long serialVersionUID = 1981789833769906676L;
/**
* A default boat class name; can be used, e.g., in regatta configuration "templates" which later
* are used to configure several different regattas for different boat classes.
*/
public static final String DEFAULT_NAME = "Default";
private double hullLengthInMeters;
private String displayName;
@@ -3,10 +3,10 @@ package com.sap.sailing.domain.common.dto;
import java.io.Serializable;
import java.util.List;
import com.sap.sailing.domain.common.Duration;
import com.sap.sailing.domain.common.MaxPointsReason;
import com.sap.sailing.domain.common.RaceIdentifier;
import com.sap.sailing.domain.common.Tack;
import com.sap.sse.common.Duration;
/**
* Holds a single competitor's scoring details for a single race. It may optionally contain
@@ -23,11 +23,11 @@ public class RaceColumnDTO extends NamedDTO implements Serializable {
private Map<FleetDTO, RaceDTO> racesPerFleet;
private Double explicitFactor;
private double effectiveFactor;
private Map<FleetDTO, RaceLogTrackingInfoDTO> raceLogTrackingInfos = new HashMap<FleetDTO, RaceLogTrackingInfoDTO>();
private Map<FleetDTO, RaceLogTrackingInfoDTO> raceLogTrackingInfos;
public RaceColumnDTO() {
trackedRaceIdentifiersPerFleet = new HashMap<FleetDTO, RegattaAndRaceIdentifier>();
raceLogTrackingInfos = new HashMap<FleetDTO, RaceLogTrackingInfoDTO>();
racesPerFleet = new HashMap<FleetDTO, RaceDTO>();
fleets = new ArrayList<FleetDTO>();
}
@@ -2,7 +2,7 @@ package com.sap.sailing.domain.common.dto;
import java.io.Serializable;
import com.sap.sailing.domain.common.Duration;
import com.sap.sse.common.Duration;
public class TrackedRaceStatisticsDTO implements Serializable {
private static final long serialVersionUID = -2123085927945474642L;
@@ -7,7 +7,8 @@ import com.sap.sailing.domain.common.Distance;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.Speed;
import com.sap.sailing.domain.common.SpeedWithBearing;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public abstract class AbstractSpeedWithAbstractBearingImpl extends AbstractSpeedImpl implements SpeedWithBearing {
private static final long serialVersionUID = 6136100417593538013L;
@@ -6,14 +6,14 @@ import com.sap.sailing.domain.common.BearingChangeAnalyzer;
public class BearingChangeAnalyzerImpl implements BearingChangeAnalyzer {
@Override
public boolean didPass(Bearing courseBeforeManeuver, double totalCourseChangeInDegrees, Bearing courseAfterManeuver,
public int didPass(Bearing courseBeforeManeuver, double totalCourseChangeInDegrees, Bearing courseAfterManeuver,
Bearing wasThisCourseReachedAndCrossedDuringManeuver) {
final boolean result;
final int result;
Bearing diffToCourseInQuestion = courseBeforeManeuver.getDifferenceTo(wasThisCourseReachedAndCrossedDuringManeuver);
if (Math.signum(diffToCourseInQuestion.getDegrees()) == Math.signum(totalCourseChangeInDegrees)) {
// simple case: the actual course change was greater than what was required in that direction to
// reach the course in question
result = Math.abs(diffToCourseInQuestion.getDegrees()) <= Math.abs(totalCourseChangeInDegrees);
result = (int) ((Math.abs(totalCourseChangeInDegrees) + 360. - Math.abs(diffToCourseInQuestion.getDegrees())) / 360.);
} else {
// more complicated: the smallest possible course change required may have been to a different direction than the
// actual course change. The course in question may still have been reached and crossed in the actual course
@@ -24,7 +24,7 @@ public class BearingChangeAnalyzerImpl implements BearingChangeAnalyzer {
// Approach: revert the course change required; revert 005deg to 355deg and check again with this reverted course change.
Bearing revertedDiffToCourseInQuestion = new DegreeBearingImpl(-360 * Math.signum(diffToCourseInQuestion
.getDegrees())+diffToCourseInQuestion.getDegrees());
result = Math.abs(revertedDiffToCourseInQuestion.getDegrees()) <= Math.abs(totalCourseChangeInDegrees);
result = (int) ((Math.abs(totalCourseChangeInDegrees) + 360. - Math.abs(revertedDiffToCourseInQuestion.getDegrees())) / 360.);
}
return result;
}
@@ -25,10 +25,10 @@ public class CountryCodeFactoryImpl implements CountryCodeFactory {
byIanaInternet = new HashMap<String, CountryCode>();
all = new HashSet<CountryCode>();
add(new CountryCodeImpl("AFGHANISTAN", "AF", "AFG", "af", "AFG", "AFG", "004", "93"));
add(new CountryCodeImpl("ÅLAND ISLANDS", "AX", "ALA", "ax", null, null, "248", null));
add(new CountryCodeImpl("ÅLAND ISLANDS", "AX", "ALA", "ax", null, null, "248", null));
add(new CountryCodeImpl("ALBANIA", "AL", "ALB", "al", "AL", "ALB", "008", "355"));
add(new CountryCodeImpl("ALDERNEY", null, null, null, "GBA", null, null, null));
add(new CountryCodeImpl("ALGERIA (El Djazaïr)", "DZ", "DZA", "dz", "DZ", "ALG", "012", "213"));
add(new CountryCodeImpl("ALGERIA (El Djazaïr)", "DZ", "DZA", "dz", "DZ", "ALG", "012", "213"));
add(new CountryCodeImpl("AMERICAN SAMOA", "AS", "ASM", "as", null, "ASA", "016", "1-684"));
add(new CountryCodeImpl("ANDORRA", "AD", "AND", "ad", "AND", "AND", "020", "376"));
add(new CountryCodeImpl("ANGOLA", "AO", "AGO", "ao", null, "ANG", "024", "244"));
@@ -81,10 +81,10 @@ public class CountryCodeFactoryImpl implements CountryCodeFactory {
add(new CountryCodeImpl("CONGO, THE DEMOCRATIC REPUBLIC OF THE (formerly Zaire)", "CD", "COD", "cd", "ZRE", "COD", "180", "243"));
add(new CountryCodeImpl("COOK ISLANDS", "CK", "COK", "ck", null, "COK", "184", "682"));
add(new CountryCodeImpl("COSTA RICA", "CR", "CRI", "cr", "CR", "CRC", "188", "506"));
add(new CountryCodeImpl("CÔTE D'IVOIRE (Ivory Coast)", "CI", "CIV", "ci", "CI", "CIV", "384", "225"));
add(new CountryCodeImpl("CÔTE D'IVOIRE (Ivory Coast)", "CI", "CIV", "ci", "CI", "CIV", "384", "225"));
add(new CountryCodeImpl("CROATIA (Hrvatska)", "HR", "HRV", "hr", "HR", "CRO", "191", "385"));
add(new CountryCodeImpl("CUBA", "CU", "CUB", "cu", "CU", "CUB", "192", "53"));
add(new CountryCodeImpl("CURAÇAO", "CW", "CUW", "cw", null, null, "531", "599"));
add(new CountryCodeImpl("CURAÇAO", "CW", "CUW", "cw", null, null, "531", "599"));
add(new CountryCodeImpl("CYPRUS", "CY", "CYP", "cy", "CY", "CYP", "196", "357"));
add(new CountryCodeImpl("CZECH REPUBLIC", "CZ", "CZE", "cz", "CZ", "CZE", "203", "420"));
add(new CountryCodeImpl("DENMARK", "DK", "DNK", "dk", "DK", "DEN", "208", "45"));
@@ -156,7 +156,7 @@ public class CountryCodeFactoryImpl implements CountryCodeFactory {
add(new CountryCodeImpl("LESOTHO", "LS", "LSO", "ls", "LS", "LES", "426", "266"));
add(new CountryCodeImpl("LIBERIA", "LR", "LBR", "lr", "LB", "LBR", "430", "231"));
add(new CountryCodeImpl("LIBYA (Libyan Arab Jamahirya)", "LY", "LBY", "ly", "LAR", "LBA", "434", "218"));
add(new CountryCodeImpl("LIECHTENSTEIN (Fürstentum Liechtenstein)", "LI", "LIE", "li", "FL", "LIE", "438", "423"));
add(new CountryCodeImpl("LIECHTENSTEIN (Fürstentum Liechtenstein)", "LI", "LIE", "li", "FL", "LIE", "438", "423"));
add(new CountryCodeImpl("LITHUANIA", "LT", "LTU", "lt", "LT", "LTU", "440", "370"));
add(new CountryCodeImpl("LUXEMBOURG", "LU", "LUX", "lu", "L", "LUX", "442", "352"));
add(new CountryCodeImpl("MACAO (Special Administrative Region of China)", "MO", "MAC", "mo", null, null, "446", "853"));
@@ -180,7 +180,7 @@ public class CountryCodeFactoryImpl implements CountryCodeFactory {
add(new CountryCodeImpl("MONTENEGRO", "ME", "MNE", "me", "MNE", "MNE", "499", "382"));
add(new CountryCodeImpl("MONTSERRAT", "MS", "MSR", "ms", null, null, "500", "1-664"));
add(new CountryCodeImpl("MOROCCO", "MA", "MAR", "ma", "MA", "MAR", "504", "212"));
add(new CountryCodeImpl("MOZAMBIQUE (Moçambique)", "MZ", "MOZ", "mz", "MOC", "MOZ", "508", "258"));
add(new CountryCodeImpl("MOZAMBIQUE (Moçambique)", "MZ", "MOZ", "mz", "MOC", "MOZ", "508", "258"));
add(new CountryCodeImpl("MYANMAR (formerly Burma)", "MM", "MMR", "mm", "BUR", "MYA", "104", "95"));
add(new CountryCodeImpl("NAMIBIA", "NA", "NAM", "na", "NAM", "NAM", "516", "264"));
add(new CountryCodeImpl("NAURU", "NR", "NRU", "nr", "NAU", "NRU", "520", "674"));
@@ -210,11 +210,11 @@ public class CountryCodeFactoryImpl implements CountryCodeFactory {
add(new CountryCodeImpl("PORTUGAL", "PT", "PRT", "pt", "P", "POR", "620", "351"));
add(new CountryCodeImpl("PUERTO RICO", "PR", "PRI", "pr", null, "PUR", "630", "1"));
add(new CountryCodeImpl("QATAR", "QA", "QAT", "qa", "Q", "QAT", "634", "974"));
add(new CountryCodeImpl("RÉUNION", "RE", "REU", "re", null, null, "638", "262"));
add(new CountryCodeImpl("RÉUNION", "RE", "REU", "re", null, null, "638", "262"));
add(new CountryCodeImpl("ROMANIA", "RO", "ROU", "ro", "RO", "ROU", "642", "40"));
add(new CountryCodeImpl("RUSSIAN FEDERATION", "RU", "RUS", "ru", "RUS", "RUS", "643", "7"));
add(new CountryCodeImpl("RWANDA", "RW", "RWA", "rw", "RWA", "RWA", "646", "250"));
add(new CountryCodeImpl("SAINT BARTHÉLEMY", "BL", "BLM", "bl", null, null, "652", null));
add(new CountryCodeImpl("SAINT BARTHÉLEMY", "BL", "BLM", "bl", null, null, "652", null));
add(new CountryCodeImpl("SAINT HELENA", "SH", "SHN", "sh", null, null, "654", "290"));
add(new CountryCodeImpl("SAINT KITTS AND NEVIS", "KN", "KNA", "kn", null, "SKN", "659", "1-869"));
add(new CountryCodeImpl("SAINT LUCIA", "LC", "LCA", "lc", "WL", "LCA", "662", "1-758"));
@@ -238,7 +238,7 @@ public class CountryCodeFactoryImpl implements CountryCodeFactory {
add(new CountryCodeImpl("SOUTH AFRICA (Zuid Afrika)", "ZA", "ZAF", "za", "ZA", "RSA", "710", "27"));
add(new CountryCodeImpl("SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS", "GS", "SGS", "gs", null, null, "239", null));
add(new CountryCodeImpl("SOVIET UNION (Internet code still used)", null, null, "su", null, null, null, null));
add(new CountryCodeImpl("SPAIN (España)", "ES", "ESP", "es", "E", "ESP", "724", "34"));
add(new CountryCodeImpl("SPAIN (España)", "ES", "ESP", "es", "E", "ESP", "724", "34"));
add(new CountryCodeImpl("SRI LANKA (formerly Ceylon)", "LK", "LKA", "lk", "CL", "SRI", "144", "94"));
add(new CountryCodeImpl("SUDAN", "SD", "SDN", "sd", "SUD", "SUD", "736", "249"));
add(new CountryCodeImpl("SURINAME", "SR", "SUR", "sr", "SME", "SUR", "740", "597"));
@@ -1,13 +1,31 @@
package com.sap.sailing.domain.common.impl;
import java.util.ArrayList;
import java.util.List;
import com.sap.sailing.domain.common.PolarSheetGenerationSettings;
public class PolarSheetGenerationSettingsImpl implements PolarSheetGenerationSettings {
public static PolarSheetGenerationSettings createStandardPolarSettings() {
Integer[] levels = { 4, 6, 8, 10, 12, 14, 16, 20, 25, 30 };
WindSteppingWithMaxDistance windStepping = new WindSteppingWithMaxDistance(levels, 2.0);
return new PolarSheetGenerationSettingsImpl(200, 0.1, 10, 20, 0.1, true, true, 2, 0.05, true, windStepping,
double[] levels = { 4., 6., 8., 10., 12., 14., 16., 20., 25., 30. };
WindSpeedSteppingWithMaxDistance windStepping = new WindSpeedSteppingWithMaxDistance(levels, 2.5);
return new PolarSheetGenerationSettingsImpl(50, 0.1, 20, 20, 0.1, true, true, 2, 0.05, true, windStepping,
false);
}
public static PolarSheetGenerationSettings createBackendPolarSettings() {
List<Double> levelList = new ArrayList<Double>();
for (double levelValue = 0.5; levelValue < 35; levelValue = levelValue + 0.5) {
levelList.add(levelValue);
}
double[] levels = new double[levelList.size()];
int i=0;
for (Double level : levelList) {
levels[i++] = level;
}
WindSpeedSteppingWithMaxDistance windStepping = new WindSpeedSteppingWithMaxDistance(levels, 0.5);
return new PolarSheetGenerationSettingsImpl(50, 0.1, 20, 20, 0.1, true, true, 2, 0.05, true, windStepping,
false);
}
@@ -22,7 +40,7 @@ public class PolarSheetGenerationSettingsImpl implements PolarSheetGenerationSet
private double outlierDetectionNeighboorhoodRadius;
private double outlierMinimumNeighboorhoodPct;
private boolean useOnlyEstimationForWindDirection;
private WindSteppingWithMaxDistance windStepping;
private WindSpeedSteppingWithMaxDistance windStepping;
private boolean splitByWindGauges;
//GWT
@@ -32,7 +50,7 @@ public class PolarSheetGenerationSettingsImpl implements PolarSheetGenerationSet
Integer minimumDataCountPerAngle, Integer numberOfHistogramColumns, double minimumConfidenceMeasure,
boolean useOnlyWindGaugesForWindSpeed, boolean shouldRemoveOutliers,
double outlierDetectionNeighboorhoodRadius, double outlierMinimumNeighboorhoodPct,
boolean useOnlyEstimationForWindDirection, WindSteppingWithMaxDistance windStepping,
boolean useOnlyEstimationForWindDirection, WindSpeedSteppingWithMaxDistance windStepping,
boolean splitByWindGauges) {
this.minimumDataCountPerGraph = minimumDataCountPerGraph;
this.minimumWindConfidence = minimumWindConfidence;
@@ -99,7 +117,7 @@ public class PolarSheetGenerationSettingsImpl implements PolarSheetGenerationSet
}
@Override
public WindSteppingWithMaxDistance getWindStepping() {
public WindSpeedSteppingWithMaxDistance getWindSpeedStepping() {
return windStepping;
}
@@ -108,4 +126,85 @@ public class PolarSheetGenerationSettingsImpl implements PolarSheetGenerationSet
return splitByWindGauges;
}
@Override
public boolean areDefault() {
return createStandardPolarSettings().equals(this);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
long temp;
temp = Double.doubleToLongBits(minimumConfidenceMeasure);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((minimumDataCountPerAngle == null) ? 0 : minimumDataCountPerAngle.hashCode());
result = prime * result + ((minimumDataCountPerGraph == null) ? 0 : minimumDataCountPerGraph.hashCode());
temp = Double.doubleToLongBits(minimumWindConfidence);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + ((numberOfHistogramColumns == null) ? 0 : numberOfHistogramColumns.hashCode());
temp = Double.doubleToLongBits(outlierDetectionNeighboorhoodRadius);
result = prime * result + (int) (temp ^ (temp >>> 32));
temp = Double.doubleToLongBits(outlierMinimumNeighboorhoodPct);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + (shouldRemoveOutliers ? 1231 : 1237);
result = prime * result + (splitByWindGauges ? 1231 : 1237);
result = prime * result + (useOnlyEstimationForWindDirection ? 1231 : 1237);
result = prime * result + (useOnlyWindGaugesForWindSpeed ? 1231 : 1237);
result = prime * result + ((windStepping == null) ? 0 : windStepping.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PolarSheetGenerationSettingsImpl other = (PolarSheetGenerationSettingsImpl) obj;
if (Double.doubleToLongBits(minimumConfidenceMeasure) != Double
.doubleToLongBits(other.minimumConfidenceMeasure))
return false;
if (minimumDataCountPerAngle == null) {
if (other.minimumDataCountPerAngle != null)
return false;
} else if (!minimumDataCountPerAngle.equals(other.minimumDataCountPerAngle))
return false;
if (minimumDataCountPerGraph == null) {
if (other.minimumDataCountPerGraph != null)
return false;
} else if (!minimumDataCountPerGraph.equals(other.minimumDataCountPerGraph))
return false;
if (Double.doubleToLongBits(minimumWindConfidence) != Double.doubleToLongBits(other.minimumWindConfidence))
return false;
if (numberOfHistogramColumns == null) {
if (other.numberOfHistogramColumns != null)
return false;
} else if (!numberOfHistogramColumns.equals(other.numberOfHistogramColumns))
return false;
if (Double.doubleToLongBits(outlierDetectionNeighboorhoodRadius) != Double
.doubleToLongBits(other.outlierDetectionNeighboorhoodRadius))
return false;
if (Double.doubleToLongBits(outlierMinimumNeighboorhoodPct) != Double
.doubleToLongBits(other.outlierMinimumNeighboorhoodPct))
return false;
if (shouldRemoveOutliers != other.shouldRemoveOutliers)
return false;
if (splitByWindGauges != other.splitByWindGauges)
return false;
if (useOnlyEstimationForWindDirection != other.useOnlyEstimationForWindDirection)
return false;
if (useOnlyWindGaugesForWindSpeed != other.useOnlyWindGaugesForWindSpeed)
return false;
if (windStepping == null) {
if (other.windStepping != null)
return false;
} else if (!windStepping.equals(other.windStepping))
return false;
return true;
}
}
@@ -4,7 +4,7 @@ import java.util.Map;
import com.sap.sailing.domain.common.PolarSheetsData;
import com.sap.sailing.domain.common.PolarSheetsHistogramData;
import com.sap.sailing.domain.common.WindStepping;
import com.sap.sailing.domain.common.WindSpeedStepping;
public class PolarSheetsDataImpl implements PolarSheetsData {
@@ -12,11 +12,9 @@ public class PolarSheetsDataImpl implements PolarSheetsData {
private Number[][] averagedPolarDataByWindSpeed;
private boolean complete;
private int dataCount;
private WindStepping stepping;
private WindSpeedStepping stepping;
private Map<Integer,Integer[]> dataCountPerAngleForWindspeed;
@@ -25,9 +23,10 @@ public class PolarSheetsDataImpl implements PolarSheetsData {
//For GWT Serialization
PolarSheetsDataImpl() {};
public PolarSheetsDataImpl(Number[][] averagedPolarDataByWindSpeed, boolean complete, int dataCount, Map<Integer,Integer[]> dataCountPerAngleForWindspeed, WindStepping stepping, Map<Integer, Map<Integer, PolarSheetsHistogramData>> histogramDataMap) {
public PolarSheetsDataImpl(Number[][] averagedPolarDataByWindSpeed, int dataCount,
Map<Integer, Integer[]> dataCountPerAngleForWindspeed, WindSpeedStepping stepping,
Map<Integer, Map<Integer, PolarSheetsHistogramData>> histogramDataMap) {
this.averagedPolarDataByWindSpeed = averagedPolarDataByWindSpeed;
this.complete = complete;
this.dataCount = dataCount;
this.dataCountPerAngleForWindspeed = dataCountPerAngleForWindspeed;
this.stepping = stepping;
@@ -40,11 +39,6 @@ public class PolarSheetsDataImpl implements PolarSheetsData {
return averagedPolarDataByWindSpeed;
}
@Override
public boolean isComplete() {
return complete;
}
@Override
public int getDataCount() {
return dataCount;
@@ -57,7 +51,7 @@ public class PolarSheetsDataImpl implements PolarSheetsData {
}
@Override
public WindStepping getStepping() {
public WindSpeedStepping getStepping() {
return stepping;
}
@@ -0,0 +1,61 @@
package com.sap.sailing.domain.common.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.sap.sailing.domain.common.LegType;
import com.sap.sailing.domain.common.PolarSheetsXYDiagramData;
import com.sap.sailing.domain.common.Tack;
import com.sap.sse.common.Util.Pair;
public class PolarSheetsXYDiagramDataImpl implements PolarSheetsXYDiagramData {
private static final long serialVersionUID = 778667444303004468L;
PolarSheetsXYDiagramDataImpl() {
}
private Map<Pair<LegType, Tack>, List<Pair<Double, Double>>> pointsForAverageSpeedMovingAverage;
private Map<Pair<LegType, Tack>, List<Pair<Double, Double>>> pointsForAverageConfidence;
public PolarSheetsXYDiagramDataImpl(List<Pair<Double, Double>> pointsForUpwindStarboardAverageSpeedMovingAverage,
List<Pair<Double, Double>> pointsForUpwindStarboardAverageConfidence,
List<Pair<Double, Double>> pointsForUpwindPortAverageSpeedMovingAverage,
List<Pair<Double, Double>> pointsForUpwindPortAverageConfidence,
List<Pair<Double, Double>> pointsForDownwindStarboardAverageSpeedMovingAverage,
List<Pair<Double, Double>> pointsForDownwindStarboardAverageConfidence,
List<Pair<Double, Double>> pointsForDownwindPortAverageSpeedMovingAverage,
List<Pair<Double, Double>> pointsForDownwindPortAverageConfidence) {
pointsForAverageSpeedMovingAverage = new HashMap<Pair<LegType, Tack>, List<Pair<Double, Double>>>();
pointsForAverageConfidence = new HashMap<Pair<LegType, Tack>, List<Pair<Double, Double>>>();
pointsForAverageSpeedMovingAverage.put(new Pair<LegType, Tack>(LegType.UPWIND, Tack.STARBOARD),
pointsForUpwindStarboardAverageSpeedMovingAverage);
pointsForAverageConfidence.put(new Pair<LegType, Tack>(LegType.UPWIND, Tack.STARBOARD),
pointsForUpwindStarboardAverageConfidence);
pointsForAverageSpeedMovingAverage.put(new Pair<LegType, Tack>(LegType.UPWIND, Tack.PORT),
pointsForUpwindPortAverageSpeedMovingAverage);
pointsForAverageConfidence.put(new Pair<LegType, Tack>(LegType.UPWIND, Tack.PORT),
pointsForUpwindPortAverageConfidence);
pointsForAverageSpeedMovingAverage.put(new Pair<LegType, Tack>(LegType.DOWNWIND, Tack.STARBOARD),
pointsForDownwindStarboardAverageSpeedMovingAverage);
pointsForAverageConfidence.put(new Pair<LegType, Tack>(LegType.DOWNWIND, Tack.STARBOARD),
pointsForDownwindStarboardAverageConfidence);
pointsForAverageSpeedMovingAverage.put(new Pair<LegType, Tack>(LegType.DOWNWIND, Tack.PORT),
pointsForDownwindPortAverageSpeedMovingAverage);
pointsForAverageConfidence.put(new Pair<LegType, Tack>(LegType.DOWNWIND, Tack.PORT),
pointsForDownwindPortAverageConfidence);
}
@Override
public List<Pair<Double, Double>> getPointsForAverageSpeedMovingAverage(Tack tack, LegType legType) {
return pointsForAverageSpeedMovingAverage.get(new Pair<LegType, Tack>(legType, tack));
}
@Override
public List<Pair<Double, Double>> getPointsForAverageConfidence(Tack tack, LegType legType) {
return pointsForAverageConfidence.get(new Pair<LegType, Tack>(legType, tack));
}
}
@@ -40,9 +40,12 @@ public class RGBColor extends AbstractColor {
b = Integer.parseInt(htmlColor.substring(4, 6), 16);
break;
case 3:
r = Integer.parseInt(htmlColor.substring(0, 1), 16);
g = Integer.parseInt(htmlColor.substring(1, 2), 16);
b = Integer.parseInt(htmlColor.substring(2, 3), 16);
final int r0 = Integer.parseInt(htmlColor.substring(0, 1), 16);
r = 16*r0 + r0;
final int g0 = Integer.parseInt(htmlColor.substring(1, 2), 16);
g = 16*g0 + g0;
final int b0 = Integer.parseInt(htmlColor.substring(2, 3), 16);
b = 16*b0 + b0;
break;
case 1:
r = g = b = Integer.parseInt(htmlColor.substring(0, 1), 16);
@@ -0,0 +1,109 @@
package com.sap.sailing.domain.common.impl;
import java.util.Arrays;
import com.sap.sailing.domain.common.WindSpeedStepping;
public class WindSpeedSteppingImpl implements WindSpeedStepping {
//For GWT Serialization
protected WindSpeedSteppingImpl() {};
private static final long serialVersionUID = 2215693490331489508L;
protected double[] levels;
public WindSpeedSteppingImpl(double[] levels) {
this.levels = levels;
}
public int getNumberOfLevels() {
return levels.length;
}
@Override
public int getLevelIndexForValue(double speed) {
for (int i = 0; i < levels.length - 1; i++) {
if (speed < levels[i] + ((levels[i+1] - levels[i]) / 2.)) {
return i;
}
}
return levels.length - 1;
}
@Override
public double[] getRawStepping() {
return levels;
}
@Override
public Double getSteppedValueForValue(double speed) {
int levelIndex = getLevelIndexForValue(speed);
Double result = -1.0;
if (levelIndex >= 0) {
result = levels[levelIndex];
}
return result;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(levels);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
WindSpeedSteppingImpl other = (WindSpeedSteppingImpl) obj;
if (!Arrays.equals(levels, other.levels))
return false;
return true;
}
@Override
public int getLevelIndexFloorForValue(double speed) {
int result = -1;
for (int i = 0; i < levels.length - 1; i++) {
if (speed >= levels[i]) {
result = i;
}
}
return result;
}
@Override
public double getDistanceToLevelFloor(double speed) {
double result = 0;
int floor = getLevelIndexFloorForValue(speed);
if (floor == -1) {
result = 0;
} else {
result = speed - levels[floor];
}
return result;
}
@Override
public int getLevelIndexCeilingForValue(double speed) {
int floor = getLevelIndexFloorForValue(speed);
int result;
if (floor == -1) {
result = -1;
}
if (levels[floor] == speed) {
result = floor;
} else {
result = floor + 1;
}
return result;
}
}
@@ -1,17 +1,17 @@
package com.sap.sailing.domain.common.impl;
public class WindSteppingWithMaxDistance extends WindSteppingImpl {
public class WindSpeedSteppingWithMaxDistance extends WindSpeedSteppingImpl {
private static final long serialVersionUID = -2207840179212727591L;
private double maxDistance;
//For GWT Serialization
WindSteppingWithMaxDistance() {
WindSpeedSteppingWithMaxDistance() {
super();
};
public WindSteppingWithMaxDistance(Integer[] levels, double maxDistance) {
public WindSpeedSteppingWithMaxDistance(double[] levels, double maxDistance) {
super(levels);
this.maxDistance = maxDistance;
}
@@ -20,7 +20,7 @@ public class WindSteppingWithMaxDistance extends WindSteppingImpl {
public int getLevelIndexForValue(double speed) {
int result = -1;
for (int i = 0; i < levels.length - 1; i++) {
double threshold = levels[i] + ((levels[i+1] - levels[i]) / 2);
double threshold = levels[i] + ((levels[i+1] - levels[i]) / 2.);
if (speed < threshold) {
if (threshold - speed <= maxDistance * 2) {
result = i;
@@ -39,4 +39,30 @@ public class WindSteppingWithMaxDistance extends WindSteppingImpl {
public double getMaxDistance() {
return maxDistance;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
long temp;
temp = Double.doubleToLongBits(maxDistance);
result = prime * result + (int) (temp ^ (temp >>> 32));
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
WindSpeedSteppingWithMaxDistance other = (WindSpeedSteppingWithMaxDistance) obj;
if (Double.doubleToLongBits(maxDistance) != Double.doubleToLongBits(other.maxDistance))
return false;
return true;
}
}
@@ -1,47 +0,0 @@
package com.sap.sailing.domain.common.impl;
import com.sap.sailing.domain.common.WindStepping;
public class WindSteppingImpl implements WindStepping {
//For GWT Serialization
protected WindSteppingImpl() {};
private static final long serialVersionUID = 2215693490331489508L;
protected Integer[] levels;
public WindSteppingImpl(Integer[] levels) {
this.levels = levels;
}
public int getNumberOfLevels() {
return levels.length;
}
@Override
public int getLevelIndexForValue(double speed) {
for (int i = 0; i < levels.length - 1; i++) {
if (speed < levels[i] + ((levels[i+1] - levels[i]) / 2)) {
return i;
}
}
return levels.length - 1;
}
@Override
public Integer[] getRawStepping() {
return levels;
}
@Override
public int getSteppedValueForValue(double speed) {
int levelIndex = getLevelIndexForValue(speed);
int result = - 1;
if (levelIndex >= 0) {
result = levels[levelIndex];
}
return result;
}
}
@@ -5,9 +5,9 @@ import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import com.sap.sailing.domain.common.Duration;
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
/**
* See http://my.opera.com/core/blog/2010/03/03/everything-you-need-to-know-about-html5-video-and-audio-2
@@ -1,6 +1,6 @@
package com.sap.sailing.domain.common.media;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sse.common.TimePoint;
public class MediaUtil {
@@ -1,32 +1,28 @@
package com.sap.sailing.domain.common.racelog.tracking;
import com.sap.sailing.domain.common.racelog.RaceLogServletConstants;
/**
* Shared between GWT and Android. Used for creating and deciphering the URL
* encoded by the QRCode, which gives the tracking app all necessary information
* for creating the device mapping.
* This includes the leaderboard name, race-column name and fleet name to identify
* which RaceLog to add the {@code DeviceMappingEvent} to. Also, either a competitor
* or mark ID is added, to which the device should be mapped. Timestamps for the
* beginning and the end of the mapping are also included.
* Shared between GWT and Android. Used for creating and deciphering the URL encoded by the QRCode, which gives the
* tracking app all necessary information for creating the device mapping of either the race or leaderboard/regatta.
* <p>
* The URL points to the apk-file of the app deployed to the {@code www} directory
* of the server, with additional {@code GET}-parameters:
* <ul>
* <li>{@link RaceLogServletConstants#PARAMS_LEADERBOARD_NAME}</li>
* <li>{@link RaceLogServletConstants#PARAMS_RACE_COLUMN_NAME}</li>
* <li>{@link RaceLogServletConstants#PARAMS_RACE_FLEET_NAME}</li>
* <li>either {@link #COMPETITOR_ID_AS_STRING} or {@link #MARK_ID_AS_STRING}</li>
* <li>{@link #FROM_MILLIS}</li>
* <li>{@link #TO_MILLIS}</li>
* </ul>
* The field that server for mapping a device for an individual race are deprecated (see {@link DeviceMappingOnRaceQRCodeWidget}).
* <p>
* The structure of the URL is documented in the <a href="http://wiki.sapsailing.com/wiki/tracking-app-api-v1-draft">Wiki</a>.
* {@code http://<host>/tracking/checkin?event_id=<e>&leaderboard_name=<l>&competitor_id=<c>}
*
* @author Fredrik Teschke
*/
public interface DeviceMappingConstants {
static final String COMPETITOR_ID_AS_STRING = "competitor";
static final String MARK_ID_AS_STRING = "mark";
static final String FROM_MILLIS = "from";
static final String TO_MILLIS = "to";
static final String URL_BASE = "/tracking/checkin";
static final String EVENT_ID = "event_id";
static final String LEADERBOARD_NAME = "leaderboardName";
static final String COMPETITOR_ID_AS_STRING = "competitorId";
static final String MARK_ID_AS_STRING = "markId";
static final String DEVICE_UUID = "deviceUuid";
static final String DEVICE_TYPE = "deviceType";
static final String PUSH_DEVICE_ID = "pushDeviceId";
static final String FROM_MILLIS = "fromMillis";
static final String TO_MILLIS = "toMillis";
@Deprecated
static final String APK_PATH = "/apps/com.sap.sailing.android.tracking.app.apk";
}
@@ -0,0 +1,7 @@
package com.sap.sailing.domain.common.racelog.tracking;
import java.io.Serializable;
public class DoesNotHaveRegattaLogException extends Exception implements Serializable {
private static final long serialVersionUID = 963948633131929332L;
}
@@ -9,5 +9,5 @@ package com.sap.sailing.domain.common.racelog.tracking;
*
*/
public interface MappableToDevice {
String getIdAsString();
}
@@ -1,6 +1,8 @@
package com.sap.sailing.domain.common.racelog.tracking;
public class NoCorrespondingServiceRegisteredException extends RuntimeException {
import java.io.Serializable;
public class NoCorrespondingServiceRegisteredException extends RuntimeException implements Serializable {
public String type;
public String serviceInterface;
private static final long serialVersionUID = -358955216089477585L;
@@ -1,6 +1,8 @@
package com.sap.sailing.domain.common.racelog.tracking;
public class NotDenotedForRaceLogTrackingException extends Exception {
import java.io.Serializable;
public class NotDenotedForRaceLogTrackingException extends Exception implements Serializable {
private static final long serialVersionUID = 6721038282862173471L;
@@ -1,8 +1,9 @@
package com.sap.sailing.domain.common.racelog.tracking;
import java.io.IOException;
import java.io.Serializable;
public class TransformationException extends IOException {
public class TransformationException extends IOException implements Serializable {
private static final long serialVersionUID = -7795777645371428971L;
public TransformationException() {
@@ -14,13 +14,13 @@ import java.util.Iterator;
import org.junit.Test;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.deckmanadapter.DeckmanAdapter;
import com.sap.sailing.domain.deckmanadapter.DeckmanAdapterFactory;
import com.sap.sailing.domain.deckmanadapter.Record;
import com.sap.sailing.domain.deckmanadapter.impl.FieldType;
import com.sap.sailing.domain.tracking.GPSFixMoving;
import com.sap.sailing.domain.tracking.Wind;
import com.sap.sse.common.TimePoint;
public class TestDeckmanLogfileParsing {
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
@@ -8,6 +8,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: com.sap.sailing.domain,
com.sap.sailing.domain.common,
com.sap.sailing.domain.shared.android,
com.sap.sailing.server.trackfiles
com.sap.sailing.server.trackfiles,
com.sap.sse.common
Import-Package: org.osgi.framework
Bundle-Activator: com.sap.sailing.domain.deckmanadapter.impl.Activator
@@ -8,17 +8,17 @@ import java.util.Map;
import com.sap.sailing.domain.base.Timed;
import com.sap.sailing.domain.common.Position;
import com.sap.sailing.domain.common.SpeedWithBearing;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
import com.sap.sailing.domain.common.impl.DegreePosition;
import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sailing.domain.deckmanadapter.impl.FieldType;
import com.sap.sailing.domain.tracking.GPSFixMoving;
import com.sap.sailing.domain.tracking.Positioned;
import com.sap.sailing.domain.tracking.Wind;
import com.sap.sailing.domain.tracking.impl.GPSFixMovingImpl;
import com.sap.sailing.domain.tracking.impl.WindImpl;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class Record implements Timed, Positioned {
private static final long serialVersionUID = -7939775022865795801L;
@@ -13,12 +13,12 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.Timeout;
import com.sap.sailing.domain.common.impl.MillisecondsTimePoint;
import com.sap.sailing.domain.igtimiadapter.datatypes.AntHrm;
import com.sap.sailing.domain.igtimiadapter.datatypes.Fix;
import com.sap.sailing.domain.igtimiadapter.datatypes.GpsLatLong;
import com.sap.sailing.domain.igtimiadapter.datatypes.GpsQualitySatCount;
import com.sap.sse.common.Util;
import com.sap.sse.common.impl.MillisecondsTimePoint;
public class FixFactoryTest {
@Rule public Timeout AbstractTracTracLiveTestTimeout = new Timeout(2 * 60 * 1000);
Loaded 100 of 2327 files, more files were not shown because too many files have changed in this diff. Show more