diff --git a/java/com.sap.sailing.polars.test/src/com/sap/sailing/polars/caching/test/PolarFixCacheRaceIntervalTest.java b/java/com.sap.sailing.polars.test/src/com/sap/sailing/polars/caching/test/PolarFixCacheRaceIntervalTest.java deleted file mode 100644 index f3ee8c2b40f..00000000000 --- a/java/com.sap.sailing.polars.test/src/com/sap/sailing/polars/caching/test/PolarFixCacheRaceIntervalTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.sap.sailing.polars.caching.test; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.mock; - -import java.util.Calendar; -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; - -import com.sap.sailing.domain.base.Competitor; -import com.sap.sailing.domain.tracking.TrackedRace; -import com.sap.sailing.polars.caching.PolarFixCacheRaceInterval; -import com.sap.sse.common.TimePoint; -import com.sap.sse.common.Util.Pair; -import com.sap.sse.common.impl.MillisecondsTimePoint; - -public class PolarFixCacheRaceIntervalTest { - - @Test - public void testIntervalJoin() { - TrackedRace mockedTrackedRace1 = mock(TrackedRace.class); - TrackedRace mockedTrackedRace2 = mock(TrackedRace.class); - - Competitor mockedCompetitor1 = mock(Competitor.class); - Competitor mockedCompetitor2 = mock(Competitor.class); - - Calendar calender = Calendar.getInstance(); - calender.set(2014, 3, 17, 16, 0, 0); - TimePoint timePoint1 = new MillisecondsTimePoint(calender.getTime()); - calender.set(2014, 3, 17, 16, 10, 0); - TimePoint timePoint2 = new MillisecondsTimePoint(calender.getTime()); - - PolarFixCacheRaceInterval interval1 = createInterval1( - mockedTrackedRace1, mockedTrackedRace2, mockedCompetitor1, - mockedCompetitor2, timePoint1, timePoint2); - - PolarFixCacheRaceInterval interval2 = createInterval2( - mockedTrackedRace1, mockedTrackedRace2, mockedCompetitor1, - timePoint2); - PolarFixCacheRaceInterval joined = interval1.join(interval2); - - Map>> joinedMap = joined - .getCompetitorAndTimepointsForRace(); - - Map> explicitIntervalForRace1 = joinedMap.get(mockedTrackedRace1); - assertThat(explicitIntervalForRace1, notNullValue(Map.class)); - Pair explicitIntervalForCompetitor1 = explicitIntervalForRace1.get(mockedCompetitor1); - assertThat(explicitIntervalForCompetitor1, notNullValue(Pair.class)); - - TimePoint start1 = explicitIntervalForCompetitor1.getA(); - TimePoint end1 = explicitIntervalForCompetitor1.getB(); - - assertThat(start1, is(timePoint1)); - assertThat(end1, is(timePoint2)); - - } - - private PolarFixCacheRaceInterval createInterval1( - TrackedRace mockedTrackedRace1, TrackedRace mockedTrackedRace2, - Competitor mockedCompetitor1, Competitor mockedCompetitor2, - TimePoint timePoint1, TimePoint timePoint2) { - Map>> competitorAndTimepointsForRace = new HashMap>>(); - HashMap> mapForRace1 = new HashMap>(); - mapForRace1.put(mockedCompetitor1, new Pair(timePoint1, timePoint1)); - competitorAndTimepointsForRace.put(mockedTrackedRace1, mapForRace1); - HashMap> mapForRace2 = new HashMap>(); - mapForRace2.put(mockedCompetitor2, new Pair(timePoint1, timePoint2)); - competitorAndTimepointsForRace.put(mockedTrackedRace2, mapForRace2); - PolarFixCacheRaceInterval interval1 = new PolarFixCacheRaceInterval( - competitorAndTimepointsForRace); - return interval1; - } - - private PolarFixCacheRaceInterval createInterval2( - TrackedRace mockedTrackedRace1, TrackedRace mockedTrackedRace2, - Competitor mockedCompetitor1, TimePoint timePoint2) { - Map>> competitorAndTimepointsForRace = new HashMap>>(); - HashMap> mapForRace1 = new HashMap>(); - mapForRace1.put(mockedCompetitor1, new Pair( - timePoint2, timePoint2)); - competitorAndTimepointsForRace.put(mockedTrackedRace1, mapForRace1); - PolarFixCacheRaceInterval interval2 = new PolarFixCacheRaceInterval( - competitorAndTimepointsForRace); - return interval2; - } -} diff --git a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/PolarDataService.java b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/PolarDataService.java index 3050c4ec7ea..102170be112 100644 --- a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/PolarDataService.java +++ b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/PolarDataService.java @@ -17,16 +17,11 @@ import com.sap.sailing.domain.common.Speed; import com.sap.sailing.domain.common.Tack; import com.sap.sailing.domain.tracking.GPSFixMoving; import com.sap.sailing.domain.tracking.TrackedRace; -import com.sap.sailing.polars.analysis.PolarSheetAnalyzer; -import com.sap.sailing.polars.data.PolarFix; import com.sap.sailing.polars.regression.NotEnoughDataHasBeenAddedException; /** * Public Facade interface allowing access to the polars of {@link BoatClass}es. * - * It uses a {@link PolarSheetAnalyzer} for more advanced analysis. It's methods are facaded in this interface for - * central access. - * * The interesting methods for a user are {@link #getSpeed(BoatClass, Speed, Bearing, boolean)} if data for a specific angle is * needed and {@link #getAverageSpeedWithBearing(BoatClass, Speed, LegType, Tack)} * which also returns the average angle for the provided parameters. @@ -41,7 +36,7 @@ public interface PolarDataService { * @param boatClass * @param windSpeed * @param bearingToTheWind - * Boat's direction relative to the wind. either in -180 -> +180 or 0 -> 359 degrees interval + * Boat's direction relative to the wind. either in -180 -> +180 or 0 -> 359 degrees interval. The true wind! * @return The speed the boat is moving at for the specified wind and bearing according to the polar diagram. * @throws NotEnoughDataHasBeenAddedException */ @@ -58,7 +53,7 @@ public interface PolarDataService { * @param tack * Polar data can vary depending on the tack the boat is on. * @return The estimated average speed of a boat for the supplied parameters with the estimated average bearing to - * the wind and a confidence which consists of the confidences of the wind speed, and boat speed sources (50%) + * the true wind and a confidence which consists of the confidences of the wind speed, and boat speed sources (50%) * and a confidence calculated using the amount of underlying fixes (50%). 0 <= confidence < 1
* A value with zero confidence doesn't have any significance!

* @@ -90,16 +85,6 @@ public interface PolarDataService { PolarSheetsData generatePolarSheet(Set trackedRaces, PolarSheetGenerationSettings settings, Executor executor) throws InterruptedException, ExecutionException; - void newRaceFinishedTracking(TrackedRace trackedRace); - - /** - * @param key - * The {@link BoatClass} to obtain fixes for. - * @return All raw polar fixes for the {@link BoatClass}. The implementation is responsible for deciding wether a - * cache is used or not. - */ - Set getPolarFixesForBoatClass(BoatClass key); - /** * * @param boatClass @@ -115,6 +100,14 @@ public interface PolarDataService { */ Set getAllBoatClassesWithPolarSheetsAvailable(); + /** + * To be called in an appropriate listener. + * Starting point for fixes entering the backend polar data mining pipeline. + * + * @param fix + * @param competitor + * @param createdTrackedRace + */ void competitorPositionChanged(GPSFixMoving fix, Competitor competitor, TrackedRace createdTrackedRace); /** diff --git a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/NoCacheEntryException.java b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/NoCacheEntryException.java deleted file mode 100644 index b4cfec4d06a..00000000000 --- a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/NoCacheEntryException.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.sap.sailing.polars.caching; - -import java.util.Set; - -import com.sap.sailing.domain.tracking.TrackedRace; -import com.sap.sailing.polars.data.PolarFix; - -public class NoCacheEntryException extends Exception { - - private static final long serialVersionUID = 5547683568438235668L; - private final Set notCached; - private final Set resultList; - - public NoCacheEntryException(Set notCached, Set resultList) { - this.notCached = notCached; - this.resultList = resultList; - } - - public Set getNotCached() { - return notCached; - } - - public Set getCachedResultList() { - return resultList; - } - -} diff --git a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCache.java b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCache.java deleted file mode 100644 index c9306b315f2..00000000000 --- a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCache.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.sap.sailing.polars.caching; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Executor; - -import com.sap.sailing.domain.base.BoatClass; -import com.sap.sailing.domain.common.RegattaAndRaceIdentifier; -import com.sap.sailing.domain.tracking.TrackedRace; -import com.sap.sailing.polars.data.PolarFix; -import com.sap.sailing.util.SmartFutureCache; - -public class PolarFixCache extends - SmartFutureCache>, PolarFixCacheRaceInterval> { - - private final List cacheUpdateDoneListeners = new ArrayList(); - - public PolarFixCache(Executor executor) { - super(new PolarFixCacheUpdater(executor), "polarFixCache"); - } - - @Override - protected void cache(BoatClass key, Map> value) { - super.cache(key, value); - synchronized (cacheUpdateDoneListeners) { - for (PolarFixCacheUpdateDoneListener listener : cacheUpdateDoneListeners) { - listener.cacheUpdateDoneForBoatClass(key); - } - } - } - - public void addListener(PolarFixCacheUpdateDoneListener listener) { - synchronized (cacheUpdateDoneListeners) { - cacheUpdateDoneListeners.add(listener); - } - } - - public void removeListener(PolarFixCacheUpdateDoneListener listener) { - synchronized (cacheUpdateDoneListeners) { - if (cacheUpdateDoneListeners.contains(listener)) { - cacheUpdateDoneListeners.remove(listener); - } - } - } - - public Set getFixesForTrackedRaces(Set trackedRaces) throws NoCacheEntryException { - Set resultList = new HashSet(); - Set notCached = new HashSet(); - for (TrackedRace trackedRace : trackedRaces) { - Map> result = get(trackedRace.getRace().getBoatClass(), false); - List resultForRace = result.get(trackedRace.getRaceIdentifier()); - if (resultForRace == null) { - notCached.add(trackedRace); - } else { - resultList.addAll(resultForRace); - } - } - if (notCached.size() > 0) { - throw new NoCacheEntryException(notCached, resultList); - } - return resultList; - } - -} diff --git a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCacheRaceInterval.java b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCacheRaceInterval.java deleted file mode 100644 index ed6717bc50f..00000000000 --- a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCacheRaceInterval.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.sap.sailing.polars.caching; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import com.sap.sailing.domain.base.Competitor; -import com.sap.sailing.domain.tracking.TrackedRace; -import com.sap.sailing.polars.aggregation.PolarFixRaceInterval; -import com.sap.sailing.util.SmartFutureCache.UpdateInterval; -import com.sap.sse.common.TimePoint; -import com.sap.sse.common.Util.Pair; - -public class PolarFixCacheRaceInterval implements UpdateInterval, PolarFixRaceInterval { - - private final Map>> competitorAndTimepointsForRace; - - public PolarFixCacheRaceInterval( - Map>> competitorAndTimepointsForRace) { - this.competitorAndTimepointsForRace = competitorAndTimepointsForRace; - } - - @Override - public Map>> getCompetitorAndTimepointsForRace() { - return competitorAndTimepointsForRace; - } - - @Override - public PolarFixCacheRaceInterval join(PolarFixCacheRaceInterval otherUpdateInterval) { - Map>> joinedInterval = new HashMap>>(); - Set racesContainedInEitherMap = new HashSet(); - for (TrackedRace race : competitorAndTimepointsForRace.keySet()) { - racesContainedInEitherMap.add(race); - } - Map>> otherUpdateIntervalInExplicitForm = otherUpdateInterval - .getCompetitorAndTimepointsForRace(); - for (TrackedRace race : otherUpdateIntervalInExplicitForm.keySet()) { - racesContainedInEitherMap.add(race); - } - - for (TrackedRace race : racesContainedInEitherMap) { - HashMap> joinedMap = new HashMap>(); - Map> mapOfTimpointCompetitorPairs = competitorAndTimepointsForRace - .get(race); - if (mapOfTimpointCompetitorPairs != null) { - joinedMap.putAll(mapOfTimpointCompetitorPairs); - } - Map> mapOfOtherTimpointCompetitorPairs = otherUpdateIntervalInExplicitForm - .get(race); - if (mapOfOtherTimpointCompetitorPairs != null) { - mergeMap(joinedMap, mapOfOtherTimpointCompetitorPairs); - } - joinedInterval.put(race, joinedMap); - } - return new PolarFixCacheRaceInterval(joinedInterval); - } - - private void mergeMap(HashMap> joinedMap, - Map> mapOfOtherTimpointCompetitorPairs) { - for (Entry> otherEntry : mapOfOtherTimpointCompetitorPairs.entrySet()) { - - Competitor competitor = otherEntry.getKey(); - Pair otherValue = otherEntry.getValue(); - Pair existingValue = joinedMap.get(competitor); - if (existingValue != null) { - Pair joinedTimepointInterval = joinTimepointIntervals(existingValue, otherValue); - joinedMap.put(competitor, joinedTimepointInterval); - } else { - joinedMap.put(competitor, otherValue); - } - - } - } - - /** - * This method ignores a possible gap between the two intervals. - * - * @param existingValue - * @param otherValue - * @return - */ - private Pair joinTimepointIntervals(Pair existingValue, - Pair otherValue) { - TimePoint startExisting = existingValue.getA(); - TimePoint endExisting = existingValue.getB(); - TimePoint startOther = otherValue.getA(); - TimePoint endOther = otherValue.getB(); - - TimePoint startNew = startExisting.before(startOther) ? startExisting : startOther; - TimePoint endNew = endExisting.after(endOther) ? endExisting : endOther; - - return new Pair(startNew, endNew); - } - -} \ No newline at end of file diff --git a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCacheUpdateDoneListener.java b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCacheUpdateDoneListener.java deleted file mode 100644 index 75a32432e04..00000000000 --- a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCacheUpdateDoneListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.sap.sailing.polars.caching; - -import com.sap.sailing.domain.base.BoatClass; - -public interface PolarFixCacheUpdateDoneListener { - - void cacheUpdateDoneForBoatClass(BoatClass key); - -} diff --git a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCacheUpdater.java b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCacheUpdater.java deleted file mode 100644 index db782760f85..00000000000 --- a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarFixCacheUpdater.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.sap.sailing.polars.caching; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.Executor; - -import com.sap.sailing.domain.base.BoatClass; -import com.sap.sailing.domain.common.RegattaAndRaceIdentifier; -import com.sap.sailing.domain.common.impl.PolarSheetGenerationSettingsImpl; -import com.sap.sailing.polars.aggregation.PolarFixAggregator; -import com.sap.sailing.polars.data.PolarFix; -import com.sap.sailing.util.SmartFutureCache.CacheUpdater; - -public class PolarFixCacheUpdater implements - CacheUpdater>, PolarFixCacheRaceInterval> { - - private final Executor executor; - - public PolarFixCacheUpdater(Executor executor) { - this.executor = executor; - } - - @Override - public Map> computeCacheUpdate(BoatClass key, - PolarFixCacheRaceInterval updateInterval) throws Exception { - PolarFixAggregator aggregator = new PolarFixAggregator(updateInterval, - PolarSheetGenerationSettingsImpl.createStandardPolarSettings(), executor); - Thread.sleep(updateInterval.getCompetitorAndTimepointsForRace().keySet().iterator().next() - .getMillisecondsOverWhichToAverageSpeed() / 2); - aggregator.startPolarFixAggregation(); - - return aggregator.get(); - } - - @Override - public Map> provideNewCacheValue(BoatClass key, - Map> oldCacheValue, - Map> computedCacheUpdate, PolarFixCacheRaceInterval updateInterval) { - Map> newCacheValue = new HashMap>(); - if (oldCacheValue != null) { - newCacheValue.putAll(oldCacheValue); - } - for (Entry> newEntry : computedCacheUpdate.entrySet()) { - List oldList = newCacheValue.get(newEntry.getKey()); - if (oldList != null) { - oldList.addAll(newEntry.getValue()); - } else { - newCacheValue.put(newEntry.getKey(), newEntry.getValue()); - } - } - return newCacheValue; - } - -} diff --git a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarSheetPerBoatClassCache.java b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarSheetPerBoatClassCache.java deleted file mode 100644 index 94e4fa0a4c8..00000000000 --- a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarSheetPerBoatClassCache.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.sap.sailing.polars.caching; - -import com.sap.sailing.domain.base.BoatClass; -import com.sap.sailing.domain.common.PolarSheetsData; -import com.sap.sailing.polars.PolarDataService; -import com.sap.sailing.util.SmartFutureCache; - -public class PolarSheetPerBoatClassCache extends - SmartFutureCache - implements PolarFixCacheUpdateDoneListener { - - public PolarSheetPerBoatClassCache(PolarDataService polarDataService) { - super(new PolarSheetPerBoatClassCacheUpdater(polarDataService), "PolarSheetPerBoatClassCache"); - } - - @Override - public void cacheUpdateDoneForBoatClass(BoatClass key) { - triggerUpdate(key, new EmptyUpdateInterval()); - } - -} diff --git a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarSheetPerBoatClassCacheUpdater.java b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarSheetPerBoatClassCacheUpdater.java deleted file mode 100644 index fb94b05ea47..00000000000 --- a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/caching/PolarSheetPerBoatClassCacheUpdater.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.sap.sailing.polars.caching; - -import com.sap.sailing.domain.base.BoatClass; -import com.sap.sailing.domain.common.PolarSheetGenerationSettings; -import com.sap.sailing.domain.common.PolarSheetsData; -import com.sap.sailing.domain.common.impl.PolarSheetGenerationSettingsImpl; -import com.sap.sailing.polars.PolarDataService; -import com.sap.sailing.polars.generation.PolarSheetGenerator; -import com.sap.sailing.util.SmartFutureCache.CacheUpdater; -import com.sap.sailing.util.SmartFutureCache.EmptyUpdateInterval; - -public class PolarSheetPerBoatClassCacheUpdater implements - CacheUpdater { - - private final PolarDataService polarDataService; - - public PolarSheetPerBoatClassCacheUpdater(PolarDataService polarDataService) { - this.polarDataService = polarDataService; - } - - @Override - public PolarSheetsData computeCacheUpdate(BoatClass key, EmptyUpdateInterval updateInterval) throws Exception { - PolarSheetGenerationSettings settings = PolarSheetGenerationSettingsImpl.createStandardPolarSettings(); - PolarSheetGenerator generator = new PolarSheetGenerator(polarDataService.getPolarFixesForBoatClass(key), - settings); - PolarSheetsData generationResult = generator.generate(); - return generationResult; - } - - @Override - public PolarSheetsData provideNewCacheValue(BoatClass key, PolarSheetsData oldCacheValue, - PolarSheetsData computedCacheUpdate, EmptyUpdateInterval updateInterval) { - return computedCacheUpdate; - } - -} diff --git a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/impl/PolarDataServiceImpl.java b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/impl/PolarDataServiceImpl.java index 31212550927..0c62dec8d4d 100644 --- a/java/com.sap.sailing.polars/src/com/sap/sailing/polars/impl/PolarDataServiceImpl.java +++ b/java/com.sap.sailing.polars/src/com/sap/sailing/polars/impl/PolarDataServiceImpl.java @@ -1,8 +1,5 @@ package com.sap.sailing.polars.impl; -import java.util.HashSet; -import java.util.List; -import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; @@ -16,7 +13,6 @@ import com.sap.sailing.domain.common.BoatClassMasterdata; import com.sap.sailing.domain.common.LegType; import com.sap.sailing.domain.common.PolarSheetGenerationSettings; import com.sap.sailing.domain.common.PolarSheetsData; -import com.sap.sailing.domain.common.RegattaAndRaceIdentifier; import com.sap.sailing.domain.common.Speed; import com.sap.sailing.domain.common.Tack; import com.sap.sailing.domain.tracking.GPSFixMoving; @@ -24,8 +20,6 @@ import com.sap.sailing.domain.tracking.TrackedRace; import com.sap.sailing.polars.PolarDataService; import com.sap.sailing.polars.aggregation.PolarFixAggregator; import com.sap.sailing.polars.aggregation.SimplePolarFixRaceInterval; -import com.sap.sailing.polars.caching.PolarFixCache; -import com.sap.sailing.polars.caching.PolarSheetPerBoatClassCache; import com.sap.sailing.polars.data.PolarFix; import com.sap.sailing.polars.generation.PolarSheetGenerator; import com.sap.sailing.polars.mining.PolarDataMiner; @@ -42,15 +36,9 @@ import com.sap.sailing.util.SmartFutureCache; */ public class PolarDataServiceImpl implements PolarDataService { - private final PolarFixCache polarFixCache; - private final PolarSheetPerBoatClassCache polarSheetPerBoatClassCache; - private final PolarDataMiner polarDataMiner; public PolarDataServiceImpl(Executor executor) { - this.polarFixCache = new PolarFixCache(executor); - this.polarSheetPerBoatClassCache = new PolarSheetPerBoatClassCache(this); - polarFixCache.addListener(polarSheetPerBoatClassCache); this.polarDataMiner = new PolarDataMiner(); } @@ -84,69 +72,28 @@ public class PolarDataServiceImpl implements PolarDataService { public PolarSheetsData generatePolarSheet(Set trackedRaces, PolarSheetGenerationSettings settings, Executor executor) throws InterruptedException, ExecutionException { Set fixes; - // If settings are default, look into cache - // if (settings.areDefault()) { - // try { - // fixes = polarFixCache.getFixesForTrackedRaces(trackedRaces); - // } catch (NoCacheEntryException e) { - // // If there is no cache entry for at least one of the races: Aggregate for non-cached races. - // fixes = e.getCachedResultList(); - // PolarFixAggregator aggregator = new PolarFixAggregator( - // new SimplePolarFixRaceInterval(e.getNotCached()), - // settings, executor); - // aggregator.startPolarFixAggregation(); - // fixes.addAll(aggregator.getAggregationResultAsSingleList()); - // } - // } else { PolarFixAggregator aggregator = new PolarFixAggregator(new SimplePolarFixRaceInterval(trackedRaces), settings, executor); aggregator.startPolarFixAggregation(); fixes = aggregator.getAggregationResultAsSingleList(); - // } PolarSheetGenerator generator = new PolarSheetGenerator(fixes, settings); return generator.generate(); } - @Override - public void newRaceFinishedTracking(TrackedRace trackedRace) { - // TODO add a similar listening method, that deletes all cached data on removal of race - // HashSet set = new HashSet(); - // set.add(trackedRace); - // polarFixCache.triggerUpdate(trackedRace.getRace().getBoatClass(), new PolarFixCacheRaceInterval(set)); - } - - @Override - public Set getPolarFixesForBoatClass(BoatClass key) { - Map> fixesInMap = polarFixCache.get(key, false); - Set resultSet = new HashSet(); - for (List value : fixesInMap.values()) { - resultSet.addAll(value); - } - return resultSet; - } - @Override public PolarSheetsData getPolarSheetForBoatClass(BoatClass boatClass) { return polarDataMiner.createFullSheetForBoatClass(boatClass); - //return polarSheetPerBoatClassCache.get(boatClass, false); } @Override public Set getAllBoatClassesWithPolarSheetsAvailable() { return polarDataMiner.getAvailableBoatClasses(); - //return polarSheetPerBoatClassCache.keySet(); } @Override public void competitorPositionChanged(final GPSFixMoving fix, final Competitor competitor, final TrackedRace createdTrackedRace) { polarDataMiner.addFix(fix, competitor, createdTrackedRace); - // TODO build datamining pipeline for the cache - - // PolarFixCacheRaceInterval interval = new PolarFixCacheRaceInterval(createIntervalSpecification( - // createdTrackedRace, competitor, timePoint)); - // polarFixCache.triggerUpdate(createdTrackedRace.getRace().getBoatClass(), interval); - } @Override @@ -154,15 +101,4 @@ public class PolarDataServiceImpl implements PolarDataService { return polarDataMiner.getDataCountsForWindSpeed(boatClass, windSpeed, startAngleInclusive, endAngleExclusive); } - // private Map>> createIntervalSpecification( - // TrackedRace createdTrackedRace, Competitor competitor, TimePoint timePoint) { - // HashMap>> result = new HashMap>>(); - // HashMap> competitorMap = new HashMap>(); - // competitorMap.put(competitor, new Pair(timePoint, timePoint)); - // result.put(createdTrackedRace, competitorMap); - // return result; - // } - } diff --git a/java/com.sap.sailing.server/src/com/sap/sailing/server/impl/RacingEventServiceImpl.java b/java/com.sap.sailing.server/src/com/sap/sailing/server/impl/RacingEventServiceImpl.java index d4f2a8c0cb4..f0220da566a 100755 --- a/java/com.sap.sailing.server/src/com/sap/sailing/server/impl/RacingEventServiceImpl.java +++ b/java/com.sap.sailing.server/src/com/sap/sailing/server/impl/RacingEventServiceImpl.java @@ -89,7 +89,6 @@ import com.sap.sailing.domain.common.RegattaIdentifier; import com.sap.sailing.domain.common.RegattaName; import com.sap.sailing.domain.common.Renamable; import com.sap.sailing.domain.common.ScoringSchemeType; -import com.sap.sailing.domain.common.TrackedRaceStatusEnum; import com.sap.sailing.domain.common.WindSource; import com.sap.sailing.domain.common.dto.FleetDTO; import com.sap.sailing.domain.common.dto.RegattaCreationParametersDTO; @@ -201,8 +200,8 @@ import com.sap.sse.common.search.ResultImpl; import com.sap.sse.replication.OperationExecutionListener; import com.sap.sse.replication.OperationWithResult; import com.sap.sse.replication.ReplicationMasterDescriptor; -import com.sap.sse.util.ClearStateTestSupport; import com.sap.sse.replication.impl.OperationWithResultWithIdWrapper; +import com.sap.sse.util.ClearStateTestSupport; public class RacingEventServiceImpl implements RacingEventService, ClearStateTestSupport, RegattaListener, LeaderboardRegistry, Replicator { @@ -1924,7 +1923,6 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes replicate(new TrackRegatta(regatta.getRegattaIdentifier())); regattaTrackingCache.put(regatta, result); ensureRegattaIsObservedForDefaultLeaderboardAndAutoLeaderboardLinking(result); - addRaceTrackingFinishedListenerForPolarFixCache(result); } return result; } finally { @@ -1932,28 +1930,6 @@ public class RacingEventServiceImpl implements RacingEventService, ClearStateTes } } - private void addRaceTrackingFinishedListenerForPolarFixCache(DynamicTrackedRegatta result) { - RaceListener raceListenerForPolarFixCacheUpdate = new RaceListener() { - @Override - public void raceRemoved(TrackedRace trackedRace) { - // TODO remove fixes from polar fix cache - } - - @Override - public void raceAdded(final TrackedRace trackedRace) { - trackedRace.addListener(new AbstractRaceChangeListener() { - @Override - public void statusChanged(TrackedRaceStatus newStatus) { - if (newStatus.getStatus() == TrackedRaceStatusEnum.FINISHED) { - polarDataService.newRaceFinishedTracking(trackedRace); - } - } - }); - } - }; - result.addRaceListener(raceListenerForPolarFixCacheUpdate); - } - @Override public DynamicTrackedRegatta getTrackedRegatta(com.sap.sailing.domain.base.Regatta regatta) { return regattaTrackingCache.get(regatta);