mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-23 12:33:53 +00:00
First draft of fix for 3150
This commit is contained in:
1 parent
3e03f2fa02
commit
320a0f889f
6 files changed
+85
-54
No files matched your search
+2
@@ -73,4 +73,6 @@ public class AppConstants {
|
||||
|
||||
public final static String INTENT_ACTION_IS_TRACKING = PACKAGE_NAME + "action.is.tracking";
|
||||
public final static String INTENT_ACTION_IS_TRACKING_EXTRA = PACKAGE_NAME + "action.is.tracking.extra";
|
||||
|
||||
public final static String GWT_MAP_AND_WIND_CHART_HTML = "gwt/EmbeddedMapAndWindChart.html";
|
||||
}
|
||||
+2
@@ -49,4 +49,6 @@ public interface DataStore {
|
||||
|
||||
UUID getCourseUUID();
|
||||
void setCourseUUID(UUID uuid);
|
||||
|
||||
String getMapUrl(String baseUrl, ManagedRace race, String eventId, boolean showWindCharts, boolean showStreamlets, boolean showSimulation, boolean showMapControls);
|
||||
}
|
||||
+26
-6
@@ -1,12 +1,11 @@
|
||||
package com.sap.sailing.racecommittee.app.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.*;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import com.sap.sailing.android.shared.util.CollectionUtils;
|
||||
import com.sap.sailing.domain.abstractlog.race.SimpleRaceLogIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.SimpleRaceLogIdentifierImpl;
|
||||
@@ -17,14 +16,18 @@ import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.base.SharedDomainFactory;
|
||||
import com.sap.sailing.domain.base.impl.SharedDomainFactoryImpl;
|
||||
import com.sap.sailing.domain.base.racegroup.RaceGroup;
|
||||
import com.sap.sailing.racecommittee.app.AppConstants;
|
||||
import com.sap.sailing.racecommittee.app.domain.ManagedRace;
|
||||
import com.sap.sailing.racecommittee.app.domain.ManagedRaceIdentifier;
|
||||
import com.sap.sailing.racecommittee.app.domain.impl.FleetIdentifierImpl;
|
||||
import com.sap.sailing.racecommittee.app.utils.UrlHelper;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.Util.Triple;
|
||||
|
||||
public enum InMemoryDataStore implements DataStore {
|
||||
INSTANCE;
|
||||
|
||||
private static String TAG = InMemoryDataStore.class.getName();
|
||||
private HashMap<Serializable, EventBase> eventsById;
|
||||
private HashMap<SimpleRaceLogIdentifier, ManagedRace> managedRaceById;
|
||||
private HashMap<Serializable, Mark> marksById;
|
||||
@@ -170,7 +173,7 @@ public enum InMemoryDataStore implements DataStore {
|
||||
* order to allow for retrieving a managed race with exclusively the information provided by a
|
||||
* SimpleRaceLogIdentifier (which is less than the information provided by a ManagedRaceIdentifier)
|
||||
*
|
||||
* @param id
|
||||
* @param escapedId
|
||||
* serialized version of a ManagedRaceIdentifier
|
||||
* @return
|
||||
* corresponding SimpleRaceLogIdentifier
|
||||
@@ -260,4 +263,21 @@ public enum InMemoryDataStore implements DataStore {
|
||||
public void setCourseUUID(UUID uuid) {
|
||||
courseUUID = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMapUrl(String baseUrl, ManagedRace race, String eventId, boolean showWindCharts, boolean showStreamlets, boolean showSimulation, boolean showMapControls) {
|
||||
String url = "";
|
||||
// get simple race log identifier
|
||||
Util.Triple<String, String, String> triple = FleetIdentifierImpl.unescape(race.getId());
|
||||
SimpleRaceLogIdentifier identifier = new SimpleRaceLogIdentifierImpl(triple.getA(), triple.getB(), triple.getC());
|
||||
Object [] params = {"regattaLikeName", "raceColumnName", "fleetName", "eventId", "viewShowWindChart", "viewShowStreamlets", "viewShowSimulation", "viewShowMapControls"};
|
||||
Object [] values = {identifier.getRegattaLikeParentName(), identifier.getRaceColumnName(), identifier.getFleetName(), eventId, showWindCharts, showStreamlets, showSimulation, showMapControls};
|
||||
try {
|
||||
url = UrlHelper.generateUrl(baseUrl, AppConstants.GWT_MAP_AND_WIND_CHART_HTML, params, values).toString();
|
||||
} catch (MalformedURLException e) {
|
||||
Log.e(TAG, "An error occured while generating the map url: " + e.getMessage());
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
||||
+33
-20
@@ -49,6 +49,7 @@ import com.sap.sailing.racecommittee.app.domain.ManagedRace;
|
||||
import com.sap.sailing.racecommittee.app.domain.ManagedRaceIdentifier;
|
||||
import com.sap.sailing.racecommittee.app.domain.configuration.impl.PreferencesRegattaConfigurationLoader;
|
||||
import com.sap.sailing.racecommittee.app.ui.fragments.lists.PositionListFragment;
|
||||
import com.sap.sailing.racecommittee.app.utils.UrlHelper;
|
||||
import com.sap.sailing.server.gateway.deserialization.JsonDeserializer;
|
||||
import com.sap.sailing.server.gateway.deserialization.coursedata.impl.ControlPointDeserializer;
|
||||
import com.sap.sailing.server.gateway.deserialization.coursedata.impl.CourseBaseDeserializer;
|
||||
@@ -111,8 +112,9 @@ public class OnlineDataManager extends DataManager {
|
||||
|
||||
// ExLog.i(context, TAG, "getEventsLoader created new loader...");
|
||||
|
||||
return new OnlineDataLoader<Collection<EventBase>>(context, new URL(preferences.getServerBaseURL()
|
||||
+ "/sailingserver/events"), parser, handler);
|
||||
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/events", new String[0], new Object[0]);
|
||||
return new OnlineDataLoader<Collection<EventBase>>(context,
|
||||
url, parser, handler);
|
||||
}
|
||||
}, getContext());
|
||||
}
|
||||
@@ -166,10 +168,11 @@ public class OnlineDataManager extends DataManager {
|
||||
globalConfiguration, RaceGroupDeserializer.create(domainFactory,
|
||||
RegattaConfigurationJsonDeserializer.create()));
|
||||
DataHandler<Collection<ManagedRace>> handler = new ManagedRacesDataHandler(OnlineDataManager.this);
|
||||
return new OnlineDataLoader<Collection<ManagedRace>>(context, new URL(preferences.getServerBaseURL()
|
||||
+ "/sailingserver/rc/racegroups?" + RaceLogServletConstants.PARAM_COURSE_AREA_FILTER + "="
|
||||
+ courseAreaId.toString() + "&" + RaceLogServletConstants.PARAMS_CLIENT_UUID + "="
|
||||
+ MessageSendingService.uuid), parser, handler);
|
||||
|
||||
Object[] params = {RaceLogServletConstants.PARAM_COURSE_AREA_FILTER, RaceLogServletConstants.PARAMS_CLIENT_UUID};
|
||||
Object[] values = {courseAreaId.toString(), MessageSendingService.uuid};
|
||||
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/rc/racegroups",params, values);
|
||||
return new OnlineDataLoader<Collection<ManagedRace>>(context, url, parser, handler);
|
||||
}
|
||||
}, getContext());
|
||||
}
|
||||
@@ -191,10 +194,12 @@ public class OnlineDataManager extends DataManager {
|
||||
String raceColumnName = URLEncoder.encode(identifier.getRaceName(), MessageSendingService.charsetName);
|
||||
String fleetName = URLEncoder.encode(identifier.getFleet().getName(), MessageSendingService.charsetName);
|
||||
|
||||
return new OnlineDataLoader<Collection<Mark>>(context, new URL(preferences.getServerBaseURL()
|
||||
+ "/sailingserver/rc/marks?" + RaceLogServletConstants.PARAMS_LEADERBOARD_NAME + "="
|
||||
+ raceGroupName + "&" + RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME + "=" + raceColumnName
|
||||
+ "&" + RaceLogServletConstants.PARAMS_RACE_FLEET_NAME + "=" + fleetName), parser, handler);
|
||||
Object[] params = {RaceLogServletConstants.PARAMS_LEADERBOARD_NAME,
|
||||
RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME,
|
||||
RaceLogServletConstants.PARAMS_RACE_FLEET_NAME};
|
||||
Object[] values = {raceGroupName, raceColumnName, fleetName};
|
||||
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/rc/marks", params, values);
|
||||
return new OnlineDataLoader<Collection<Mark>>(context, url, parser, handler);
|
||||
}
|
||||
}, getContext());
|
||||
}
|
||||
@@ -218,10 +223,13 @@ public class OnlineDataManager extends DataManager {
|
||||
String raceColumnName = URLEncoder.encode(identifier.getRaceName(), MessageSendingService.charsetName);
|
||||
String fleetName = URLEncoder.encode(identifier.getFleet().getName(), MessageSendingService.charsetName);
|
||||
|
||||
return new OnlineDataLoader<CourseBase>(context, new URL(preferences.getServerBaseURL()
|
||||
+ "/sailingserver/rc/currentcourse?" + RaceLogServletConstants.PARAMS_LEADERBOARD_NAME + "="
|
||||
+ raceGroupName + "&" + RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME + "=" + raceColumnName
|
||||
+ "&" + RaceLogServletConstants.PARAMS_RACE_FLEET_NAME + "=" + fleetName), parser, handler);
|
||||
Object[] params = {RaceLogServletConstants.PARAMS_LEADERBOARD_NAME,
|
||||
RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME,
|
||||
RaceLogServletConstants.PARAMS_RACE_FLEET_NAME};
|
||||
Object[] values = {raceGroupName, raceColumnName, fleetName};
|
||||
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/rc/currentcourse", params, values);
|
||||
|
||||
return new OnlineDataLoader<CourseBase>(context, url, parser, handler);
|
||||
}
|
||||
}, getContext());
|
||||
}
|
||||
@@ -247,10 +255,12 @@ public class OnlineDataManager extends DataManager {
|
||||
String raceColumnName = URLEncoder.encode(identifier.getRaceName(), MessageSendingService.charsetName);
|
||||
String fleetName = URLEncoder.encode(identifier.getFleet().getName(), MessageSendingService.charsetName);
|
||||
|
||||
return new OnlineDataLoader<Collection<Competitor>>(context, new URL(preferences.getServerBaseURL()
|
||||
+ "/sailingserver/rc/competitors?" + RaceLogServletConstants.PARAMS_LEADERBOARD_NAME + "="
|
||||
+ raceGroupName + "&" + RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME + "=" + raceColumnName
|
||||
+ "&" + RaceLogServletConstants.PARAMS_RACE_FLEET_NAME + "=" + fleetName), parser, handler);
|
||||
Object[] params = {RaceLogServletConstants.PARAMS_LEADERBOARD_NAME,
|
||||
RaceLogServletConstants.PARAMS_RACE_COLUMN_NAME,
|
||||
RaceLogServletConstants.PARAMS_RACE_FLEET_NAME};
|
||||
Object[] values = {raceGroupName, raceColumnName, fleetName};
|
||||
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/rc/competitors", params, values);
|
||||
return new OnlineDataLoader<Collection<Competitor>>(context, url, parser, handler);
|
||||
}
|
||||
}, getContext());
|
||||
}
|
||||
@@ -270,8 +280,11 @@ public class OnlineDataManager extends DataManager {
|
||||
String encodedIdentifier = URLEncoder.encode(identifier.getClientIdentifier(), MessageSendingService.charsetName);
|
||||
encodedIdentifier = encodedIdentifier.replace("+", "%20");
|
||||
|
||||
return new OnlineDataLoader<DeviceConfiguration>(context, new URL(preferences.getServerBaseURL()
|
||||
+ "/sailingserver/rc/configuration?client=" + encodedIdentifier), parser, handler);
|
||||
Object[] params = {"client"};
|
||||
Object[] values = {encodedIdentifier};
|
||||
URL url = UrlHelper.generateUrl(preferences.getServerBaseURL(), "/sailingserver/rc/configuration", params, values);
|
||||
return new OnlineDataLoader<DeviceConfiguration>(context,
|
||||
url, parser, handler);
|
||||
}
|
||||
}, getContext());
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.sap.sailing.racecommittee.app.utils;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
public class UrlHelper {
|
||||
public static URL generateUrl(String baseURL, String path, Object[] params, Object[] values) throws MalformedURLException {
|
||||
Uri.Builder builder = Uri.parse(baseURL).buildUpon();
|
||||
builder.path(path);
|
||||
for (int index = 0; index < params.length; index++){
|
||||
builder.appendQueryParameter("" + params[index], "" + values[index]);
|
||||
}
|
||||
return new URL(builder.build().toString());
|
||||
}
|
||||
}
|
||||
+5
-28
@@ -6,12 +6,11 @@ import android.support.v4.content.LocalBroadcastManager;
|
||||
import android.util.Log;
|
||||
import com.sap.sailing.android.shared.data.http.HttpGetRequest;
|
||||
import com.sap.sailing.android.shared.util.NetworkHelper;
|
||||
import com.sap.sailing.domain.abstractlog.race.SimpleRaceLogIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.SimpleRaceLogIdentifierImpl;
|
||||
import com.sap.sailing.racecommittee.app.AppConstants;
|
||||
import com.sap.sailing.racecommittee.app.AppPreferences;
|
||||
import com.sap.sailing.racecommittee.app.data.DataManager;
|
||||
import com.sap.sailing.racecommittee.app.data.DataStore;
|
||||
import com.sap.sailing.racecommittee.app.data.OnlineDataManager;
|
||||
import com.sap.sailing.racecommittee.app.domain.ManagedRace;
|
||||
import com.sap.sailing.racecommittee.app.domain.impl.FleetIdentifierImpl;
|
||||
import com.sap.sse.common.Util;
|
||||
@@ -24,19 +23,12 @@ import java.net.URL;
|
||||
|
||||
public class WindHelper {
|
||||
private static String TAG = WindHelper.class.getName();
|
||||
private final static String GWT_MAP_AND_WIND_CHART_HTML = "gwt/EmbeddedMapAndWindChart.html";
|
||||
|
||||
public static void isTrackedRace(final Context context, final ManagedRace race){
|
||||
try {
|
||||
Util.Triple<String, String, String> triple = FleetIdentifierImpl.unescape(race.getId());
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(getBaseUrl(context));
|
||||
builder.append("/sailingserver/api/v1/events/");
|
||||
builder.append(getEventId(context));
|
||||
builder.append("/racestates");
|
||||
builder.append("?filterByLeaderboard=" + triple.getA());
|
||||
|
||||
URL serverUrl = new URL(builder.toString());
|
||||
String path = "/sailingserver/api/v1/events/"+ getEventId(context) + "/racestates";
|
||||
URL serverUrl = UrlHelper.generateUrl(getBaseUrl(context), path, new Object[]{"filterByLeaderboard"}, new Object[]{triple.getA()});
|
||||
|
||||
HttpGetRequest request = new HttpGetRequest(serverUrl, context);
|
||||
NetworkHelper.getInstance(context).executeHttpJsonRequestAsnchronously(request, new NetworkHelper.NetworkHelperSuccessListener() {
|
||||
@@ -97,22 +89,7 @@ public class WindHelper {
|
||||
}
|
||||
|
||||
public static String generateMapURL(Context context, ManagedRace race ,boolean showWindCharts, boolean showStreamlets, boolean showSimulation, boolean showMapControls){
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
// get simple race log identifier
|
||||
Util.Triple<String, String, String> triple = FleetIdentifierImpl.unescape(race.getId());
|
||||
SimpleRaceLogIdentifier identifier = new SimpleRaceLogIdentifierImpl(triple.getA(), triple.getB(), triple.getC());
|
||||
|
||||
builder.append(getBaseUrl(context));
|
||||
builder.append(GWT_MAP_AND_WIND_CHART_HTML);
|
||||
builder.append("?regattaLikeName=" + identifier.getRegattaLikeParentName());
|
||||
builder.append("&raceColumnName=" + identifier.getRaceColumnName());
|
||||
builder.append("&fleetName=" + identifier.getFleetName());
|
||||
builder.append("&eventId=" + getEventId(context));
|
||||
builder.append("&viewShowWindChart=" + showWindCharts);
|
||||
builder.append("&viewShowStreamlets=" + showStreamlets);
|
||||
builder.append("&viewShowSimulation=" + showSimulation);
|
||||
builder.append("&viewShowMapControls=" + showMapControls);
|
||||
return builder.toString();
|
||||
DataStore dataStore = OnlineDataManager.create(context).getDataStore();
|
||||
return dataStore.getMapUrl(AppPreferences.on(context).getServerBaseURL(), race, getEventId(context), showWindCharts, showStreamlets, showSimulation, showMapControls);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user