mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-19 04:05:36 +00:00
bug5902: rewrite mode selection logic. Former selection by 'mode' url parameter was exchanged by guessing the mode based on existing url parameters.
This commit is contained in:
+37
-17
@@ -3,8 +3,8 @@ package com.sap.sailing.gwt.home.desktop.places.qrcode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.place.shared.PlaceTokenizer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.sap.sailing.domain.common.MailInvitationType;
|
||||
@@ -28,7 +28,7 @@ import com.sap.sse.gwt.client.AbstractBasePlace;
|
||||
*
|
||||
*/
|
||||
public class QRCodePlace extends AbstractBasePlace {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(QRCodePlace.class.getName());
|
||||
public static final String PARAM_REGATTA_NAME = "regatta_name";
|
||||
public static final String PARAM_REGATTA_SECRET = "secret";
|
||||
private static final String PARAM_MODE = "mode";
|
||||
@@ -79,44 +79,44 @@ public class QRCodePlace extends AbstractBasePlace {
|
||||
try {
|
||||
mode = InvitationMode.valueOf(getParameter(PARAM_MODE));
|
||||
targetServer = Window.Location.getParameter(PARAM_SERVER);
|
||||
if (mode.isPublicInvite()) {
|
||||
if (isPublicInviteRequest()) {
|
||||
// alternative direct link version
|
||||
publicRegattaName = Window.Location.getParameter(PARAM_REGATTA_NAME);
|
||||
regattaRegistrationLinkSecret = Window.Location.getParameter(PARAM_REGATTA_SECRET);
|
||||
if (publicRegattaName == null || regattaRegistrationLinkSecret == null || targetServer == null) {
|
||||
GWT.log("Missing parameter for regatta, secret or server");
|
||||
logger.severe("Missing parameter for regatta, secret or server");
|
||||
}
|
||||
} else {
|
||||
rawCheckInUrl = Window.Location.getParameter(DeviceMappingConstants.URL_CHECKIN_URL);
|
||||
if (rawCheckInUrl != null) {
|
||||
parseUrl(rawCheckInUrl);
|
||||
if (leaderboardName == null) {
|
||||
GWT.log("No parameter " + DeviceMappingConstants.URL_LEADERBOARD_NAME + " found!");
|
||||
logger.severe("No parameter " + DeviceMappingConstants.URL_LEADERBOARD_NAME + " found!");
|
||||
}
|
||||
if (competitorId == null
|
||||
&& (mode == InvitationMode.COMPETITOR || mode == InvitationMode.COMPETITOR_2)) {
|
||||
GWT.log("No parameter " + DeviceMappingConstants.URL_COMPETITOR_ID_AS_STRING + " found!");
|
||||
logger.severe("No parameter " + DeviceMappingConstants.URL_COMPETITOR_ID_AS_STRING + " found!");
|
||||
}
|
||||
if (boatId == null && (mode == InvitationMode.COMPETITOR || mode == InvitationMode.COMPETITOR_2)) {
|
||||
GWT.log("No parameter " + DeviceMappingConstants.URL_BOAT_ID_AS_STRING + " found!");
|
||||
logger.severe("No parameter " + DeviceMappingConstants.URL_BOAT_ID_AS_STRING + " found!");
|
||||
}
|
||||
if (markId == null && (mode == InvitationMode.COMPETITOR || mode == InvitationMode.COMPETITOR_2)) {
|
||||
GWT.log("No parameter " + DeviceMappingConstants.URL_MARK_ID_AS_STRING + " found!");
|
||||
logger.severe("No parameter " + DeviceMappingConstants.URL_MARK_ID_AS_STRING + " found!");
|
||||
}
|
||||
if ((competitorId != null || boatId != null || markId != null)
|
||||
&& mode == InvitationMode.BOUY_TENDER) {
|
||||
GWT.log("Found parameter " + DeviceMappingConstants.URL_COMPETITOR_ID_AS_STRING
|
||||
logger.warning("Found parameter " + DeviceMappingConstants.URL_COMPETITOR_ID_AS_STRING
|
||||
+ " will be ignored in bouy tender mode!");
|
||||
}
|
||||
if (eventId == null) {
|
||||
GWT.log("No parameter " + DeviceMappingConstants.URL_EVENT_ID + " found!");
|
||||
logger.severe("No parameter " + DeviceMappingConstants.URL_EVENT_ID + " found!");
|
||||
}
|
||||
} else {
|
||||
GWT.log("No parameter " + DeviceMappingConstants.URL_CHECKIN_URL + " found!");
|
||||
logger.severe("No parameter " + DeviceMappingConstants.URL_CHECKIN_URL + " found!");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
GWT.log("No parameter " + PARAM_MODE + " found, or value not valid");
|
||||
logger.severe("No parameter " + PARAM_MODE + " found, or value not valid");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,28 +135,28 @@ public class QRCodePlace extends AbstractBasePlace {
|
||||
try {
|
||||
eventId = UUID.fromString(parameter.getB());
|
||||
} catch (IllegalArgumentException e) {
|
||||
GWT.log("Invalid " + DeviceMappingConstants.URL_EVENT_ID);
|
||||
logger.severe("Invalid " + DeviceMappingConstants.URL_EVENT_ID);
|
||||
eventId = null;
|
||||
}
|
||||
} else if (DeviceMappingConstants.URL_COMPETITOR_ID_AS_STRING.equals(parameter.getA())) {
|
||||
try {
|
||||
competitorId = UUID.fromString(parameter.getB());
|
||||
} catch (IllegalArgumentException e) {
|
||||
GWT.log("Invalid " + DeviceMappingConstants.URL_COMPETITOR_ID_AS_STRING);
|
||||
logger.severe("Invalid " + DeviceMappingConstants.URL_COMPETITOR_ID_AS_STRING);
|
||||
competitorId = null;
|
||||
}
|
||||
} else if (DeviceMappingConstants.URL_BOAT_ID_AS_STRING.equals(parameter.getA())) {
|
||||
try {
|
||||
boatId = UUID.fromString(parameter.getB());
|
||||
} catch (IllegalArgumentException e) {
|
||||
GWT.log("Invalid " + DeviceMappingConstants.URL_BOAT_ID_AS_STRING);
|
||||
logger.severe("Invalid " + DeviceMappingConstants.URL_BOAT_ID_AS_STRING);
|
||||
boatId = null;
|
||||
}
|
||||
} else if (DeviceMappingConstants.URL_MARK_ID_AS_STRING.equals(parameter.getA())) {
|
||||
try {
|
||||
markId = UUID.fromString(parameter.getB());
|
||||
} catch (IllegalArgumentException e) {
|
||||
GWT.log("Invalid " + DeviceMappingConstants.URL_MARK_ID_AS_STRING);
|
||||
logger.severe("Invalid " + DeviceMappingConstants.URL_MARK_ID_AS_STRING);
|
||||
boatId = null;
|
||||
}
|
||||
} else if (DeviceMappingConstants.URL_LEADERBOARD_NAME.equals(parameter.getA())) {
|
||||
@@ -175,7 +175,7 @@ public class QRCodePlace extends AbstractBasePlace {
|
||||
|
||||
Collection<Pair<String, String>> pairs = new ArrayList<Pair<String, String>>();
|
||||
if (urlArguments.length < 2) {
|
||||
GWT.log("No parameters found!");
|
||||
logger.severe("No parameters found!");
|
||||
} else {
|
||||
String[] urlParams = urlArguments[1].split("&");
|
||||
for (String urlParam : urlParams) {
|
||||
@@ -253,4 +253,24 @@ public class QRCodePlace extends AbstractBasePlace {
|
||||
return new QRCodePlace(token);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if available URL parameter are indicating a competitor/boat request.
|
||||
*
|
||||
* @return true if it is a competitor request (former COMPETITOR, COMPETITOR_2 or COMPETITOR_3 mode)
|
||||
*/
|
||||
static boolean isCompetitorOrBoatRequest() {
|
||||
return Window.Location.getParameter(DeviceMappingConstants.URL_CHECKIN_URL) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if available URL parameter are indicating a public invite request.
|
||||
*
|
||||
* @return true if it is a public invite request (former PUBLIC_INVITE or PUBLIC_INVITE3 mode)
|
||||
*/
|
||||
static boolean isPublicInviteRequest() {
|
||||
return Window.Location.getParameter(QRCodePlace.PARAM_REGATTA_NAME) != null
|
||||
&& Window.Location.getParameter(QRCodePlace.PARAM_REGATTA_SECRET) != null
|
||||
&& Window.Location.getParameter(QRCodePlace.PARAM_SERVER) != null;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-20
@@ -9,6 +9,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.common.BranchIOConstants;
|
||||
import com.sap.sailing.domain.common.dto.BoatDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.gwt.home.desktop.places.qrcode.QRCodePlace.InvitationMode;
|
||||
import com.sap.sailing.gwt.ui.shared.MarkDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.QRCodeEvent;
|
||||
import com.sap.sse.common.Util;
|
||||
@@ -110,8 +111,7 @@ public class QRCodePresenter {
|
||||
}
|
||||
|
||||
private void showQrCode(QRCodeView view) {
|
||||
switch (place.getMode()) {
|
||||
case BOUY_TENDER:
|
||||
if (place.getMode() == InvitationMode.BOUY_TENDER) {
|
||||
logger.info("QR Code for buoy tender to be shown");
|
||||
if (place.getEncodedCheckInUrl() == null || place.getEncodedCheckInUrl().isEmpty()) {
|
||||
view.setError();
|
||||
@@ -119,10 +119,7 @@ public class QRCodePresenter {
|
||||
dataCollector = new DataCollector(view);
|
||||
retrieveEvent(place.getEventId());
|
||||
}
|
||||
break;
|
||||
case COMPETITOR:
|
||||
case COMPETITOR_2:
|
||||
case COMPETITOR_3:
|
||||
} else if (QRCodePlace.isCompetitorOrBoatRequest()) {
|
||||
logger.info("QR Code for competitor/boat/buoy tracking to be shown");
|
||||
if (place.getEncodedCheckInUrl() == null || place.getEncodedCheckInUrl().isEmpty()) {
|
||||
view.setError();
|
||||
@@ -140,14 +137,13 @@ public class QRCodePresenter {
|
||||
}
|
||||
retrieveEvent(place.getEventId());
|
||||
}
|
||||
break;
|
||||
case PUBLIC_INVITE:
|
||||
case PUBLIC_INVITE3:
|
||||
} else if (QRCodePlace.isPublicInviteRequest()) {
|
||||
logger.info("QR Code for public regatta invite to be shown");
|
||||
// as the event is most likely displayed on a different server anyway, do not load additional data
|
||||
dataCollector = new DataCollector(view);
|
||||
dataCollector.proceedIfFinished();
|
||||
break;
|
||||
} else {
|
||||
logger.severe("QR Code cannot be created. Request type cannot be identified.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,8 +264,7 @@ public class QRCodePresenter {
|
||||
|
||||
private void proceedIfFinished() {
|
||||
logger.info("Checking if data for QR Code is loaded");
|
||||
switch (place.getMode()) {
|
||||
case BOUY_TENDER:
|
||||
if (place.getMode() == InvitationMode.BOUY_TENDER) {
|
||||
if (eventIsSet) {
|
||||
logger.info("About to show QR Code for buoy tender");
|
||||
String branchIoUrl = BranchIOConstants.BUOYPINGER_APP_BRANCHIO + "?"
|
||||
@@ -278,10 +273,7 @@ public class QRCodePresenter {
|
||||
} else {
|
||||
logger.info("Event is missing for buoy tender QR Code");
|
||||
}
|
||||
break;
|
||||
case COMPETITOR:
|
||||
case COMPETITOR_2:
|
||||
case COMPETITOR_3:
|
||||
} else if (QRCodePlace.isCompetitorOrBoatRequest()) {
|
||||
if (participantIsSet && eventIsSet) {
|
||||
logger.info("About to show QR Code for competitor/boat/mark tracking");
|
||||
String sailInsightBranch = place.getMode().getMailInvitationType().getBranchIOinviteURL();
|
||||
@@ -297,13 +289,12 @@ public class QRCodePresenter {
|
||||
logger.info("Event is missing for competitor/boat/mark tracking QR Code");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PUBLIC_INVITE:
|
||||
case PUBLIC_INVITE3:
|
||||
} else if (QRCodePlace.isPublicInviteRequest()) {
|
||||
logger.info("About to show QR Code for public regatta invite");
|
||||
view.showPublic(place.getPublicRegattaName(),
|
||||
place.getPublicInviteBranchIOUrl(place.getMode().getMailInvitationType()));
|
||||
break;
|
||||
} else {
|
||||
logger.severe("Cannot identify request type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user