mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-22 21:55:39 +00:00
renamed further occurrences of "...event..." to "...regatta...", including XcelsiusApp servlet
This commit is contained in:
+20
-31
@@ -254,7 +254,7 @@ through the /moderator servlet. We may want to consider merging both
|
||||
into one in the future.
|
||||
|
||||
/admin
|
||||
action=listracesinevent: outputs a JSON object describing the
|
||||
action=listracesinregatta: outputs a JSON object describing the
|
||||
races and their paramURLs available for tracking in
|
||||
the following form:
|
||||
[ { "name": ..., // race name
|
||||
@@ -274,13 +274,13 @@ into one in the future.
|
||||
liveURI: the live data URI for the TracTrac server
|
||||
storedURI: the stored data URI for the TracTrac server; usually
|
||||
the port number of this URI is that of liveURI + 1
|
||||
action=stopevent: stops tracking of all races of the event; this
|
||||
also stops all wind tracking for the races of the event
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
action=stopregatta: stops tracking of all races of the regatta; this
|
||||
also stops all wind tracking for the races of the regatta
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
action=addrace: starts tracking a single race; if other races of
|
||||
the same event/regatta are already being tracked,
|
||||
the race is added to the event
|
||||
the race is added to the regatta
|
||||
paramURL: the URL from where metadata about the race
|
||||
can be obtained; the resulting document includes
|
||||
UUIDs of waypoints, competitors, etc.
|
||||
@@ -289,17 +289,17 @@ into one in the future.
|
||||
the port number of this URI is that of liveURI + 1
|
||||
action=stoprace: stops tracking of a single race, also stopping the
|
||||
wind trackers that were started for this race; other
|
||||
races of the same event that were being tracked will
|
||||
races of the same regatta that were being tracked will
|
||||
continue being tracked.
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
racename: name of the race, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
action=receiveexpeditionwind: starts a wind tracker that receives
|
||||
wind data through a UDP port from an Expedition
|
||||
client; the wind is fed into a wind track for the
|
||||
race specified by eventname/racename.
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
race specified by regattaname/racename.
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
racename: name of the race, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
@@ -309,14 +309,14 @@ into one in the future.
|
||||
time and location specified by the Expedition
|
||||
message.
|
||||
action=stopreceivingexpeditionwind: stops an expedition wind tracker
|
||||
for the race specified by eventname/racename
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
for the race specified by regattaname/racename
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
racename: name of the race, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
action=listwindtrackers: lists all wind trackers currently
|
||||
registered in the server instance. The output
|
||||
structure is an array of {eventname,racename,windtrackerinfo}
|
||||
structure is an array of {regattaname,racename,windtrackerinfo}
|
||||
objects where "windtrackerinfo" is a tracker type-specific
|
||||
string field which may contain, e.g., the tracker type
|
||||
name or, in case of a UDP port-based tracker,
|
||||
@@ -326,7 +326,7 @@ into one in the future.
|
||||
wind track of the race specified. If no time is
|
||||
specified, the measurement is assumed to have been
|
||||
taken at the current time.
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
racename: name of the race, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
@@ -351,7 +351,7 @@ into one in the future.
|
||||
will be used as the default. However, it's
|
||||
unlikely that this will match the time point
|
||||
of the wind to remove by the millisecond.
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
racename: name of the race, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
@@ -380,7 +380,7 @@ into one in the future.
|
||||
}
|
||||
"EXPEDITION": { ... }
|
||||
}
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
racename: name of the race, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
@@ -398,7 +398,7 @@ into one in the future.
|
||||
"windKnotSpeed": ..., // wind info
|
||||
"toLatDeg": ..., // translated position
|
||||
"toLngDeg" } // translated position
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
racename: name of the race, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
@@ -433,18 +433,7 @@ into one in the future.
|
||||
"team": [ { // the sailors forming the team
|
||||
"name": ...,
|
||||
"description": ... } ... ] } ... ]
|
||||
"races": [ // list of races in the event
|
||||
"name": ...,
|
||||
"boatclass": ...,
|
||||
"start": ..., // race start time as millisecond
|
||||
// timestamp, Integer.MAX_VALUE
|
||||
// if not started yet
|
||||
"legs": [ { // legs in the course's order
|
||||
"start": ..., // name of the leg start mark
|
||||
"end": ... } // name of the leg end mark
|
||||
... ]
|
||||
... ]
|
||||
action=listracesinevent: // list of races in the event
|
||||
"races": [ // list of races in the regatta
|
||||
"name": ...,
|
||||
"boatclass": ...,
|
||||
"start": ..., // race start time as millisecond
|
||||
@@ -469,7 +458,7 @@ into one in the future.
|
||||
"knotspeed": ..., // boat speed in knots
|
||||
"tack": [STARBOARD|PORT] } ... ] // side on which sails are
|
||||
} ... ] }
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
racename: name of the race, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
@@ -496,7 +485,7 @@ into one in the future.
|
||||
"name": ..., // buoy name
|
||||
"lat": ..., // optional; if buoy pos known
|
||||
"lng": ... } ... ] } // optionsl; if buoy pos known
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
racename: name of the race, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
@@ -570,7 +559,7 @@ into one in the future.
|
||||
"ranks": [ { // the overall total ranks, across legs
|
||||
"competitor": ..., // name of competitor
|
||||
"rank": ... } ... ] }
|
||||
eventname: name of the event, as returned by the "listevents"
|
||||
regattaname: name of the regatta, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
racename: name of the race, as returned by the "listevents"
|
||||
action on the /moderator servlet
|
||||
|
||||
+3
-3
@@ -79,19 +79,19 @@ public class ServerReplicationTest extends AbstractServerReplicationTest {
|
||||
BoatClass boatClass = masterDomainFactory.getOrCreateBoatClass(boatClassName, /* typicallyStartsUpwind */ true);
|
||||
final String baseEventName = "Test Event";
|
||||
AddRegatta addEventOperation = new AddRegatta(baseEventName, boatClassName, /* boatClassTypicallyStartsUpwind */ true);
|
||||
Regatta event = master.apply(addEventOperation);
|
||||
Regatta regatta = master.apply(addEventOperation);
|
||||
final String raceName = "Test Race";
|
||||
final CourseImpl masterCourse = new CourseImpl("Test Course", new ArrayList<Waypoint>());
|
||||
RaceDefinition race = new RaceDefinitionImpl(raceName, masterCourse, boatClass,
|
||||
new ArrayList<Competitor>());
|
||||
AddRaceDefinition addRaceOperation = new AddRaceDefinition(new RegattaName(event.getName()), race);
|
||||
AddRaceDefinition addRaceOperation = new AddRaceDefinition(new RegattaName(regatta.getName()), race);
|
||||
master.apply(addRaceOperation);
|
||||
masterCourse.addWaypoint(0, masterDomainFactory.createWaypoint(masterDomainFactory.getOrCreateBuoy("Buoy1")));
|
||||
masterCourse.addWaypoint(1, masterDomainFactory.createWaypoint(masterDomainFactory.getOrCreateBuoy("Buoy2")));
|
||||
masterCourse.addWaypoint(2, masterDomainFactory.createWaypoint(masterDomainFactory.getOrCreateBuoy("Buoy3")));
|
||||
masterCourse.removeWaypoint(1);
|
||||
Thread.sleep(1000); // wait 1s for JMS to deliver the message and the message to be applied
|
||||
Regatta replicaEvent = replica.getRegatta(new RegattaName(event.getName()));
|
||||
Regatta replicaEvent = replica.getRegatta(new RegattaName(regatta.getName()));
|
||||
assertNotNull(replicaEvent);
|
||||
RaceDefinition replicaRace = replicaEvent.getRaceByName(raceName);
|
||||
assertNotNull(replicaRace);
|
||||
|
||||
+3
-3
@@ -74,17 +74,17 @@ public class TrackedRaceContentsReplicationTest extends AbstractServerReplicatio
|
||||
new BoatImpl("GER 61", DomainFactory.INSTANCE.getOrCreateBoatClass("470", /* typicallyStartsUpwind */ true), "GER 61"));
|
||||
final String baseEventName = "Test Event";
|
||||
AddRegatta addEventOperation = new AddRegatta(baseEventName, boatClassName, /* boatClassTypicallyStartsUpwind */ true);
|
||||
Regatta event = master.apply(addEventOperation);
|
||||
Regatta regatta = master.apply(addEventOperation);
|
||||
final String raceName = "Test Race";
|
||||
final CourseImpl masterCourse = new CourseImpl("Test Course", new ArrayList<Waypoint>());
|
||||
RaceDefinition race = new RaceDefinitionImpl(raceName, masterCourse, boatClass, Collections.singletonList(competitor));
|
||||
AddRaceDefinition addRaceOperation = new AddRaceDefinition(new RegattaName(event.getName()), race);
|
||||
AddRaceDefinition addRaceOperation = new AddRaceDefinition(new RegattaName(regatta.getName()), race);
|
||||
master.apply(addRaceOperation);
|
||||
masterCourse.addWaypoint(0, masterDomainFactory.createWaypoint(masterDomainFactory.getOrCreateBuoy("Buoy1")));
|
||||
masterCourse.addWaypoint(1, masterDomainFactory.createWaypoint(masterDomainFactory.getOrCreateBuoy("Buoy2")));
|
||||
masterCourse.addWaypoint(2, masterDomainFactory.createWaypoint(masterDomainFactory.getOrCreateBuoy("Buoy3")));
|
||||
masterCourse.removeWaypoint(1);
|
||||
raceIdentifier = new RegattaNameAndRaceName(event.getName(), raceName);
|
||||
raceIdentifier = new RegattaNameAndRaceName(regatta.getName(), raceName);
|
||||
trackedRegatta = master.apply(new TrackRegatta(raceIdentifier));
|
||||
trackedRace = (DynamicTrackedRace) master.apply(new CreateTrackedRace(raceIdentifier,
|
||||
MongoWindStoreFactory.INSTANCE.getMongoWindStore(MongoFactory.INSTANCE.getDefaultMongoObjectFactory(),
|
||||
|
||||
+4
-4
@@ -15,7 +15,7 @@ import com.sap.sailing.domain.tracking.WindStore;
|
||||
public class RaceTrackerMock implements RaceTracker{
|
||||
|
||||
private Long id;
|
||||
private Regatta event;
|
||||
private Regatta regatta;
|
||||
private Set<RaceDefinition> raceDefinitions;
|
||||
private boolean isTracking;
|
||||
|
||||
@@ -25,10 +25,10 @@ public class RaceTrackerMock implements RaceTracker{
|
||||
|
||||
|
||||
|
||||
public RaceTrackerMock(Long id, Regatta event, Set<RaceDefinition> raceDefinitions, boolean isTracking) {
|
||||
public RaceTrackerMock(Long id, Regatta regatta, Set<RaceDefinition> raceDefinitions, boolean isTracking) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.event = event;
|
||||
this.regatta = regatta;
|
||||
this.raceDefinitions = raceDefinitions;
|
||||
this.isTracking = isTracking;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public class RaceTrackerMock implements RaceTracker{
|
||||
|
||||
@Override
|
||||
public Regatta getRegatta() {
|
||||
return event;
|
||||
return regatta;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+33
-33
@@ -41,7 +41,7 @@ public class RaceTrackerStartStopTest {
|
||||
private final static String BOATCLASSNAME = "HAPPYBOATCLASS";
|
||||
|
||||
private RacingEventServiceImplMock racingEventService;
|
||||
private Regatta event;
|
||||
private Regatta regatta;
|
||||
private BoatClass boatClass;
|
||||
private Set<RaceTracker> raceTrackerSet = new HashSet<RaceTracker>();
|
||||
|
||||
@@ -57,21 +57,21 @@ public class RaceTrackerStartStopTest {
|
||||
public void setUp() {
|
||||
racingEventService = new RacingEventServiceImplMock();
|
||||
boatClass = new BoatClassImpl(BOATCLASSNAME, /* typicallyStartsUpwind */ true);
|
||||
event = new RegattaImpl(EVENTNAME, boatClass);
|
||||
racingEventService.getEventsByName().put(EVENTNAME, event);
|
||||
TrackedRegatta trackedRegatta1 = racingEventService.getOrCreateTrackedRegatta(event);
|
||||
racingEventService.getEventsByNameMap().put(EVENTNAME, event);
|
||||
regatta = new RegattaImpl(EVENTNAME, boatClass);
|
||||
racingEventService.getEventsByName().put(EVENTNAME, regatta);
|
||||
TrackedRegatta trackedRegatta1 = racingEventService.getOrCreateTrackedRegatta(regatta);
|
||||
racingEventService.getEventsByNameMap().put(EVENTNAME, regatta);
|
||||
raceTrackerSet = new HashSet<RaceTracker>();
|
||||
raceDef1 = new RaceDefinitionImpl(RACENAME1, new CourseImpl("Course1", new ArrayList<Waypoint>()), boatClass, new ArrayList<Competitor>());
|
||||
raceDef2 = new RaceDefinitionImpl(RACENAME2, new CourseImpl("Course2", new ArrayList<Waypoint>()), boatClass, new ArrayList<Competitor>());
|
||||
raceDef3 = new RaceDefinitionImpl(RACENAME3, new CourseImpl("Course3", new ArrayList<Waypoint>()), boatClass, new ArrayList<Competitor>());
|
||||
event.addRace(raceDef1);
|
||||
regatta.addRace(raceDef1);
|
||||
trackedRegatta1.createTrackedRace(raceDef1, /* windStore */ EmptyWindStore.INSTANCE, /* millisecondsOverWhichToAverageWind */ 0l,
|
||||
/* millisecondsOverWhichToAverageSpeed */ 0l, /* raceDefinitionSetToUpdate */ null);
|
||||
event.addRace(raceDef2);
|
||||
regatta.addRace(raceDef2);
|
||||
trackedRegatta1.createTrackedRace(raceDef2, /* windStore */ EmptyWindStore.INSTANCE, /* millisecondsOverWhichToAverageWind */ 0l,
|
||||
/* millisecondsOverWhichToAverageSpeed */ 0l, /* raceDefinitionSetToUpdate */ null);
|
||||
event.addRace(raceDef3);
|
||||
regatta.addRace(raceDef3);
|
||||
trackedRegatta1.createTrackedRace(raceDef3, /* windStore */ EmptyWindStore.INSTANCE, /* millisecondsOverWhichToAverageWind */ 0l,
|
||||
/* millisecondsOverWhichToAverageSpeed */ 0l, /* raceDefinitionSetToUpdate */ null);
|
||||
Set<RaceDefinition> raceDefinitionSetRace1 = new HashSet<RaceDefinition>();
|
||||
@@ -86,13 +86,13 @@ public class RaceTrackerStartStopTest {
|
||||
Long trackerID1 = new Long(1);
|
||||
Long trackerID2 = new Long(2);
|
||||
Long trackerID3 = new Long(3);
|
||||
raceTracker1 = new RaceTrackerMock(new Long(1), event, raceDefinitionSetRace1, true);
|
||||
raceTracker2 = new RaceTrackerMock(new Long(2), event, raceDefinitionSetRace2, true);
|
||||
raceTracker3 = new RaceTrackerMock(new Long(3), event, raceDefinitionSetRace3, true);
|
||||
raceTracker1 = new RaceTrackerMock(new Long(1), regatta, raceDefinitionSetRace1, true);
|
||||
raceTracker2 = new RaceTrackerMock(new Long(2), regatta, raceDefinitionSetRace2, true);
|
||||
raceTracker3 = new RaceTrackerMock(new Long(3), regatta, raceDefinitionSetRace3, true);
|
||||
raceTrackerSet.add(raceTracker1);
|
||||
raceTrackerSet.add(raceTracker2);
|
||||
raceTrackerSet.add(raceTracker3);
|
||||
racingEventService.getRaceTrackersByEventMap().put(event, raceTrackerSet);
|
||||
racingEventService.getRaceTrackersByEventMap().put(regatta, raceTrackerSet);
|
||||
racingEventService.getRaceTrackersByIDMap().put(trackerID1, raceTracker1);
|
||||
racingEventService.getRaceTrackersByIDMap().put(trackerID2, raceTracker2);
|
||||
racingEventService.getRaceTrackersByIDMap().put(trackerID3, raceTracker3);
|
||||
@@ -103,14 +103,14 @@ public class RaceTrackerStartStopTest {
|
||||
*/
|
||||
@Test
|
||||
public void testStopTrackingRace() throws MalformedURLException, IOException, InterruptedException {
|
||||
Regatta event = racingEventService.getRegattaByName(EVENTNAME);
|
||||
TrackedRegatta trackedRegatta = racingEventService.getTrackedRegatta(event);
|
||||
assertNotNull(event.getRaceByName(RACENAME2));
|
||||
assertNotNull(trackedRegatta.getExistingTrackedRace(event.getRaceByName(RACENAME2)));
|
||||
racingEventService.stopTracking(event, raceDef2);
|
||||
Regatta regatta = racingEventService.getRegattaByName(EVENTNAME);
|
||||
TrackedRegatta trackedRegatta = racingEventService.getTrackedRegatta(regatta);
|
||||
assertNotNull(regatta.getRaceByName(RACENAME2));
|
||||
assertNotNull(trackedRegatta.getExistingTrackedRace(regatta.getRaceByName(RACENAME2)));
|
||||
racingEventService.stopTracking(regatta, raceDef2);
|
||||
// the raceDef2 should still be part of the event, and the corresponding tracked race should still be part
|
||||
// of the tracked event
|
||||
assertNotNull(event.getRaceByName(RACENAME2));
|
||||
assertNotNull(regatta.getRaceByName(RACENAME2));
|
||||
boolean foundTrackedRaceForRaceDef2 = false;
|
||||
for (TrackedRace trackedRace : trackedRegatta.getTrackedRaces()) {
|
||||
if (trackedRace.getRace().getName().equals(RACENAME2)) {
|
||||
@@ -129,7 +129,7 @@ public class RaceTrackerStartStopTest {
|
||||
// The RaceTrakcersByEvent map should contain a tracker with a set of RaceDefinitions, containing the
|
||||
// raceDefinition1
|
||||
assertEquals(1, racingEventService.getRaceTrackersByEventMap().size());
|
||||
Iterator<RaceTracker> raceTrackerIter = racingEventService.getRaceTrackersByEventMap().get(event).iterator();
|
||||
Iterator<RaceTracker> raceTrackerIter = racingEventService.getRaceTrackersByEventMap().get(regatta).iterator();
|
||||
while (raceTrackerIter.hasNext()) {
|
||||
RaceTracker currentTracker = raceTrackerIter.next();
|
||||
assertSame(raceTracker1, currentTracker);
|
||||
@@ -140,14 +140,14 @@ public class RaceTrackerStartStopTest {
|
||||
*/
|
||||
@Test
|
||||
public void testRemoveRace() throws MalformedURLException, IOException, InterruptedException {
|
||||
Regatta event = racingEventService.getRegattaByName(EVENTNAME);
|
||||
TrackedRegatta trackedRegatta = racingEventService.getTrackedRegatta(event);
|
||||
assertNotNull(event.getRaceByName(RACENAME2));
|
||||
assertNotNull(trackedRegatta.getExistingTrackedRace(event.getRaceByName(RACENAME2)));
|
||||
racingEventService.removeRace(event, raceDef2);
|
||||
Regatta regatta = racingEventService.getRegattaByName(EVENTNAME);
|
||||
TrackedRegatta trackedRegatta = racingEventService.getTrackedRegatta(regatta);
|
||||
assertNotNull(regatta.getRaceByName(RACENAME2));
|
||||
assertNotNull(trackedRegatta.getExistingTrackedRace(regatta.getRaceByName(RACENAME2)));
|
||||
racingEventService.removeRace(regatta, raceDef2);
|
||||
// the raceDef2 should be removed from the event, and the corresponding tracked race should be removed
|
||||
// from the tracked event
|
||||
assertNull(event.getRaceByName(RACENAME2));
|
||||
assertNull(regatta.getRaceByName(RACENAME2));
|
||||
boolean foundTrackedRaceForRaceDef2 = false;
|
||||
for (TrackedRace trackedRace : trackedRegatta.getTrackedRaces()) {
|
||||
if (trackedRace.getRace().getName().equals(RACENAME2)) {
|
||||
@@ -156,9 +156,9 @@ public class RaceTrackerStartStopTest {
|
||||
}
|
||||
assertFalse(foundTrackedRaceForRaceDef2);
|
||||
// The trackers map should still contain the raceTrackers
|
||||
assertTrue(racingEventService.getRaceTrackersByEventMap().get(event).contains(raceTracker1));
|
||||
assertTrue(racingEventService.getRaceTrackersByEventMap().get(event).contains(raceTracker2));
|
||||
assertTrue(racingEventService.getRaceTrackersByEventMap().get(event).contains(raceTracker3));
|
||||
assertTrue(racingEventService.getRaceTrackersByEventMap().get(regatta).contains(raceTracker1));
|
||||
assertTrue(racingEventService.getRaceTrackersByEventMap().get(regatta).contains(raceTracker2));
|
||||
assertTrue(racingEventService.getRaceTrackersByEventMap().get(regatta).contains(raceTracker3));
|
||||
// The raceTrackerMap should still contain the raceTrackers. These raceTracker should not contain the raceDefinition raceDef2 anymore
|
||||
assertTrue(racingEventService.getRaceTrackersByIDMap().containsValue(raceTracker1));
|
||||
assertTrue(racingEventService.getRaceTrackersByIDMap().containsValue(raceTracker2));
|
||||
@@ -181,12 +181,12 @@ public class RaceTrackerStartStopTest {
|
||||
*/
|
||||
@Test
|
||||
public void testRemoveLastRaceOfTracker() throws MalformedURLException, IOException, InterruptedException {
|
||||
racingEventService.removeRace(event, raceDef1);
|
||||
racingEventService.removeRace(event, raceDef2);
|
||||
racingEventService.removeRace(regatta, raceDef1);
|
||||
racingEventService.removeRace(regatta, raceDef2);
|
||||
// The event map should still contain the raceTrackers except of raceTracker1 and raceTracker2
|
||||
assertFalse(racingEventService.getRaceTrackersByEventMap().get(event).contains(raceTracker1));
|
||||
assertFalse(racingEventService.getRaceTrackersByEventMap().get(event).contains(raceTracker2));
|
||||
assertTrue(racingEventService.getRaceTrackersByEventMap().get(event).contains(raceTracker3));
|
||||
assertFalse(racingEventService.getRaceTrackersByEventMap().get(regatta).contains(raceTracker1));
|
||||
assertFalse(racingEventService.getRaceTrackersByEventMap().get(regatta).contains(raceTracker2));
|
||||
assertTrue(racingEventService.getRaceTrackersByEventMap().get(regatta).contains(raceTracker3));
|
||||
// The RaceTrackerByID map should still contain raceTracker3, but not raceTracker1 and raceTracker2 anymore
|
||||
assertFalse(racingEventService.getRaceTrackersByIDMap().containsValue(raceTracker1));
|
||||
assertFalse(racingEventService.getRaceTrackersByIDMap().containsValue(raceTracker2));
|
||||
|
||||
+3
-3
@@ -115,13 +115,13 @@ public class RaceTrackerTest {
|
||||
|
||||
/**
|
||||
* This test asserts that tracking the same race twice doesn't create another tracker and in particular no
|
||||
* new tracked event / tracked race.
|
||||
* new tracked regatta / tracked race.
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testTrackingSameRaceWithoutStopping() throws Exception {
|
||||
TrackedRegatta oldTrackedEvent = raceHandle.getTrackedEvent();
|
||||
TrackedRace oldTrackedRace = getTrackedRace(oldTrackedEvent);
|
||||
TrackedRegatta oldTrackedRegatta = raceHandle.getTrackedEvent();
|
||||
TrackedRace oldTrackedRace = getTrackedRace(oldTrackedRegatta);
|
||||
RacesHandle myRaceHandle = service.addTracTracRace(paramUrl, liveUri, storedUri, EmptyWindStore.INSTANCE, /* timeoutInMilliseconds */ 60000);
|
||||
TrackedRegatta newTrackedEvent = myRaceHandle.getTrackedEvent();
|
||||
TrackedRace newTrackedRace = getTrackedRace(newTrackedEvent);
|
||||
|
||||
@@ -48,11 +48,11 @@ import com.sap.sailing.expeditionconnector.ExpeditionListener;
|
||||
* An OSGi service that can be used to track boat races using a TracTrac connector that pushes
|
||||
* live GPS boat location, waypoint, coarse and mark passing data.<p>
|
||||
*
|
||||
* If a race/event is already being tracked, another {@link #addTracTracRace(URL, URI, URI, WindStore, long)} or
|
||||
* If a race/regatta is already being tracked, another {@link #addTracTracRace(URL, URI, URI, WindStore, long)} or
|
||||
* {@link #addRegatta(URL, URI, URI, WindStore, long)} call will have no effect, even if a different
|
||||
* {@link WindStore} is requested.<p>
|
||||
*
|
||||
* When the tracking of a race/event is {@link #stopTracking(Regatta, RaceDefinition) stopped}, the next
|
||||
* When the tracking of a race/regatta is {@link #stopTracking(Regatta, RaceDefinition) stopped}, the next
|
||||
* time it's started to be tracked, a new {@link TrackedRace} at least will be constructed. This also
|
||||
* means that when a {@link TrackedRegatta} exists that still holds other {@link TrackedRace}s, the
|
||||
* no longer tracked {@link TrackedRace} will be removed from the {@link TrackedRegatta}.
|
||||
@@ -64,7 +64,7 @@ import com.sap.sailing.expeditionconnector.ExpeditionListener;
|
||||
*/
|
||||
public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetcher, RaceFetcher {
|
||||
/**
|
||||
* @return a thread-safe copy of the events currently known by the service; it's safe for callers to iterate over
|
||||
* @return a thread-safe copy of the regattas currently known by the service; it's safe for callers to iterate over
|
||||
* the iterable returned, and no risk of a {@link ConcurrentModificationException} exists
|
||||
*/
|
||||
Iterable<Regatta> getAllRegattas();
|
||||
@@ -74,12 +74,12 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
@Override
|
||||
Regatta getRegatta(RegattaName regattaName);
|
||||
|
||||
Regatta getRegatta(RegattaIdentifier eventIdentifier);
|
||||
Regatta getRegatta(RegattaIdentifier regattaIdentifier);
|
||||
|
||||
@Override
|
||||
RaceDefinition getRace(RegattaAndRaceIdentifier raceIdentifier);
|
||||
|
||||
TrackedRace getTrackedRace(Regatta event, RaceDefinition r);
|
||||
TrackedRace getTrackedRace(Regatta regatta, RaceDefinition race);
|
||||
|
||||
TrackedRace getTrackedRace(RegattaAndRaceIdentifier raceIdentifier);
|
||||
|
||||
@@ -148,17 +148,17 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
throws MalformedURLException, FileNotFoundException, URISyntaxException, Exception;
|
||||
|
||||
/**
|
||||
* Stops tracking all races of the event specified. This will also stop tracking wind for all races of this event.
|
||||
* Stops tracking all races of the regatta specified. This will also stop tracking wind for all races of this regatta.
|
||||
* See {@link #stopTrackingWind(Regatta, RaceDefinition)}. If there were multiple calls to
|
||||
* {@link #addTracTracRace(URL, URI, URI, WindStore, long)} with an equal combination of URLs/URIs, the {@link TracTracRaceTracker}
|
||||
* already tracking the race was re-used. The trackers will be stopped by this call regardless of how many calls
|
||||
* were made that ensured they were tracking.
|
||||
*/
|
||||
void stopTracking(Regatta event) throws MalformedURLException, IOException, InterruptedException;
|
||||
void stopTracking(Regatta regatta) throws MalformedURLException, IOException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Removes <code>race</code> and any corresponding {@link #getTrackedRace(Regatta, RaceDefinition) tracked race} from
|
||||
* this service. If it was the last {@link RaceDefinition} in its {@link Regatta}, the <code>event</code> is removed
|
||||
* this service. If it was the last {@link RaceDefinition} in its {@link Regatta}, the <code>regatta</code> is removed
|
||||
* as well and will no longer be returned by {@link #getAllRegattas()}. The wind tracking is stopped for
|
||||
* <code>race</code>.
|
||||
* <p>
|
||||
@@ -170,12 +170,12 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
* {@link #getTrackedRace(Regatta, RaceDefinition) corresponding} {@link TrackedRace} as its
|
||||
* {@link RaceInLeaderboard#getTrackedRace()}.
|
||||
*
|
||||
* @param event
|
||||
* @param regatta
|
||||
* the event to remove
|
||||
* @param race
|
||||
* the race to remove
|
||||
*/
|
||||
void removeRace(Regatta event, RaceDefinition race) throws MalformedURLException, IOException,InterruptedException;
|
||||
void removeRace(Regatta regatta, RaceDefinition race) throws MalformedURLException, IOException,InterruptedException;
|
||||
|
||||
/**
|
||||
* Stops all {@link RaceTracker}s currently tracking <code>race</code>. Note that if the same tracker also may have
|
||||
@@ -185,7 +185,7 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
* same tracker) as well as the corresponding {@link TrackedRace}s will continue to exist, e.g., when asking
|
||||
* {@link #getTrackedRace(Regatta, RaceDefinition)}.
|
||||
*/
|
||||
void stopTracking(Regatta event, RaceDefinition race) throws MalformedURLException, IOException, InterruptedException;
|
||||
void stopTracking(Regatta regatta, RaceDefinition race) throws MalformedURLException, IOException, InterruptedException;
|
||||
|
||||
/**
|
||||
* @param port
|
||||
@@ -266,7 +266,7 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
|
||||
void storeSwissTimingDummyRace(String racMessage, String stlMesssage, String ccgMessage) throws IllegalArgumentException;
|
||||
|
||||
void stopTrackingAndRemove(Regatta event) throws MalformedURLException, IOException, InterruptedException;
|
||||
void stopTrackingAndRemove(Regatta regatta) throws MalformedURLException, IOException, InterruptedException;
|
||||
|
||||
void removeEvent(Regatta regatta) throws MalformedURLException, IOException, InterruptedException;
|
||||
|
||||
@@ -338,9 +338,9 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
* Adds <code>raceDefinition</code> to the {@link Regatta} such that it will appear in {@link Regatta#getAllRaces()}
|
||||
* and {@link Regatta#getRaceByName(String)}.
|
||||
*
|
||||
* @param addToEvent identifier of an event that must exist already
|
||||
* @param addToRegatta identifier of an regatta that must exist already
|
||||
*/
|
||||
void addRace(RegattaIdentifier addToEvent, RaceDefinition raceDefinition);
|
||||
void addRace(RegattaIdentifier addToRegatta, RaceDefinition raceDefinition);
|
||||
|
||||
void updateLeaderboardGroup(String oldName, String newName, String description, List<String> leaderboardNames);
|
||||
|
||||
@@ -366,12 +366,12 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
* Dual, reading operation for {@link #serializeForInitialReplication(ObjectOutputStream)}. In other words, when
|
||||
* this operation returns, this service instance is in a state "equivalent" to that of the service instance that
|
||||
* produced the stream contents in its {@link #serializeForInitialReplication(ObjectOutputStream)}. "Equivalent"
|
||||
* here means that a replica will have equal sets of events, tracked events, leaderboards and leaderboard groups but
|
||||
* here means that a replica will have equal sets of regattas, tracked regattas, leaderboards and leaderboard groups but
|
||||
* will not have any active trackers for wind or positions because it relies on these elements to be sent through
|
||||
* the replication channel.
|
||||
* <p>
|
||||
*
|
||||
* Tracked events read from the stream are observed (see {@link RaceListener}) by this object for automatic updates
|
||||
* Tracked regattas read from the stream are observed (see {@link RaceListener}) by this object for automatic updates
|
||||
* to the default leaderboard and for automatic linking to leaderboard columns. It is assumed that no explicit
|
||||
* replication of these operations will happen based on the changes performed on the replication master.<p>
|
||||
*
|
||||
|
||||
@@ -20,7 +20,7 @@ public abstract class Servlet extends HttpServlet {
|
||||
|
||||
protected static final String PARAM_ACTION = "action";
|
||||
|
||||
protected static final String PARAM_NAME_EVENTNAME = "eventname";
|
||||
protected static final String PARAM_NAME_REGATTANAME = "regattaname";
|
||||
|
||||
protected static final String PARAM_NAME_RACENAME = "racename";
|
||||
|
||||
@@ -40,16 +40,16 @@ public abstract class Servlet extends HttpServlet {
|
||||
return racingEventServiceTracker.getService();
|
||||
}
|
||||
|
||||
protected Regatta getEvent(HttpServletRequest req) {
|
||||
Regatta event = getService().getRegattaByName(req.getParameter(PARAM_NAME_EVENTNAME));
|
||||
return event;
|
||||
protected Regatta getRegatta(HttpServletRequest req) {
|
||||
Regatta regatta = getService().getRegattaByName(req.getParameter(PARAM_NAME_REGATTANAME));
|
||||
return regatta;
|
||||
}
|
||||
|
||||
protected RaceDefinition getRaceDefinition(HttpServletRequest req) {
|
||||
Regatta event = getEvent(req);
|
||||
if (event != null) {
|
||||
Regatta regatta = getRegatta(req);
|
||||
if (regatta != null) {
|
||||
String racename = req.getParameter(PARAM_NAME_RACENAME);
|
||||
for (RaceDefinition race : event.getAllRaces()) {
|
||||
for (RaceDefinition race : regatta.getAllRaces()) {
|
||||
if (race.getName().equals(racename)) {
|
||||
return race;
|
||||
}
|
||||
@@ -58,9 +58,9 @@ public abstract class Servlet extends HttpServlet {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected RaceDefinition getRaceDefinition(Regatta event, HttpServletRequest req) {
|
||||
protected RaceDefinition getRaceDefinition(Regatta regatta, HttpServletRequest req) {
|
||||
String racename = req.getParameter(PARAM_NAME_RACENAME);
|
||||
for (RaceDefinition race : event.getAllRaces()) {
|
||||
for (RaceDefinition race : regatta.getAllRaces()) {
|
||||
if (race.getName().equals(racename)) {
|
||||
return race;
|
||||
}
|
||||
@@ -86,11 +86,11 @@ public abstract class Servlet extends HttpServlet {
|
||||
}
|
||||
|
||||
protected TrackedRace getTrackedRace(HttpServletRequest req) {
|
||||
Regatta event = getEvent(req);
|
||||
Regatta regatta = getRegatta(req);
|
||||
RaceDefinition race = getRaceDefinition(req);
|
||||
TrackedRace trackedRace = null;
|
||||
if (event != null && race != null) {
|
||||
trackedRace = getService().getOrCreateTrackedRegatta(event).getTrackedRace(race);
|
||||
if (regatta != null && race != null) {
|
||||
trackedRace = getService().getOrCreateTrackedRegatta(regatta).getTrackedRace(race);
|
||||
}
|
||||
return trackedRace;
|
||||
}
|
||||
|
||||
@@ -57,9 +57,9 @@ public class AdminApp extends Servlet {
|
||||
|
||||
private static final String ACTION_NAME_ADD_RACE = "addrace";
|
||||
|
||||
private static final String ACTION_NAME_LIST_RACES_IN_EVENT = "listracesinevent";
|
||||
private static final String ACTION_NAME_LIST_RACES_IN_REGATTA = "listracesinregatta";
|
||||
|
||||
private static final String ACTION_NAME_STOP_EVENT = "stopevent";
|
||||
private static final String ACTION_NAME_STOP_REGATTA = "stopregatta";
|
||||
|
||||
private static final String ACTION_NAME_STOP_RACE = "stoprace";
|
||||
|
||||
@@ -127,11 +127,11 @@ public class AdminApp extends Servlet {
|
||||
if (action != null) {
|
||||
if (ACTION_NAME_ADD_EVENT.equals(action)) {
|
||||
addEvent(req, resp);
|
||||
} else if (ACTION_NAME_STOP_EVENT.equals(action)) {
|
||||
stopEvent(req, resp);
|
||||
} else if (ACTION_NAME_STOP_REGATTA.equals(action)) {
|
||||
stopRegatta(req, resp);
|
||||
} else if (ACTION_NAME_ADD_RACE.equals(action)) {
|
||||
addRace(req, resp);
|
||||
} else if (ACTION_NAME_LIST_RACES_IN_EVENT.equals(action)) {
|
||||
} else if (ACTION_NAME_LIST_RACES_IN_REGATTA.equals(action)) {
|
||||
listRacesInEvent(req, resp);
|
||||
} else if (ACTION_NAME_STOP_RACE.equals(action)) {
|
||||
stopRace(req, resp);
|
||||
@@ -164,7 +164,7 @@ public class AdminApp extends Servlet {
|
||||
}
|
||||
|
||||
private void setAveraging(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||
Regatta regatta = getEvent(req);
|
||||
Regatta regatta = getRegatta(req);
|
||||
if (regatta == null) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Event not found");
|
||||
} else {
|
||||
@@ -203,15 +203,15 @@ public class AdminApp extends Servlet {
|
||||
|
||||
private void addWindToMarks(HttpServletRequest req, HttpServletResponse resp) throws IOException,
|
||||
InvalidDateException, NoWindException {
|
||||
Regatta event = getEvent(req);
|
||||
if (event == null) {
|
||||
Regatta regatta = getRegatta(req);
|
||||
if (regatta == null) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Event not found");
|
||||
} else {
|
||||
RaceDefinition race = getRaceDefinition(req);
|
||||
if (race == null) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Race not found");
|
||||
} else {
|
||||
TrackedRace trackedRace = getService().getOrCreateTrackedRegatta(event).getTrackedRace(race);
|
||||
TrackedRace trackedRace = getService().getOrCreateTrackedRegatta(regatta).getTrackedRace(race);
|
||||
TimePoint time = getTimePoint(req, PARAM_NAME_TIME, PARAM_NAME_TIME_MILLIS, MillisecondsTimePoint.now());
|
||||
TimePoint oneHourLater = new MillisecondsTimePoint(time.asMillis()+3600*1000);
|
||||
String[] latitudes = req.getParameterValues(PARAM_NAME_LATDEG);
|
||||
@@ -225,7 +225,7 @@ public class AdminApp extends Servlet {
|
||||
Wind wind = trackedRace.getWind(pos, time);
|
||||
if (wind == null) {
|
||||
throw new NoWindException("No wind set for race "+race.getName()+
|
||||
" in event "+event.getName()+" while computing wind lines on marks");
|
||||
" in regatta "+regatta.getName()+" while computing wind lines on marks");
|
||||
}
|
||||
Distance d = wind.travel(time, oneHourLater);
|
||||
Position to = pos.translateGreatCircle(wind.getBearing(), d);
|
||||
@@ -245,15 +245,15 @@ public class AdminApp extends Servlet {
|
||||
}
|
||||
|
||||
private void showWind(HttpServletRequest req, HttpServletResponse resp) throws IOException, InvalidDateException {
|
||||
Regatta event = getEvent(req);
|
||||
if (event == null) {
|
||||
Regatta regatta = getRegatta(req);
|
||||
if (regatta == null) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Event not found");
|
||||
} else {
|
||||
RaceDefinition race = getRaceDefinition(req);
|
||||
if (race == null) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Race not found");
|
||||
} else {
|
||||
TrackedRace trackedRace = getService().getOrCreateTrackedRegatta(event).getTrackedRace(race);
|
||||
TrackedRace trackedRace = getService().getOrCreateTrackedRegatta(regatta).getTrackedRace(race);
|
||||
TimePoint from = getTimePoint(req, PARAM_NAME_FROM_TIME, PARAM_NAME_FROM_TIME_MILLIS,
|
||||
trackedRace.getStartOfRace()==null?new MillisecondsTimePoint(0):
|
||||
/* 24h before race start */ new MillisecondsTimePoint(trackedRace.getStartOfRace().asMillis()-24*3600*1000));
|
||||
@@ -299,18 +299,18 @@ public class AdminApp extends Servlet {
|
||||
}
|
||||
|
||||
private void setWind(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||
Regatta e = getEvent(req);
|
||||
Iterable<Regatta> events;
|
||||
Regatta e = getRegatta(req);
|
||||
Iterable<Regatta> regattas;
|
||||
if (e == null) {
|
||||
events = getService().getAllRegattas();
|
||||
regattas = getService().getAllRegattas();
|
||||
} else {
|
||||
events = Collections.singleton(e);
|
||||
regattas = Collections.singleton(e);
|
||||
}
|
||||
for (Regatta event : events) {
|
||||
RaceDefinition r = getRaceDefinition(event, req);
|
||||
for (Regatta regatta : regattas) {
|
||||
RaceDefinition r = getRaceDefinition(regatta, req);
|
||||
Iterable<RaceDefinition> races;
|
||||
if (r == null) {
|
||||
races = event.getAllRaces();
|
||||
races = regatta.getAllRaces();
|
||||
} else {
|
||||
races = Collections.singleton(r);
|
||||
}
|
||||
@@ -337,7 +337,7 @@ public class AdminApp extends Servlet {
|
||||
try {
|
||||
TimePoint timePoint = getTimePoint(req, PARAM_NAME_TIME, PARAM_NAME_TIME_MILLIS, MillisecondsTimePoint.now());
|
||||
Wind wind = new WindImpl(p, timePoint, speed);
|
||||
final DynamicTrackedRace trackedRace = getService().getOrCreateTrackedRegatta(event).getTrackedRace(race);
|
||||
final DynamicTrackedRace trackedRace = getService().getOrCreateTrackedRegatta(regatta).getTrackedRace(race);
|
||||
trackedRace.recordWind(wind, trackedRace.getWindSources(WindSourceType.WEB).iterator().next());
|
||||
} catch (InvalidDateException ex) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Couldn't parse time specification " + ex.getMessage());
|
||||
@@ -350,8 +350,8 @@ public class AdminApp extends Servlet {
|
||||
}
|
||||
|
||||
private void removeWind(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||
Regatta event = getEvent(req);
|
||||
if (event == null) {
|
||||
Regatta regatta = getRegatta(req);
|
||||
if (regatta == null) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Event not found");
|
||||
} else {
|
||||
RaceDefinition race = getRaceDefinition(req);
|
||||
@@ -367,7 +367,7 @@ public class AdminApp extends Servlet {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Wind source type name " + sourceName + " unknown");
|
||||
} else {
|
||||
try {
|
||||
final DynamicTrackedRace trackedRace = getService().getOrCreateTrackedRegatta(event)
|
||||
final DynamicTrackedRace trackedRace = getService().getOrCreateTrackedRegatta(regatta)
|
||||
.getTrackedRace(race);
|
||||
WindTrack windTrack = trackedRace.getOrCreateWindTrack(trackedRace.getWindSources(windSourceType).iterator().next());
|
||||
TimePoint timePoint = getTimePoint(req, PARAM_NAME_TIME, PARAM_NAME_TIME_MILLIS,
|
||||
@@ -378,7 +378,7 @@ public class AdminApp extends Servlet {
|
||||
resp.getWriter().println("Successfully removed entry "+wind);
|
||||
} else {
|
||||
resp.getWriter().println(
|
||||
"No wind recorded for event " + event.getName() + " and race " + race.getName()
|
||||
"No wind recorded for regatta " + regatta.getName() + " and race " + race.getName()
|
||||
+ " at " + timePoint.asDate()+". No error, just no effect :-)");
|
||||
}
|
||||
} catch (InvalidDateException e) {
|
||||
@@ -392,33 +392,33 @@ public class AdminApp extends Servlet {
|
||||
|
||||
private void listWindTrackers(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||
JSONArray windTrackers = new JSONArray();
|
||||
for (Triple<Regatta, RaceDefinition, String> eventAndRaceAndPort : getService().getWindTrackedRaces()) {
|
||||
for (Triple<Regatta, RaceDefinition, String> regattaAndRaceAndPort : getService().getWindTrackedRaces()) {
|
||||
JSONObject windTracker = new JSONObject();
|
||||
windTracker.put("eventname", eventAndRaceAndPort.getA().getName());
|
||||
windTracker.put("racename", eventAndRaceAndPort.getB().getName());
|
||||
windTracker.put("windtrackerinfo", eventAndRaceAndPort.getC());
|
||||
windTracker.put("regattaname", regattaAndRaceAndPort.getA().getName());
|
||||
windTracker.put("racename", regattaAndRaceAndPort.getB().getName());
|
||||
windTracker.put("windtrackerinfo", regattaAndRaceAndPort.getC());
|
||||
windTrackers.add(windTracker);
|
||||
}
|
||||
windTrackers.writeJSONString(resp.getWriter());
|
||||
}
|
||||
|
||||
private void stopReceivingExpeditionWindForRace(HttpServletRequest req, HttpServletResponse resp) throws SocketException, IOException {
|
||||
Regatta event = getEvent(req);
|
||||
if (event == null) {
|
||||
Regatta regatta = getRegatta(req);
|
||||
if (regatta == null) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Event not found");
|
||||
} else {
|
||||
RaceDefinition race = getRaceDefinition(req);
|
||||
if (race == null) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Race not found");
|
||||
} else {
|
||||
getService().stopTrackingWind(event, race);
|
||||
getService().stopTrackingWind(regatta, race);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void startReceivingExpeditionWindForRace(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||
Regatta event = getEvent(req);
|
||||
if (event == null) {
|
||||
Regatta regatta = getRegatta(req);
|
||||
if (regatta == null) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Event not found");
|
||||
} else {
|
||||
RaceDefinition race = getRaceDefinition(req);
|
||||
@@ -431,17 +431,17 @@ public class AdminApp extends Servlet {
|
||||
} else {
|
||||
String correctByDeclination = req
|
||||
.getParameter(PARAM_NAME_CORRECT_EXPEDITION_WIND_BEARING_BY_DECLINATION);
|
||||
getService().startTrackingWind(event, race, Boolean.valueOf(correctByDeclination));
|
||||
getService().startTrackingWind(regatta, race, Boolean.valueOf(correctByDeclination));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void stopEvent(HttpServletRequest req, HttpServletResponse resp) throws MalformedURLException, IOException,
|
||||
private void stopRegatta(HttpServletRequest req, HttpServletResponse resp) throws MalformedURLException, IOException,
|
||||
InterruptedException {
|
||||
Regatta event = getEvent(req);
|
||||
if (event != null) {
|
||||
getService().stopTracking(event);
|
||||
Regatta regatta = getRegatta(req);
|
||||
if (regatta != null) {
|
||||
getService().stopTracking(regatta);
|
||||
} else {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Event not found");
|
||||
}
|
||||
@@ -479,16 +479,16 @@ public class AdminApp extends Servlet {
|
||||
}
|
||||
|
||||
private void stopRace(HttpServletRequest req, HttpServletResponse resp) throws MalformedURLException, IOException, InterruptedException {
|
||||
Regatta event = getEvent(req);
|
||||
if (event != null) {
|
||||
Regatta regatta = getRegatta(req);
|
||||
if (regatta != null) {
|
||||
RaceDefinition race = getRaceDefinition(req);
|
||||
if (race == null) {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Race not found");
|
||||
} else {
|
||||
getService().stopTracking(event, race);
|
||||
getService().stopTracking(regatta, race);
|
||||
}
|
||||
} else {
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Event not found");
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Regatta not found");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ public class CourseChangeReplicator implements CourseListener {
|
||||
private final RegattaAndRaceIdentifier raceIdentifier;
|
||||
private final RacingEventServiceImpl replicator;
|
||||
|
||||
public CourseChangeReplicator(RacingEventServiceImpl replicator, Regatta event, RaceDefinition raceDefinition) {
|
||||
raceIdentifier = new RegattaNameAndRaceName(event.getName(), raceDefinition.getName());
|
||||
public CourseChangeReplicator(RacingEventServiceImpl replicator, Regatta regatta, RaceDefinition raceDefinition) {
|
||||
raceIdentifier = new RegattaNameAndRaceName(regatta.getName(), raceDefinition.getName());
|
||||
this.replicator = replicator;
|
||||
}
|
||||
|
||||
|
||||
@@ -349,15 +349,16 @@ public class ModeratorApp extends Servlet {
|
||||
}
|
||||
|
||||
private void listEvents(HttpServletResponse resp) throws IOException {
|
||||
JSONArray eventList = new JSONArray();
|
||||
for (Regatta event : getService().getAllRegattas()) {
|
||||
// TODO one a new top-level event will have been introduced, produce it here
|
||||
JSONArray regattaList = new JSONArray();
|
||||
for (Regatta regatta : getService().getAllRegattas()) {
|
||||
JSONObject jsonEvent = new JSONObject();
|
||||
jsonEvent.put("name", event.getName());
|
||||
if (event.getBoatClass() != null) {
|
||||
jsonEvent.put("boatclass", event.getBoatClass().getName());
|
||||
jsonEvent.put("name", regatta.getName());
|
||||
if (regatta.getBoatClass() != null) {
|
||||
jsonEvent.put("boatclass", regatta.getBoatClass().getName());
|
||||
}
|
||||
JSONArray jsonCompetitors = new JSONArray();
|
||||
for (Competitor competitor : event.getCompetitors()) {
|
||||
for (Competitor competitor : regatta.getCompetitors()) {
|
||||
JSONObject jsonCompetitor = new JSONObject();
|
||||
jsonCompetitor.put("name", competitor.getName());
|
||||
jsonCompetitor.put("nationality", competitor.getTeam().getNationality().getThreeLetterIOCAcronym());
|
||||
@@ -376,9 +377,9 @@ public class ModeratorApp extends Servlet {
|
||||
}
|
||||
jsonEvent.put("competitors", jsonCompetitors);
|
||||
JSONArray jsonRaces = new JSONArray();
|
||||
for (RaceDefinition race : event.getAllRaces()) {
|
||||
for (RaceDefinition race : regatta.getAllRaces()) {
|
||||
// don't wait for the arrival of a tracked race; just ignore it if it's not currently being tracked
|
||||
TrackedRace trackedRace = getService().getOrCreateTrackedRegatta(event).getExistingTrackedRace(race);
|
||||
TrackedRace trackedRace = getService().getOrCreateTrackedRegatta(regatta).getExistingTrackedRace(race);
|
||||
if (trackedRace != null) {
|
||||
JSONObject jsonRace = new JSONObject();
|
||||
jsonRace.put("name", race.getName());
|
||||
@@ -397,8 +398,8 @@ public class ModeratorApp extends Servlet {
|
||||
}
|
||||
}
|
||||
jsonEvent.put("races", jsonRaces);
|
||||
eventList.add(jsonEvent);
|
||||
regattaList.add(jsonEvent);
|
||||
}
|
||||
eventList.writeJSONString(resp.getWriter());
|
||||
regattaList.writeJSONString(resp.getWriter());
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -462,8 +462,8 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
|
||||
@Override
|
||||
public void addRace(RegattaIdentifier addToRegatta, RaceDefinition raceDefinition) {
|
||||
Regatta event = getRegatta(addToRegatta);
|
||||
event.addRace(raceDefinition); // will trigger the raceAdded operation because this service is listening on all its events
|
||||
Regatta regatta = getRegatta(addToRegatta);
|
||||
regatta.addRace(raceDefinition); // will trigger the raceAdded operation because this service is listening on all its regattass
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -891,12 +891,12 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackedRace getTrackedRace(Regatta e, RaceDefinition r) {
|
||||
return getOrCreateTrackedRegatta(e).getTrackedRace(r);
|
||||
public TrackedRace getTrackedRace(Regatta regatta, RaceDefinition race) {
|
||||
return getOrCreateTrackedRegatta(regatta).getTrackedRace(race);
|
||||
}
|
||||
|
||||
private TrackedRace getExistingTrackedRace(Regatta e, RaceDefinition r) {
|
||||
return getOrCreateTrackedRegatta(e).getExistingTrackedRace(r);
|
||||
private TrackedRace getExistingTrackedRace(Regatta regatta, RaceDefinition race) {
|
||||
return getOrCreateTrackedRegatta(regatta).getExistingTrackedRace(race);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -7,12 +7,12 @@ import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class AddRaceDefinition extends AbstractRacingEventServiceOperation<Void> {
|
||||
private static final long serialVersionUID = -2282997511967012426L;
|
||||
private final RegattaIdentifier eventIdentifier;
|
||||
private final RegattaIdentifier regattaIdentifier;
|
||||
private final RaceDefinition raceDefinition;
|
||||
|
||||
public AddRaceDefinition(RegattaIdentifier eventIdentifier, RaceDefinition raceDefinition) {
|
||||
public AddRaceDefinition(RegattaIdentifier regattaIdentifier, RaceDefinition raceDefinition) {
|
||||
super();
|
||||
this.eventIdentifier = eventIdentifier;
|
||||
this.regattaIdentifier = regattaIdentifier;
|
||||
this.raceDefinition = raceDefinition;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AddRaceDefinition extends AbstractRacingEventServiceOperation<Void>
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) {
|
||||
toState.addRace(eventIdentifier, raceDefinition);
|
||||
toState.addRace(regattaIdentifier, raceDefinition);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -29,12 +29,12 @@ public class RemoveAndUntrackRace extends AbstractRaceOperation<Void> {
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) {
|
||||
Regatta event = toState.getRegatta(getRaceIdentifier());
|
||||
if (event!= null) {
|
||||
RaceDefinition race = event.getRaceByName(getRaceIdentifier().getRaceName());
|
||||
Regatta regatta = toState.getRegatta(getRaceIdentifier());
|
||||
if (regatta!= null) {
|
||||
RaceDefinition race = regatta.getRaceByName(getRaceIdentifier().getRaceName());
|
||||
if (race != null) {
|
||||
try {
|
||||
toState.removeRace(event, race);
|
||||
toState.removeRace(regatta, race);
|
||||
} catch (IOException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
+3
-3
@@ -15,11 +15,11 @@ public class StopTrackingRace extends AbstractRaceOperation<Void> {
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) throws Exception {
|
||||
Regatta event = toState.getRegatta(getRaceIdentifier());
|
||||
if (event != null) {
|
||||
Regatta regatta = toState.getRegatta(getRaceIdentifier());
|
||||
if (regatta != null) {
|
||||
RaceDefinition r = toState.getRace(getRaceIdentifier());
|
||||
if (r != null) {
|
||||
toState.stopTracking(event, r);
|
||||
toState.stopTracking(regatta, r);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
+3
-3
@@ -19,9 +19,9 @@ public class StopTrackingRegatta extends AbstractRacingEventServiceOperation<Voi
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) throws MalformedURLException, IOException, InterruptedException {
|
||||
Regatta event = toState.getRegatta(regattaIdentifier);
|
||||
if (event != null) {
|
||||
toState.stopTracking(event);
|
||||
Regatta regatta = toState.getRegatta(regattaIdentifier);
|
||||
if (regatta != null) {
|
||||
toState.stopTracking(regatta);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+23
-31
@@ -48,50 +48,42 @@ public class Action {
|
||||
return service;
|
||||
}
|
||||
|
||||
public HashMap<String, Regatta> getEvents() {
|
||||
public HashMap<String, Regatta> getRegattas() {
|
||||
final HashMap<String, Regatta> result = new HashMap<String, Regatta>();
|
||||
|
||||
for (final Regatta event : this.service.getAllRegattas()) {
|
||||
result.put(event.getName(), event);
|
||||
for (final Regatta regatta : this.service.getAllRegattas()) {
|
||||
result.put(regatta.getName(), regatta);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public Regatta getEvent() throws IOException {
|
||||
public Regatta getRegatta() throws IOException {
|
||||
/*
|
||||
* EVENT
|
||||
* REGATTA
|
||||
*/
|
||||
final String regattaName = getAttribute("event");
|
||||
|
||||
final String regattaName = getAttribute("regatta");
|
||||
if (regattaName == null) {
|
||||
say("Use the event= parameter to specify the event");
|
||||
|
||||
say("Use the regatta= parameter to specify the regatta");
|
||||
return null;
|
||||
}
|
||||
|
||||
final Regatta event = getEvent(regattaName);
|
||||
|
||||
if (event == null) {
|
||||
say("Event " + regattaName + " not found.");
|
||||
|
||||
final Regatta regatta = getEvent(regattaName);
|
||||
if (regatta == null) {
|
||||
say("Regatta " + regattaName + " not found.");
|
||||
return null;
|
||||
}
|
||||
|
||||
return event;
|
||||
return regatta;
|
||||
}
|
||||
|
||||
public Regatta getEvent(String name) {
|
||||
for (final Regatta event : this.service.getAllRegattas()) {
|
||||
if (name.equals(event.getName())) {
|
||||
return event;
|
||||
for (final Regatta regatta : this.service.getAllRegattas()) {
|
||||
if (name.equals(regatta.getName())) {
|
||||
return regatta;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public RaceDefinition getRace(Regatta event) throws IOException {
|
||||
public RaceDefinition getRace(Regatta regatta) throws IOException {
|
||||
/*
|
||||
* Get the race
|
||||
*/
|
||||
@@ -106,7 +98,7 @@ public class Action {
|
||||
/*
|
||||
* RACE
|
||||
*/
|
||||
final RaceDefinition race = getRace(event, raceName);
|
||||
final RaceDefinition race = getRace(regatta, raceName);
|
||||
|
||||
if (race == null) {
|
||||
say("Race " + raceName + " not found.");
|
||||
@@ -117,19 +109,19 @@ public class Action {
|
||||
return race;
|
||||
}
|
||||
|
||||
public HashMap<String, RaceDefinition> getRaces(Regatta event) {
|
||||
public HashMap<String, RaceDefinition> getRaces(Regatta regatta) {
|
||||
final HashMap<String, RaceDefinition> result = new HashMap<String, RaceDefinition>();
|
||||
|
||||
for (final RaceDefinition race : event.getAllRaces()) {
|
||||
for (final RaceDefinition race : regatta.getAllRaces()) {
|
||||
result.put(race.getName(), race);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public RaceDefinition getRace(Regatta event, String name) {
|
||||
if ((event != null) && (name != null)) {
|
||||
for (RaceDefinition race : event.getAllRaces()) {
|
||||
public RaceDefinition getRace(Regatta regatta, String name) {
|
||||
if ((regatta != null) && (name != null)) {
|
||||
for (RaceDefinition race : regatta.getAllRaces()) {
|
||||
if (name.equals(race.getName())) {
|
||||
return race;
|
||||
}
|
||||
@@ -139,8 +131,8 @@ public class Action {
|
||||
return null;
|
||||
}
|
||||
|
||||
public TrackedRace getTrackedRace(Regatta event, RaceDefinition race) throws IOException {
|
||||
DynamicTrackedRegatta trackedRegatta = getService().getOrCreateTrackedRegatta(event);
|
||||
public TrackedRace getTrackedRace(Regatta regatta, RaceDefinition race) throws IOException {
|
||||
DynamicTrackedRegatta trackedRegatta = getService().getOrCreateTrackedRegatta(regatta);
|
||||
TrackedRace trackedRace = trackedRegatta == null ? null : trackedRegatta.getExistingTrackedRace(race);
|
||||
return trackedRace;
|
||||
}
|
||||
|
||||
+3
-3
@@ -44,9 +44,9 @@ public class GPSPerRace extends Action {
|
||||
|
||||
public void perform() throws Exception {
|
||||
// Get data from request
|
||||
final Regatta event = getEvent();
|
||||
final RaceDefinition race = getRace(event);
|
||||
final TrackedRace trackedRace = getTrackedRace(event, race);
|
||||
final Regatta regatta = getRegatta();
|
||||
final RaceDefinition race = getRace(regatta);
|
||||
final TrackedRace trackedRace = getTrackedRace(regatta, race);
|
||||
if (trackedRace != null) {
|
||||
final TimePoint time = getTimePoint(trackedRace);
|
||||
// Prepare document
|
||||
|
||||
+5
-5
@@ -34,13 +34,13 @@ public class ListEvents extends Action {
|
||||
public void perform() throws Exception {
|
||||
final Document table = getTable("data");
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm zzz");
|
||||
final HashMap<String, Regatta> events = getEvents();
|
||||
for (final String regattaName : events.keySet()) {
|
||||
final Regatta event = events.get(regattaName);
|
||||
final HashMap<String, RaceDefinition> races = getRaces(event);
|
||||
final HashMap<String, Regatta> regattas = getRegattas();
|
||||
for (final String regattaName : regattas.keySet()) {
|
||||
final Regatta regatta = regattas.get(regattaName);
|
||||
final HashMap<String, RaceDefinition> races = getRaces(regatta);
|
||||
for (final String raceName : races.keySet()) {
|
||||
RaceDefinition race = races.get(raceName);
|
||||
final TrackedRace trackedRace = getTrackedRace(event, race);
|
||||
final TrackedRace trackedRace = getTrackedRace(regatta, race);
|
||||
if (trackedRace != null) {
|
||||
addRow();
|
||||
addColumn(race.getBoatClass().getName());
|
||||
|
||||
+3
-3
@@ -42,9 +42,9 @@ public class RankPerLeg extends Action {
|
||||
|
||||
public void perform() throws Exception {
|
||||
// Get data from request
|
||||
final Regatta event = getEvent();
|
||||
final RaceDefinition race = getRace(event);
|
||||
final TrackedRace trackedRace = getTrackedRace(event, race);
|
||||
final Regatta regatta = getRegatta();
|
||||
final RaceDefinition race = getRace(regatta);
|
||||
final TrackedRace trackedRace = getTrackedRace(regatta, race);
|
||||
if (trackedRace != null) {
|
||||
final TimePoint time = getTimePoint(trackedRace);
|
||||
// Prepare document
|
||||
|
||||
+3
-3
@@ -41,10 +41,10 @@ public class RankPerLeg2 extends Action {
|
||||
|
||||
public void perform() throws Exception {
|
||||
// Get data from request
|
||||
final Regatta event = getEvent();
|
||||
final RaceDefinition race = getRace(event);
|
||||
final Regatta regatta = getRegatta();
|
||||
final RaceDefinition race = getRace(regatta);
|
||||
if (race != null) {
|
||||
final TrackedRace trackedRace = getTrackedRace(event, race);
|
||||
final TrackedRace trackedRace = getTrackedRace(regatta, race);
|
||||
if (trackedRace != null) {
|
||||
final TimePoint time = getTimePoint(trackedRace);
|
||||
// Prepare document
|
||||
|
||||
+3
-3
@@ -39,9 +39,9 @@ public class RankPerRace extends Action {
|
||||
|
||||
public void perform() throws Exception {
|
||||
// Get data from request
|
||||
final Regatta event = getEvent();
|
||||
final RaceDefinition race = getRace(event);
|
||||
final TrackedRace trackedRace = getTrackedRace(event, race);
|
||||
final Regatta regatta = getRegatta();
|
||||
final RaceDefinition race = getRace(regatta);
|
||||
final TrackedRace trackedRace = getTrackedRace(regatta, race);
|
||||
if (trackedRace != null) {
|
||||
final TimePoint time = getTimePoint(trackedRace);
|
||||
// Prepare document
|
||||
|
||||
Reference in New Issue
Block a user