mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-09 22:01:02 +00:00
allow for leg detail transmission selection per race column in a leaderboard
The leg details are already properly copied into the data access object on the server and transmitted properly. Next step: add race column expansion in the UI so that first the individual legs---and, if expanded further---a selected set of detail columns for the leg are shown
This commit is contained in:
1 parent
caac6acf35
commit
e9366a9855
6 files changed
+72
-25
No files matched your search
+2
-1
@@ -482,7 +482,8 @@ public class LeaderboardConfigPanel extends FormPanel implements EventDisplayer,
|
||||
private void leaderboardSelectionChanged() {
|
||||
final String leaderboardName = getSelectedLeaderboardName();
|
||||
if (leaderboardName != null) {
|
||||
sailingService.getLeaderboardByName(leaderboardName, new Date(), new AsyncCallback<LeaderboardDAO>() {
|
||||
sailingService.getLeaderboardByName(leaderboardName, new Date(),
|
||||
/* namesOfRacesForWhichToLoadLegDetails */ null, new AsyncCallback<LeaderboardDAO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to fetch leaderboard " + leaderboardName
|
||||
|
||||
+5
-2
@@ -43,7 +43,7 @@ public class LeaderboardPanel extends FormPanel {
|
||||
|
||||
/**
|
||||
* The leaderboard name is used to
|
||||
* {@link SailingServiceAsync#getLeaderboardByName(String, java.util.Date, com.google.gwt.user.client.rpc.AsyncCallback)
|
||||
* {@link SailingServiceAsync#getLeaderboardByName(String, java.util.Date, String[], com.google.gwt.user.client.rpc.AsyncCallback)
|
||||
* obtain the leaderboard contents} from the server. It may change in case the leaderboard is renamed.
|
||||
*/
|
||||
private String leaderboardName;
|
||||
@@ -316,7 +316,10 @@ public class LeaderboardPanel extends FormPanel {
|
||||
}
|
||||
|
||||
private void loadCompleteLeaderboard(Date date) {
|
||||
getSailingService().getLeaderboardByName(getLeaderboardName(), date, new AsyncCallback<LeaderboardDAO>() {
|
||||
getSailingService().getLeaderboardByName(getLeaderboardName(), date,
|
||||
// TODO replace by the list of expanded races once we can expand race columns
|
||||
/* namesOfRacesForWhichToLoadLegDetails */ null,
|
||||
new AsyncCallback<LeaderboardDAO>() {
|
||||
@Override
|
||||
public void onSuccess(LeaderboardDAO result) {
|
||||
updateLeaderboard(result);
|
||||
|
||||
+3
-1
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -59,7 +60,8 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
public List<String> getLeaderboardNames() throws Exception;
|
||||
|
||||
public LeaderboardDAO getLeaderboardByName(String leaderboardName, Date date) throws Exception;
|
||||
LeaderboardDAO getLeaderboardByName(String leaderboardName, Date date,
|
||||
Collection<String> namesOfRacesForWhichToLoadLegDetails) throws Exception;
|
||||
|
||||
void createLeaderboard(String leaderboardName, int[] discardThresholds);
|
||||
|
||||
|
||||
+14
-1
@@ -1,10 +1,13 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
import com.sap.sailing.domain.leaderboard.RaceInLeaderboard;
|
||||
import com.sap.sailing.gwt.ui.shared.CompetitorDAO;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDAO;
|
||||
import com.sap.sailing.gwt.ui.shared.GPSFixDAO;
|
||||
@@ -69,7 +72,17 @@ public interface SailingServiceAsync {
|
||||
|
||||
void setWindSource(String eventName, String raceName, String windSourceName, AsyncCallback<Void> callback);
|
||||
|
||||
void getLeaderboardByName(String leaderboardName, Date date, AsyncCallback<LeaderboardDAO> callback);
|
||||
/**
|
||||
* @param namesOfRacesForWhichToLoadLegDetails
|
||||
* if <code>null</code>, no {@link LeaderboardEntryDAO#legDetails leg details} will be present in the
|
||||
* result ({@link LeaderboardEntryDAO#legDetails} will be <code>null</code> for all
|
||||
* {@link LeaderboardEntryDAO} objects contained). Otherwise, the {@link LeaderboardEntryDAO#legDetails}
|
||||
* list will contain one entry per leg of the race {@link Course} for those race columns whose
|
||||
* {@link RaceInLeaderboard#getName() name} is contained in <code>namesOfRacesForWhichToLoadLegDetails</code>.
|
||||
* For all other columns, {@link LeaderboardEntryDAO#legDetails} is <code>null</code>.
|
||||
*/
|
||||
void getLeaderboardByName(String leaderboardName, Date date,
|
||||
Collection<String> namesOfRacesForWhichToLoadLegDetails, AsyncCallback<LeaderboardDAO> callback);
|
||||
|
||||
void getLeaderboardNames(AsyncCallback<List<String>> callback);
|
||||
|
||||
|
||||
+40
-12
@@ -6,6 +6,7 @@ import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
@@ -24,6 +25,7 @@ import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Buoy;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Distance;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.Leg;
|
||||
import com.sap.sailing.domain.base.Position;
|
||||
@@ -100,7 +102,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
mongoObjectFactory = MongoObjectFactory.INSTANCE;
|
||||
}
|
||||
|
||||
public LeaderboardDAO getLeaderboardByName(String leaderboardName, Date date) throws Exception {
|
||||
public LeaderboardDAO getLeaderboardByName(String leaderboardName, Date date, Collection<String> namesOfRacesForWhichToLoadLegDetails) throws Exception {
|
||||
LeaderboardDAO result = null;
|
||||
Leaderboard leaderboard = getService().getLeaderboardByName(leaderboardName);
|
||||
if (leaderboard != null) {
|
||||
@@ -124,7 +126,9 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
result.competitors.add(competitorDAO);
|
||||
for (RaceInLeaderboard raceColumn : leaderboard.getRaceColumns()) {
|
||||
Entry entry = leaderboard.getEntry(competitor, raceColumn, timePoint);
|
||||
LeaderboardEntryDAO entryDAO = getLeaderboardEntryDAO(entry, raceColumn.getTrackedRace(), competitor, timePoint);
|
||||
LeaderboardEntryDAO entryDAO = getLeaderboardEntryDAO(entry, raceColumn.getTrackedRace(),
|
||||
competitor, timePoint, namesOfRacesForWhichToLoadLegDetails != null
|
||||
&& namesOfRacesForWhichToLoadLegDetails.contains(raceColumn.getName()));
|
||||
row.fieldsByRaceName.put(raceColumn.getName(), entryDAO);
|
||||
result.rows.put(competitorDAO, row);
|
||||
}
|
||||
@@ -143,7 +147,7 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
if (raceColumn != null) {
|
||||
MillisecondsTimePoint timePoint = new MillisecondsTimePoint(date);
|
||||
return getLeaderboardEntryDAO(leaderboard.getEntry(competitor, raceColumn, timePoint),
|
||||
raceColumn.getTrackedRace(), competitor, timePoint);
|
||||
raceColumn.getTrackedRace(), competitor, timePoint, /* addLegDetails */ false);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Didn't find race "+raceName+" in leaderboard "+leaderboardName);
|
||||
}
|
||||
@@ -155,24 +159,48 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
}
|
||||
}
|
||||
|
||||
private LeaderboardEntryDAO getLeaderboardEntryDAO(Entry entry, TrackedRace trackedRace, Competitor competitor, TimePoint timePoint) throws NoWindException {
|
||||
private LeaderboardEntryDAO getLeaderboardEntryDAO(Entry entry, TrackedRace trackedRace, Competitor competitor,
|
||||
TimePoint timePoint, boolean addLegDetails) throws NoWindException {
|
||||
LeaderboardEntryDAO entryDAO = new LeaderboardEntryDAO();
|
||||
entryDAO.netPoints = entry.getNetPoints();
|
||||
entryDAO.totalPoints = entry.getTotalPoints();
|
||||
entryDAO.reasonForMaxPoints = entry.getMaxPointsReason().name();
|
||||
entryDAO.discarded = entry.isDiscarded();
|
||||
for (Leg leg : trackedRace.getRace().getCourse().getLegs()) {
|
||||
TrackedLegOfCompetitor trackedLeg = trackedRace.getTrackedLeg(competitor, leg);
|
||||
LegEntryDAO legEntry = createLegEntry(trackedLeg, timePoint);
|
||||
entryDAO.legDetails.add(legEntry);
|
||||
if (addLegDetails) {
|
||||
entryDAO.legDetails = new ArrayList<LegEntryDAO>();
|
||||
for (Leg leg : trackedRace.getRace().getCourse().getLegs()) {
|
||||
TrackedLegOfCompetitor trackedLeg = trackedRace.getTrackedLeg(competitor, leg);
|
||||
LegEntryDAO legEntry = createLegEntry(trackedLeg, timePoint);
|
||||
entryDAO.legDetails.add(legEntry);
|
||||
}
|
||||
}
|
||||
return entryDAO;
|
||||
}
|
||||
|
||||
private LegEntryDAO createLegEntry(TrackedLegOfCompetitor trackedLeg, TimePoint timePoint) {
|
||||
LegEntryDAO result = new LegEntryDAO();
|
||||
result.averageSpeedOverGroundInKnots = trackedLeg.getAverageSpeedOverGround(timePoint).getKnots();
|
||||
// TODO continue here, copying trackedLeg entries to result...
|
||||
private LegEntryDAO createLegEntry(TrackedLegOfCompetitor trackedLeg, TimePoint timePoint) throws NoWindException {
|
||||
LegEntryDAO result;
|
||||
if (trackedLeg == null) {
|
||||
result = null;
|
||||
} else {
|
||||
result = new LegEntryDAO();
|
||||
Speed averageSpeedOverGround = trackedLeg.getAverageSpeedOverGround(timePoint);
|
||||
result.averageSpeedOverGroundInKnots = averageSpeedOverGround == null ? null : averageSpeedOverGround
|
||||
.getKnots();
|
||||
SpeedWithBearing speedOverGround = trackedLeg.getSpeedOverGround(timePoint);
|
||||
result.currentSpeedOverGroundInKnots = speedOverGround == null ? null : speedOverGround.getKnots();
|
||||
Distance distanceTraveled = trackedLeg.getDistanceTraveled(timePoint);
|
||||
result.distanceTraveledInMeters = distanceTraveled == null ? null : distanceTraveled.getMeters();
|
||||
result.estimatedTimeToNextWaypointInSeconds = trackedLeg.getEstimatedTimeToNextMarkInSeconds(timePoint);
|
||||
result.finished = trackedLeg.hasFinishedLeg(timePoint);
|
||||
result.gapToLeaderInSeconds = trackedLeg.getGapToLeaderInSeconds(timePoint);
|
||||
result.rank = trackedLeg.getRank(timePoint);
|
||||
result.started = trackedLeg.hasStartedLeg(timePoint);
|
||||
Speed velocityMadeGood = trackedLeg.getVelocityMadeGood(timePoint);
|
||||
result.velocityMadeGoodInKnots = velocityMadeGood == null ? null : velocityMadeGood.getKnots();
|
||||
Distance windwardDistanceToGo = trackedLeg.getWindwardDistanceToGo(timePoint);
|
||||
result.windwardDistanceToGoInMeters = windwardDistanceToGo == null ? null : windwardDistanceToGo
|
||||
.getMeters();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -11,14 +11,14 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
*
|
||||
*/
|
||||
public class LegEntryDAO implements IsSerializable {
|
||||
public double distanceTraveledInMeters;
|
||||
public double averageSpeedOverGroundInKnots;
|
||||
public int rank;
|
||||
public double gapToLeaderInSeconds;
|
||||
public double estimatedTimeToNextWaypointInSeconds;
|
||||
public double currentSpeedOverGroundInKnots;
|
||||
public double velocityMadeGoodInKnots;
|
||||
public double windwardDistanceToGoInMeters;
|
||||
public Double distanceTraveledInMeters;
|
||||
public Double averageSpeedOverGroundInKnots;
|
||||
public Integer rank;
|
||||
public Double gapToLeaderInSeconds;
|
||||
public Double estimatedTimeToNextWaypointInSeconds;
|
||||
public Double currentSpeedOverGroundInKnots;
|
||||
public Double velocityMadeGoodInKnots;
|
||||
public Double windwardDistanceToGoInMeters;
|
||||
public boolean started;
|
||||
public boolean finished;
|
||||
}
|
||||
Reference in new issue
Block a user