mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 01:16:40 +00:00
Implemented locale handling for sailorsInfoWebsiteURL selection and
moved the special locale dependent code for the legacy sailorsInfoWebsiteURL field to the automatic porting code
This commit is contained in:
+11
-2
@@ -2170,9 +2170,18 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
|
||||
private boolean loadLegacySailorsInfoWebsiteURL(Event event, DBObject eventDBObject) {
|
||||
String sailorsInfoWebSiteURLAsString = (String) eventDBObject.get(FieldNames.EVENT_SAILORS_INFO_WEBSITE_URL.name());
|
||||
if (sailorsInfoWebSiteURLAsString != null && event.hasSailorsInfoWebsiteURL(null)) {
|
||||
if (sailorsInfoWebSiteURLAsString != null) {
|
||||
try {
|
||||
event.addSailorsInfoWebsiteURL(null, new URL(sailorsInfoWebSiteURLAsString));
|
||||
// The legacy sailors info URL (only used at Kieler/Travemuender Woche events) used to have 2 localized versions:
|
||||
// The german version with no suffix (e.g. http://sailorsinfo.travemuender-woche.com)
|
||||
// The englich/international version with "/en" suffix (e.g. http://sailorsinfo.travemuender-woche.com/en)
|
||||
if(!event.hasSailorsInfoWebsiteURL(null)) {
|
||||
final String englishURL = sailorsInfoWebSiteURLAsString + (sailorsInfoWebSiteURLAsString.endsWith("/") ? "" : "/") + "en";
|
||||
event.addSailorsInfoWebsiteURL(null, new URL(englishURL));
|
||||
}
|
||||
if(!event.hasSailorsInfoWebsiteURL(Locale.GERMAN)) {
|
||||
event.addSailorsInfoWebsiteURL(Locale.GERMAN, new URL(sailorsInfoWebSiteURLAsString));
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
logger.severe("Error parsing sailors info website URL "+sailorsInfoWebSiteURLAsString+" for event "+event.getName()+". Ignoring this URL.");
|
||||
}
|
||||
|
||||
+2
@@ -99,6 +99,8 @@ public interface EventBase extends Named, WithDescription, Renamable, WithID, Wi
|
||||
boolean hasSailorsInfoWebsiteURL(Locale locale);
|
||||
|
||||
void removeSailorsInfoWebsiteURL(Locale locale);
|
||||
|
||||
URL getSailorsInfoWebsiteURLOrFallback(Locale locale);
|
||||
|
||||
Iterable<? extends LeaderboardGroupBase> getLeaderboardGroups();
|
||||
|
||||
|
||||
+11
@@ -230,6 +230,17 @@ public abstract class EventBaseImpl implements EventBase {
|
||||
public boolean hasSailorsInfoWebsiteURL(Locale locale) {
|
||||
return this.sailorsInfoWebsiteURLs.containsKey(locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getSailorsInfoWebsiteURLOrFallback(Locale locale) {
|
||||
final URL result;
|
||||
if(hasSailorsInfoWebsiteURL(locale)) {
|
||||
result = this.sailorsInfoWebsiteURLs.get(locale);
|
||||
} else {
|
||||
result = this.sailorsInfoWebsiteURLs.get(null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ImageDescriptor> getImages() {
|
||||
|
||||
+5
-14
@@ -1,10 +1,10 @@
|
||||
package com.sap.sailing.gwt.home.communication.event;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -15,11 +15,11 @@ import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sailing.gwt.home.communication.SailingAction;
|
||||
import com.sap.sailing.gwt.home.communication.SailingDispatchContext;
|
||||
import com.sap.sailing.gwt.home.communication.eventview.EventViewDTO;
|
||||
import com.sap.sailing.gwt.home.communication.eventview.RegattaMetadataDTO;
|
||||
import com.sap.sailing.gwt.home.communication.eventview.EventViewDTO.EventType;
|
||||
import com.sap.sailing.gwt.home.communication.eventview.RegattaMetadataDTO;
|
||||
import com.sap.sailing.gwt.home.server.EventActionUtil;
|
||||
import com.sap.sailing.gwt.home.server.LeaderboardContext;
|
||||
import com.sap.sailing.gwt.home.server.EventActionUtil.LeaderboardCallback;
|
||||
import com.sap.sailing.gwt.home.server.LeaderboardContext;
|
||||
import com.sap.sailing.gwt.server.HomeServiceUtil;
|
||||
import com.sap.sse.common.media.MediaTagConstants;
|
||||
import com.sap.sse.gwt.dispatch.shared.caching.IsClientCacheable;
|
||||
@@ -51,7 +51,8 @@ public class GetEventViewAction implements SailingAction<EventViewDTO>, IsClient
|
||||
ImageDescriptor logoImage = event.findImageWithTag(MediaTagConstants.LOGO);
|
||||
dto.setLogoImage(logoImage != null ? HomeServiceUtil.convertToImageDTO(logoImage) : null);
|
||||
dto.setOfficialWebsiteURL(event.getOfficialWebsiteURL() == null ? null : event.getOfficialWebsiteURL().toString());
|
||||
dto.setSailorsInfoWebsiteURL(event.getSailorsInfoWebsiteURL() == null ? null : event.getSailorsInfoWebsiteURL().toString());
|
||||
URL sailorsInfoWebsiteURL = event.getSailorsInfoWebsiteURLOrFallback(context.getClientLocale());
|
||||
dto.setSailorsInfoWebsiteURL(sailorsInfoWebsiteURL == null ? null : sailorsInfoWebsiteURL.toString());
|
||||
|
||||
dto.setHasMedia(HomeServiceUtil.hasMedia(event));
|
||||
dto.setState(HomeServiceUtil.calculateEventState(event));
|
||||
@@ -104,16 +105,6 @@ public class GetEventViewAction implements SailingAction<EventViewDTO>, IsClient
|
||||
} else {
|
||||
dto.setType(dto.getRegattas().size() == 1 ? EventType.SINGLE_REGATTA: EventType.MULTI_REGATTA);
|
||||
}
|
||||
|
||||
// Special solution for localization of SailorsInfo URL
|
||||
if(dto.getSailorsInfoWebsiteURL() != null && !Locale.GERMAN.equals(context.getClientLocale())) {
|
||||
String localizedURL = dto.getSailorsInfoWebsiteURL();
|
||||
if(!localizedURL.endsWith("/")) {
|
||||
localizedURL += "/";
|
||||
}
|
||||
localizedURL += "en";
|
||||
dto.setSailorsInfoWebsiteURL(localizedURL);
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user