fix for bug1707: storing score corrections also for competitors not currently attached to leaderboard

This commit is contained in:
Axel Uhl committed 2014-01-20 22:04:01 +01:00
1 parent 31074ccf2d
commit 53ef4ea85c
5 files changed
+94 -2

No files matched your search

@@ -96,6 +96,24 @@ public interface ScoreCorrection extends Serializable {
* the race column specified by <code>raceInLeaderboard</code>.
*/
boolean hasCorrectionFor(RaceColumn raceInLeaderboard);
/**
* @return all race columns for which this score corrections object has at least one correction; note that this
* object may hold corrections also for competitors that are not currently returned by
* {@link Leaderboard#getCompetitors()}, e.g., because one or more tracked races are not currently attached
* to the leaderboard. It is still useful to retain these corrections as the race(s) may re-appear later on.
* In particular, those corrections should be stored persistently.
*/
Iterable<RaceColumn> getRaceColumnsThatHaveCorrections();
/**
* @return all competitors for which this score corrections object has at least one correction in column
* <code>raceColumn</code>; note that this object may hold corrections also for competitors that are not
* currently returned by {@link Leaderboard#getCompetitors()}, e.g., because one or more tracked races are
* not currently attached to the leaderboard. It is still useful to retain these corrections as the race(s)
* may re-appear later on. In particular, those corrections should be stored persistently.
*/
Iterable<Competitor> getCompetitorsThatHaveCorrectionsIn(RaceColumn raceColumn);
/**
* Tells when the score correction was last updated. This should usually be the "validity time" and not the
@@ -40,4 +40,5 @@ public interface SettableScoreCorrection extends ScoreCorrection {
void notifyListenersAboutCarriedPointsChange(Competitor competitor, Double oldCarriedPoints, Double newCarriedPoints);
void notifyListenersAboutIsSuppressedChange(Competitor competitor, boolean suppressed);
}
@@ -473,4 +473,32 @@ public class ScoreCorrectionImpl implements SettableScoreCorrection {
return leaderboard;
}
@Override
public Iterable<RaceColumn> getRaceColumnsThatHaveCorrections() {
Set<RaceColumn> result = new HashSet<>();
for (Pair<Competitor, RaceColumn> correctedScoresKey : correctedScores.keySet()) {
result.add(correctedScoresKey.getB());
}
for (Pair<Competitor, RaceColumn> maxPointsReasonsKey : maxPointsReasons.keySet()) {
result.add(maxPointsReasonsKey.getB());
}
return result;
}
@Override
public Iterable<Competitor> getCompetitorsThatHaveCorrectionsIn(RaceColumn raceColumn) {
Set<Competitor> result = new HashSet<>();
for (Pair<Competitor, RaceColumn> correctedScoresKey : correctedScores.keySet()) {
if (raceColumn == correctedScoresKey.getB()) {
result.add(correctedScoresKey.getA());
}
}
for (Pair<Competitor, RaceColumn> maxPointsReasonsKey : maxPointsReasons.keySet()) {
if (raceColumn == maxPointsReasonsKey.getB()) {
result.add(maxPointsReasonsKey.getA());
}
}
return result;
}
}