mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-21 11:40:01 +00:00
added services for starttracking and stoptracking
Change-Id: I542645ab24fa221f21685d1545c36df221172a9c
This commit is contained in:
1 parent
e5984ab0f5
commit
941143abd6
6 files changed
+155
-14
No files matched your search
@@ -70,6 +70,7 @@ bearerToken = com.sap.sailing.server.security.BearerTokenOrBasicOrFormAuthentica
|
||||
/api/v1/leaderboards/*/racecolumnfactors/** = bearerToken
|
||||
/api/v1/leaderboards/*/settrackingtimes/** = bearerToken
|
||||
/api/v1/leaderboards/*/starttracking/** = bearerToken
|
||||
/api/v1/leaderboards/*/stoptracking/** = bearerToken
|
||||
/api/v1/regattas/*/addracecolumns/** = bearerToken
|
||||
/api/v1/regattas/*/removeracecolumn = bearerToken
|
||||
/api/v1/regattas/*/competitors/*/add = bearerToken
|
||||
|
||||
+31
@@ -3,6 +3,7 @@ package com.sap.sailing.server.gateway.jaxrs.api;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
@@ -52,6 +53,8 @@ import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.base.Nationality;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.domain.common.MaxPointsReason;
|
||||
import com.sap.sailing.domain.common.NoWindException;
|
||||
@@ -700,6 +703,34 @@ public class LeaderboardsResource extends AbstractSailingServerResource {
|
||||
return result;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{leaderboardName}/stoptracking")
|
||||
public Response stopTracking(@PathParam("leaderboardName") String leaderboardName,
|
||||
@QueryParam(RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME) String raceColumnName,
|
||||
@QueryParam(RaceLogServletConstants.PARAMS_RACE_FLEET_NAME) String fleetName) throws MalformedURLException, IOException, InterruptedException {
|
||||
SecurityUtils.getSubject().checkPermission(Permission.LEADERBOARD.getStringPermissionForObjects(Mode.UPDATE, leaderboardName));
|
||||
final LeaderboardAndRaceColumnAndFleetAndResponse leaderboardAndRaceColumnAndFleetAndResponse = getLeaderboardAndRaceColumnAndFleet(leaderboardName, raceColumnName, fleetName);
|
||||
final Response result;
|
||||
if (leaderboardAndRaceColumnAndFleetAndResponse.getFleet() != null) {
|
||||
JSONObject jsonResult = new JSONObject();
|
||||
final TrackedRace trackedRace = leaderboardAndRaceColumnAndFleetAndResponse.getRaceColumn().getTrackedRace(leaderboardAndRaceColumnAndFleetAndResponse.getFleet());
|
||||
if (trackedRace == null) {
|
||||
result = Response.status(Status.PRECONDITION_FAILED).entity("no tracked race").build();
|
||||
} else {
|
||||
final Regatta regatta = trackedRace.getTrackedRegatta().getRegatta();
|
||||
final RaceDefinition race = trackedRace.getRace();
|
||||
getService().stopTracking(regatta, race);
|
||||
jsonResult.put("regatta", regatta.getName());
|
||||
jsonResult.put("race", race.getName());
|
||||
result = Response.ok(jsonResult.toJSONString()).build();
|
||||
}
|
||||
} else {
|
||||
result = leaderboardAndRaceColumnAndFleetAndResponse.getResponse();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{leaderboardName}/marks")
|
||||
|
||||
@@ -122,7 +122,7 @@ name to make sure you get to the event you're interested in.
|
||||
<td>Adds one or more race columns to a regatta</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="regattasRemoveRaceColumn.html">/api/v1/regattas/{regattaname}/removeracecolumn?racecolumn={racecolumnname}</a></td>
|
||||
<td><a href="regattasRemoveRaceColumn.html">/api/v1/regattas/{regattaname}/removeracecolumn</a></td>
|
||||
<td>Removes a race column from a regatta</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -174,13 +174,21 @@ name to make sure you get to the event you're interested in.
|
||||
<td>Gets the details of a competitor in the context of a leaderboard</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="leaderboardRaceMarksGetDoc.html">/api/v1/leaderboards/{name}/marks?race_column={name}&fleet={name}</a></td>
|
||||
<td><a href="leaderboardRaceMarksGetDoc.html">/api/v1/leaderboards/{name}/marks</a></td>
|
||||
<td>Gets the marks of a race (from the RaceLog and if possible the TrackedRace)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="leaderboardRaceSetTrackingTimes.html">/api/v1/leaderboards/{name}/settrackingtimes?race_column={name}&fleet={name}</a></td>
|
||||
<td><a href="leaderboardRaceSetTrackingTimes.html">/api/v1/leaderboards/{name}/settrackingtimes</a></td>
|
||||
<td>Modifies the race's tracking interval</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="leaderboardRaceStartTracking.html">/api/v1/leaderboards/{name}/starttracking</a></td>
|
||||
<td>Starts tracking for a race log / smart phone-tracked race</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="leaderboardRaceStopTracking.html">/api/v1/leaderboards/{name}/stoptracking</a></td>
|
||||
<td>Stops tracking for a race</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="leaderboardMarkGpsFixesPostDoc.html">/api/v1/leaderboards/{name}/marks/{id}/gps_fixes</a></td>
|
||||
<td>Pings the location of a mark via the RegattaLog</td>
|
||||
|
||||
+4
-11
@@ -12,15 +12,7 @@
|
||||
<h2>URL: /api/v1/leaderboards/{name}/settrackingtimes?race_column={name}&fleet={name}</h2>
|
||||
|
||||
<b>Description:</b>
|
||||
<p>Modifies the tracking start/finish times for a race. If nothing is specified about the start
|
||||
of tracking time (none of the parameters startoftracking and startoftrackingasmillis present),
|
||||
no modification will be applied to the tracking start time, and no race log entry will be created
|
||||
for it. If one of the two parameters is provided but with an empty value, the tracking start time
|
||||
will be set to <tt>null</tt> explicitly.</p>
|
||||
<p>Likewise, the same holds for endoftracking and endoftrackingmillis, accordingly.
|
||||
</p>
|
||||
<p>The resulting JSON document tells which of the startoftracking and endoftracking times have been
|
||||
set for the race and to which value.
|
||||
<p>Starts tracking for a race. By default, wind tracking is activated,
|
||||
</p>
|
||||
<br/>
|
||||
<table>
|
||||
@@ -55,10 +47,11 @@ set for the race and to which value.
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Example:</td>
|
||||
<td>http://127.0.0.1:8888/sailingserver/api/v1/leaderboards/TracTrac%20Virtual%20Course%20Marks%20Test/settrackingtimes?race_column=R1&fleet=Default&startoftracking=2007-01-03T13:05:00Z<br>
|
||||
<td>http://127.0.0.1:8888/sailingserver/api/v1/leaderboards/TracTrac%20Virtual%20Course%20Marks%20Test/starttracking?race_column=R1&fleet=Default<br>
|
||||
delivers <pre>
|
||||
{
|
||||
"startoftracking": 1167829500000
|
||||
"addeddenotation": true
|
||||
"regatta": "TracTrac Virtual Course Marks Test"
|
||||
}
|
||||
</pre></td>
|
||||
</tr>
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<!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='../../../../fontface.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</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SAP Sailing Analytics Webservices API Version 1.0</h1>
|
||||
<h2>URL: /api/v1/leaderboards/{name}/starttracking?race_column={name}&fleet={name}</h2>
|
||||
|
||||
<b>Description:</b>
|
||||
<p>Starts tracking the race identified by the race_column and fleet parameters.
|
||||
If no smartphone tracking denotation exists yet for that race, one is added.
|
||||
Wind tracking can be configured using optional request parameters.</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>race_column, fleet</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Optional parameters:</td>
|
||||
<td>
|
||||
<div>trackWind a boolean value, defaulting to true; tells whether to start receiving live wind data for the tracked race</div>
|
||||
<div>correctWindDirectionByMagneticDeclination a boolean value, defaulting to true; if trackWind is true,
|
||||
this parameter controls whether the wind directions received are to be corrected by the magnetic
|
||||
declination</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Request method:</td>
|
||||
<td>POST</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Example:</td>
|
||||
<td>http://127.0.0.1:8888/sailingserver/api/v1/leaderboards/TracTrac%20Virtual%20Course%20Marks%20Test/settrackingtimes?race_column=R1&fleet=Default&startoftracking=2007-01-03T13:05:00Z<br>
|
||||
delivers <pre>
|
||||
{"addeddenotation":false, "regatta":"TracTrac Virtual Course Marks Test"}
|
||||
</pre>
|
||||
where the addeddenotation field tells whether an annotation for smartphone tracking had to be added
|
||||
in order to be able to track the race.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="height: 1em;"></div>
|
||||
<a href="index.html">Back to Web Service Overview</a>
|
||||
</body>
|
||||
</html>
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<!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='../../../../fontface.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</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SAP Sailing Analytics Webservices API Version 1.0</h1>
|
||||
<h2>URL: /api/v1/leaderboards/{name}/stoptracking?race_column={name}&fleet={name}</h2>
|
||||
|
||||
<b>Description:</b>
|
||||
<p>Stops tracking the race identified by the race_column and fleet parameters.
|
||||
</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>race_column, fleet</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Optional parameters:</td>
|
||||
<td>None</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Request method:</td>
|
||||
<td>POST</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Example:</td>
|
||||
<td>curl -X POST -H "Authorization: Bearer w9YSIfr/Zf6a127SZDddkhdAtQuuv0Jm1PSXlo1Yvd0=" "http://127.0.0.1:8888/sailingserver/api/v1/leaderboards/Smartphone%20Tracking%20Test%2022.06/stoptracking?race_column=K1&fleet=Blue"<br>
|
||||
delivers the regatta and race name of the race whose tracking got stopped:<pre>
|
||||
{"regatta":"Smartphone Tracking Test 22.06","race":"Smartphone Tracking Test 22.06 K1 Blue"}
|
||||
</pre></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