mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 18:33:54 +00:00
addressing bug 733: looking up a Regatta by raceID first in RacingEventService before using a default regatta
This commit is contained in:
1 parent
6518cd4569
commit
32427f3a2d
8 files changed
+35
-10
No files matched your search
+4
-1
@@ -93,7 +93,10 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
|
||||
@Override
|
||||
public Regatta getOrCreateRegatta(String raceID, TrackedRegattaRegistry trackedRegattaRegistry) {
|
||||
Regatta result = raceIDToRegattaCache.get(raceID);
|
||||
Regatta result = trackedRegattaRegistry.getRememberedRegattaForRace(raceID);
|
||||
if (result == null) {
|
||||
result = raceIDToRegattaCache.get(raceID);
|
||||
}
|
||||
if (result == null) {
|
||||
result = new RegattaImpl(raceID, null, trackedRegattaRegistry);
|
||||
logger.info("Created regatta "+result.getName()+" ("+result.hashCode()+")");
|
||||
|
||||
-1
@@ -73,7 +73,6 @@ public class SwissTimingRaceTrackerImpl extends AbstractRaceTrackerImpl implemen
|
||||
DomainFactory domainFactory, SwissTimingFactory factory, RaceSpecificMessageLoader messageLoader,
|
||||
TrackedRegattaRegistry trackedRegattaRegistry, boolean canSendRequests, long delayToLiveInMillis) throws InterruptedException,
|
||||
UnknownHostException, IOException, ParseException {
|
||||
// TODO bug 733: use trackedRegattaRegistry to obtain a regatta using the race ID
|
||||
this(domainFactory.getOrCreateRegatta(raceID, trackedRegattaRegistry), raceID, hostname, port, windStore, domainFactory, factory,
|
||||
messageLoader, trackedRegattaRegistry, canSendRequests, delayToLiveInMillis);
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.domain.test;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -40,7 +41,7 @@ public class DummyTrackedRegattaRegistry implements TrackedRegattaRegistry {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Regatta getRememberedRegattaForRace(RaceDefinition race) {
|
||||
public Regatta getRememberedRegattaForRace(Serializable race) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -2,6 +2,7 @@ package com.sap.sailing.domain.tractracadapter;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -241,4 +242,9 @@ public interface DomainFactory {
|
||||
*/
|
||||
void removeRace(Event tractracEvent, Race tractracRace, TrackedRegattaRegistry trackedRegattaRegistry);
|
||||
|
||||
/**
|
||||
* Computes an ID to use for a {@link RaceDefinition} based on the TracTrac race.
|
||||
*/
|
||||
Serializable getRaceID(Race tractracRace);
|
||||
|
||||
}
|
||||
+7
-1
@@ -2,6 +2,7 @@ package com.sap.sailing.domain.tractracadapter.impl;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -314,6 +315,11 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
ReceiverType.MARKPASSINGS, ReceiverType.MARKPOSITIONS, ReceiverType.RACESTARTFINISH, ReceiverType.RAWPOSITIONS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getRaceID(Race tractracRace) {
|
||||
return tractracRace.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRace(com.tractrac.clientmodule.Event tractracEvent, Race tractracRace, TrackedRegattaRegistry trackedRegattaRegistry) {
|
||||
RaceDefinition raceDefinition;
|
||||
@@ -370,7 +376,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
Pair<List<Competitor>, BoatClass> competitorsAndDominantBoatClass = getCompetitorsAndDominantBoatClass(race);
|
||||
logger.info("Creating RaceDefinitionImpl for race "+race.getName());
|
||||
raceDefinition = new RaceDefinitionImpl(race.getName(), course, competitorsAndDominantBoatClass.getB(),
|
||||
competitorsAndDominantBoatClass.getA(), race.getId());
|
||||
competitorsAndDominantBoatClass.getA(), getRaceID(race));
|
||||
// add to domain Event only if boat class matches
|
||||
if (raceDefinition.getBoatClass() == trackedRegatta.getRegatta().getBoatClass()) {
|
||||
trackedRegatta.getRegatta().addRace(raceDefinition);
|
||||
|
||||
+8
-1
@@ -5,6 +5,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Serializable;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -173,12 +174,18 @@ public class TracTracRaceTrackerImpl extends AbstractRaceTrackerImpl implements
|
||||
// Start live and stored data streams
|
||||
ioThread = new Thread(controller, "I/O for event "+tractracEvent.getName()+", race URL "+paramURL);
|
||||
for (Race tractracRace : tractracEvent.getRaceList()) {
|
||||
// Try to find a pre-associated event based on the Race ID
|
||||
if (regatta == null) {
|
||||
Serializable raceID = domainFactory.getRaceID(tractracRace);
|
||||
regatta = trackedRegattaRegistry.getRememberedRegattaForRace(raceID);
|
||||
}
|
||||
// removeRace may detach the domain regatta from the domain factory if that
|
||||
// removed the last race; therefore, it's important to getOrCreate the
|
||||
// domain regatta *after* calling removeRace
|
||||
domainFactory.removeRace(tractracEvent, tractracRace, trackedRegattaRegistry);
|
||||
}
|
||||
// TODO bug 733: use trackedRegattaRegistry to obtain a regatta using the race ID
|
||||
// if regatta is still null, no previous assignment of any of the races in this TracTrac event to a Regatta was found;
|
||||
// in this case, create a default regatta based on the TracTrac event data
|
||||
this.regatta = regatta == null ? domainFactory.getOrCreateRegatta(tractracEvent, trackedRegattaRegistry) : regatta;
|
||||
trackedRegatta = trackedRegattaRegistry.getOrCreateTrackedRegatta(this.regatta);
|
||||
receivers = new HashSet<Receiver>();
|
||||
|
||||
+6
-3
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.domain.tracking;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
|
||||
@@ -34,10 +36,11 @@ public interface TrackedRegattaRegistry {
|
||||
* regatta will be returned.
|
||||
* <p>
|
||||
*
|
||||
* If no such explicit assignment has been performed, an "appropriate" non-persistent default regatta will be
|
||||
* selected and returned.
|
||||
* If no such explicit assignment has been performed, <code>null</code> is returned.
|
||||
*
|
||||
* @param raceID the ID as obtained from {@link RaceDefinition#getId()}
|
||||
*/
|
||||
Regatta getRememberedRegattaForRace(RaceDefinition race);
|
||||
Regatta getRememberedRegattaForRace(Serializable raceID);
|
||||
|
||||
/**
|
||||
* Persistently remembers the association of the race with its {@link RaceDefinition#getId()} to the
|
||||
|
||||
+2
-2
@@ -1374,8 +1374,8 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
}
|
||||
|
||||
@Override
|
||||
public Regatta getRememberedRegattaForRace(RaceDefinition race) {
|
||||
return persistentRegattasForRaceIDs.get(race.getId().toString());
|
||||
public Regatta getRememberedRegattaForRace(Serializable raceID) {
|
||||
return persistentRegattasForRaceIDs.get(raceID.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user