From 52c819d6e7a4574da847324576b641a8a9f56e2f Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Tue, 9 Oct 2018 17:57:48 +0200 Subject: [PATCH 1/7] fixed passing on of quoted keyword queries through REST API Change-Id: I2cb64dca46d7688ec5224dd17ef04f50249d5e45 --- .../communication/search/GetSearchResultsAction.java | 9 ++++++--- .../places/whatsnew/resources/SailingAnalyticsNotes.html | 6 ++++++ .../sailing/server/gateway/jaxrs/api/SearchResource.java | 3 ++- .../src/com/sap/sse/common/search/KeywordQuery.java | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/communication/search/GetSearchResultsAction.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/communication/search/GetSearchResultsAction.java index cb35019ea21..323131f35f9 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/communication/search/GetSearchResultsAction.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/communication/search/GetSearchResultsAction.java @@ -45,11 +45,14 @@ public class GetSearchResultsAction implements SailingAction execute(SailingDispatchContext ctx) throws DispatchException { KeywordQuery searchQuery = new KeywordQuery(Util.splitAlongWhitespaceRespectingDoubleQuotedPhrases(searchText)); RacingEventService service = ctx.getRacingEventService(); + final ListResult result; if (remoteServerName == null) { - return getListResult(service.search(searchQuery), ctx.getRequestBaseURL(), false); + result = getListResult(service.search(searchQuery), ctx.getRequestBaseURL(), false); + } else { + RemoteSailingServerReference remoteServer = service.getRemoteServerReferenceByName(remoteServerName); + result = getListResult(service.searchRemotely(remoteServerName, searchQuery), remoteServer.getURL(), true); } - RemoteSailingServerReference remoteServer = service.getRemoteServerReferenceByName(remoteServerName); - return getListResult(service.searchRemotely(remoteServerName, searchQuery), remoteServer.getURL(), true); + return result; } @GwtIncompatible diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/places/whatsnew/resources/SailingAnalyticsNotes.html b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/places/whatsnew/resources/SailingAnalyticsNotes.html index adb57cb6d42..6ba5e480582 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/places/whatsnew/resources/SailingAnalyticsNotes.html +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/places/whatsnew/resources/SailingAnalyticsNotes.html @@ -4,6 +4,12 @@

What's New - SAP Sailing Analytics

+
October 2018
+
    +
  • Searching for phrases containing whitespace characters with double quotes such as "Tobias Schadewaldt" will now work + across a distributed server and event landscape.
  • +
