mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-16 17:21:00 +00:00
Fixes bug 3392: Marks now fetchable from RaceColumn
This commit is contained in:
1 parent
dfe73bfc9e
commit
a5717714df
2 files changed
+85
-18
No files matched your search
@@ -240,9 +240,8 @@ public interface RaceColumn extends Named {
|
||||
/**
|
||||
* Provides the combined set of competitors from all {@link #getTrackedRace(Fleet) tracked races attached to this
|
||||
* column} or, in case a fleet does not have a tracked race attached, the competitors registered through the
|
||||
* respective {@link RaceLog} {@link #getRaceLog(Fleet) attached to this column for that fleet}. Note that this does
|
||||
* not include competitors registered through any {@link RegattaLog} on the structure owning (directly or
|
||||
* transitively) this column.
|
||||
* respective {@link RaceLog} {@link #getRaceLog(Fleet)} or {@link RegattaLog} {@link #getRegattaLog()} attached to
|
||||
* this column for that fleet.
|
||||
*/
|
||||
Iterable<Competitor> getAllCompetitors();
|
||||
|
||||
@@ -250,4 +249,17 @@ public interface RaceColumn extends Named {
|
||||
* Same as {@link #getAllCompetitors()}, but restricted to the single race identified by the <code>fleet</code> parameter.
|
||||
*/
|
||||
Iterable<Competitor> getAllCompetitors(Fleet fleet);
|
||||
|
||||
/**
|
||||
* Provides the combined set of marks from all {@link #getTrackedRace(Fleet) tracked races attached to this
|
||||
* column} or, in case a fleet does not have a tracked race attached, the competitors registered through the
|
||||
* respective {@link RaceLog} {@link #getRaceLog(Fleet)} or {@link RegattaLog} {@link #getRegattaLog()} attached to
|
||||
* this column for that fleet.
|
||||
*/
|
||||
Iterable<Mark> getAllMarks();
|
||||
|
||||
/**
|
||||
* Same as {@link #getAllCompetitors()}, but restricted to the single race identified by the <code>fleet</code> parameter.
|
||||
*/
|
||||
Iterable<Mark> getAllMarks(Fleet fleet);
|
||||
}
|
||||
+70
-15
@@ -2,6 +2,7 @@ package com.sap.sailing.domain.base.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -10,11 +11,14 @@ import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.DefinedMarkFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RegisteredCompetitorsAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.domain.common.RaceIdentifier;
|
||||
import com.sap.sailing.domain.racelog.RaceLogIdentifier;
|
||||
import com.sap.sailing.domain.racelog.RaceLogStore;
|
||||
@@ -25,14 +29,14 @@ import com.sap.sse.common.Util;
|
||||
|
||||
public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implements RaceColumn {
|
||||
private static final long serialVersionUID = -7801617988982540470L;
|
||||
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AbstractRaceColumn.class.getName());
|
||||
|
||||
private TrackedRaces trackedRaces;
|
||||
private Map<Fleet, RaceIdentifier> raceIdentifiers;
|
||||
|
||||
private Map<Fleet, RaceLog> raceLogs;
|
||||
|
||||
|
||||
private transient RaceLogStore raceLogStore;
|
||||
private RegattaLikeIdentifier regattaLikeParent;
|
||||
|
||||
@@ -47,7 +51,7 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
|
||||
this.raceLogStore = raceLogStore;
|
||||
this.regattaLikeParent = regattaLikeParent;
|
||||
for (final Fleet fleet : getFleets()) {
|
||||
reloadRaceLog(fleet);
|
||||
reloadRaceLog(fleet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +61,7 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
|
||||
return raceLogs.get(fleet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RaceLogIdentifier getRaceLogIdentifier(Fleet fleet) {
|
||||
return new RaceLogIdentifierImpl(regattaLikeParent, getName(), fleet);
|
||||
@@ -115,13 +119,13 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
|
||||
getRaceColumnListeners().notifyListenersAboutTrackedRaceUnlinked(this, fleet, previouslyLinkedRace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeRaceIdentifier(Fleet fleet) {
|
||||
releaseTrackedRace(fleet);
|
||||
this.raceIdentifiers.remove(fleet);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Fleet getFleetOfCompetitor(Competitor competitor) {
|
||||
for (final Fleet fleet : getFleets()) {
|
||||
@@ -156,7 +160,7 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
@@ -164,14 +168,16 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
|
||||
|
||||
@Override
|
||||
public void reloadRaceLog(Fleet fleet) {
|
||||
synchronized(raceLogs) {
|
||||
synchronized (raceLogs) {
|
||||
RaceLogIdentifier identifier = getRaceLogIdentifier(fleet);
|
||||
RaceLog newOrLoadedRaceLog = raceLogStore.getRaceLog(identifier, /*ignoreCache*/ true);
|
||||
RaceLog newOrLoadedRaceLog = raceLogStore.getRaceLog(identifier, /* ignoreCache */true);
|
||||
RaceLog raceLogAvailable = raceLogs.get(fleet);
|
||||
if (raceLogAvailable == null) {
|
||||
RaceColumnRaceLogReplicator listener = new RaceColumnRaceLogReplicator(this, identifier);
|
||||
// FIXME Wouldn't this skip any listener notifications that a merge below would trigger if the race log already existed?
|
||||
// FIXME For example, how about the race log-provided score corrections that need application to the leaderboard and replication?
|
||||
// FIXME Wouldn't this skip any listener notifications that a merge below would trigger if the race log
|
||||
// already existed?
|
||||
// FIXME For example, how about the race log-provided score corrections that need application to the
|
||||
// leaderboard and replication?
|
||||
newOrLoadedRaceLog.addListener(listener);
|
||||
raceLogs.put(fleet, newOrLoadedRaceLog);
|
||||
final TrackedRace trackedRace = getTrackedRace(fleet);
|
||||
@@ -206,7 +212,7 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
|
||||
if (trackedRace != null) {
|
||||
trackedRace.attachRaceLog(raceLog);
|
||||
}
|
||||
}, /* prio */ 0);
|
||||
}, /* prio */0);
|
||||
// because this will add the race log to the tracked race's attachedRaceLogs collection again, and
|
||||
// the new DynamicTrackedRaceLogListener that the readObject(...) method had constructed for the
|
||||
// tracked race will be added as a listener to the race log whose listeners collection otherwise would
|
||||
@@ -219,7 +225,6 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
|
||||
trackedRaces.setMasterDataExportOngoingThreadFlag(flagValue);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterable<Competitor> getAllCompetitors() {
|
||||
Set<Competitor> result = new HashSet<>();
|
||||
@@ -228,7 +233,7 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
|
||||
if (trackedRace != null) {
|
||||
Util.addAll(trackedRace.getRace().getCompetitors(), result);
|
||||
} else {
|
||||
// if no tracked race is found, use competitors from race/regatta log depending on whether
|
||||
// if no tracked race is found, use competitors from race/regatta log depending on whether
|
||||
// the mapping event is present or not; this assumes that if a tracked
|
||||
// race exists, its competitors set takes precedence over what's in the race log. Usually,
|
||||
// the tracked race will have the same competitors as those in the race log, or more because
|
||||
@@ -248,15 +253,65 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
|
||||
if (trackedRace != null) {
|
||||
result = trackedRace.getRace().getCompetitors();
|
||||
} else {
|
||||
// if no tracked race is found, use competitors from race/regatta log depending on whether
|
||||
// if no tracked race is found, use competitors from race/regatta log depending on whether
|
||||
// the mapping event is present or not; this assumes that if a tracked
|
||||
// race exists, its competitors set takes precedence over what's in the race log. Usually,
|
||||
// the tracked race will have the same competitors as those in the race log, or more because
|
||||
// those from the regatta log are added to the tracked race as well.
|
||||
RegattaLog regattaLog = getRegattaLog();
|
||||
//FIXME: soon to be removed, as RaceLogDefineMarkEvent is deprecated
|
||||
Set<Competitor> viaRaceLog = new RegisteredCompetitorsAnalyzer(getRaceLog(fleet), regattaLog).analyze();
|
||||
result = viaRaceLog;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Mark> getAllMarks() {
|
||||
Set<Mark> result = new HashSet<>();
|
||||
for (Fleet fleet : getFleets()) {
|
||||
TrackedRace trackedRace = getTrackedRace(fleet);
|
||||
if (trackedRace != null) {
|
||||
for (Waypoint waypoint : trackedRace.getRace().getCourse().getWaypoints()) {
|
||||
Util.addAll(waypoint.getMarks(), result);
|
||||
}
|
||||
} else {
|
||||
// if no tracked race is found, use competitors from race/regatta log depending on whether
|
||||
// the mapping event is present or not; this assumes that if a tracked
|
||||
// race exists, its competitors set takes precedence over what's in the race log. Usually,
|
||||
// the tracked race will have the same competitors as those in the race log, or more because
|
||||
// those from the regatta log are added to the tracked race as well.
|
||||
RegattaLog regattaLog = getRegattaLog();
|
||||
Collection<Mark> viaRegattaLog = new DefinedMarkFinder<>(regattaLog).analyze();
|
||||
//FIXME: soon to be removed, as RaceLogDefineMarkEvent is deprecated
|
||||
Collection<Mark> viaRaceLog = new DefinedMarkFinder<>(getRaceLog(fleet)).analyze();
|
||||
result.addAll(viaRaceLog);
|
||||
result.addAll(viaRegattaLog);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Mark> getAllMarks(Fleet fleet) {
|
||||
Set<Mark> result = new HashSet<>();
|
||||
TrackedRace trackedRace = getTrackedRace(fleet);
|
||||
if (trackedRace != null) {
|
||||
for (Waypoint waypoint : trackedRace.getRace().getCourse().getWaypoints()) {
|
||||
Util.addAll(waypoint.getMarks(), result);
|
||||
}
|
||||
} else {
|
||||
// if no tracked race is found, use competitors from race/regatta log depending on whether
|
||||
// the mapping event is present or not; this assumes that if a tracked
|
||||
// race exists, its competitors set takes precedence over what's in the race log. Usually,
|
||||
// the tracked race will have the same competitors as those in the race log, or more because
|
||||
// those from the regatta log are added to the tracked race as well.
|
||||
RegattaLog regattaLog = getRegattaLog();
|
||||
Collection<Mark> viaRegattaLog = new DefinedMarkFinder<>(regattaLog).analyze();
|
||||
Collection<Mark> viaRaceLog = new DefinedMarkFinder<>(getRaceLog(fleet)).analyze();
|
||||
result.addAll(viaRaceLog);
|
||||
result.addAll(viaRegattaLog);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user