Merge branch 'master' into bug4339

This commit is contained in:
Steffen Schaefer committed 2018-04-23 16:53:45 +02:00
commit 322a4552db
11 files changed
+102 -56

No files matched your search

@@ -7,25 +7,29 @@ import com.sap.sse.common.settings.generic.IntegerSetting;
public class AutoplayPerspectiveOwnSettings extends AbstractGenericSerializableSettings {
private static final long serialVersionUID = -9013901094746556797L;
BooleanSetting fullscreen;
BooleanSetting switchToLive;
IntegerSetting timeToSwitchBeforeRaceStart;
private BooleanSetting fullscreen;
private BooleanSetting switchToLive;
private IntegerSetting timeToSwitchBeforeRaceStartInSeconds;
private IntegerSetting waitTimeAfterRaceEndInSeconds;
public AutoplayPerspectiveOwnSettings() {
}
public AutoplayPerspectiveOwnSettings(boolean fullscreen, boolean switchToLive, int timeToSwitchBeforeRaceStart) {
public AutoplayPerspectiveOwnSettings(boolean fullscreen, boolean switchToLive,
int timeToSwitchBeforeRaceStartInSeconds, int waitTimeAfterRaceEndInSeconds) {
super();
this.fullscreen.setValue(fullscreen);
this.switchToLive.setValue(switchToLive);
this.timeToSwitchBeforeRaceStart.setValue(timeToSwitchBeforeRaceStart);
this.timeToSwitchBeforeRaceStartInSeconds.setValue(timeToSwitchBeforeRaceStartInSeconds);
this.waitTimeAfterRaceEndInSeconds.setValue(waitTimeAfterRaceEndInSeconds);
}
@Override
protected void addChildSettings() {
fullscreen = new BooleanSetting("fullscreen", this, true);
switchToLive = new BooleanSetting("switchToLive", this, true);
timeToSwitchBeforeRaceStart = new IntegerSetting("timeToSwitchBeforeRaceStart", this, 180);
timeToSwitchBeforeRaceStartInSeconds = new IntegerSetting("timeToSwitchBeforeRaceStart", this, 180);
waitTimeAfterRaceEndInSeconds = new IntegerSetting("waitTimeAfterRaceEnd", this, 60);
}
@@ -37,7 +41,11 @@ public class AutoplayPerspectiveOwnSettings extends AbstractGenericSerializableS
return switchToLive.getValue();
}
public int getTimeToSwitchBeforeRaceStart() {
return timeToSwitchBeforeRaceStart.getValue();
public int getTimeToSwitchBeforeRaceStartInSeconds() {
return timeToSwitchBeforeRaceStartInSeconds.getValue();
}
public int getWaitTimeAfterRaceEndInSeconds() {
return waitTimeAfterRaceEndInSeconds.getValue();
}
}
@@ -12,21 +12,24 @@ import com.sap.sse.gwt.client.dialog.DataEntryDialog.Validator;
import com.sap.sse.gwt.client.shared.components.SettingsDialogComponent;
public class AutoplaySettingsDialogComponent implements SettingsDialogComponent<AutoplayPerspectiveOwnSettings> {
private AutoplayPerspectiveOwnSettings initialSettings;
private final AutoplayPerspectiveOwnSettings initialSettings;
private final StringMessages stringMessages;
private CheckBox fullScreen;
private CheckBox switchToLiveRaceAutomatically;
private IntegerBox timeBeforeRaceStartInput;
private IntegerBox waitTimeAfterRaceEndInput;
AutoplaySettingsDialogComponent(AutoplayPerspectiveOwnSettings settings) {
this.initialSettings = settings;
stringMessages = StringMessages.INSTANCE;
}
@Override
public Widget getAdditionalWidget(DataEntryDialog<?> dialog) {
VerticalPanel vp = new VerticalPanel();
StringMessages stringMessages = StringMessages.INSTANCE;
fullScreen = dialog.createCheckbox(stringMessages.startBrowserFullscreen());
fullScreen.setValue(initialSettings.isFullscreen());
vp.add(fullScreen);
@@ -38,8 +41,14 @@ public class AutoplaySettingsDialogComponent implements SettingsDialogComponent<
Label timeBeforeRaceStartDescription = new Label(stringMessages.timeBeforeRaceStart());
vp.add(timeBeforeRaceStartDescription);
timeBeforeRaceStartInput = dialog.createIntegerBox(initialSettings.getTimeToSwitchBeforeRaceStart(), 5);
timeBeforeRaceStartInput = dialog.createIntegerBox(initialSettings.getTimeToSwitchBeforeRaceStartInSeconds(), 5);
vp.add(timeBeforeRaceStartInput);
Label timeAfterRaceEndDescription = new Label(stringMessages.timeAfterRaceEnd());
vp.add(timeAfterRaceEndDescription);
waitTimeAfterRaceEndInput = dialog.createIntegerBox(initialSettings.getWaitTimeAfterRaceEndInSeconds(), 5);
vp.add(waitTimeAfterRaceEndInput);
return vp;
}
@@ -47,7 +56,7 @@ public class AutoplaySettingsDialogComponent implements SettingsDialogComponent<
@Override
public AutoplayPerspectiveOwnSettings getResult() {
return new AutoplayPerspectiveOwnSettings(fullScreen.getValue(), switchToLiveRaceAutomatically.getValue(),
timeBeforeRaceStartInput.getValue());
timeBeforeRaceStartInput.getValue(), waitTimeAfterRaceEndInput.getValue());
}
@Override
@@ -55,9 +64,9 @@ public class AutoplaySettingsDialogComponent implements SettingsDialogComponent<
return new Validator<AutoplayPerspectiveOwnSettings>() {
@Override
public String getErrorMessage(AutoplayPerspectiveOwnSettings valueToValidate) {
if (valueToValidate.timeToSwitchBeforeRaceStart.getValue() < 0) {
// TODO i18n
return "negative delay";
if (valueToValidate.getTimeToSwitchBeforeRaceStartInSeconds() < 0
|| valueToValidate.getWaitTimeAfterRaceEndInSeconds() < 0) {
return stringMessages.delaysMustNotBeNegative();
} else {
return null;
}
@@ -2,6 +2,7 @@ package com.sap.sailing.gwt.autoplay.client.nodes;
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
import com.sap.sailing.gwt.autoplay.client.app.AutoPlayClientFactory;
import com.sap.sailing.gwt.autoplay.client.app.AutoplayPerspectiveOwnSettings;
import com.sap.sailing.gwt.autoplay.client.events.FailureEvent;
import com.sap.sailing.gwt.autoplay.client.nodes.base.AutoPlayNode;
import com.sap.sailing.gwt.autoplay.client.nodes.base.RootNodeBase;
@@ -53,4 +54,16 @@ public class RootNodeClassic extends RootNodeBase {
transitionTo(idle);
}
@Override
protected long getSwitchBeforeRaceStartInMillis() {
AutoplayPerspectiveOwnSettings ownSettings = getClientFactory().getAutoPlayCtx().getAutoplaySettings().getPerspectiveOwnSettings();
return ownSettings.getTimeToSwitchBeforeRaceStartInSeconds() * 1000;
}
@Override
protected long getWaitTimeAfterRaceEndInMillis() {
AutoplayPerspectiveOwnSettings ownSettings = getClientFactory().getAutoPlayCtx().getAutoplaySettings().getPerspectiveOwnSettings();
return ownSettings.getWaitTimeAfterRaceEndInSeconds() * 1000;
}
}
@@ -82,4 +82,14 @@ public class RootNodeSixtyInch extends RootNodeBase {
}
transitionTo(idleLoop);
}
@Override
protected long getSwitchBeforeRaceStartInMillis() {
return 3*60*1000;
}
@Override
protected long getWaitTimeAfterRaceEndInMillis() {
return 60*1000;
}
}
@@ -95,7 +95,8 @@ public abstract class RootNodeBase extends BaseCompositeNode {
this.leaderBoardName = cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName();
AutoplayHelper.getLiveRace(cf.getSailingService(), cf.getErrorReporter(), cf.getAutoPlayCtx().getEvent(),
leaderBoardName, cf.getDispatch(), new AsyncCallback<Pair<Long, RegattaAndRaceIdentifier>>() {
leaderBoardName, cf.getDispatch(), getWaitTimeAfterRaceEndInMillis(),
getSwitchBeforeRaceStartInMillis(), new AsyncCallback<Pair<Long, RegattaAndRaceIdentifier>>() {
@Override
public void onSuccess(Pair<Long, RegattaAndRaceIdentifier> result) {
errorCount = 0;
@@ -142,6 +143,10 @@ public abstract class RootNodeBase extends BaseCompositeNode {
});
}
protected abstract long getSwitchBeforeRaceStartInMillis();
protected abstract long getWaitTimeAfterRaceEndInMillis();
private final void setCurrentState(boolean isPreLiveRace, RegattaAndRaceIdentifier liveRace, RootNodeState goingTo,
RootNodeState comingFrom) {
if (goingTo != comingFrom) {
@@ -44,9 +44,6 @@ import com.sap.sse.gwt.client.player.Timer;
import com.sap.sse.gwt.client.player.Timer.PlayModes;
public class AutoplayHelper {
private static final long PRE_RACE_DELAY = 180000;
private static final long WAIT_TIME_AFTER_END_OF_RACE_MIILIS = 60 * 1000; // 1 min
private static final RaceMapResources raceMapResources = GWT.create(RaceMapResources.class);
private static Timer fastCurrentTimeProvider = new Timer(PlayModes.Live,
/* delayBetweenAutoAdvancesInMilliseconds */1000l);
@@ -66,8 +63,8 @@ public class AutoplayHelper {
}
public static void getLiveRace(SailingServiceAsync sailingService, ErrorReporter errorReporter, EventDTO event,
String leaderBoardName, SailingDispatchSystem dispatch,
AsyncCallback<Pair<Long, RegattaAndRaceIdentifier>> callback) {
String leaderBoardName, SailingDispatchSystem dispatch, long waitTimeAfterRaceEndInMillis,
long switchBeforeRaceStartInMillis, AsyncCallback<Pair<Long, RegattaAndRaceIdentifier>> callback) {
if (fastCurrentTimeProvider.getRefreshInterval() != 1000) {
fastCurrentTimeProvider.setRefreshInterval(1000);
}
@@ -98,7 +95,8 @@ public class AutoplayHelper {
fastCurrentTimeProvider.adjustClientServerOffset(clientTimeWhenRequestWasSent, serverTimeDuringRequest,
clientTimeWhenResponseWasReceived);
Pair<Long, RegattaAndRaceIdentifier> timeToStartAndRaceIdentifier = checkForLiveRace(
selectedLeaderboard, serverTimeDuringRequest, raceTimesInfoProvider);
selectedLeaderboard, serverTimeDuringRequest, raceTimesInfoProvider,
waitTimeAfterRaceEndInMillis, switchBeforeRaceStartInMillis);
callback.onSuccess(timeToStartAndRaceIdentifier);
// kill old provider!
raceTimesInfoProvider.terminate();
@@ -125,7 +123,8 @@ public class AutoplayHelper {
* Side effect free method to get a LifeRace from a timesProvider and a leaderboard
*/
public static Pair<Long, RegattaAndRaceIdentifier> checkForLiveRace(AbstractLeaderboardDTO currentLeaderboard,
Date serverTimeDuringRequest, RaceTimesInfoProvider raceTimesInfoProvider) {
Date serverTimeDuringRequest, RaceTimesInfoProvider raceTimesInfoProvider,
long waitTimeAfterRaceEndInMillis, long switchBeforeRaceStartInMillis) {
Map<RegattaAndRaceIdentifier, RaceTimesInfoDTO> raceTimesInfos = raceTimesInfoProvider.getRaceTimesInfos();
for (RaceColumnDTO race : currentLeaderboard.getRaceList()) {
for (FleetDTO fleet : race.getFleets()) {
@@ -134,15 +133,16 @@ public class AutoplayHelper {
RaceTimesInfoDTO raceTimes = raceTimesInfos.get(raceIdentifier);
boolean notNullInRequiredValues = raceTimes != null && raceTimes.startOfTracking != null
&& raceTimes.getStartOfRace() != null;
boolean raceHasNotEndedOrOnlyRecentlyEnded = raceTimes.endOfRace == null
|| serverTimeDuringRequest.getTime()
- raceTimes.delayToLiveInMs < raceTimes.endOfRace.getTime()
+ WAIT_TIME_AFTER_END_OF_RACE_MIILIS;
+ waitTimeAfterRaceEndInMillis;
if (notNullInRequiredValues && raceHasNotEndedOrOnlyRecentlyEnded) {
long startTimeInMs = raceTimes.getStartOfRace().getTime();
long startIn = startTimeInMs - serverTimeDuringRequest.getTime() - raceTimes.delayToLiveInMs;
if (startIn <= PRE_RACE_DELAY && startIn > NEGATIVE_SANITY_CHECK) {
if (startIn <= switchBeforeRaceStartInMillis && startIn > NEGATIVE_SANITY_CHECK) {
startOfLifeRace = raceTimes.getStartOfRace();
return new Pair<Long, RegattaAndRaceIdentifier>(startIn, raceIdentifier);
}
@@ -1299,6 +1299,7 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages,
String startBrowserFullscreen();
String switchToLiveRaceAutomatically();
String timeBeforeRaceStart();
String timeAfterRaceEnd();
String showXYDiagram();
String xyDiagram();
String boatSpeed();
@@ -2152,11 +2153,12 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages,
String newExpeditionRace();
String newExpeditionCompetitor();
String selectOneCompetitorToMapTheImportedData();
String startTypingForSuggestions();
String startTypingForSuggestions();
String maneuverTable();
String speedIn();
String speedOut();
String selectAtLeastOneCompetitorManeuver();
String noDataManeuverTable();
String errorTryingToDetermineBoatLinkedToCompetitor(String raceColumnName, String leaderboardName, String message);
String delaysMustNotBeNegative();
}
@@ -1267,7 +1267,8 @@ startAutoplay=Start autoplay
autoplaySettings=Autoplay settings
startBrowserFullscreen=Start browser in fullscreen mode
switchToLiveRaceAutomatically=Switch to live race automatically
timeBeforeRaceStart=time before race start (in s)
timeBeforeRaceStart=Time to switch to race before race start (in s)
timeAfterRaceEnd=Time to show race after race end (in s)
errorTryingToGetEvents=Error trying to get events: {0}
showXYDiagram=Show x-y-diagram
xyDiagram=x-y-Diagram
@@ -2147,4 +2148,5 @@ speedIn=Speed in
speedOut=Speed out
selectAtLeastOneCompetitorManeuver=To show the maneuver table, select at least one competitor
noDataManeuverTable=There are no maneuvers detected yet
errorTryingToDetermineBoatLinkedToCompetitor=Error trying to determine boat linked to competitor {0} in leaderboard {1}: {2}
errorTryingToDetermineBoatLinkedToCompetitor=Error trying to determine boat linked to competitor {0} in leaderboard {1}: {2}
delaysMustNotBeNegative=Delays must not be negative
@@ -1256,7 +1256,8 @@ startAutoplay=Automatisches Abspielen starten
autoplaySettings=Einstellungen für automatisches Abspielen
startBrowserFullscreen=Browser im Vollbildmodus starten
switchToLiveRaceAutomatically=Automatisches Umschalten zum Live-Rennen
timeBeforeRaceStart=Zeit vor dem Rennstart (in s)
timeBeforeRaceStart=Zeitraum vor dem Rennstart, in welchem bereits das Rennen angezeigt wird (in s)
timeAfterRaceEnd=Zeit nach dem Rennende, in welchem noch das Rennen angezeigt wird (in s)
errorTryingToGetEvents=Fehler beim Laden von Veranstaltungen: {0}
createDefaultSettingsForAllRegattas=Standardeinstellungen für alle Regatten anlegen...
noOverallEventSelected=Keine übergeordnete Veranstaltung ausgewählt...
@@ -2143,4 +2144,5 @@ speedIn=Anfangsgeschwindigkeit
speedOut=Endgeschwindigkeit
selectAtLeastOneCompetitorManeuver=Um die Manövertabelle anzuzeigen, muss mindestens ein Teilnehmer ausgewählt werden
noDataManeuverTable=Es wurde noch keine Manöver erkannt
errorTryingToDetermineBoatLinkedToCompetitor=Fehler bei der Ermittlung des Bootes für Teilnehmer {0} in Ergebnisliste {1}: {2}
errorTryingToDetermineBoatLinkedToCompetitor=Fehler bei der Ermittlung des Bootes für Teilnehmer {0} in Ergebnisliste {1}: {2}
delaysMustNotBeNegative=Abhängige Zeiten dürfen nicht negativ sein
@@ -11,7 +11,9 @@ Require-Bundle: org.hamcrest;bundle-version="1.1.0",
com.sap.sse.mongodb;bundle-version="1.0.0",
org.mongodb.mongo-java-driver;bundle-version="2.13.0",
com.sap.sailing.domain.common,
com.sap.sse.common
com.sap.sse.common,
jcl.over.slf4j;bundle-version="1.6.4";resolution:=optional,
slf4j.api;bundle-version="1.6.4";resolution:=optional
Bundle-ClassPath: lib/cglib-nodep-2.2.3.jar,
.
Automatic-Module-Name: com.sap.sailing.selenium.test
@@ -1,27 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.sap.sailing.selenium.test"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[debug]" value="org.eclipse.jdt.junit.launchconfig"/>
<mapEntry key="[run]" value="org.eclipse.jdt.junit.launchconfig"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.sap.sailing.selenium.test"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8&quot; javaProject=&quot;com.sap.sailing.selenium.test&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#13;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;com.sap.sailing.selenium.test&quot;/&gt;&#13;&#10;&lt;/runtimeClasspathEntry&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.sap.sailing.targetplatform.base/plugins/target-base/jcl-over-slf4j-1.6.4.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/com.sap.sailing.targetplatform.base/plugins/target-base/slf4j-api-1.6.4.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.sap.sailing.selenium.test"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Dselenium.test.environment.configuration=local-test-environment.xml"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/com.sap.sailing.selenium.test"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[debug]" value="org.eclipse.jdt.junit.launchconfig"/>
<mapEntry key="[run]" value="org.eclipse.jdt.junit.launchconfig"/>
</mapAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.sap.sailing.selenium.test"/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.sap.sailing.selenium.test"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Dselenium.test.environment.configuration=local-test-environment.xml"/>
</launchConfiguration>