+
August 2018
  • The windstreamlets are now colored dynamically according to the wind fields maximum and minimum wind speed.
  • diff --git a/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/SearchResource.java b/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/SearchResource.java index 07a4a06de54..468f5b15716 100755 --- a/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/SearchResource.java +++ b/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/SearchResource.java @@ -17,6 +17,7 @@ import com.sap.sailing.server.gateway.serialization.impl.EventBaseJsonSerializer import com.sap.sailing.server.gateway.serialization.impl.LeaderboardGroupBaseJsonSerializer; import com.sap.sailing.server.gateway.serialization.impl.LeaderboardSearchResultJsonSerializer; import com.sap.sailing.server.gateway.serialization.impl.VenueJsonSerializer; +import com.sap.sse.common.Util; import com.sap.sse.common.search.KeywordQuery; import com.sap.sse.common.search.Result; @@ -37,7 +38,7 @@ public class SearchResource extends AbstractSailingServerResource { @GET @Produces("application/json;charset=UTF-8") public Response search(@QueryParam("q") String keywords) { - KeywordQuery query = new KeywordQuery(keywords.split(" ")); + KeywordQuery query = new KeywordQuery(Util.splitAlongWhitespaceRespectingDoubleQuotedPhrases(keywords)); Iterable searchResults = search(query).getHits(); JSONArray jsonSearchResults = new JSONArray(); for (LeaderboardSearchResult searchResult : searchResults) { diff --git a/java/com.sap.sse.common/src/com/sap/sse/common/search/KeywordQuery.java b/java/com.sap.sse.common/src/com/sap/sse/common/search/KeywordQuery.java index dc6a5a49d3c..d40b8097920 100755 --- a/java/com.sap.sse.common/src/com/sap/sse/common/search/KeywordQuery.java +++ b/java/com.sap.sse.common/src/com/sap/sse/common/search/KeywordQuery.java @@ -45,7 +45,9 @@ public class KeywordQuery implements Query, Serializable { } else { sb.append(' '); } + sb.append('"'); sb.append(keyword); + sb.append('"'); } return sb.toString(); } From 16f6ec97d8cb5f4a70d9a394e681e5485f6861a6 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Tue, 9 Oct 2018 17:58:53 +0200 Subject: [PATCH 2/7] fixed typo in release notes Change-Id: I0eccf58008a6b80b27845d763d34f4e6e2dd5dfb --- .../places/whatsnew/resources/SailingAnalyticsNotes.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/places/whatsnew/resources/SailingAnalyticsNotes.html b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/places/whatsnew/resources/SailingAnalyticsNotes.html index 6ba5e480582..be534fbc260 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/places/whatsnew/resources/SailingAnalyticsNotes.html +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/desktop/places/whatsnew/resources/SailingAnalyticsNotes.html @@ -27,7 +27,7 @@
  • The suggested statistics are now grouped by their retriever chain
  • The aggregator and statistic control switched places and are now linked together. This means that all aggregators/statistics can always be selected, but are grayed out if one component isn't supported - by the other (e.g. an aggreagtor doesn't exist for the currently selected statistic). The other + by the other (e.g. an aggregator doesn't exist for the currently selected statistic). The other component will be reset when an unsupported component is selected.
  • Counting aggregators now work directly on the retrieved data elements and don't require the selection of a specific statistic. Changing to a counting aggregator when a statistic is selected From c320e8a414fc7e41cc8d7955efe3674fe28a1d74 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Tue, 9 Oct 2018 18:07:47 +0200 Subject: [PATCH 3/7] added app_features.json to com.sap.sailing.www/ to support app upgrade hint when ready Change-Id: I7f3c71edba45330066d4c186ee4de1ae7d1f2adf --- java/com.sap.sailing.www/app_features.json | 1 + 1 file changed, 1 insertion(+) create mode 100644 java/com.sap.sailing.www/app_features.json diff --git a/java/com.sap.sailing.www/app_features.json b/java/com.sap.sailing.www/app_features.json new file mode 100644 index 00000000000..0743ca91f40 --- /dev/null +++ b/java/com.sap.sailing.www/app_features.json @@ -0,0 +1 @@ +{ showNewVersionHint: false } \ No newline at end of file From be425b68a55de350b70c93f7a1f46cea7cf7c6ac Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Thu, 11 Oct 2018 15:08:18 +0200 Subject: [PATCH 4/7] added GPSFixTrack.isValid(FixType) to prepare for mark passing algorithm using it Change-Id: Ic4102f2dd8d9cde614a6421533a1cef1c45330c0 --- .../src/com/sap/sailing/domain/tracking/GPSFixTrack.java | 7 +++++++ .../sap/sailing/domain/tracking/impl/GPSFixTrackImpl.java | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/GPSFixTrack.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/GPSFixTrack.java index 4e2674fd8ac..26b14401a53 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/GPSFixTrack.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/GPSFixTrack.java @@ -191,4 +191,11 @@ public interface GPSFixTrack extends MappedTra */ SpeedWithBearingStepsIterable getSpeedWithBearingSteps(TimePoint fromTimePoint, TimePoint toTimePoint); + /** + * For a fix that doesn't necessarily need to be part of this track already decides whether this fix is considered + * valid in the scope of this track. This means that if the fix is part of the track it will be returned in + * {@link #getFixes()} if and only if this method returns {@code true}. + */ + boolean isValid(FixType e); + } diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/GPSFixTrackImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/GPSFixTrackImpl.java index f4266d5e422..5167dbafdac 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/GPSFixTrackImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/GPSFixTrackImpl.java @@ -947,6 +947,11 @@ public abstract class GPSFixTrackImpl extends }; } + @Override + public boolean isValid(FixType e) { + return isValid(getInternalFixes(), e); + } + /** * When redefining this method, make sure to redefine * {@link #invalidateValidityAndEstimatedSpeedAndDistanceCaches(GPSFix)} accordingly. This implementation checks the From d24d71c78497b3a8483014a5a58f7649c001907b Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Thu, 11 Oct 2018 15:46:52 +0200 Subject: [PATCH 5/7] use the new GPSFixTrack.isValid(FixType) method in mark passing calculator to exclude invalid fixes from candidate determination Change-Id: Ia6e449f81f57568554bd86baf3f7f58cc4b00539 --- .../MarkPassingCalculatorTest.java | 3 +- .../markpassing/AbstractMarkPassingTest.java | 3 +- .../MarkPassingCalculatorPerformanceTest.java | 3 +- .../markpassing/MarkPassingWhiteBoxTest.java | 11 +++---- .../CandidateFinder.java | 5 +-- .../MarkPassingCalculator.java | 25 ++++++++------- .../MarkPassingUpdateListener.java | 24 +++++++------- .../StorePositionUpdateStrategy.java | 3 +- .../impl/CandidateFinderImpl.java | 31 ++++++++++--------- 9 files changed, 55 insertions(+), 53 deletions(-) diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculatorTest.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculatorTest.java index dc42138e41f..469a7edde33 100755 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculatorTest.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculatorTest.java @@ -19,6 +19,7 @@ import com.sap.sailing.domain.base.Regatta; import com.sap.sailing.domain.base.Waypoint; import com.sap.sailing.domain.base.impl.CourseImpl; import com.sap.sailing.domain.common.tracking.GPSFix; +import com.sap.sailing.domain.common.tracking.GPSFixMoving; import com.sap.sailing.domain.tracking.DynamicTrackedRace; import com.sap.sailing.domain.tracking.DynamicTrackedRegatta; import com.sap.sse.common.TimePoint; @@ -55,7 +56,7 @@ public class MarkPassingCalculatorTest { mpc.suspend(); mpc.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, Map> markFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, List> removedMarkPassings, List> suppressedMarkPassings, diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/AbstractMarkPassingTest.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/AbstractMarkPassingTest.java index 02a9297240f..5a3a1c81c7f 100755 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/AbstractMarkPassingTest.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/AbstractMarkPassingTest.java @@ -25,7 +25,6 @@ import com.sap.sailing.domain.common.WindSourceType; import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl; import com.sap.sailing.domain.common.impl.WindImpl; import com.sap.sailing.domain.common.impl.WindSourceImpl; -import com.sap.sailing.domain.common.tracking.GPSFix; import com.sap.sailing.domain.common.tracking.GPSFixMoving; import com.sap.sailing.domain.markpassingcalculation.Candidate; import com.sap.sailing.domain.markpassingcalculation.CandidateChooser; @@ -277,7 +276,7 @@ public abstract class AbstractMarkPassingTest extends OnlineTracTracBasedTest { protected void calculateMarkPassingsForPartialTrack(Competitor c, final TimePoint upToTimePoint, CandidateFinder finder, CandidateChooser chooser) { - List fixes = new ArrayList(); + List fixes = new ArrayList<>(); try { getTrackedRace().getTrack(c).lockForRead(); for (GPSFixMoving fix : getTrackedRace().getTrack(c).getFixes()) { diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/MarkPassingCalculatorPerformanceTest.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/MarkPassingCalculatorPerformanceTest.java index 2012379d515..9ea10518dcc 100755 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/MarkPassingCalculatorPerformanceTest.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/MarkPassingCalculatorPerformanceTest.java @@ -14,7 +14,6 @@ import org.junit.Test; import com.sap.sailing.domain.common.SpeedWithBearing; import com.sap.sailing.domain.common.impl.DegreePosition; import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl; -import com.sap.sailing.domain.common.tracking.GPSFix; import com.sap.sailing.domain.common.tracking.GPSFixMoving; import com.sap.sailing.domain.common.tracking.impl.GPSFixMovingImpl; import com.sap.sailing.domain.markpassingcalculation.Candidate; @@ -56,7 +55,7 @@ public class MarkPassingCalculatorPerformanceTest extends AbstractMockedRaceMark @Test public void testFinder() { CandidateFinder f = new CandidateFinderImpl(race); - List fixesAdded = new ArrayList<>(); + List fixesAdded = new ArrayList<>(); for (int i = 0; i < 1000; i++) { GPSFixMoving fix = rndFix(); race.recordFix(ron, fix); diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/MarkPassingWhiteBoxTest.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/MarkPassingWhiteBoxTest.java index ac03a5b9533..a45ce4fea44 100755 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/MarkPassingWhiteBoxTest.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/markpassing/MarkPassingWhiteBoxTest.java @@ -8,8 +8,8 @@ import java.util.Arrays; import java.util.List; import java.util.NavigableSet; -import org.junit.Test; import org.junit.Ignore; +import org.junit.Test; import com.sap.sailing.domain.base.Course; import com.sap.sailing.domain.base.Waypoint; @@ -17,7 +17,6 @@ import com.sap.sailing.domain.base.impl.WaypointImpl; import com.sap.sailing.domain.common.PassingInstruction; import com.sap.sailing.domain.common.impl.DegreePosition; import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl; -import com.sap.sailing.domain.common.tracking.GPSFix; import com.sap.sailing.domain.common.tracking.GPSFixMoving; import com.sap.sailing.domain.common.tracking.impl.GPSFixMovingImpl; import com.sap.sailing.domain.markpassingcalculation.Candidate; @@ -53,7 +52,7 @@ public class MarkPassingWhiteBoxTest extends AbstractMockedRaceMarkPassingTest { race.recordFix(ron, fix2); CandidateFinder finder = new CandidateFinderImpl(race); CandidateChooser chooser = new CandidateChooserImpl(race); - List fixes = new ArrayList(); + List fixes = new ArrayList<>(); fixes.add(fix1); fixes.add(fix2); Util.Pair, Iterable> candidateDeltas = finder.getCandidateDeltas(ron, fixes); @@ -95,7 +94,7 @@ public class MarkPassingWhiteBoxTest extends AbstractMockedRaceMarkPassingTest { race.recordFix(tom, fix1); race.recordFix(tom, fix3); - List fixes = new ArrayList<>(); + List fixes = new ArrayList<>(); fixes.add(fix1); fixes.add(fix3); Util.Pair, Iterable> cans = finder.getCandidateDeltas(tom, fixes); @@ -126,7 +125,7 @@ public class MarkPassingWhiteBoxTest extends AbstractMockedRaceMarkPassingTest { CandidateFinderImpl finder = new CandidateFinderImpl(race); race.recordFix(tom, fix1); race.recordFix(tom, fix2); - List fixes = new ArrayList<>(); + List fixes = new ArrayList<>(); fixes.addAll(Arrays.asList(fix1, fix2)); Util.Pair, Iterable> cans = finder.getCandidateDeltas(tom, fixes); Double inFront = cans.getA().iterator().next().getProbability(); @@ -194,7 +193,7 @@ public class MarkPassingWhiteBoxTest extends AbstractMockedRaceMarkPassingTest { race.recordFix(ben, fix1); race.recordFix(ben, fix2); race.recordFix(ben, fix3); - List fixes = new ArrayList<>(); + List fixes = new ArrayList<>(); fixes.addAll(Arrays.asList(fix1, fix2, fix3)); Util.Pair, Iterable> cans = finder.getCandidateDeltas(ben, fixes); Candidate inFront = Util.get(cans.getA(), 0); diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/CandidateFinder.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/CandidateFinder.java index b67baa44004..b19d6881369 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/CandidateFinder.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/CandidateFinder.java @@ -7,6 +7,7 @@ import com.sap.sailing.domain.base.Competitor; import com.sap.sailing.domain.base.Mark; import com.sap.sailing.domain.base.Waypoint; import com.sap.sailing.domain.common.tracking.GPSFix; +import com.sap.sailing.domain.common.tracking.GPSFixMoving; import com.sap.sse.common.TimePoint; import com.sap.sse.common.Util; import com.sap.sse.common.Util.Pair; @@ -24,7 +25,7 @@ public interface CandidateFinder { * fixes. * @return new {@link Candidate}s and those that should be removed. */ - Util.Pair, Iterable> getCandidateDeltas(Competitor c, Iterable fixes); + Util.Pair, Iterable> getCandidateDeltas(Competitor c, Iterable fixes); /** * When initializing or refreshing the calculator, the whole race until now is evaluated. For that purpose all of the @@ -40,7 +41,7 @@ public interface CandidateFinder { * @return The fixes for each Competitor that may have changed their status as a {@link Candidate} because of new * mark fixes.. */ - Map> calculateFixesAffectedByNewMarkFixes(Map> newMarkFixes); + Map> calculateFixesAffectedByNewMarkFixes(Map> newMarkFixes); /** * Notifies this finder about the race's start time having changed. The finder is only interested in the non-inferred diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculator.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculator.java index b695075ccb2..015881f1f2f 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculator.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingCalculator.java @@ -18,6 +18,7 @@ import com.sap.sailing.domain.base.Course; import com.sap.sailing.domain.base.Mark; import com.sap.sailing.domain.base.Waypoint; import com.sap.sailing.domain.common.tracking.GPSFix; +import com.sap.sailing.domain.common.tracking.GPSFixMoving; import com.sap.sailing.domain.markpassingcalculation.impl.CandidateChooserImpl; import com.sap.sailing.domain.markpassingcalculation.impl.CandidateFinderImpl; import com.sap.sailing.domain.tracking.DynamicTrackedRace; @@ -61,7 +62,7 @@ public class MarkPassingCalculator { */ private final StorePositionUpdateStrategy endMarker = new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, List> removedMarkPassings, @@ -229,7 +230,7 @@ public class MarkPassingCalculator { try { logger.fine("MarkPassingCalculator is listening on race "+raceName); boolean finished = false; - final Map> competitorFixes = new HashMap<>(); + final Map> competitorFixes = new HashMap<>(); final Map> markFixes = new HashMap<>(); final List addedWaypoints = new ArrayList<>(); final List removedWaypoints = new ArrayList<>(); @@ -361,22 +362,22 @@ public class MarkPassingCalculator { * {@link CandidateChooser} to calculate any new {@link MarkPassing}s (see {@link ComputeMarkPassings}). * */ - private void computeMarkPasses(Map> newCompetitorFixes, + private void computeMarkPasses(Map> newCompetitorFixes, Map> newMarkFixes) { logger.finer("Calculating markpassings for race "+raceName+" with " + newCompetitorFixes.size() + " new competitor Fixes and " + newMarkFixes.size() + " new mark fixes."); - Map> combinedCompetitorFixes = new HashMap<>(); + Map> combinedCompetitorFixes = new HashMap<>(); - for (Entry> competitorEntry : newCompetitorFixes.entrySet()) { - Set fixesForCompetitor = new HashSet<>(); + for (Entry> competitorEntry : newCompetitorFixes.entrySet()) { + Set fixesForCompetitor = new HashSet<>(); combinedCompetitorFixes.put(competitorEntry.getKey(), fixesForCompetitor); fixesForCompetitor.addAll(competitorEntry.getValue()); } if (!newMarkFixes.isEmpty()) { // FIXME bug 2745 use new mark fixes to invalidate chooser's mark position and mutual mark/waypoint distance cache - for (Entry> fixesAffectedByNewMarkFixes : finder + for (Entry> fixesAffectedByNewMarkFixes : finder .calculateFixesAffectedByNewMarkFixes(newMarkFixes).entrySet()) { - Set fixes = combinedCompetitorFixes.get(fixesAffectedByNewMarkFixes.getKey()); + Set fixes = combinedCompetitorFixes.get(fixesAffectedByNewMarkFixes.getKey()); if (fixes == null) { fixes = new HashSet<>(); combinedCompetitorFixes.put(fixesAffectedByNewMarkFixes.getKey(), fixes); @@ -385,7 +386,7 @@ public class MarkPassingCalculator { } } List> tasks = new ArrayList<>(); - for (final Entry> c : combinedCompetitorFixes.entrySet()) { + for (final Entry> c : combinedCompetitorFixes.entrySet()) { final Runnable runnable = new ComputeMarkPassings(c.getKey(), c.getValue()); tasks.add(new Callable() { @Override @@ -412,9 +413,9 @@ public class MarkPassingCalculator { private class ComputeMarkPassings implements Runnable { final Competitor c; - final Iterable fixes; + final Iterable fixes; - public ComputeMarkPassings(Competitor c, Iterable fixes) { + public ComputeMarkPassings(Competitor c, Iterable fixes) { this.c = c; this.fixes = fixes; } @@ -462,7 +463,7 @@ public class MarkPassingCalculator { suspended = false; enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingUpdateListener.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingUpdateListener.java index 00b1a8be99f..354875b1e36 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingUpdateListener.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/MarkPassingUpdateListener.java @@ -44,13 +44,13 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { public void competitorPositionChanged(final GPSFixMoving fix, final Competitor competitor) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, List> removedMarkPassings, List> suppressedMarkPassings, List unSuppressedMarkPassings, CandidateFinder candidateFinder, CandidateChooser candidateChooser) { - List list = competitorFixes.get(competitor); + List list = competitorFixes.get(competitor); if (list == null) { list = new ArrayList<>(); competitorFixes.put(competitor, list); @@ -64,7 +64,7 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { public void markPositionChanged(final GPSFix fix, final Mark mark, boolean firstInTrack) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, @@ -84,7 +84,7 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { public void waypointAdded(final int zeroBasedIndex, final Waypoint waypointThatGotAdded) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, @@ -102,7 +102,7 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { public void waypointRemoved(final int zeroBasedIndex, final Waypoint waypointThatGotRemoved) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, @@ -120,7 +120,7 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { final TimePoint timePointOfFixedPassing) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, @@ -135,7 +135,7 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { public void removeFixedPassing(final Competitor c, final Integer zeroBasedIndexOfWaypoint) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, @@ -150,7 +150,7 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { public void addSuppressedPassing(final Competitor c, final Integer zeroBasedIndexOfWaypoint) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, @@ -165,7 +165,7 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { public void removeSuppressedPassing(final Competitor c) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, @@ -180,7 +180,7 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { public void startOfRaceChanged(TimePoint oldStartOfRace, TimePoint newStartOfRace) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, @@ -199,7 +199,7 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { public void startOfTrackingChanged(TimePoint oldStartOfTracking, TimePoint newStartOfTracking) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, @@ -218,7 +218,7 @@ public class MarkPassingUpdateListener extends AbstractRaceChangeListener { public void finishedTimeChanged(TimePoint oldFinishedTime, TimePoint newFinishedTime) { markPassingCalculator.enqueueUpdate(new StorePositionUpdateStrategy() { @Override - public void storePositionUpdate(Map> competitorFixes, + public void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/StorePositionUpdateStrategy.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/StorePositionUpdateStrategy.java index 108491ddb5c..813acc05d4b 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/StorePositionUpdateStrategy.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/StorePositionUpdateStrategy.java @@ -7,6 +7,7 @@ import com.sap.sailing.domain.base.Competitor; import com.sap.sailing.domain.base.Mark; import com.sap.sailing.domain.base.Waypoint; import com.sap.sailing.domain.common.tracking.GPSFix; +import com.sap.sailing.domain.common.tracking.GPSFixMoving; import com.sap.sse.common.TimePoint; import com.sap.sse.common.Util.Pair; import com.sap.sse.common.Util.Triple; @@ -21,7 +22,7 @@ public interface StorePositionUpdateStrategy { * Adds its fix either to competitorFixes or markFixes, depending what the fix is for. If * no fixes exist yet for that object, a new entry is created. */ - void storePositionUpdate(Map> competitorFixes, Map> markFixes, + void storePositionUpdate(Map> competitorFixes, Map> markFixes, List addedWaypoints, List removedWaypoints, IntHolder smallestChangedWaypointIndex, List> fixedMarkPassings, List> removedMarkPassings, List> suppressedMarkPassings, List unSuppressedMarkPassings, CandidateFinder candidateFinder, CandidateChooser candidateChooser); diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/CandidateFinderImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/CandidateFinderImpl.java index 171ddb82cf9..68b6e9e6f23 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/CandidateFinderImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/CandidateFinderImpl.java @@ -223,7 +223,7 @@ public class CandidateFinderImpl implements CandidateFinder { } } else { for (final Competitor competitor : race.getRace().getCompetitors()) { - final List newFixesForCompetitor = new ArrayList<>(); + final List newFixesForCompetitor = new ArrayList<>(); final DynamicGPSFixTrack track = race.getTrack(competitor); if (track != null) { track.lockForRead(); @@ -289,7 +289,7 @@ public class CandidateFinderImpl implements CandidateFinder { @Override public Util.Pair, Iterable> getAllCandidates(Competitor c) { - Set fixes = getAllFixes(c); + Set fixes = getAllFixes(c); distanceCache.get(c).clear(); xteCache.get(c).clear(); synchronized (xteCandidates) { @@ -302,9 +302,9 @@ public class CandidateFinderImpl implements CandidateFinder { } @Override - public Map> calculateFixesAffectedByNewMarkFixes(Map> markFixes) { + public Map> calculateFixesAffectedByNewMarkFixes(Map> markFixes) { // TODO Right now creates on time stretch between the 2 outside markfixes - Map> affectedFixes = new HashMap<>(); + Map> affectedFixes = new HashMap<>(); TimePoint start = null; TimePoint end = null; for (Entry> fixes : markFixes.entrySet()) { @@ -317,9 +317,9 @@ public class CandidateFinderImpl implements CandidateFinder { } } for (Competitor c : race.getRace().getCompetitors()) { - List competitorFixes = new ArrayList<>(); + List competitorFixes = new ArrayList<>(); DynamicGPSFixTrack track = race.getTrack(c); - GPSFix comFix = track.getFirstFixAtOrAfter(start); + GPSFixMoving comFix = track.getFirstFixAtOrAfter(start); if (comFix != null) { if (end != null) { while (comFix != null && !comFix.getTimePoint().after(end)) { @@ -345,7 +345,7 @@ public class CandidateFinderImpl implements CandidateFinder { } @Override - public Util.Pair, Iterable> getCandidateDeltas(Competitor c, Iterable fixes) { + public Util.Pair, Iterable> getCandidateDeltas(Competitor c, Iterable fixes) { List newCans = new ArrayList<>(); List wrongCans = new ArrayList<>(); Course course = race.getRace().getCourse(); @@ -408,7 +408,7 @@ public class CandidateFinderImpl implements CandidateFinder { badCans.addAll(distanceCans.values()); distanceCans.clear(); } - Set allFixes = getAllFixes(c); + Set allFixes = getAllFixes(c); newCans.addAll(checkForDistanceCandidateChanges(c, allFixes, changedWaypoints).getA()); newCans.addAll(checkForXTECandidatesChanges(c, allFixes, changedWaypoints).getA()); result.put(c, new Util.Pair, List>(newCans, badCans)); @@ -525,13 +525,13 @@ public class CandidateFinderImpl implements CandidateFinder { return instruction; } - private Set getAllFixes(Competitor c) { - Set fixes = new TreeSet(comp); + private Set getAllFixes(Competitor c) { + Set fixes = new TreeSet<>(comp); if (timeRangeForValidCandidates.getTimeRangeOrNull() != null) { DynamicGPSFixTrack track = race.getTrack(c); track.lockForRead(); try { - for (GPSFix fix : track.getFixes( + for (GPSFixMoving fix : track.getFixes( timeRangeForValidCandidates.getTimeRangeOrNull().from(), /* fromInclusive */ true, timeRangeForValidCandidates.getTimeRangeOrNull().to(), /* toInclusive */ true)) { fixes.add(fix); @@ -549,7 +549,7 @@ public class CandidateFinderImpl implements CandidateFinder { * probability exceeds {@link #penaltyForSkipping}, the fix is considered a candidate. */ private Util.Pair, List> checkForDistanceCandidateChanges(Competitor c, - Iterable fixes, Iterable waypoints) { + Iterable fixes, Iterable waypoints) { Util.Pair, List> result = new Util.Pair, List>( new ArrayList(), new ArrayList()); TreeSet affectedFixes = new TreeSet(comp); @@ -705,12 +705,13 @@ public class CandidateFinderImpl implements CandidateFinder { * @param waypointAsList */ private Util.Pair, List> checkForXTECandidatesChanges(Competitor c, - Iterable fixes, Iterable waypoints) { + Iterable fixes, Iterable waypoints) { Util.Pair, List> result = new Util.Pair, List>( new ArrayList(), new ArrayList()); DynamicGPSFixTrack track = race.getTrack(c); - for (GPSFix fix : fixes) { - if (timeRangeForValidCandidates.getTimeRangeOrNull() != null && timeRangeForValidCandidates.getTimeRangeOrNull().includes(fix.getTimePoint())) { + for (GPSFixMoving fix : fixes) { + if (timeRangeForValidCandidates.getTimeRangeOrNull() != null && timeRangeForValidCandidates.getTimeRangeOrNull().includes(fix.getTimePoint()) + && track.isValid(fix)) { TimePoint t = fix.getTimePoint(); GPSFix fixBefore; GPSFix fixAfter; From 3a07f8dea470cd6878fe2892c34796a2a7745a95 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Thu, 11 Oct 2018 16:40:16 +0200 Subject: [PATCH 6/7] fixed locking aspects of checking for fix validity in mark passing calculator Change-Id: Id95ca925571f80637cff144f5865c35c1f79c784 --- .../impl/CandidateFinderImpl.java | 173 +++++++++--------- 1 file changed, 89 insertions(+), 84 deletions(-) diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/CandidateFinderImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/CandidateFinderImpl.java index 68b6e9e6f23..e810772b38f 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/CandidateFinderImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/markpassingcalculation/impl/CandidateFinderImpl.java @@ -710,112 +710,117 @@ public class CandidateFinderImpl implements CandidateFinder { new ArrayList(), new ArrayList()); DynamicGPSFixTrack track = race.getTrack(c); for (GPSFixMoving fix : fixes) { - if (timeRangeForValidCandidates.getTimeRangeOrNull() != null && timeRangeForValidCandidates.getTimeRangeOrNull().includes(fix.getTimePoint()) - && track.isValid(fix)) { + if (timeRangeForValidCandidates.getTimeRangeOrNull() != null && timeRangeForValidCandidates.getTimeRangeOrNull().includes(fix.getTimePoint())) { TimePoint t = fix.getTimePoint(); - GPSFix fixBefore; - GPSFix fixAfter; + GPSFix fixBefore = null; + GPSFix fixAfter = null; + final boolean fixIsValid; track.lockForRead(); try { - fixBefore = track.getLastFixBefore(t); - fixAfter = track.getFirstFixAfter(t); + fixIsValid = track.isValid(fix); + if (fixIsValid) { + fixBefore = track.getLastFixBefore(t); + fixAfter = track.getFirstFixAfter(t); + } } finally { track.unlockAfterRead(); } - Map> xtesBefore = null; - Map> xtesAfter = null; - TimePoint tBefore = null; - TimePoint tAfter = null; - if (fixBefore != null) { - xtesBefore = getXTE(c, fixBefore); - tBefore = fixBefore.getTimePoint(); - } - if (fixAfter != null) { - xtesAfter = getXTE(c, fixAfter); - tAfter = fixAfter.getTimePoint(); - } - Map> xtes = getXTE(c, fix); - for (Waypoint w : waypoints) { - List> oldCandidates = new ArrayList<>(); - Map, Candidate> newCandidates = new HashMap, Candidate>(); - Map, Candidate> waypointCandidates = getXteCandidates(c, w); - for (List fixPair : waypointCandidates.keySet()) { - if (fixPair.contains(fix)) { - oldCandidates.add(fixPair); - } + if (fixIsValid) { + Map> xtesBefore = null; + Map> xtesAfter = null; + TimePoint tBefore = null; + TimePoint tAfter = null; + if (fixBefore != null) { + xtesBefore = getXTE(c, fixBefore); + tBefore = fixBefore.getTimePoint(); } - List wayPointXTEs = xtes.get(w); - final int size = wayPointXTEs == null ? 0 : wayPointXTEs.size(); - if (size > 0) { - Double xte = wayPointXTEs.get(0).getMeters(); - if (xte == 0) { - newCandidates.put(Arrays.asList(fix, fix), createCandidate(c, 0, 0, t, t, w, true)); - } else { - if (fixAfter != null && xtesAfter != null && !xtesAfter.get(w).isEmpty()) { - Double xteAfter = xtesAfter.get(w).get(0).getMeters(); - if (xteAfter != null && xte < 0 != xteAfter <= 0) { - newCandidates.put(Arrays.asList(fix, fixAfter), - createCandidate(c, xte, xteAfter, t, tAfter, w, true)); - } + if (fixAfter != null) { + xtesAfter = getXTE(c, fixAfter); + tAfter = fixAfter.getTimePoint(); + } + Map> xtes = getXTE(c, fix); + for (Waypoint w : waypoints) { + List> oldCandidates = new ArrayList<>(); + Map, Candidate> newCandidates = new HashMap, Candidate>(); + Map, Candidate> waypointCandidates = getXteCandidates(c, w); + for (List fixPair : waypointCandidates.keySet()) { + if (fixPair.contains(fix)) { + oldCandidates.add(fixPair); } - if (fixBefore != null && !xtesBefore.get(w).isEmpty()) { - Double xteBefore = xtesBefore.get(w).get(0).getMeters(); - if (xte < 0 != xteBefore <= 0) { - newCandidates.put(Arrays.asList(fixBefore, fix), - createCandidate(c, xteBefore, xte, tBefore, t, w, true)); + } + List wayPointXTEs = xtes.get(w); + final int size = wayPointXTEs == null ? 0 : wayPointXTEs.size(); + if (size > 0) { + Double xte = wayPointXTEs.get(0).getMeters(); + if (xte == 0) { + newCandidates.put(Arrays.asList(fix, fix), createCandidate(c, 0, 0, t, t, w, true)); + } else { + if (fixAfter != null && xtesAfter != null && !xtesAfter.get(w).isEmpty()) { + Double xteAfter = xtesAfter.get(w).get(0).getMeters(); + if (xteAfter != null && xte < 0 != xteAfter <= 0) { + newCandidates.put(Arrays.asList(fix, fixAfter), + createCandidate(c, xte, xteAfter, t, tAfter, w, true)); + } + } + if (fixBefore != null && !xtesBefore.get(w).isEmpty()) { + Double xteBefore = xtesBefore.get(w).get(0).getMeters(); + if (xte < 0 != xteBefore <= 0) { + newCandidates.put(Arrays.asList(fixBefore, fix), + createCandidate(c, xteBefore, xte, tBefore, t, w, true)); + } } } } - } - if (size > 1) { - Double xte = wayPointXTEs.get(1).getMeters(); - if (xte == 0) { - newCandidates.put(Arrays.asList(fix, fix), createCandidate(c, 0, 0, t, t, w, false)); - } else { - if (fixAfter != null && xtesAfter != null && xtesAfter.get(w).size() >= 2) { - Double xteAfter = xtesAfter.get(w).get(1).getMeters(); - if (xte < 0 != xteAfter <= 0) { - newCandidates.put(Arrays.asList(fix, fixAfter), - createCandidate(c, xte, xteAfter, t, tAfter, w, - /* still portMark in case of single-mark waypoint */ Util.size(w.getMarks()) < 2)); + if (size > 1) { + Double xte = wayPointXTEs.get(1).getMeters(); + if (xte == 0) { + newCandidates.put(Arrays.asList(fix, fix), createCandidate(c, 0, 0, t, t, w, false)); + } else { + if (fixAfter != null && xtesAfter != null && xtesAfter.get(w).size() >= 2) { + Double xteAfter = xtesAfter.get(w).get(1).getMeters(); + if (xte < 0 != xteAfter <= 0) { + newCandidates.put(Arrays.asList(fix, fixAfter), + createCandidate(c, xte, xteAfter, t, tAfter, w, + /* still portMark in case of single-mark waypoint */ Util.size(w.getMarks()) < 2)); + } } - } - if (fixBefore != null && xtesBefore.get(w).size() >= 2) { - Double xteBefore = xtesBefore.get(w).get(1).getMeters(); - if (xte < 0 != xteBefore <= 0) { - newCandidates.put(Arrays.asList(fixBefore, fix), - createCandidate(c, xteBefore, xte, tBefore, t, w, - /* still portMark in case of single-mark waypoint */ Util.size(w.getMarks()) < 2)); + if (fixBefore != null && xtesBefore.get(w).size() >= 2) { + Double xteBefore = xtesBefore.get(w).get(1).getMeters(); + if (xte < 0 != xteBefore <= 0) { + newCandidates.put(Arrays.asList(fixBefore, fix), + createCandidate(c, xteBefore, xte, tBefore, t, w, + /* still portMark in case of single-mark waypoint */ Util.size(w.getMarks()) < 2)); + } } } } - } - for (Entry, Candidate> candidateWithFixes : newCandidates.entrySet()) { - Candidate newCan = candidateWithFixes.getValue(); - List canFixes = candidateWithFixes.getKey(); - if (oldCandidates.contains(canFixes)) { - oldCandidates.remove(canFixes); - Candidate oldCan = waypointCandidates.get(canFixes); - if (newCan.compareTo(oldCan) != 0) { - result.getB().add(oldCan); - waypointCandidates.remove(canFixes); + for (Entry, Candidate> candidateWithFixes : newCandidates.entrySet()) { + Candidate newCan = candidateWithFixes.getValue(); + List canFixes = candidateWithFixes.getKey(); + if (oldCandidates.contains(canFixes)) { + oldCandidates.remove(canFixes); + Candidate oldCan = waypointCandidates.get(canFixes); + if (newCan.compareTo(oldCan) != 0) { + result.getB().add(oldCan); + waypointCandidates.remove(canFixes); + if (newCan.getProbability() > penaltyForSkipping) { + result.getA().add(newCan); + logger.finest("Added XTE " + newCan.toString() + "for " + c); + waypointCandidates.put(canFixes, newCan); + } + } + } else { if (newCan.getProbability() > penaltyForSkipping) { result.getA().add(newCan); logger.finest("Added XTE " + newCan.toString() + "for " + c); waypointCandidates.put(canFixes, newCan); } } - } else { - if (newCan.getProbability() > penaltyForSkipping) { - result.getA().add(newCan); - logger.finest("Added XTE " + newCan.toString() + "for " + c); - waypointCandidates.put(canFixes, newCan); - } } - } - for (List badCanFixes : oldCandidates) { - result.getB().add(waypointCandidates.get(badCanFixes)); - waypointCandidates.remove(badCanFixes); + for (List badCanFixes : oldCandidates) { + result.getB().add(waypointCandidates.get(badCanFixes)); + waypointCandidates.remove(badCanFixes); + } } } } From 1f56437873271ab6b64b5a7c8a6e181a269baa48 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Fri, 12 Oct 2018 16:29:34 +0200 Subject: [PATCH 7/7] assume only Number, not Integer or Double; types don't survive backup/restore as of now Change-Id: I1e07dfca2859e76e99e2380d4dbe0eee6379aa73 --- .../domain/persistence/impl/DomainObjectFactoryImpl.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/DomainObjectFactoryImpl.java b/java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/DomainObjectFactoryImpl.java index 749cf0d754d..895c93f9890 100644 --- a/java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/DomainObjectFactoryImpl.java +++ b/java/com.sap.sailing.domain.persistence/src/com/sap/sailing/domain/persistence/impl/DomainObjectFactoryImpl.java @@ -558,7 +558,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory { .size()]; int i = 0; for (Object discardingThresholdAsObject : dbDiscardIndexResultsStartingWithHowManyRaces) { - discardIndexResultsStartingWithHowManyRaces[i++] = (Integer) discardingThresholdAsObject; + discardIndexResultsStartingWithHowManyRaces[i++] = ((Number) discardingThresholdAsObject).intValue(); } result = new ThresholdBasedResultDiscardingRuleImpl(discardIndexResultsStartingWithHowManyRaces); } @@ -1266,8 +1266,9 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory { logger.log(Level.WARNING, "Error loading racing procedure configration for regatta.", e); } } - final Double buoyZoneRadiusInHullLengths = (Double) dbRegatta + final Number buoyZoneRadiusInHullLengthsAsNumber = (Number) dbRegatta .get(FieldNames.REGATTA_BUOY_ZONE_RADIUS_IN_HULL_LENGTHS.name()); + final Double buoyZoneRadiusInHullLengths = buoyZoneRadiusInHullLengthsAsNumber==null?null:(Double) buoyZoneRadiusInHullLengthsAsNumber.doubleValue(); final Boolean useStartTimeInference = (Boolean) dbRegatta .get(FieldNames.REGATTA_USE_START_TIME_INFERENCE.name()); final Boolean controlTrackingFromStartAndFinishTimes = (Boolean) dbRegatta