mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
Merge branch 'master' into bug1018
Conflicts: java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/mock/MockedTrackedRace.java java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/test/mock/MockedTrackedRaceWithStartTimeAndRanks.java java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedLeg.java java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/TrackedRace.java java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedLegImpl.java java/com.sap.sailing.gwt.ui.test/src/com/sap/sailing/gwt/ui/test/MockedTrackedRace.java java/com.sap.sailing.server/src/com/sap/sailing/server/masterdata/DummyTrackedRace.java The merge conflict was largely caused by the introduction of target time estimation which conflicted with a few new methods introduced on branch bug1018
This commit is contained in:
commit
869967f5b6
27 files changed
+637
-26
No files matched your search
+64
@@ -37,6 +37,8 @@ import com.sap.sailing.domain.common.Tack;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.common.tracking.GPSFix;
|
||||
import com.sap.sailing.domain.common.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.polars.NotEnoughDataHasBeenAddedException;
|
||||
import com.sap.sailing.domain.tracking.DynamicTrackedRace;
|
||||
import com.sap.sailing.domain.tracking.GPSFixTrack;
|
||||
import com.sap.sailing.domain.tracking.TrackedLeg;
|
||||
import com.sap.sailing.domain.tracking.TrackedLegOfCompetitor;
|
||||
@@ -54,6 +56,7 @@ import com.sap.sailing.server.gateway.serialization.impl.BoatClassJsonSerializer
|
||||
import com.sap.sailing.server.gateway.serialization.impl.BoatJsonSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.ColorJsonSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.CompetitorJsonSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.DurationJsonSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.FleetJsonSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.NationalityJsonSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.PersonJsonSerializer;
|
||||
@@ -80,6 +83,19 @@ public class RegattasResource extends AbstractSailingServerResource {
|
||||
.entity("Could not find a race with name '" + raceName + "' in regatta '" + regattaName + "'.")
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
|
||||
|
||||
private Response getNoTrackedRaceErrorResponse(String regattaName, String raceName) {
|
||||
return Response.status(Status.NOT_FOUND)
|
||||
.entity("No tracked race for race with name '" + raceName + "' in regatta '" + regattaName + "'.")
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
|
||||
private Response getNotEnoughDataAvailabeErrorResponse(String regattaName, String raceName) {
|
||||
return Response.status(Status.NOT_FOUND)
|
||||
.entity("No wind or polar data for race with name '" + raceName + "' in regatta '" + regattaName + "'.")
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces("application/json;charset=UTF-8")
|
||||
@@ -404,6 +420,54 @@ public class RegattasResource extends AbstractSailingServerResource {
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the target time of the race
|
||||
*
|
||||
* @param regattaName
|
||||
* the name of the regatta
|
||||
* @return -1 if not enough polar data or no wind information is available
|
||||
*/
|
||||
@GET
|
||||
@Produces("application/json;charset=UTF-8")
|
||||
@Path("{regattaname}/races/{racename}/targettime")
|
||||
public Response getTargetTime(@PathParam("regattaname") String regattaName, @PathParam("racename") String raceName,
|
||||
@QueryParam("timeasmillis") Long timeasmillis) {
|
||||
if (timeasmillis == null) {
|
||||
timeasmillis = System.currentTimeMillis();
|
||||
}
|
||||
TimePoint timePoint = new MillisecondsTimePoint(timeasmillis);
|
||||
Response response;
|
||||
Regatta regatta = findRegattaByName(regattaName);
|
||||
if (regatta == null) {
|
||||
response = getBadRegattaErrorResponse(regattaName);
|
||||
} else {
|
||||
RaceDefinition race = findRaceByName(regatta, raceName);
|
||||
if (race == null) {
|
||||
response = getBadRaceErrorResponse(regattaName, raceName);
|
||||
} else {
|
||||
DynamicTrackedRace trackedRace = getService().getTrackedRace(regatta, race);
|
||||
if (trackedRace != null) {
|
||||
Duration targetTime;
|
||||
try {
|
||||
targetTime = trackedRace.getEstimatedTimeToComplete(timePoint);
|
||||
|
||||
DurationJsonSerializer serializer = new DurationJsonSerializer();
|
||||
|
||||
JSONObject jsonCourse = serializer.serialize(targetTime);
|
||||
String json = jsonCourse.toJSONString();
|
||||
response = Response.ok(json, MediaType.APPLICATION_JSON).build();
|
||||
} catch (NotEnoughDataHasBeenAddedException | NoWindException e) {
|
||||
response = getNotEnoughDataAvailabeErrorResponse(regattaName, raceName);
|
||||
}
|
||||
} else {
|
||||
response = getNoTrackedRaceErrorResponse(regattaName, raceName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the relevant times of the race.
|
||||
|
||||
@@ -84,6 +84,10 @@ name to make sure you get to the event you're interested in.
|
||||
<td><a href="raceCourseGetDoc.html">/api/v1/regattas/{regattaname}/races/{racename}/course</a></td>
|
||||
<td>Gets the course of a race</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="raceTargetTimeGetDoc.html">/api/v1/regattas/{regattaname}/races/{racename}/targettime</a></td>
|
||||
<td>Gets the estimated target time of a race</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="raceWindGetDoc.html">/api/v1/regattas/{regattaname}/races/{racename}/wind</a></td>
|
||||
<td>Gets all GPS positions and data values for the wind of a race</td>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<link href='../../../../sailing-fontface-1.0.cache.css' media='screen' rel='stylesheet' title='Default stylesheet' type='text/css' />
|
||||
<link href='../../../main.css' media='screen' rel='stylesheet' title='Default stylesheet' type='text/css' />
|
||||
<link rel='icon' href='../../../../sap.ico' type='image/x-icon'>
|
||||
<title>SAP Sailing Analytics Webservices API Version 1.0 Beta</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SAP Sailing Analytics Webservices API Version 1.0 Beta</h1>
|
||||
<h2>URL: /api/v1/regattas/{regattaname}/races/{racename}/targettime</h2>
|
||||
|
||||
<b>Description:</b>
|
||||
<p>Gets the estimated target time of the race</p>
|
||||
<br/>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Webservice Type:</td>
|
||||
<td>REST</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Output format:</td>
|
||||
<td>Json</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Mandatory parameters:</td>
|
||||
<td>None</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Optional parameters:</td>
|
||||
<td>timeasmillis [default: current time on server]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Request method:</td>
|
||||
<td>GET</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Example:</td>
|
||||
<td><a href="http://www.sapsailing.com/sailingserver/api/v1/regattas/TW%202013%20(Finn)/races/Finn%20Race%204/targettime?timeasmillis=1431433847707">http://www.sapsailing.com/sailingserver/api/v1/regattas/TW%202013%20(Finn)/races/Finn%20Race%204/targettime?timeasmillis=1431433847707</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="height: 1em;"></div>
|
||||
<a href="index.html">Back to Web Service Overview</a>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user