use RefNo as ID for ORC certificates; distinguish valid/invalid in certificate search

This commit is contained in:
Axel Uhl
2020-03-11 00:13:24 +01:00
parent b0ecf94880
commit ffc00ddbf0
18 changed files with 322 additions and 151 deletions
@@ -5,10 +5,12 @@ import java.util.Map;
import com.sap.sailing.domain.common.impl.KnotSpeedImpl;
import com.sap.sse.common.Bearing;
import com.sap.sse.common.CountryCode;
import com.sap.sse.common.Distance;
import com.sap.sse.common.Duration;
import com.sap.sse.common.Speed;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.Util.Pair;
import com.sap.sse.common.WithID;
import com.sap.sse.common.impl.DegreeBearingImpl;
@@ -24,10 +26,9 @@ import com.sap.sse.common.impl.DegreeBearingImpl;
* {@link RankingMetric}.
* <p>
*
* The {@link WithID} interface is to be implemented such that a {@link String} is produced as the ID that contains the
* concatenation (without intermediate white space) of the {@code NatAuth}, the {@code CertNo} and the {@code BIN}
* fields, as provided as single fields in the JSON representation, and as provided in the concatenated form in the
* {@code NATCERTN.FILE_ID} column in the RMS format.
* The {@link WithID} interface is to be implemented based on the {@link #getReferenceNumber()} which is unique across the
* ORC world-wide certificate database. Note that the {@link #getBoatKey()} consisting of the {@link #getFileId()} and the
* {@link #getIssuingCountry()} field values is a unique key for the boat to which the certificate belongs.
* <p>
*
* The certificate contains time allowances (or, conversely, speed predictions) for a combination of true wind speeds
@@ -64,14 +65,38 @@ public interface ORCCertificate extends WithID, Serializable {
Bearing[] ALLOWANCES_TRUE_WIND_ANGLES = { new DegreeBearingImpl(52), new DegreeBearingImpl(60),
new DegreeBearingImpl(75), new DegreeBearingImpl(90), new DegreeBearingImpl(110),
new DegreeBearingImpl(120), new DegreeBearingImpl(135), new DegreeBearingImpl(150) };
/**
* As the ID of an ORC certificate we use the concatenation (without intermediate white space) of the
* {@code NatAuth}, the {@code CertNo} and the {@code BIN} fields, as provided as single fields in the JSON
* representation
* We use the {@link #getReferenceNumber() reference number ("RefNo")} as the ID of a certificate document.
* It is unique for all of ORC's certificates issued world-wide.
*/
@Override
String getId();
String getReferenceNumber();
/**
* Technically, at ORC a certificate's boat is identified by a "file ID" as returned by this method, together
* with the {@link #getIssuingCountry() issuing country} which together makes this a unique boat key. For each
* such boat key there is at most one valid certificate at a time.
*/
String getFileId();
/**
* The country whose authority issued this certificate. Together with the {@link #getFileId() file ID} this makes for a
* unique key of the boat to which this certifiate belongs.
*/
CountryCode getIssuingCountry();
/**
* A unique key of the boat to which this certificate belongs; it consists of the {@link #getFileId() file ID} and the
* {@link #getIssuingCountry() issuing country}. For any such key the ORC database delivers at most one valid certificate
* at any given time.
*/
default Pair<String, CountryCode> getBoatKey() {
return new Pair<>(getFileId(), getIssuingCountry());
}
/**
* Returns the sailnumber of the {@link Competitor} which this certificate belongs to.
*
@@ -6,6 +6,7 @@ import java.util.Map;
import com.sap.sailing.domain.common.impl.NauticalMileDistance;
import com.sap.sailing.domain.common.orc.ORCCertificate;
import com.sap.sse.common.Bearing;
import com.sap.sse.common.CountryCode;
import com.sap.sse.common.Distance;
import com.sap.sse.common.Duration;
import com.sap.sse.common.Speed;
@@ -24,7 +25,7 @@ import com.sap.sse.common.Util;
public class ORCCertificateImpl implements ORCCertificate {
private static final long serialVersionUID = 8725162998514202782L;
private final String idConsistingOfNatAuthCertNoAndBIN;
private final String referenceNumber;
public final static Distance NAUTICAL_MILE = new NauticalMileDistance(1);
@@ -35,7 +36,9 @@ public class ORCCertificateImpl implements ORCCertificate {
private final Duration gph;
private final Double cdl;
private final TimePoint issueDate;
private final String fileId;
private final CountryCode issuingCountry;
/**
* The "core" of the certificate for performance curve scoring; the values in the map tell how fast the boat
* described by this certificate is expected to sail for the true wind speed (TWS) provided by the key, and the true
@@ -111,11 +114,13 @@ public class ORCCertificateImpl implements ORCCertificate {
* {@link ORCCertificate#ALLOWANCES_TRUE_WIND_ANGLES}.
*/
public ORCCertificateImpl(Speed[] allowancesTrueWindSpeeds, Bearing[] allowancesTrueWindAngles,
String idConsistingOfNatAuthCertNoAndBIN, String sailnumber, String boatName, String boatClassName,
Distance length, Duration gph, Double cdl, TimePoint issueDate,
String referenceNumber, String fileId, String sailnumber, String boatName,
String boatClassName, Distance length, Duration gph, Double cdl,
TimePoint issueDate, CountryCode issuingCountry,
Map<Speed, Map<Bearing, Speed>> velocityPredictionsPerTrueWindSpeedAndAngle, Map<Speed, Bearing> beatAngles,
Map<Speed, Speed> beatVMGPredictionPerTrueWindSpeed, Map<Speed, Duration> beatAllowancePerTrueWindSpeed,
Map<Speed, Bearing> runAngles, Map<Speed, Speed> runVMGPredictionPerTrueWindSpeed,
Map<Speed, Bearing> runAngles,
Map<Speed, Speed> runVMGPredictionPerTrueWindSpeed,
Map<Speed, Duration> runAllowancePerTrueWindSpeed,
Map<Speed, Speed> windwardLeewardSpeedPredictionsPerTrueWindSpeed,
Map<Speed, Speed> longDistanceSpeedPredictionsPerTrueWindSpeed,
@@ -123,7 +128,9 @@ public class ORCCertificateImpl implements ORCCertificate {
Map<Speed, Speed> nonSpinnakerSpeedPredictionsPerTrueWindSpeed) {
this.allowancesTrueWindAngles = allowancesTrueWindAngles;
this.allowancesTrueWindSpeeds = allowancesTrueWindSpeeds;
this.idConsistingOfNatAuthCertNoAndBIN = idConsistingOfNatAuthCertNoAndBIN;
this.referenceNumber = referenceNumber;
this.fileId = fileId;
this.issuingCountry = issuingCountry;
this.sailNumber = sailnumber;
this.boatName = boatName;
this.boatClassName = boatClassName;
@@ -150,21 +157,23 @@ public class ORCCertificateImpl implements ORCCertificate {
* {@link ORCCertificate#ALLOWANCES_TRUE_WIND_ANGLES}, respectively, for the matrix of time allowances
* or, conversely, the speed predictions.
*/
public ORCCertificateImpl(String idConsistingOfNatAuthCertNoAndBIN,
String sailnumber, String boatName, String boatClassName,
Distance length, Duration gph,
Double cdl, TimePoint issueDate,
Map<Speed, Map<Bearing, Speed>> velocityPredictionsPerTrueWindSpeedAndAngle,
public ORCCertificateImpl(String referenceNumber,
String fileId, String sailnumber, String boatName,
String boatClassName, Distance length,
Duration gph, Double cdl,
TimePoint issueDate,
CountryCode issuingCountry, Map<Speed, Map<Bearing, Speed>> velocityPredictionsPerTrueWindSpeedAndAngle,
Map<Speed, Bearing> beatAngles, Map<Speed, Speed> beatVMGPredictionPerTrueWindSpeed,
Map<Speed, Duration> beatAllowancePerTrueWindSpeed, Map<Speed, Bearing> runAngles,
Map<Speed, Duration> beatAllowancePerTrueWindSpeed,
Map<Speed, Bearing> runAngles,
Map<Speed, Speed> runVMGPredictionPerTrueWindSpeed,
Map<Speed, Duration> runAllowancePerTrueWindSpeed,
Map<Speed, Speed> windwardLeewardSpeedPredictionsPerTrueWindSpeed,
Map<Speed, Speed> longDistanceSpeedPredictionsPerTrueWindSpeed,
Map<Speed, Speed> circularRandomSpeedPredictionsPerTrueWindSpeed,
Map<Speed, Speed> nonSpinnakerSpeedPredictionsPerTrueWindSpeed) {
this(ALLOWANCES_TRUE_WIND_SPEEDS, ALLOWANCES_TRUE_WIND_ANGLES, idConsistingOfNatAuthCertNoAndBIN, sailnumber,
boatName, boatClassName, length, gph, cdl, issueDate, velocityPredictionsPerTrueWindSpeedAndAngle,
this(ALLOWANCES_TRUE_WIND_SPEEDS, ALLOWANCES_TRUE_WIND_ANGLES, referenceNumber, fileId, sailnumber, boatName,
boatClassName, length, gph, cdl, issueDate, issuingCountry, velocityPredictionsPerTrueWindSpeedAndAngle,
beatAngles, beatVMGPredictionPerTrueWindSpeed, beatAllowancePerTrueWindSpeed, runAngles,
runVMGPredictionPerTrueWindSpeed, runAllowancePerTrueWindSpeed,
windwardLeewardSpeedPredictionsPerTrueWindSpeed, longDistanceSpeedPredictionsPerTrueWindSpeed,
@@ -173,7 +182,22 @@ public class ORCCertificateImpl implements ORCCertificate {
@Override
public String getId() {
return idConsistingOfNatAuthCertNoAndBIN;
return getReferenceNumber();
}
@Override
public String getReferenceNumber() {
return referenceNumber;
}
@Override
public String getFileId() {
return fileId;
}
@Override
public CountryCode getIssuingCountry() {
return issuingCountry;
}
@Override