diff --git a/java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/MongoObjectFactoryImpl.java b/java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/MongoObjectFactoryImpl.java index abda22de5c5..fdd33deee66 100644 --- a/java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/MongoObjectFactoryImpl.java +++ b/java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/MongoObjectFactoryImpl.java @@ -2107,7 +2107,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory { final Document fingerprintDoc = Document.parse(fingerprintjson.toString()); result.put(FieldNames.MANEUVER_FINGERPRINT.name(), fingerprintDoc); storeRaceIdentifier(result, raceIdentifier); - final List maneuverDoc = storeManeuvers( maneuvers , raceIdentifier, course); + final List maneuverDoc = storeManeuvers(maneuvers , raceIdentifier, course); result.put(FieldNames.MANEUVERS.name(), maneuverDoc); maneuverCollection.replaceOne(query, result, new ReplaceOptions().upsert(true)); } diff --git a/java/com.sap.sailing.domain.racelogtrackingadapter.test/src/com/sap/sailing/domain/racelogtracking/test/impl/GPSFixStoreListenerTest.java b/java/com.sap.sailing.domain.racelogtrackingadapter.test/src/com/sap/sailing/domain/racelogtracking/test/impl/GPSFixStoreListenerTest.java index b37fe54fd27..77a4c579ef1 100644 --- a/java/com.sap.sailing.domain.racelogtrackingadapter.test/src/com/sap/sailing/domain/racelogtracking/test/impl/GPSFixStoreListenerTest.java +++ b/java/com.sap.sailing.domain.racelogtrackingadapter.test/src/com/sap/sailing/domain/racelogtracking/test/impl/GPSFixStoreListenerTest.java @@ -42,7 +42,7 @@ public class GPSFixStoreListenerTest extends AbstractGPSFixStoreTest { barrier.await(100, TimeUnit.MILLISECONDS); // During iteration in the main thread this causes a modification that makes the iterator throw a // ConcurrentModificationException on next() - store.addListener((DeviceIdentifier device, GPSFixMoving fix, boolean returnManeuverChanges, boolean returnLiveDelay) -> { + store.addListener((DeviceIdentifier device, Iterable fixes, boolean returnManeuverChanges, boolean returnLiveDelay) -> { return null; }, device); barrier.await(100, TimeUnit.MILLISECONDS); @@ -71,7 +71,7 @@ public class GPSFixStoreListenerTest extends AbstractGPSFixStoreTest { } @Override - public Iterable> fixReceived(DeviceIdentifier device, GPSFixMoving fix, boolean returnManeuverChanges, boolean returnLiveDelay) { + public Iterable> fixesReceived(DeviceIdentifier device, Iterable fixes, boolean returnManeuverChanges, boolean returnLiveDelay) { try { barrier.await(100, TimeUnit.MILLISECONDS); } catch (TimeoutException e) { diff --git a/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/fixtracker/FixLoaderAndTracker.java b/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/fixtracker/FixLoaderAndTracker.java index f2a6afa14b8..72b133a7edb 100755 --- a/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/fixtracker/FixLoaderAndTracker.java +++ b/java/com.sap.sailing.domain.racelogtrackingadapter/src/com/sap/sailing/domain/racelogtracking/impl/fixtracker/FixLoaderAndTracker.java @@ -206,10 +206,11 @@ public class FixLoaderAndTracker implements TrackingDataLoader { private final FixReceivedListener listener = new FixReceivedListener() { @Override - public Iterable> fixReceived(DeviceIdentifier device, - Timed fix, boolean returnManeuverChanges, boolean returnLiveDelay) { + public Iterable> fixesReceived(DeviceIdentifier device, + Iterable fixes, boolean returnManeuverChanges, boolean returnLiveDelay) { final Set maneuverChanged = new HashSet<>(); final Map delayToLive = new HashMap<>(); + // TODO bug6236: how to improve performance of device mappings look-up when we have received multiple fixes from the same device? if (!preemptiveStopRequested.get() && trackedRace.getStartOfTracking() != null) { final TimePoint timePoint = fix.getTimePoint(); deviceMappings.forEachMappingOfDeviceIncludingTimePoint(device, fix.getTimePoint(), diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/racelog/tracking/FixReceivedListener.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/racelog/tracking/FixReceivedListener.java index 5f670427d78..81532b4c86a 100644 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/racelog/tracking/FixReceivedListener.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/racelog/tracking/FixReceivedListener.java @@ -1,5 +1,7 @@ package com.sap.sailing.domain.racelog.tracking; +import java.util.Collections; + import com.sap.sailing.domain.common.DeviceIdentifier; import com.sap.sailing.domain.common.RegattaAndRaceIdentifier; import com.sap.sse.common.Duration; @@ -12,6 +14,7 @@ import com.sap.sse.common.Util.Triple; * @param * the type of fixes this listener can consume. */ +@FunctionalInterface public interface FixReceivedListener { /** * @@ -34,6 +37,32 @@ public interface FixReceivedListener { * returned can be empty but is never {@code null}. It can also contain multiple identifiers if the device * mapping is currently ambiguous. */ - Iterable> fixReceived(DeviceIdentifier device, FixT fix, + default Iterable> fixReceived(DeviceIdentifier device, FixT fix, + boolean returnManeuverChanges, boolean returnLiveDelay) { + return fixesReceived(device, Collections.singleton(fix), returnManeuverChanges, returnLiveDelay); + } + + /** + * + * @param device + * the device that recorded the fix. Cannot be null. + * @param fixes + * The fixes that were stored. Must not be null but may be empty + * @param returnLiveDelay + * if {@code true} then all listeners to which the fixes are forwarded shall check to which races the fix + * maps and report the live delay for the newest of those {@code fixes} for all those races as the third + * component of the resulting {@link Triple}s. + * @param returnManeuverUpdate + * if {@code true}, all listeners to which this fixes are forwarded shall check whether the fixes feed + * into a competitor's track in the scope of a race where for that competitor the maneuver list has + * changed since the last call of this type; if so, the race identifier will be part of the result, with + * the {@link Boolean} component being {@code true} for that race. Otherwise, the {@link Boolean} + * component is {@code false} or the race is not listed in the result. + * @return An {@link Iterable} with {@link RegattaAndRaceIdentifier}s is returned that will contain races with new + * maneuvers which were not available at the last time the given device stored a fix. The {@link Iterable} + * returned can be empty but is never {@code null}. It can also contain multiple identifiers if the device + * mapping is currently ambiguous. + */ + Iterable> fixesReceived(DeviceIdentifier device, Iterable fixes, boolean returnManeuverChanges, boolean returnLiveDelay); }