mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-02 09:09:37 +00:00
# cleanup of gateway
This commit is contained in:
1 parent
c9452731ff
commit
bafc6a7b53
3 files changed
+28
-21
No files matched your search
-1
@@ -20,7 +20,6 @@ public class EventDataJsonExportServlet extends AbstractJsonHttpServlet {
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
|
||||
JsonSerializer<EventData> eventSerializer = createSerializer();
|
||||
JSONArray result = new JSONArray();
|
||||
for (EventData event : getService().getAllEvents()) {
|
||||
|
||||
+12
@@ -26,8 +26,16 @@ import com.sap.sailing.domain.base.racegroup.impl.SeriesWithRowsImpl;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.RegattaLeaderboard;
|
||||
|
||||
/**
|
||||
* Used to convert {@link Leaderboard}s to {@link RaceGroup}s.
|
||||
*/
|
||||
public class RaceGroupFactory {
|
||||
|
||||
/**
|
||||
* Convert given {@link Leaderboard} to a {@link RaceGroup}.
|
||||
* @param leaderboard to be converted.
|
||||
* @return the {@link RaceGroup}.
|
||||
*/
|
||||
public RaceGroup convert(Leaderboard leaderboard) {
|
||||
String name = leaderboard.getName();
|
||||
|
||||
@@ -71,6 +79,10 @@ public class RaceGroupFactory {
|
||||
return cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a series to race column mapping. If there are no series all race columns will
|
||||
* be mapped from a default series.
|
||||
*/
|
||||
private Map<Series, List<RaceColumn>> getSeriesToRaceColumns(Leaderboard leaderboard) {
|
||||
Map<Series, List<RaceColumn>> seriesToRaceColumns = new HashMap<>();
|
||||
|
||||
|
||||
+16
-20
@@ -11,7 +11,6 @@ import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.sap.sailing.domain.base.CourseArea;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.racegroup.RaceGroup;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.racelog.RaceLog;
|
||||
@@ -47,7 +46,11 @@ public class RaceGroupJsonExportServlet extends AbstractJsonHttpServlet {
|
||||
return;
|
||||
}
|
||||
|
||||
CourseArea filterCourseArea = getCourseArea(courseAreaId);
|
||||
CourseArea filterCourseArea = getService().getCourseArea(courseAreaId);
|
||||
if (filterCourseArea == null) {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND, "No course area found with given UUID.");
|
||||
return;
|
||||
}
|
||||
|
||||
JsonSerializer<RaceGroup> serializer = createSerializer();
|
||||
JSONArray result = new JSONArray();
|
||||
@@ -63,20 +66,6 @@ public class RaceGroupJsonExportServlet extends AbstractJsonHttpServlet {
|
||||
result.writeJSONString(response.getWriter());
|
||||
}
|
||||
|
||||
private CourseArea getCourseArea(UUID courseAreaId) {
|
||||
for (Event event : getService().getAllEvents()) {
|
||||
if (event.getVenue() == null) {
|
||||
continue;
|
||||
}
|
||||
for (CourseArea courseArea : event.getVenue().getCourseAreas()) {
|
||||
if (courseArea.getId().equals(courseAreaId)) {
|
||||
return courseArea;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private UUID toUUID(String value) {
|
||||
try {
|
||||
return UUID.fromString(value);
|
||||
@@ -86,10 +75,17 @@ public class RaceGroupJsonExportServlet extends AbstractJsonHttpServlet {
|
||||
}
|
||||
|
||||
private static JsonSerializer<RaceGroup> createSerializer() {
|
||||
return new RaceGroupJsonSerializer(new BoatClassJsonSerializer(), new CourseAreaJsonSerializer(),
|
||||
new SeriesWithRowsOfRaceGroupSerializer(new SeriesWithRowsJsonSerializer(
|
||||
new RaceRowsOfSeriesWithRowsSerializer(new RaceRowJsonSerializer(new FleetJsonSerializer(
|
||||
new ColorJsonSerializer()), new RaceCellJsonSerializer(createRaceLogSerializer()))))));
|
||||
return new RaceGroupJsonSerializer(
|
||||
new BoatClassJsonSerializer(),
|
||||
new CourseAreaJsonSerializer(),
|
||||
new SeriesWithRowsOfRaceGroupSerializer(
|
||||
new SeriesWithRowsJsonSerializer(
|
||||
new RaceRowsOfSeriesWithRowsSerializer(
|
||||
new RaceRowJsonSerializer(
|
||||
new FleetJsonSerializer(
|
||||
new ColorJsonSerializer()),
|
||||
new RaceCellJsonSerializer(
|
||||
createRaceLogSerializer()))))));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user