mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-16 17:21:00 +00:00
Service for getting marks now returns marks defined on Regatta
This commit is contained in:
1 parent
4addae99f1
commit
70609813f0
1 file changed
+13
-4
+13
-4
@@ -543,7 +543,18 @@ public class LeaderboardsResource extends AbstractSailingServerResource {
|
||||
.entity("Could not find a leaderboard with name '" + leaderboardName + "'.")
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
final Set<Mark> marks;
|
||||
|
||||
if (! (leaderboard instanceof HasRegattaLike)) {
|
||||
return Response.status(Status.NOT_FOUND)
|
||||
.entity("Leaderboard with name '"+ leaderboardName+ "'does not contain a RegattaLog'.")
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
LeaderboardThatHasRegattaLike regattaLikeLeaderboard = (LeaderboardThatHasRegattaLike) leaderboard;
|
||||
RegattaLog regattaLog = ((HasRegattaLike) regattaLikeLeaderboard).getRegattaLike().getRegattaLog();
|
||||
|
||||
final Set<Mark> marks = new HashSet<Mark>();
|
||||
Util.addAll(new DefinedMarkFinder<>(regattaLog).analyze(), marks);
|
||||
|
||||
if (raceColumnName == null) {
|
||||
if (fleetName != null) {
|
||||
return Response
|
||||
@@ -551,7 +562,6 @@ public class LeaderboardsResource extends AbstractSailingServerResource {
|
||||
.entity("Either specify neither raceColumnName nor fleetName, only raceColumnName, or raceColumnName and fleetName but not only fleetName")
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
} else {
|
||||
marks = new HashSet<Mark>();
|
||||
for (RaceColumn raceColumn : leaderboard.getRaceColumns()) {
|
||||
for (Fleet fleet : raceColumn.getFleets()) {
|
||||
RaceLog raceLog = raceColumn.getRaceLog(fleet);
|
||||
@@ -578,11 +588,10 @@ public class LeaderboardsResource extends AbstractSailingServerResource {
|
||||
.entity("Could not find fleet '" + fleetName + "' in leaderboard '" + leaderboardName
|
||||
+ "'.").type(MediaType.TEXT_PLAIN).build();
|
||||
} else {
|
||||
marks = getMarksForFleet(raceColumn, fleet);
|
||||
marks.addAll(getMarksForFleet(raceColumn, fleet));
|
||||
}
|
||||
} else {
|
||||
// Return all marks for a certain race column
|
||||
marks = new HashSet<Mark>();
|
||||
for (Fleet fleet : raceColumn.getFleets()) {
|
||||
Util.addAll(getMarksForFleet(raceColumn, fleet), marks);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user