mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-11 14:50:56 +00:00
whenever a RaceDefinition is added to a persistent Regatta owned by RacingEventService, record persistently
This commit is contained in:
1 parent
32427f3a2d
commit
3208a21d1b
5 files changed
+30
-27
No files matched your search
@@ -346,11 +346,13 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
|
||||
/**
|
||||
* @param regattaToAddTo
|
||||
* if <code>null</code>, an existing regatta by the name of the TracTrac event with the boat class name
|
||||
* appended in parentheses will be looked up; if not found, a default regatta with that name will be
|
||||
* created, with a single default series and a single default fleet. If a valid {@link RegattaIdentifier}
|
||||
* is specified, a regatta lookup is performed with that identifier; if the regatta is found, it is used
|
||||
* to add the races to. Otherwise, a default regatta as described above will be created and used.
|
||||
* if <code>null</code> or no regatta by that identifier is found, an existing regatta by the name of the
|
||||
* TracTrac event with the boat class name appended in parentheses will be looked up; if not found, a
|
||||
* default regatta with that name will be created, with a single default series and a single default
|
||||
* fleet. If a valid {@link RegattaIdentifier} is specified, a regatta lookup is performed with that
|
||||
* identifier; if the regatta is found, it is used to add the races to, and
|
||||
* {@link #setRegattaForRace(Regatta, RaceDefinition)} is called to remember the association
|
||||
* persistently. Otherwise, a default regatta as described above will be created and used.
|
||||
* @param windStore
|
||||
* must not be <code>null</code>, but can, e.g., be an {@link EmptyWindStore}
|
||||
*/
|
||||
|
||||
+15
-3
@@ -570,11 +570,18 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
@Override
|
||||
public void addRace(RegattaIdentifier addToRegatta, RaceDefinition raceDefinition) {
|
||||
Regatta regatta = getRegatta(addToRegatta);
|
||||
regatta.addRace(raceDefinition); // will trigger the raceAdded operation because this service is listening on all its regattass
|
||||
regatta.addRace(raceDefinition); // will trigger the raceAdded operation because this service is listening on all its regattas
|
||||
}
|
||||
|
||||
/**
|
||||
* If the <code>regatta</code> {@link Regatta#isPersistent() is a persistent one}, the association of the race with the
|
||||
* regatta is remembered persistently so that {@link #getRememberedRegattaForRace(Serializable)} will provide it.
|
||||
*/
|
||||
@Override
|
||||
public void raceAdded(Regatta regatta, RaceDefinition raceDefinition) {
|
||||
if (regatta.isPersistent()) {
|
||||
setRegattaForRace(regatta, raceDefinition);
|
||||
}
|
||||
final CourseChangeReplicator listener = new CourseChangeReplicator(this, regatta, raceDefinition);
|
||||
courseListeners.put(raceDefinition, listener);
|
||||
raceDefinition.getCourse().addCourseListener(listener);
|
||||
@@ -1378,8 +1385,13 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
return persistentRegattasForRaceIDs.get(raceID.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRegattaForRace(Regatta regatta, RaceDefinition race) {
|
||||
/**
|
||||
* Persistently remembers the association of the race with its {@link RaceDefinition#getId()} to the
|
||||
* <code>regatta</code> with its {@link Regatta#getRegattaIdentifier() identifier} so that the next time
|
||||
* {@link #getRememberedRegattaForRace(RaceDefinition)} is called with <code>race</code> as argument,
|
||||
* <code>regatta</code> will be returned.
|
||||
*/
|
||||
private void setRegattaForRace(Regatta regatta, RaceDefinition race) {
|
||||
persistentRegattasForRaceIDs.put(race.getId().toString(), regatta);
|
||||
mongoObjectFactory.storeRegattaForRaceID(race.getId().toString(), regatta);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user