Merge branch 'master' into bug4009

This commit is contained in:
Steffen Schaefer committed 2017-01-26 15:31:34 +01:00
commit 86ae110571
734 files changed
+8349 -37385

No files matched your search

@@ -1,6 +1,7 @@
package com.sap.sailing.domain.abstractlog.race;
import com.sap.sailing.domain.abstractlog.Revokable;
public interface RaceLogEndOfTrackingEvent extends RaceLogEvent {
public interface RaceLogEndOfTrackingEvent extends RaceLogEvent, Revokable {
}
@@ -1,5 +1,7 @@
package com.sap.sailing.domain.abstractlog.race;
public interface RaceLogStartOfTrackingEvent extends RaceLogEvent {
import com.sap.sailing.domain.abstractlog.Revokable;
public interface RaceLogStartOfTrackingEvent extends RaceLogEvent, Revokable {
}
@@ -13,12 +13,30 @@ public class ConfirmedFinishPositioningListFinder extends RaceLogAnalyzer<Compet
@Override
protected CompetitorResults performAnalysis() {
return performAnalysis(/* eventToIgnore */ null);
}
private CompetitorResults performAnalysis(RaceLogFinishPositioningConfirmedEvent eventToIgnore) {
for (RaceLogEvent event : getPassEventsDescending()) {
if (event instanceof RaceLogFinishPositioningConfirmedEvent) {
if (event != eventToIgnore && event instanceof RaceLogFinishPositioningConfirmedEvent) {
RaceLogFinishPositioningConfirmedEvent finishPositioningEvent = (RaceLogFinishPositioningConfirmedEvent) event;
return finishPositioningEvent.getPositionedCompetitorsIDsNamesMaxPointsReasons();
}
}
return null;
}
/**
* Same as {@link #analyze()}, only that if {@code event} is found in the log then it is ignored for this
* analysis. This way, the method returns a result as it would have been without {@code event} in the
* {@link RaceLog}. This can be useful, e.g., to determine the result prior to the last update.
*/
public CompetitorResults analyzeIgnoring(RaceLogFinishPositioningConfirmedEvent event) {
log.lockForRead();
try {
return performAnalysis(event);
} finally {
log.unlockAfterRead();
}
}
}
@@ -0,0 +1,45 @@
package com.sap.sailing.domain.abstractlog.race.analyzing.impl;
import com.sap.sailing.domain.abstractlog.race.RaceLog;
import com.sap.sailing.domain.abstractlog.race.RaceLogEndOfTrackingEvent;
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
import com.sap.sailing.domain.abstractlog.race.RaceLogStartOfTrackingEvent;
import com.sap.sse.common.Util;
import com.sap.sse.common.Util.Pair;
public class TrackingTimesEventFinder extends RaceLogAnalyzer<Util.Pair<RaceLogStartOfTrackingEvent, RaceLogEndOfTrackingEvent>> {
public TrackingTimesEventFinder(RaceLog raceLog) {
super(raceLog);
}
@Override
protected Util.Pair<RaceLogStartOfTrackingEvent, RaceLogEndOfTrackingEvent> performAnalysis() {
boolean startOfTrackingFound = false;
boolean endOfTrackingFound = false;
RaceLogStartOfTrackingEvent start = null;
RaceLogEndOfTrackingEvent end = null;
final RaceLog raceLog = getLog();
for (RaceLogEvent event : raceLog.getUnrevokedEventsDescending()) {
if (!startOfTrackingFound && event instanceof RaceLogStartOfTrackingEvent) {
start = (RaceLogStartOfTrackingEvent) event;
startOfTrackingFound = true;
}
if (!endOfTrackingFound && event instanceof RaceLogEndOfTrackingEvent) {
end = (RaceLogEndOfTrackingEvent) event;
endOfTrackingFound = true;
}
if (startOfTrackingFound && endOfTrackingFound) {
break;
}
}
final Pair<RaceLogStartOfTrackingEvent, RaceLogEndOfTrackingEvent> result;
if (startOfTrackingFound || endOfTrackingFound) {
result = new Util.Pair<>(start, end);
} else {
result = null;
}
return result;
}
}
@@ -2,7 +2,6 @@ package com.sap.sailing.domain.abstractlog.race.analyzing.impl;
import com.sap.sailing.domain.abstractlog.race.RaceLog;
import com.sap.sailing.domain.abstractlog.race.RaceLogEndOfTrackingEvent;
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
import com.sap.sailing.domain.abstractlog.race.RaceLogStartOfTrackingEvent;
import com.sap.sailing.domain.common.abstractlog.TimePointSpecificationFoundInLog;
import com.sap.sailing.domain.common.abstractlog.TimePointSpecificationFoundInLogImpl;
@@ -10,38 +9,19 @@ import com.sap.sse.common.Util;
import com.sap.sse.common.Util.Pair;
public class TrackingTimesFinder extends RaceLogAnalyzer<Util.Pair<TimePointSpecificationFoundInLog, TimePointSpecificationFoundInLog>> {
private final TrackingTimesEventFinder trackingTimesEventFinder;
public TrackingTimesFinder(RaceLog raceLog) {
super(raceLog);
this.trackingTimesEventFinder = new TrackingTimesEventFinder(raceLog);
}
@Override
protected Util.Pair<TimePointSpecificationFoundInLog, TimePointSpecificationFoundInLog> performAnalysis() {
boolean startOfTrackingFound = false;
boolean endOfTrackingFound = false;
TimePointSpecificationFoundInLog start = null;
TimePointSpecificationFoundInLog end = null;
final RaceLog raceLog = getLog();
for (RaceLogEvent event : raceLog.getUnrevokedEventsDescending()) {
if (!startOfTrackingFound && event instanceof RaceLogStartOfTrackingEvent) {
start = new TimePointSpecificationFoundInLogImpl(event.getLogicalTimePoint());
startOfTrackingFound = true;
}
if (!endOfTrackingFound && event instanceof RaceLogEndOfTrackingEvent) {
end = new TimePointSpecificationFoundInLogImpl(event.getLogicalTimePoint());
endOfTrackingFound = true;
}
if (startOfTrackingFound && endOfTrackingFound) {
break;
}
}
final Pair<TimePointSpecificationFoundInLog, TimePointSpecificationFoundInLog> result;
if (startOfTrackingFound || endOfTrackingFound) {
result = new Util.Pair<>(start, end);
} else {
result = null;
}
return result;
Pair<RaceLogStartOfTrackingEvent, RaceLogEndOfTrackingEvent> preResult = trackingTimesEventFinder.performAnalysis();
return preResult == null ? null :
new Util.Pair<TimePointSpecificationFoundInLog, TimePointSpecificationFoundInLog>(
preResult.getA()==null?null:new TimePointSpecificationFoundInLogImpl(preResult.getA().getLogicalTimePoint()),
preResult.getB()==null?null:new TimePointSpecificationFoundInLogImpl(preResult.getB().getLogicalTimePoint()));
}
}
@@ -1,6 +1,5 @@
package com.sap.sailing.domain.abstractlog.race.state;
public interface RaceStateChangedListener {
void onRacingProcedureChanged(ReadonlyRaceState state);
@@ -110,4 +110,6 @@ public interface SharedDomainFactory extends CompetitorFactory {
ControlPointWithTwoMarks getOrCreateControlPointWithTwoMarks(String id, String name, Mark left, Mark right);
RaceLogResolver getRaceLogResolver();
Mark getOrCreateMark(String name, MarkType markType);
}
@@ -48,7 +48,9 @@ public class BoatClassImpl extends NamedImpl implements BoatClass {
public BoatClassImpl(String name, boolean typicallyStartsUpwind) {
this(name, typicallyStartsUpwind, /* displayName */ null,
/* hull length */ new MeterDistance(5), /* hullBeam */ null, /* hullType */ null);
// use the typical dinghy parameters as default
/* hull length */ new MeterDistance(5), /* hullBeam */ new MeterDistance(1.8),
/* hullType */ BoatHullType.MONOHULL);
}
public BoatClassImpl(String name, BoatClassMasterdata masterData) {
@@ -154,14 +154,23 @@ public class SharedDomainFactoryImpl implements SharedDomainFactory {
return getOrCreateMark(name, name);
}
@Override
public Mark getOrCreateMark(String name, MarkType markType) {
return getOrCreateMark(name, name, markType);
}
private Mark getOrCreateMark(Serializable id, String name, MarkType markType) {
return getOrCreateMark(id, name, markType, /* color */ null, /* shape */ null, /* pattern */ null);
}
@Override
public Mark getOrCreateMark(Serializable id, String name) {
return getOrCreateMark(id, name, null, null, null, null);
return getOrCreateMark(id, name, /* type */ null, /* color */ null, /* shape */ null, /* pattern */ null);
}
@Override
public Mark getOrCreateMark(String toStringRepresentationOfID, String name) {
return getOrCreateMark(toStringRepresentationOfID, name, null, null, null, null);
return getOrCreateMark(toStringRepresentationOfID, name, /* type */ null, /* color */ null, /* shape */ null, /* pattern */ null);
}
@Override
@@ -250,7 +250,8 @@ public class TransientCompetitorStoreImpl implements CompetitorStore, Serializab
c.getFlagImage() == null ? null : c.getFlagImage().toString(),
new BoatDTO(c.getBoat().getName(), c.getBoat().getSailID(), c.getBoat().getColor()),
new BoatClassDTO(c.getBoat().getBoatClass()
.getName(), c.getBoat().getBoatClass().getDisplayName(), c.getBoat().getBoatClass().getHullLength()),
.getName(), c.getBoat().getBoatClass().getDisplayName(), c.getBoat().getBoatClass().getHullLength(),
c.getBoat().getBoatClass().getHullBeam()),
c.getTimeOnTimeFactor(), c.getTimeOnDistanceAllowancePerNauticalMile(), c.getSearchTag());
weakCompetitorDTOCache.put(c, competitorDTO);
}
@@ -1,6 +1,7 @@
package com.sap.sailing.domain.base.racegroup;
import com.sap.sailing.domain.abstractlog.race.RaceLog;
import com.sap.sailing.domain.common.TargetTimeInfo;
import com.sap.sse.common.Named;
import com.sap.sse.common.Util;
@@ -33,4 +34,11 @@ public interface RaceCell extends Named {
* index 0.
*/
int getZeroBasedIndexInFleet();
/**
* If there is a tracked race for this race and we have sufficient information about wind and the boat class's
* polar / VPP data this method will return an estimated duration for how long the race will take based on the
* current course.
*/
TargetTimeInfo getTargetTime();
}
@@ -2,6 +2,7 @@ package com.sap.sailing.domain.base.racegroup.impl;
import com.sap.sailing.domain.abstractlog.race.RaceLog;
import com.sap.sailing.domain.base.racegroup.RaceCell;
import com.sap.sailing.domain.common.TargetTimeInfo;
import com.sap.sse.common.Util;
import com.sap.sse.common.impl.NamedImpl;
@@ -21,6 +22,8 @@ public class RaceCellImpl extends NamedImpl implements RaceCell {
private final Double explicitFactor;
private final int zeroBasedIndexInFleet;
private final TargetTimeInfo targetTime;
/**
* @param zeroBasedIndexInFleet
@@ -34,12 +37,13 @@ public class RaceCellImpl extends NamedImpl implements RaceCell {
* except in case the first race column is a "virtual" one that holds a non-discardable carry-forward
* result. In this case, the second Race Column, which is the first "non-virtual" one, receives index 0.
*/
public RaceCellImpl(String raceColumnName, RaceLog raceLog, double factor, Double explicitFactor, int zeroBasedIndexInFleet) {
public RaceCellImpl(String raceColumnName, RaceLog raceLog, double factor, Double explicitFactor, int zeroBasedIndexInFleet, TargetTimeInfo targetTime) {
super(raceColumnName);
this.raceLog = raceLog;
this.factor = factor;
this.explicitFactor = explicitFactor;
this.zeroBasedIndexInFleet = zeroBasedIndexInFleet;
this.targetTime = targetTime;
}
@Override
@@ -70,9 +74,14 @@ public class RaceCellImpl extends NamedImpl implements RaceCell {
return zeroBasedIndexInFleet;
}
@Override
public TargetTimeInfo getTargetTime() {
return targetTime;
}
@Override
public String toString() {
return "RaceCellImpl [factor=" + factor + ", explicitFactor=" + explicitFactor + ", zeroBasedIndexInFleet="
+ zeroBasedIndexInFleet + ", getName()=" + getName() + "]";
+ zeroBasedIndexInFleet + ", name=" + getName() + ", targetTime: " + getTargetTime() + "]";
}
}