mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-13 15:50:59 +00:00
added a json export servlet for sailing events
This commit is contained in:
1 parent
9e0b09fab7
commit
887b2ec5dd
4 files changed
+100
-5
No files matched your search
@@ -63,6 +63,15 @@
|
|||||||
<url-pattern>/expedition</url-pattern>
|
<url-pattern>/expedition</url-pattern>
|
||||||
</servlet-mapping>
|
</servlet-mapping>
|
||||||
|
|
||||||
|
<servlet>
|
||||||
|
<servlet-name>EventsJsonExportServlet</servlet-name>
|
||||||
|
<servlet-class>com.sap.sailing.server.gateway.impl.EventsJsonExportServlet</servlet-class>
|
||||||
|
</servlet>
|
||||||
|
<servlet-mapping>
|
||||||
|
<servlet-name>EventsJsonExportServlet</servlet-name>
|
||||||
|
<url-pattern>/events</url-pattern>
|
||||||
|
</servlet-mapping>
|
||||||
|
|
||||||
<servlet>
|
<servlet>
|
||||||
<servlet-name>RegattasJsonExportServlet</servlet-name>
|
<servlet-name>RegattasJsonExportServlet</servlet-name>
|
||||||
<servlet-class>com.sap.sailing.server.gateway.impl.RegattasJsonExportServlet</servlet-class>
|
<servlet-class>com.sap.sailing.server.gateway.impl.RegattasJsonExportServlet</servlet-class>
|
||||||
|
|||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package com.sap.sailing.server.gateway.impl;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
|
||||||
|
import com.sap.sailing.domain.base.EventData;
|
||||||
|
import com.sap.sailing.server.gateway.AbstractJsonHttpServlet;
|
||||||
|
import com.sap.sailing.server.gateway.serialization.JsonSerializer;
|
||||||
|
import com.sap.sailing.server.gateway.serialization.impl.CourseAreaJsonSerializer;
|
||||||
|
import com.sap.sailing.server.gateway.serialization.impl.EventDataJsonSerializer;
|
||||||
|
import com.sap.sailing.server.gateway.serialization.impl.VenueJsonSerializer;
|
||||||
|
|
||||||
|
public class EventsJsonExportServlet extends AbstractJsonHttpServlet {
|
||||||
|
private static final long serialVersionUID = -7313766879733880267L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
JsonSerializer<EventData> eventSerializer = new EventDataJsonSerializer(new VenueJsonSerializer(new CourseAreaJsonSerializer()));
|
||||||
|
JSONArray result = new JSONArray();
|
||||||
|
for (EventData event : getService().getAllEvents()) {
|
||||||
|
result.add(eventSerializer.serialize(event));
|
||||||
|
}
|
||||||
|
setJsonResponseHeader(response);
|
||||||
|
result.writeJSONString(response.getWriter());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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>Gateway services</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>SAP Sailing Analytics - Web Services</h1>
|
||||||
|
<h2>Name: events</h2>
|
||||||
|
|
||||||
|
<b>Description:</b>
|
||||||
|
<p>This service exports all existing events with their venues and course areas</p>
|
||||||
|
<br/>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Webservice Type:</td>
|
||||||
|
<td>REST</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Output format:</td>
|
||||||
|
<td>Json</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Url:</td>
|
||||||
|
<td>http://www.sapsailing.com/sailingserver/events</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Mandatory parameters:</td>
|
||||||
|
<td>None</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Optional parameters:</td>
|
||||||
|
<td>None</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Request method:</td>
|
||||||
|
<td>GET</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Example:</td>
|
||||||
|
<td>http://www.sapsailing.com/sailingserver/events</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<a href="index.html">Back to Web Service Overview</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -18,16 +18,16 @@
|
|||||||
</trh>
|
</trh>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><a href="eventsExportDoc.html">events</a></td>
|
||||||
|
<td>Gets all events</td>
|
||||||
|
<td><a href="eventsExportJsonSample.json">Json</a></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="regattasExportDoc.html">regattas</a></td>
|
<td><a href="regattasExportDoc.html">regattas</a></td>
|
||||||
<td>Gets all regattas</td>
|
<td>Gets all regattas</td>
|
||||||
<td><a href="regattasExportJsonSample.json">Json</a></td>
|
<td><a href="regattasExportJsonSample.json">Json</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td><a href="leaderboardExportDoc.html">leaderboard</a></td>
|
|
||||||
<td>Gets a leaderboard</td>
|
|
||||||
<td><a href="leaderboardExportJsonSample.json">Json</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="leaderboardGroupsExportDoc.html">leaderboardgroups</a></td>
|
<td><a href="leaderboardGroupsExportDoc.html">leaderboardgroups</a></td>
|
||||||
<td>Gets all leaderboard groups</td>
|
<td>Gets all leaderboard groups</td>
|
||||||
@@ -38,6 +38,11 @@
|
|||||||
<td>Gets all leaderboards</td>
|
<td>Gets all leaderboards</td>
|
||||||
<td><a href="leaderboardsExportJsonSample.json">Json</a></td>
|
<td><a href="leaderboardsExportJsonSample.json">Json</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><a href="leaderboardExportDoc.html">leaderboard</a></td>
|
||||||
|
<td>Gets a leaderboard</td>
|
||||||
|
<td><a href="leaderboardExportJsonSample.json">Json</a></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="leaderboardGroupExportDoc.html">leaderboardgroup</a></td>
|
<td><a href="leaderboardGroupExportDoc.html">leaderboardgroup</a></td>
|
||||||
<td>Gets a group of leaderboards</td>
|
<td>Gets a group of leaderboards</td>
|
||||||
|
|||||||
Reference in new issue
Block a user