mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-02 09:09:37 +00:00
# removed obsolete servlets
This commit is contained in:
1 parent
351a835cc6
commit
2763d11782
3 files changed
+1
-174
No files matched your search
+1
@@ -72,6 +72,7 @@ public class AddToRaceLogJsonExportServlet extends JsonExportServlet {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND, "No such fleet found.");
|
||||
return;
|
||||
}
|
||||
|
||||
/// TODO: get RaceLog of RaceColumn by Fleet
|
||||
//service.apply(new RecordRaceLogEvent(leaderboardName, raceColumnName, fleetName, event));
|
||||
JsonDeserializer<RaceLogEvent> deserializer =
|
||||
|
||||
-97
@@ -1,97 +0,0 @@
|
||||
package com.sap.sailing.server.gateway.impl.rc;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.tracking.DynamicTrackedRace;
|
||||
import com.sap.sailing.domain.tracking.DynamicTrackedRegatta;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
import com.sap.sailing.domain.tracking.TrackedRegatta;
|
||||
import com.sap.sailing.server.gateway.deserialization.JsonDeserializationException;
|
||||
import com.sap.sailing.server.gateway.deserialization.impl.Helpers;
|
||||
import com.sap.sailing.server.gateway.impl.JsonExportServlet;
|
||||
|
||||
|
||||
public class ModifyRaceLogJsonExportServlet extends JsonExportServlet {
|
||||
private static final long serialVersionUID = 2197006949440887925L;
|
||||
|
||||
/// TODO: for presentation purpose only - implementation needed
|
||||
@SuppressWarnings("unused")
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
/// TODO: split race identifier into its part (leaderboard name, series name, fleet name, race column name)
|
||||
try {
|
||||
Object requestBody = JSONValue.parseWithException(request.getReader());
|
||||
JSONObject requestObject = Helpers.toJSONObjectSafe(requestBody);
|
||||
|
||||
/// TODO: deserialize request (including identifier and to-be-added event)
|
||||
String leaderboardName = "";
|
||||
String seriesName = "";
|
||||
String fleetName = "";
|
||||
String raceColumnName = "";
|
||||
RaceLogEvent raceLogEvent = null;
|
||||
|
||||
Leaderboard leaderboard = getService().getLeaderboardByName(leaderboardName);
|
||||
if (leaderboard == null) {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND, "No such leaderboard found.");
|
||||
return;
|
||||
}
|
||||
|
||||
Fleet fleet = leaderboard.getFleet(fleetName);
|
||||
if (fleet == null) {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND, "No such fleet found.");
|
||||
return;
|
||||
}
|
||||
|
||||
RaceColumn raceColumn = leaderboard.getRaceColumnByName(raceColumnName);
|
||||
if (raceColumn == null) {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND, "No such race column found.");
|
||||
return;
|
||||
}
|
||||
|
||||
TrackedRace trackedRace = raceColumn.getTrackedRace(fleet);
|
||||
if (trackedRace == null) {
|
||||
response.sendError(HttpServletResponse.SC_NOT_FOUND, "No such tracked race found.");
|
||||
return;
|
||||
}
|
||||
|
||||
DynamicTrackedRace dynamicTrackedRace = getDynamicTrackedRace(trackedRace);
|
||||
if (dynamicTrackedRace == null) {
|
||||
response.sendError(
|
||||
HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
|
||||
"Tracked race cannot be modified right now.");
|
||||
return;
|
||||
}
|
||||
|
||||
//TODO dynamicTrackedRace.recordRaceLogEvent(raceLogEvent);
|
||||
} catch (ParseException e) {
|
||||
throw new JsonDeserializationException("Invalid JSON in request body.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private DynamicTrackedRace getDynamicTrackedRace(TrackedRace trackedRace) {
|
||||
TrackedRegatta trackedRegatta = trackedRace.getTrackedRegatta();
|
||||
if (trackedRegatta == null) {
|
||||
return null;
|
||||
}
|
||||
DynamicTrackedRegatta dynamicTrackedRegatta = getService().getTrackedRegatta(trackedRegatta.getRegatta());
|
||||
if (dynamicTrackedRegatta == null) {
|
||||
return null;
|
||||
}
|
||||
return dynamicTrackedRegatta.getExistingTrackedRace(trackedRace.getRace());
|
||||
}
|
||||
|
||||
}
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
package com.sap.sailing.server.gateway.impl.rc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONValue;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
import com.sap.sailing.server.gateway.deserialization.JsonDeserializationException;
|
||||
import com.sap.sailing.server.gateway.deserialization.impl.Helpers;
|
||||
import com.sap.sailing.server.gateway.impl.JsonExportServlet;
|
||||
import com.sap.sailing.server.gateway.serialization.JsonSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.CompetitorIdJsonSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.racelog.RaceLogCourseAreaChangedEventSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.racelog.RaceLogEventSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.racelog.RaceLogEventSerializerChooser;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.racelog.RaceLogFlagEventSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.racelog.RaceLogRaceStatusEventSerializer;
|
||||
import com.sap.sailing.server.gateway.serialization.impl.racelog.RaceLogStartTimeEventSerializer;
|
||||
|
||||
|
||||
public class QueryRaceLogJsonExportServlet extends JsonExportServlet {
|
||||
private static final long serialVersionUID = 2197006949440887925L;
|
||||
private static final Logger logger = Logger.getLogger(QueryRaceLogJsonExportServlet.class.getName());
|
||||
|
||||
@Override
|
||||
protected void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
try {
|
||||
Object requestBody = JSONValue.parseWithException(request.getReader());
|
||||
JSONArray requestedIdentifiers = Helpers.toJSONArraySafe(requestBody);
|
||||
|
||||
for (Object element : requestedIdentifiers) {
|
||||
logger.info(String.format("Client requests race log for race with identifier %s.", element));
|
||||
/// TODO: deserialize identifier and look up TrackedRace
|
||||
}
|
||||
/// TODO: Return RaceLogs for found TrackedRaces...
|
||||
|
||||
} catch (ParseException e) {
|
||||
throw new JsonDeserializationException("Invalid JSON in request body.", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected JSONArray serizalizeTrack(TrackedRace trackedRace) {
|
||||
JsonSerializer<RaceLogEvent> serializer = createSerializer();
|
||||
JSONArray result = new JSONArray();
|
||||
|
||||
RaceLog log = trackedRace.getRaceLog();
|
||||
log.lockForRead();
|
||||
for (RaceLogEvent event : log.getFixes()) {
|
||||
result.add(serializer.serialize(event));
|
||||
}
|
||||
log.unlockAfterRead();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static JsonSerializer<RaceLogEvent> createSerializer() {
|
||||
JsonSerializer<Competitor> competitorSerializer = new CompetitorIdJsonSerializer();
|
||||
return new RaceLogEventSerializer(
|
||||
new RaceLogEventSerializerChooser(
|
||||
new RaceLogFlagEventSerializer(competitorSerializer),
|
||||
new RaceLogStartTimeEventSerializer(competitorSerializer),
|
||||
new RaceLogRaceStatusEventSerializer(competitorSerializer),
|
||||
new RaceLogCourseAreaChangedEventSerializer(competitorSerializer)));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user