fix for bug 3826: if a suppressed competitor's ID cannot be found in the leaderboard's competitors set, ignore that competitor instead of returning null from RaceCOmpetitorSet.computeCompetitorsFromIDs

Change-Id: I9ffb7d2ea88359c1e95670b93ef0b215a3fdabb2
This commit is contained in:
Axel Uhl committed 2016-09-08 18:17:09 +02:00
1 parent 6a479c9cce
commit 69379e1815
4 files changed
+17 -7

No files matched your search

@@ -31,7 +31,7 @@ public class LeaderboardDTO extends AbstractLeaderboardDTO implements Serializab
private String id;
/**
* The competitor list, ordered ascending by total rank
* The competitor list, ordered ascending by total rank, suppressed competitors removed
*/
public List<CompetitorDTO> competitors;
@@ -610,11 +610,17 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
return result;
}
/**
* suppressed competitors are removed from the result
*/
@Override
public List<Competitor> getCompetitorsFromBestToWorst(TimePoint timePoint) {
return getCompetitorsFromBestToWorst(getRaceColumns(), timePoint);
}
/**
* suppressed competitors are removed from the result
*/
private List<Competitor> getCompetitorsFromBestToWorst(Iterable<RaceColumn> raceColumnsToConsider, TimePoint timePoint) {
List<Competitor> result = new ArrayList<Competitor>();
for (Competitor competitor : getCompetitors()) {
@@ -123,8 +123,10 @@ public class RaceCompetitorSet extends RaceCompetitorIdsAsStringWithMD5Hash {
/**
* Tries to locate the competitors described by the IDs in {@link #idsAsStringOfCompetitorsParticipatingInRace} in
* <code>competitors</code> and returns them in a set. If not all competitors can be found, <code>null</code> is
* returned instead.
* <code>competitors</code> and returns them in a set. The subset of competitors found this way is returned.
* Note that due to the possibility of suppressing competitors it is possible that competitors are listed
* as entries in the race but cannot be resolved in the leaderboard's competitors which does not contain
* those being suppressed.
*/
private Set<CompetitorDTO> computeCompetitorsFromIDs(Iterable<CompetitorDTO> competitors) {
Set<CompetitorDTO> result;
@@ -138,10 +140,7 @@ public class RaceCompetitorSet extends RaceCompetitorIdsAsStringWithMD5Hash {
result = new HashSet<>();
for (String id : getIdsOfCompetitorsParticipatingInRaceAsStrings()) {
CompetitorDTO c = competitorsByIdAsString.get(id);
if (c == null) {
result = null;
break;
} else {
if (c != null) {
result.add(c);
}
}
@@ -15,5 +15,10 @@ public class RaceMapDataDTO implements IsSerializable {
public LinkedHashMap<CompetitorDTO, QuickRankDTO> quickRanks;
public LinkedHashMap<CompetitorDTO, Integer> competitorsInOrderOfWindwardDistanceTraveledWithOneBasedLegNumber;
public long simulationResultVersion;
/**
* The competitor IDs in their {@link Object#toString()} representation, for all competitors in the race, including those
* that may be suppressed in a leaderboard.
*/
public HashSet<String> raceCompetitorIdsAsStrings;
}