mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-05 20:03:52 +00:00
support leaderboard creation / retrieval on RacingEventService
This commit is contained in:
1 parent
64a152792b
commit
957adbc635
2 files changed
+29
-7
No files matched your search
@@ -129,8 +129,20 @@ public interface RacingEventService {
|
||||
|
||||
TrackedRace getTrackedRace(Event event, RaceDefinition r);
|
||||
|
||||
void removeLeaderboard(Leaderboard leaderboard);
|
||||
/**
|
||||
* Creates a new leaderboard with the <code>name</code> specified.
|
||||
*
|
||||
* @param discardThresholds
|
||||
* Tells the thresholds from which on a next higher number of worst races will be discarded per
|
||||
* competitor. Example: <code>[3, 6]</code> means that starting from three races the single worst race
|
||||
* will be discarded; starting from six races, the two worst races per competitor are discarded.
|
||||
*
|
||||
* @return the leaderboard created
|
||||
*/
|
||||
Leaderboard addLeaderboard(String name, int[] discardThresholds);
|
||||
|
||||
void addLeaderboard(Leaderboard leaderboard);
|
||||
void removeLeaderboard(String leaderboardName);
|
||||
|
||||
Leaderboard getLeaderboardByName(String name);
|
||||
|
||||
}
|
||||
@@ -21,6 +21,9 @@ import java.util.logging.Logger;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.impl.LeaderboardImpl;
|
||||
import com.sap.sailing.domain.leaderboard.impl.ResultDiscardingRuleImpl;
|
||||
import com.sap.sailing.domain.leaderboard.impl.ScoreCorrectionImpl;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
import com.sap.sailing.domain.tracking.WindStore;
|
||||
import com.sap.sailing.domain.tracking.WindTracker;
|
||||
@@ -71,20 +74,27 @@ public class RacingEventServiceImpl implements RacingEventService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLeaderboard(Leaderboard leaderboard) {
|
||||
leaderboards.add(leaderboard);
|
||||
public Leaderboard addLeaderboard(String name, int[] discardThresholds) {
|
||||
Leaderboard result = new LeaderboardImpl(name, new ScoreCorrectionImpl(), new ResultDiscardingRuleImpl(discardThresholds));
|
||||
leaderboardsByName.put(name, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLeaderboard(Leaderboard leaderboard) {
|
||||
leaderboards.remove(leaderboard);
|
||||
public void removeLeaderboard(String leaderboardName) {
|
||||
leaderboardsByName.remove(leaderboardName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Leaderboard getLeaderboardByName(String name) {
|
||||
return leaderboardsByName.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainFactory getDomainFactory() {
|
||||
return domainFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterable<Event> getAllEvents() {
|
||||
return Collections.unmodifiableCollection(eventsByName.values());
|
||||
|
||||
Reference in new issue
Block a user