mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-13 14:12:11 +00:00
bug4564 extracted constants and removed all jsni code in the
deserializer
This commit is contained in:
1 parent
276b46dbfc
commit
34cbfde639
5 files changed
+80
-46
No files matched your search
+16
-4
@@ -6,11 +6,23 @@ public final class ExpeditionAllInOneConstants {
|
||||
public static final String REQUEST_PARAMETER_REGATTA_NAME = "regattaName";
|
||||
public static final String REQUEST_PARAMETER_LOCALE = "locale";
|
||||
public static final String REQUEST_PARAMETER_IMPORT_START_DATA = "importStartData";
|
||||
public static final String START_TIMES = "startTimes";
|
||||
public enum ImportMode{
|
||||
NEW_COMPETITOR, NEW_EVENT, NEW_RACE;
|
||||
public static final String RESPONSE_START_TIMES = "startTimes";
|
||||
public static final String RESPONSE_EVENT_ID = "eventId";
|
||||
public static final String RESPONSE_LEADER_BOARD_NAME = "leaderboardName";
|
||||
public static final String RESPONSE_LEADER_BOARD_GROUP_NAME = "leaderboardGroupName";
|
||||
public static final String RESPONSE_REGATTA_NAME = "regattaName";
|
||||
public static final String RESPONSE_RACE_LIST = "raceNameRaceColumnNameFleetNameList";
|
||||
public static final String RESPONSE_ERRORS = "errors";
|
||||
public static final String RESPONSE_GPS_DEVICE_IDS = "gpsDeviceIds";
|
||||
public static final String RESPONSE_SENSOR_DEVICE_IDS = "sensorDeviceIds";
|
||||
public static final String RESPONSE_SENSOR_FIX_IMPORTER_TYPE = "sensorFixImporterType";
|
||||
|
||||
public enum ImportMode {
|
||||
NEW_COMPETITOR,
|
||||
NEW_EVENT,
|
||||
NEW_RACE;
|
||||
}
|
||||
|
||||
|
||||
private ExpeditionAllInOneConstants() {
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.sap.sailing.domain.common.dto;
|
||||
|
||||
public class ImportConstants {
|
||||
|
||||
public static final String RACE_NAME = "raceName";
|
||||
public static final String RACE_COLUMN_NAME = "raceColumnName";
|
||||
public static final String FLEET_NAME = "fleetName";
|
||||
public static final String FILENAME = "filename";
|
||||
public static final String REQUESTED_IMPORTER = "requestedImporter";
|
||||
public static final String EX_UUID = "exUUID";
|
||||
public static final String CLASS_NAME = "className";
|
||||
public static final String MESSAGE = "message";
|
||||
public static final String ERRORS = "errors";
|
||||
public static final String UPLOADS = "uploads";
|
||||
|
||||
private ImportConstants() {
|
||||
}
|
||||
}
|
||||
+25
-22
@@ -4,9 +4,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.json.client.JSONArray;
|
||||
import com.google.gwt.json.client.JSONObject;
|
||||
import com.sap.sailing.domain.common.dto.ExpeditionAllInOneConstants;
|
||||
import com.sap.sailing.domain.common.dto.ImportConstants;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.Util.Triple;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
@@ -14,6 +16,7 @@ import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
public class ExpeditionDataImportResponse extends AbstractDataImportResponse {
|
||||
|
||||
public static final ExpeditionDataImportResponse parse(String json) {
|
||||
GWT.debugger();
|
||||
return AbstractDataImportResponse.parse(json, "ExpeditionDataImportResponse");
|
||||
}
|
||||
|
||||
@@ -21,31 +24,31 @@ public class ExpeditionDataImportResponse extends AbstractDataImportResponse {
|
||||
}
|
||||
|
||||
public final UUID getEventId() {
|
||||
String eventId = getString("eventId");
|
||||
String eventId = getString(ExpeditionAllInOneConstants.RESPONSE_EVENT_ID);
|
||||
return eventId == null ? null : UUID.fromString(eventId);
|
||||
}
|
||||
|
||||
public final native String getLeaderboardGroupName() /*-{
|
||||
return this.leaderboardGroupName;
|
||||
}-*/;
|
||||
|
||||
public final native String getLeaderboardName() /*-{
|
||||
return this.leaderboardName;
|
||||
}-*/;
|
||||
public final String getLeaderboardGroupName() {
|
||||
return getString(ExpeditionAllInOneConstants.RESPONSE_LEADER_BOARD_GROUP_NAME);
|
||||
}
|
||||
|
||||
public final String getLeaderboardName() {
|
||||
return getString(ExpeditionAllInOneConstants.RESPONSE_LEADER_BOARD_NAME);
|
||||
}
|
||||
|
||||
public final String getRegattaName() {
|
||||
return getString(ExpeditionAllInOneConstants.RESPONSE_REGATTA_NAME);
|
||||
}
|
||||
|
||||
public final native String getRegattaName() /*-{
|
||||
return this.regattaName;
|
||||
}-*/;
|
||||
|
||||
public final List<Triple<String, String, String>> getRaceEntries() {
|
||||
ArrayList<Triple<String, String, String>> raceNameRaceColumnNameFleetNameList = new ArrayList<>();
|
||||
JSONObject jsonView = new JSONObject(this);
|
||||
JSONArray entryList = jsonView.get("raceNameRaceColumnNameFleetNameList").isArray();
|
||||
JSONArray entryList = jsonView.get(ExpeditionAllInOneConstants.RESPONSE_RACE_LIST).isArray();
|
||||
for (int i = 0; i < entryList.size(); i++) {
|
||||
JSONObject entry = entryList.get(i).isObject();
|
||||
String raceName = entry.get("raceName").isString().stringValue();
|
||||
String raceColumnName = entry.get("raceColumnName").isString().stringValue();
|
||||
String fleetName = entry.get("fleetName").isString().stringValue();
|
||||
String raceName = entry.get(ImportConstants.RACE_NAME).isString().stringValue();
|
||||
String raceColumnName = entry.get(ImportConstants.RACE_COLUMN_NAME).isString().stringValue();
|
||||
String fleetName = entry.get(ImportConstants.FLEET_NAME).isString().stringValue();
|
||||
raceNameRaceColumnNameFleetNameList
|
||||
.add(new Triple<String, String, String>(raceName, raceColumnName, fleetName));
|
||||
}
|
||||
@@ -55,7 +58,7 @@ public class ExpeditionDataImportResponse extends AbstractDataImportResponse {
|
||||
public final Iterable<TimePoint> getStartTimes() {
|
||||
final List<TimePoint> result = new ArrayList<>();
|
||||
JSONObject jsonView = new JSONObject(this);
|
||||
JSONArray startTimesList = jsonView.get(ExpeditionAllInOneConstants.START_TIMES).isArray();
|
||||
JSONArray startTimesList = jsonView.get(ExpeditionAllInOneConstants.RESPONSE_START_TIMES).isArray();
|
||||
for (int i = 0; i < startTimesList.size(); i++) {
|
||||
final long startTimeAsMillis = (long) startTimesList.get(i).isNumber().doubleValue();
|
||||
result.add(new MillisecondsTimePoint(startTimeAsMillis));
|
||||
@@ -64,16 +67,16 @@ public class ExpeditionDataImportResponse extends AbstractDataImportResponse {
|
||||
}
|
||||
|
||||
public final List<String> getGpsDeviceIds() {
|
||||
return getStringList("gpsDeviceIds");
|
||||
return getStringList(ExpeditionAllInOneConstants.RESPONSE_GPS_DEVICE_IDS);
|
||||
}
|
||||
|
||||
public final List<String> getSensorDeviceIds() {
|
||||
return getStringList("sensorDeviceIds");
|
||||
return getStringList(ExpeditionAllInOneConstants.RESPONSE_SENSOR_DEVICE_IDS);
|
||||
}
|
||||
|
||||
public final native String getSensorFixImporterType() /*-{
|
||||
return this.sensorFixImporterType;
|
||||
}-*/;
|
||||
public final String getSensorFixImporterType() {
|
||||
return getString(ExpeditionAllInOneConstants.RESPONSE_SENSOR_FIX_IMPORTER_TYPE);
|
||||
};
|
||||
|
||||
public final boolean hasEventId() {
|
||||
final String stringValue = getString("eventId");
|
||||
|
||||
+10
-10
@@ -141,16 +141,16 @@ public class ExpeditionAllInOneImportServlet extends AbstractFileUploadServlet {
|
||||
|
||||
private JSONObject toJSON(ImporterResult importerResult) {
|
||||
final JSONObject json = new JSONObject();
|
||||
json.put("eventId", importerResult.eventId == null ? null : importerResult.eventId.toString());
|
||||
json.put("leaderboardName", importerResult.leaderboardName);
|
||||
json.put("leaderboardGroupName", importerResult.leaderboardGroupName);
|
||||
json.put("regattaName", importerResult.regattaName);
|
||||
json.put("raceNameRaceColumnNameFleetNameList", ImportResultSerializer.serializeRaceList(importerResult.raceNameRaceColumnNameFleetnameList));
|
||||
json.put("errors", ImportResultSerializer.serializeErrorList(importerResult.errorList));
|
||||
json.put("gpsDeviceIds", ImportResultSerializer.serializeTrackList(importerResult.importGpsFixData));
|
||||
json.put("sensorDeviceIds", ImportResultSerializer.serializeTrackList(importerResult.importSensorFixData));
|
||||
json.put("sensorFixImporterType", importerResult.sensorFixImporterType);
|
||||
json.put(ExpeditionAllInOneConstants.START_TIMES, ImportResultSerializer.serializeIterable(importerResult.startData.getStartTimes(),
|
||||
json.put(ExpeditionAllInOneConstants.RESPONSE_EVENT_ID, importerResult.eventId == null ? null : importerResult.eventId.toString());
|
||||
json.put(ExpeditionAllInOneConstants.RESPONSE_LEADER_BOARD_NAME, importerResult.leaderboardName);
|
||||
json.put(ExpeditionAllInOneConstants.RESPONSE_LEADER_BOARD_GROUP_NAME, importerResult.leaderboardGroupName);
|
||||
json.put(ExpeditionAllInOneConstants.RESPONSE_REGATTA_NAME, importerResult.regattaName);
|
||||
json.put(ExpeditionAllInOneConstants.RESPONSE_RACE_LIST, ImportResultSerializer.serializeRaceList(importerResult.raceNameRaceColumnNameFleetnameList));
|
||||
json.put(ExpeditionAllInOneConstants.RESPONSE_ERRORS, ImportResultSerializer.serializeErrorList(importerResult.errorList));
|
||||
json.put(ExpeditionAllInOneConstants.RESPONSE_GPS_DEVICE_IDS, ImportResultSerializer.serializeTrackList(importerResult.importGpsFixData));
|
||||
json.put(ExpeditionAllInOneConstants.RESPONSE_SENSOR_DEVICE_IDS, ImportResultSerializer.serializeTrackList(importerResult.importSensorFixData));
|
||||
json.put(ExpeditionAllInOneConstants.RESPONSE_SENSOR_FIX_IMPORTER_TYPE, importerResult.sensorFixImporterType);
|
||||
json.put(ExpeditionAllInOneConstants.RESPONSE_START_TIMES, ImportResultSerializer.serializeIterable(importerResult.startData.getStartTimes(),
|
||||
startTime->startTime.asMillis()));
|
||||
return json;
|
||||
}
|
||||
|
||||
+11
-10
@@ -7,6 +7,7 @@ import java.util.stream.StreamSupport;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.sap.sailing.domain.common.dto.ImportConstants;
|
||||
import com.sap.sailing.server.gateway.trackfiles.impl.ImportResultDTO.ErrorImportDTO;
|
||||
import com.sap.sailing.server.gateway.trackfiles.impl.ImportResultDTO.TrackImportDTO;
|
||||
import com.sap.sse.common.Util.Triple;
|
||||
@@ -18,8 +19,8 @@ class ImportResultSerializer {
|
||||
|
||||
static JSONObject serializeImportResult(ImportResultDTO result) {
|
||||
final JSONObject json = new JSONObject();
|
||||
json.put("errors", serializeErrorList(result.getErrorList()));
|
||||
json.put("uploads", serializeTrackList(result.getImportResult()));
|
||||
json.put(ImportConstants.ERRORS, serializeErrorList(result.getErrorList()));
|
||||
json.put(ImportConstants.UPLOADS, serializeTrackList(result.getImportResult()));
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -43,19 +44,19 @@ class ImportResultSerializer {
|
||||
|
||||
private static JSONObject serializeRaceEntry(Triple<String, String, String> entry) {
|
||||
final JSONObject json = new JSONObject();
|
||||
json.put("raceName", entry.getA());
|
||||
json.put("raceColumnName", entry.getB());
|
||||
json.put("fleetName", entry.getC());
|
||||
json.put(ImportConstants.RACE_NAME, entry.getA());
|
||||
json.put(ImportConstants.RACE_COLUMN_NAME, entry.getB());
|
||||
json.put(ImportConstants.FLEET_NAME, entry.getC());
|
||||
return json;
|
||||
}
|
||||
|
||||
private static JSONObject serializeError(ErrorImportDTO error) {
|
||||
final JSONObject json = new JSONObject();
|
||||
json.put("filename", error.getFilename());
|
||||
json.put("requestedImporter", error.getRequestedImporter());
|
||||
json.put("exUUID", error.getExUUID());
|
||||
json.put("className", error.getName());
|
||||
json.put("message", error.getMessage());
|
||||
json.put(ImportConstants.FILENAME, error.getFilename());
|
||||
json.put(ImportConstants.REQUESTED_IMPORTER, error.getRequestedImporter());
|
||||
json.put(ImportConstants.EX_UUID, error.getExUUID());
|
||||
json.put(ImportConstants.CLASS_NAME, error.getName());
|
||||
json.put(ImportConstants.MESSAGE, error.getMessage());
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user