mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 01:59:35 +00:00
bug6031: added overallLeaderboardName / hasOverallLeaderboard fields to REST API
This commit is contained in:
1 parent
622485d130
commit
3a17220c71
8 files changed
+32
-2
No files matched your search
+1
@@ -7,6 +7,7 @@ import com.sap.sse.security.shared.WithQualifiedObjectIdentifier;
|
||||
public interface LeaderboardGroupBase extends Renamable, NamedWithUUID, WithQualifiedObjectIdentifier, WithDescription {
|
||||
void setDescriptiom(String description);
|
||||
boolean hasOverallLeaderboard();
|
||||
String getOverallLeaderboardName();
|
||||
String getDisplayName();
|
||||
void setDisplayName(String displayName);
|
||||
}
|
||||
+8
-1
@@ -5,14 +5,21 @@ import java.util.UUID;
|
||||
public class StrippedLeaderboardGroupImpl extends LeaderboardGroupBaseImpl {
|
||||
private static final long serialVersionUID = 7263952130620919924L;
|
||||
private final boolean hasOverallLeaderboard;
|
||||
private final String overallLeaderboardName;
|
||||
|
||||
public StrippedLeaderboardGroupImpl(UUID id, String name, String description, String displayName, boolean hasOverallLeaderboard) {
|
||||
public StrippedLeaderboardGroupImpl(UUID id, String name, String description, String displayName, boolean hasOverallLeaderboard, String overallLeaderboardName) {
|
||||
super(id, name, description, displayName);
|
||||
this.hasOverallLeaderboard = hasOverallLeaderboard;
|
||||
this.overallLeaderboardName = overallLeaderboardName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasOverallLeaderboard() {
|
||||
return hasOverallLeaderboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverallLeaderboardName() {
|
||||
return overallLeaderboardName;
|
||||
}
|
||||
}
|
||||
+5
@@ -112,6 +112,11 @@ public class LeaderboardGroupImpl extends LeaderboardGroupBaseImpl implements Le
|
||||
return getOverallLeaderboard() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverallLeaderboardName() {
|
||||
return hasOverallLeaderboard() ? getOverallLeaderboard().getName() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverallLeaderboard(Leaderboard overallLeaderboard) {
|
||||
this.overallLeaderboard = overallLeaderboard;
|
||||
|
||||
+4
@@ -12,6 +12,10 @@
|
||||
response which reports the time point as the number of milliseconds since the epoch (1970-01-01T00:00:00Z, "Unix time").
|
||||
The <tt>timepoint</tt> and <tt>lastScoringUpdate</tt> fields' format is not easily machine-readable,
|
||||
but we're not changing the format for reasons of backward compatibility.</li>
|
||||
<li>The REST API for <tt>/sailingserver/api/v1/events/{event-id}</tt> and <tt>/sailingserver/api/v1/leaderboardgroups/{leaderboardgroup-name-or-id}</tt>
|
||||
now have the new <tt>overallLeaderboardName</tt> field for the leaderboard group(s), and the latter now also has
|
||||
the <tt>hasOverallLeaderboard</tt> Boolean field. The <tt>overallLeaderboardName</tt> field is present if and only if
|
||||
<tt>hasOverallLeaderboard</tt> is <tt>true</tt>.</li>
|
||||
</ul>
|
||||
<h5 class="articleSubheadline">April 2024</h5>
|
||||
<ul class="bulletList">
|
||||
|
||||
+2
-1
@@ -22,8 +22,9 @@ public class LeaderboardGroupBaseJsonDeserializer implements JsonDeserializer<Le
|
||||
String description = (String) object.get(LeaderboardGroupBaseJsonSerializer.FIELD_DESCRIPTION);
|
||||
String displayName = (String) object.get(LeaderboardGroupBaseJsonSerializer.FIELD_DISPLAY_NAME);
|
||||
Boolean hasOverallLeaderboard = (Boolean) object.get(LeaderboardGroupBaseJsonSerializer.FIELD_HAS_OVERALL_LEADERBOARD);
|
||||
String overallLeaderboardName = (String) object.get(LeaderboardGroupBaseJsonSerializer.FIELD_OVERALL_LEADERBOARD_NAME);
|
||||
LeaderboardGroupBase result = new StrippedLeaderboardGroupImpl(id, name, description, displayName,
|
||||
hasOverallLeaderboard == null ? false : hasOverallLeaderboard);
|
||||
hasOverallLeaderboard == null ? false : hasOverallLeaderboard, overallLeaderboardName);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+4
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.server.gateway.serialization;
|
||||
|
||||
import com.sap.sailing.server.gateway.serialization.impl.LeaderboardGroupBaseJsonSerializer;
|
||||
|
||||
public interface LeaderboardGroupConstants {
|
||||
String ID = "id";
|
||||
String NAME = "name";
|
||||
@@ -9,4 +11,6 @@ public interface LeaderboardGroupConstants {
|
||||
String TIMEPOINT_MILLIS = "timepoint-ms";
|
||||
String EVENTS = "events";
|
||||
String LEADERBOARDS = "leaderboards";
|
||||
String HAS_OVERALL_LEADERBOARD = LeaderboardGroupBaseJsonSerializer.FIELD_HAS_OVERALL_LEADERBOARD;
|
||||
String OVERALL_LEADERBOARD_NAME = LeaderboardGroupBaseJsonSerializer.FIELD_OVERALL_LEADERBOARD_NAME;
|
||||
}
|
||||
+4
@@ -11,6 +11,7 @@ public class LeaderboardGroupBaseJsonSerializer implements JsonSerializer<Leader
|
||||
public static final String FIELD_DESCRIPTION = "description";
|
||||
public static final String FIELD_DISPLAY_NAME = "displayName";
|
||||
public static final String FIELD_HAS_OVERALL_LEADERBOARD = "hasOverallLeaderboard";
|
||||
public static final String FIELD_OVERALL_LEADERBOARD_NAME = "overallLeaderboardName";
|
||||
|
||||
public LeaderboardGroupBaseJsonSerializer() {
|
||||
}
|
||||
@@ -22,6 +23,9 @@ public class LeaderboardGroupBaseJsonSerializer implements JsonSerializer<Leader
|
||||
result.put(FIELD_DESCRIPTION, leaderboardGroup.getDescription());
|
||||
result.put(FIELD_DISPLAY_NAME, leaderboardGroup.getDisplayName());
|
||||
result.put(FIELD_HAS_OVERALL_LEADERBOARD, leaderboardGroup.hasOverallLeaderboard());
|
||||
if (leaderboardGroup.hasOverallLeaderboard()) {
|
||||
result.put(FIELD_OVERALL_LEADERBOARD_NAME, leaderboardGroup.getOverallLeaderboardName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+4
@@ -147,6 +147,10 @@ public class LeaderboardGroupsResource extends AbstractSailingServerResource {
|
||||
jsonLeaderboardGroup.put(LeaderboardGroupConstants.DESCRIPTION, leaderboardGroup.getDescription());
|
||||
jsonLeaderboardGroup.put(LeaderboardGroupConstants.TIMEPOINT, timePoint.toString());
|
||||
jsonLeaderboardGroup.put(LeaderboardGroupConstants.TIMEPOINT_MILLIS, timePoint.asMillis());
|
||||
jsonLeaderboardGroup.put(LeaderboardGroupConstants.HAS_OVERALL_LEADERBOARD, leaderboardGroup.hasOverallLeaderboard());
|
||||
if (leaderboardGroup.hasOverallLeaderboard()) {
|
||||
jsonLeaderboardGroup.put(LeaderboardGroupConstants.OVERALL_LEADERBOARD_NAME, leaderboardGroup.getOverallLeaderboardName());
|
||||
}
|
||||
final Set<Event> eventsReferencingLeaderboardGroup = new HashSet<>();
|
||||
final JSONArray idsOfEventsReferencingLeaderboardGroup = new JSONArray();
|
||||
for (final Event event : getService().getAllEvents()) {
|
||||
|
||||
Reference in new issue
Block a user