bug6096: properly handle nationality from competitor in result import now;

see https://bugzilla.sapsailing.com/bugzilla/show_bug.cgi?id=6096#c2;
The regular expression demanded a three-letter acronym at the beginning
of the sail ID; this has been relaxed now, and now the "default
nationality" coming from the competitor is finally being used for
match-making when the sail ID only has the number.
This commit is contained in:
Axel Uhl
2025-02-21 13:25:32 +01:00
parent fc15f61d63
commit e19b804676
3 changed files with 11 additions and 5 deletions
@@ -24,7 +24,7 @@ import java.util.Map;
*
*/
public abstract class AbstractSailNumberCanonicalizerAndMatcher<CompetitorType> {
protected static final String sailIdRegexpPattern = "^([A-Z][A-Z][A-Z])\\s*[^0-9]*([0-9]*)$";
protected static final String sailIdRegexpPattern = "^([A-Z][A-Z][A-Z])?\\s*[^0-9]*([0-9]*)$";
public static class SailNumberMatch {
private final String iocCode;
@@ -43,7 +43,7 @@ public abstract class AbstractSailNumberCanonicalizerAndMatcher<CompetitorType>
}
/**
* Parses a sail number into a nationality code expected at the beginning of the string,
* Parses a sail number into a nationality code expected at the beginning of the string but possibly empty,
* and a numeric part assumed to be at the end of the string. Before matching, the {@code sailId}
* string will be {@link String#trim() trimmed}, removing leading and trailing whitespace. If
* the parameter matches the {@link #sailIdRegexpPattern} then a valid {@link SailNumberMatch}
@@ -102,10 +102,10 @@ public abstract class AbstractSailNumberCanonicalizerAndMatcher<CompetitorType>
}
public Map<String, CompetitorType> canonicalizeLeaderboardSailIDs(final Iterable<CompetitorType> competitors) {
Map<String, CompetitorType> result = new HashMap<>();
final Map<String, CompetitorType> result = new HashMap<>();
for (final CompetitorType competitor : competitors) {
final String competitorIdentifyingText = getCompetitorIdentifyingText(competitor);
String canonicalizedSailID = canonicalizeSailID(competitorIdentifyingText.trim(), getThreeLetterIocCountryCode(competitor).trim());
final String canonicalizedSailID = canonicalizeSailID(competitorIdentifyingText.trim(), getThreeLetterIocCountryCode(competitor).trim());
if (canonicalizedSailID != null) {
result.put(canonicalizedSailID, competitor);
}
@@ -36,6 +36,10 @@
<li>When upgrading an application replica set through the Landscape Management panel,
other target groups such as those from an NLB will be considered correctly for adding
and removing temporary upgrade replicas and the primary/master node.</li>
<li>Added a result importer for the typical Sailwave HTML output, such as
<a href="https://www.rhkyc.org.hk/storage/app/media/Sailing/result/HONG-KONG-RACE-WEEK/2025/ILCA4.htm">https://www.rhkyc.org.hk/storage/app/media/Sailing/result/HONG-KONG-RACE-WEEK/2025/ILCA4.htm</a>.
You can add these types of URLs now in the <a href="/gwt/AdminConsole.html#ResultImportUrlsPlace:">Result import URLs</a> tab
of the Connectors category in the administration console.</li>
</ul>
<h2 class="articleSubheadline">January 2025</h2>
<ul class="bulletList">
@@ -1101,7 +1101,9 @@ public class Util {
}
/**
* Checks whether a given String is <code>null</code> or empty.
* Checks whether a given String is <code>null</code> or empty. Note that the string is not trimmed
* before performing the "empty" check, so for example " " (three spaces) <em>will</em> be considered
* having a length and <tt>true</tt> would be returned in this case.
*
* @param str
* String to check