mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 17:36:40 +00:00
Time for the data in CompetitorRaceDataDTO is now saved as Date
This commit is contained in:
1 parent
38446a3ad2
commit
5f400bf95d
6 files changed
+63
-55
No files matched your search
+1
-1
@@ -164,6 +164,6 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
void updateLeaderboardGroup(String oldName, String newName, String description, List<LeaderboardDTO> leaderboards);
|
||||
|
||||
MultiCompetitorRaceDataDTO getCompetitorsRaceData(RaceIdentifier race, List<Pair<Long, CompetitorDTO>> competitors, long stepSize, DetailType detailType)
|
||||
MultiCompetitorRaceDataDTO getCompetitorsRaceData(RaceIdentifier race, List<Pair<Date, CompetitorDTO>> competitors, long stepSize, DetailType detailType)
|
||||
throws NoWindException;
|
||||
}
|
||||
+2
-2
@@ -13,8 +13,8 @@ import com.sap.sailing.domain.common.EventIdentifier;
|
||||
import com.sap.sailing.domain.common.RaceIdentifier;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.leaderboard.RaceInLeaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sailing.domain.leaderboard.RaceInLeaderboard;
|
||||
import com.sap.sailing.gwt.ui.shared.CompetitorDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.GPSFixDTO;
|
||||
@@ -282,6 +282,6 @@ public interface SailingServiceAsync {
|
||||
* returned. If this time point is lesser than the start of race, all available data for this competitor is
|
||||
* returned.
|
||||
*/
|
||||
void getCompetitorsRaceData(RaceIdentifier race, List<Pair<Long, CompetitorDTO>> competitorsQuery, long stepSize,
|
||||
void getCompetitorsRaceData(RaceIdentifier race, List<Pair<Date,CompetitorDTO>> competitorsToLoad, long stepSize,
|
||||
DetailType detailType, AsyncCallback<MultiCompetitorRaceDataDTO> callback);
|
||||
}
|
||||
+14
-13
@@ -183,13 +183,14 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
|
||||
chartData = new MultiCompetitorRaceDataDTO(getDataToShow());
|
||||
}
|
||||
|
||||
final ArrayList<Pair<Long, CompetitorDTO>> competitorsToLoad = new ArrayList<Pair<Long, CompetitorDTO>>();
|
||||
final ArrayList<Pair<Date, CompetitorDTO>> competitorsToLoad = new ArrayList<Pair<Date, CompetitorDTO>>();
|
||||
for (CompetitorDTO competitor : competitorSelectionProvider.getSelectedCompetitors()) {
|
||||
Date chartDataDateOfNewestData = chartData.getDateOfNewestData();
|
||||
if (!chartData.contains(competitor)) {
|
||||
competitorsToLoad.add(new Pair<Long, CompetitorDTO>(-1l, competitor));
|
||||
} else if (chartData.getCompetitorRaceData(competitor).getTimePointOfNewestEvent() < chartData.getTimePointOfNewestEvent()) {
|
||||
competitorsToLoad.add(new Pair<Long, CompetitorDTO>(chartData.getCompetitorRaceData(competitor)
|
||||
.getTimePointOfNewestEvent() + getStepSize(), competitor));
|
||||
competitorsToLoad.add(new Pair<Date, CompetitorDTO>(new Date(0), competitor));
|
||||
} else if (chartData.getCompetitorRaceData(competitor).getDateOfNewestData().before(chartDataDateOfNewestData)) {
|
||||
Date competitorDateOfNewestData = chartData.getCompetitorRaceData(competitor).getDateOfNewestData();
|
||||
competitorsToLoad.add(new Pair<Date, CompetitorDTO>(new Date(competitorDateOfNewestData.getTime() + getStepSize()), competitor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,22 +264,22 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
|
||||
if (isCompetitorVisible(competitor)) {
|
||||
CompetitorRaceDataDTO competitorData = chartData.getCompetitorRaceData(competitor);
|
||||
if (competitorData != null) { //TODO Exception?
|
||||
List<Triple<String, Long, Double>> markPassingsData = competitorData.getMarkPassingsData();
|
||||
List<Triple<String, Date, Double>> markPassingsData = competitorData.getMarkPassingsData();
|
||||
List<Point> markPassingPoints = new ArrayList<Point>();
|
||||
for (Triple<String, Long, Double> markPassingData : markPassingsData) {
|
||||
for (Triple<String, Date, Double> markPassingData : markPassingsData) {
|
||||
if (markPassingData.getB() != null && markPassingData.getC() != null) {
|
||||
Point markPassingPoint = new Point(markPassingData.getB(), markPassingData.getC());
|
||||
Point markPassingPoint = new Point(markPassingData.getB().getTime(), markPassingData.getC());
|
||||
markPassingPoint.setName(markPassingData.getA());
|
||||
markPassingPoints.add(markPassingPoint);
|
||||
}
|
||||
}
|
||||
|
||||
markSeries.setPoints(markPassingPoints.toArray(new Point[0]));
|
||||
List<Pair<Long, Double>> raceData = competitorData.getRaceData();
|
||||
List<Pair<Date, Double>> raceData = competitorData.getRaceData();
|
||||
List<Point> competitorPoints = new ArrayList<Point>();
|
||||
for (Pair<Long, Double> data : raceData) {
|
||||
for (Pair<Date, Double> data : raceData) {
|
||||
if (data.getA() != null && data.getB() != null) {
|
||||
Point competitorPoint = new Point(data.getA(), data.getB());
|
||||
Point competitorPoint = new Point(data.getA().getTime(), data.getB());
|
||||
competitorPoints.add(competitorPoint);
|
||||
}
|
||||
}
|
||||
@@ -522,9 +523,9 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
|
||||
public void timeChanged(Date date) {
|
||||
//Load the new data only if the timer is in live mode and the data has been initialized by loadData()
|
||||
if (timer.getPlayMode() == PlayModes.Live && getChartData() != null) {
|
||||
long newestEvent = getChartData().getTimePointOfNewestEvent();
|
||||
Date newestEvent = getChartData().getDateOfNewestData();
|
||||
if (competitorSelectionProvider.getSelectedCompetitors().iterator().hasNext() &&
|
||||
newestEvent < date.getTime() && (date.getTime() - newestEvent) >= getStepSize()) {
|
||||
newestEvent.before(date) && (date.getTime() - newestEvent.getTime()) >= getStepSize()) {
|
||||
loadData();
|
||||
}
|
||||
}
|
||||
|
||||
+13
-12
@@ -1342,43 +1342,44 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiCompetitorRaceDataDTO getCompetitorsRaceData(RaceIdentifier race, List<Pair<Long, CompetitorDTO>> competitorsQuery,
|
||||
public MultiCompetitorRaceDataDTO getCompetitorsRaceData(RaceIdentifier race, List<Pair<Date, CompetitorDTO>> competitorsQuery,
|
||||
long stepSize, DetailType detailType) throws NoWindException {
|
||||
MultiCompetitorRaceDataDTO data = null;
|
||||
TrackedRace trackedRace = getExistingTrackedRace(race);
|
||||
if (trackedRace != null) {
|
||||
data = getMultiCompetitorRaceDataDTO(trackedRace, competitorsQuery, trackedRace.getStart().asMillis(),
|
||||
trackedRace.getTimePointOfNewestEvent().asMillis(), stepSize, detailType);
|
||||
data = getMultiCompetitorRaceDataDTO(trackedRace, competitorsQuery, trackedRace.getStart().asDate(),
|
||||
trackedRace.getTimePointOfNewestEvent().asDate(), stepSize, detailType);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private MultiCompetitorRaceDataDTO getMultiCompetitorRaceDataDTO(TrackedRace race,
|
||||
List<Pair<Long, CompetitorDTO>> competitorsQuery, long startTime, long endTime, long stepSize,
|
||||
List<Pair<Date, CompetitorDTO>> competitorsQuery, Date startDate, Date endDate, long stepSize,
|
||||
DetailType detailType) throws NoWindException {
|
||||
MultiCompetitorRaceDataDTO data = new MultiCompetitorRaceDataDTO(detailType);
|
||||
// Fetching the data from the TrackedRace
|
||||
for (Pair<Long, CompetitorDTO> competitorQuery : competitorsQuery) {
|
||||
for (Pair<Date, CompetitorDTO> competitorQuery : competitorsQuery) {
|
||||
List<Long> timePoints = new ArrayList<Long>();
|
||||
for (long i = competitorQuery.getA() < startTime ? startTime : competitorQuery.getA(); i <= endTime; i += stepSize) {
|
||||
for (long i = competitorQuery.getA().before(startDate) ? startDate.getTime() : competitorQuery.getA()
|
||||
.getTime(); i <= endDate.getTime(); i += stepSize) {
|
||||
timePoints.add(i);
|
||||
}
|
||||
|
||||
Competitor competitor = getCompetitorById(race.getRace().getCompetitors(), competitorQuery.getB().id);
|
||||
ArrayList<Triple<String, Long, Double>> markPassingsData = new ArrayList<Util.Triple<String, Long, Double>>();
|
||||
ArrayList<Pair<Long, Double>> raceData = new ArrayList<Util.Pair<Long, Double>>();
|
||||
ArrayList<Triple<String, Date, Double>> markPassingsData = new ArrayList<Triple<String, Date, Double>>();
|
||||
ArrayList<Pair<Date, Double>> raceData = new ArrayList<Pair<Date, Double>>();
|
||||
// Filling the mark passings
|
||||
for (MarkPassing markPassing : race.getMarkPassings(competitor)) {
|
||||
MillisecondsTimePoint time = new MillisecondsTimePoint(markPassing.getTimePoint().asMillis());
|
||||
if (time.asMillis() >= competitorQuery.getA()) {
|
||||
markPassingsData.add(new Triple<String, Long, Double>(markPassing.getWaypoint().getName(), time
|
||||
.asMillis(), getCompetitorRaceDataEntry(detailType, race, competitor, time)));
|
||||
if (time.asDate().after(competitorQuery.getA())) {
|
||||
markPassingsData.add(new Triple<String, Date, Double>(markPassing.getWaypoint().getName(), time
|
||||
.asDate(), getCompetitorRaceDataEntry(detailType, race, competitor, time)));
|
||||
}
|
||||
}
|
||||
// Filling the race data
|
||||
for (Long timePoint : timePoints) {
|
||||
MillisecondsTimePoint time = new MillisecondsTimePoint(timePoint);
|
||||
raceData.add(new Pair<Long, Double>(timePoint, getCompetitorRaceDataEntry(detailType, race, competitor,
|
||||
raceData.add(new Pair<Date, Double>(time.asDate(), getCompetitorRaceDataEntry(detailType, race, competitor,
|
||||
time)));
|
||||
}
|
||||
// Adding fetched data to the container
|
||||
|
||||
+23
-22
@@ -3,6 +3,7 @@ package com.sap.sailing.gwt.ui.shared;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
@@ -14,25 +15,25 @@ public class CompetitorRaceDataDTO implements IsSerializable {
|
||||
|
||||
private CompetitorDTO competitor;
|
||||
private DetailType detailType;
|
||||
private long timePointOfNewestEvent; //TODO Javadoc
|
||||
private Date dateOfNewestData; //TODO Javadoc
|
||||
/**
|
||||
* A: Bouy-Name; B: Timepoint; C: Data
|
||||
* A: Bouy-Name; B: Data-Date; C: Data
|
||||
*/
|
||||
private List<Triple<String, Long, Double>> markPassingsData;
|
||||
private List<Triple<String, Date, Double>> markPassingsData;
|
||||
/**
|
||||
* A: Timepoint; B: Data
|
||||
* A: Data-Date; B: Data
|
||||
*/
|
||||
private List<Pair<Long, Double>> raceData;
|
||||
private List<Pair<Date, Double>> raceData;
|
||||
|
||||
CompetitorRaceDataDTO() {}
|
||||
|
||||
public CompetitorRaceDataDTO(CompetitorDTO competitor, DetailType detailType,
|
||||
Collection<Triple<String, Long, Double>> markPassingsData, Collection<Pair<Long, Double>> raceData) {
|
||||
Collection<Triple<String, Date, Double>> markPassingsData, Collection<Pair<Date, Double>> raceData) {
|
||||
this.competitor = competitor;
|
||||
this.detailType = detailType;
|
||||
this.markPassingsData = new ArrayList<Triple<String, Long, Double>>();
|
||||
this.markPassingsData = new ArrayList<Triple<String, Date, Double>>();
|
||||
addAllMarkPassingsData(markPassingsData);
|
||||
this.raceData = new ArrayList<Pair<Long, Double>>();
|
||||
this.raceData = new ArrayList<Pair<Date, Double>>();
|
||||
addAllRaceData(raceData);
|
||||
}
|
||||
|
||||
@@ -44,43 +45,43 @@ public class CompetitorRaceDataDTO implements IsSerializable {
|
||||
return detailType;
|
||||
}
|
||||
|
||||
public long getTimePointOfNewestEvent() {
|
||||
return timePointOfNewestEvent;
|
||||
public Date getDateOfNewestData() {
|
||||
return dateOfNewestData;
|
||||
}
|
||||
|
||||
public List<Triple<String, Long, Double>> getMarkPassingsData() {
|
||||
public List<Triple<String, Date, Double>> getMarkPassingsData() {
|
||||
return Collections.unmodifiableList(markPassingsData);
|
||||
}
|
||||
|
||||
public void addAllMarkPassingsData(Collection<Triple<String, Long, Double>> markPassingsDataToAdd) {
|
||||
for (Triple<String, Long, Double> data : markPassingsDataToAdd) {
|
||||
public void addAllMarkPassingsData(Collection<Triple<String, Date, Double>> markPassingsDataToAdd) {
|
||||
for (Triple<String, Date, Double> data : markPassingsDataToAdd) {
|
||||
addMarkPassingsData(data);
|
||||
}
|
||||
}
|
||||
|
||||
public void addMarkPassingsData(Triple<String, Long, Double> markPassingsDataToAdd) {
|
||||
public void addMarkPassingsData(Triple<String, Date, Double> markPassingsDataToAdd) {
|
||||
getMarkPassingsData().add(markPassingsDataToAdd);
|
||||
//Updating the timePointOfNewestEvent
|
||||
if (markPassingsDataToAdd.getB() > timePointOfNewestEvent) {
|
||||
timePointOfNewestEvent = markPassingsDataToAdd.getB();
|
||||
if (markPassingsDataToAdd.getB().after(dateOfNewestData)) {
|
||||
dateOfNewestData = markPassingsDataToAdd.getB();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Pair<Long, Double>> getRaceData() {
|
||||
public List<Pair<Date, Double>> getRaceData() {
|
||||
return Collections.unmodifiableList(raceData);
|
||||
}
|
||||
|
||||
public void addAllRaceData(Collection<Pair<Long, Double>> raceDataToAdd) {
|
||||
for (Pair<Long, Double> data : raceDataToAdd) {
|
||||
public void addAllRaceData(Collection<Pair<Date, Double>> raceDataToAdd) {
|
||||
for (Pair<Date, Double> data : raceDataToAdd) {
|
||||
addRaceData(data);
|
||||
}
|
||||
}
|
||||
|
||||
public void addRaceData(Pair<Long, Double> raceDataToAdd) {
|
||||
public void addRaceData(Pair<Date, Double> raceDataToAdd) {
|
||||
getRaceData().add(raceDataToAdd);
|
||||
//Updating the timePointOfNewestEvent
|
||||
if (raceDataToAdd.getA() > timePointOfNewestEvent) {
|
||||
timePointOfNewestEvent = raceDataToAdd.getA();
|
||||
if (raceDataToAdd.getA().after(dateOfNewestData)) {
|
||||
dateOfNewestData = raceDataToAdd.getA();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-5
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.gwt.ui.shared;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -79,13 +80,17 @@ public class MultiCompetitorRaceDataDTO implements IsSerializable {
|
||||
return detailType;
|
||||
}
|
||||
|
||||
public long getTimePointOfNewestEvent() {
|
||||
long result = -1;
|
||||
public Date getDateOfNewestData() {
|
||||
Date dateOfNewestData = null;
|
||||
for (CompetitorRaceDataDTO competitorRaceData : raceData.values()) {
|
||||
long raceDataNewestEvent = competitorRaceData.getTimePointOfNewestEvent();
|
||||
result = result >= raceDataNewestEvent ? result : raceDataNewestEvent;
|
||||
Date raceDateOfNewestData = competitorRaceData.getDateOfNewestData();
|
||||
if (dateOfNewestData == null) {
|
||||
dateOfNewestData = raceDateOfNewestData;
|
||||
} else {
|
||||
dateOfNewestData = dateOfNewestData.after(raceDateOfNewestData) ? dateOfNewestData : raceDateOfNewestData;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return dateOfNewestData;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
|
||||
Reference in new issue
Block a user