Merge branch 'master' into bug3916

Conflicts:
	mobile/com.sap.sailing.racecommittee.app/src/com/sap/sailing/racecommittee/app/ui/fragments/preference/RegattaPreferenceFragment.java

Change-Id: I679391487b85c85abdf8e100b72829b1947a2ff1
This commit is contained in:
Axel Uhl committed 2016-11-29 18:06:38 +01:00
commit d51143f077
35 files changed
+386 -121

No files matched your search

@@ -1,6 +1,6 @@
package com.sap.sailing.domain.abstractlog.race;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.TimeRange;
/**
* Indicates that the protest start time for the related race has changed.
@@ -9,7 +9,9 @@ import com.sap.sse.common.TimePoint;
public interface RaceLogProtestStartTimeEvent extends RaceLogEvent {
/**
* Returns the start time of the race's protest time.
* Returns the time range of the race's protest time. The result is never {@code null}
* and the {@link TimeRange} returned always has a valid {@link TimeRange#from() start}
* and {@link TimeRange#to() end}.
*/
TimePoint getProtestStartTime();
TimeRange getProtestTime();
}
@@ -3,19 +3,20 @@ package com.sap.sailing.domain.abstractlog.race.analyzing.impl;
import com.sap.sailing.domain.abstractlog.race.RaceLog;
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
import com.sap.sailing.domain.abstractlog.race.RaceLogProtestStartTimeEvent;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.TimeRange;
public class ProtestStartTimeFinder extends RaceLogAnalyzer<TimePoint> {
public class ProtestTimeFinder extends RaceLogAnalyzer<TimeRange> {
public ProtestStartTimeFinder(RaceLog raceLog) {
public ProtestTimeFinder(RaceLog raceLog) {
super(raceLog);
}
@Override
protected TimePoint performAnalysis() {
protected TimeRange performAnalysis() {
for (RaceLogEvent event : getPassEventsDescending()) {
if (event instanceof RaceLogProtestStartTimeEvent) {
return ((RaceLogProtestStartTimeEvent) event).getProtestStartTime();
RaceLogProtestStartTimeEvent protestEvent = (RaceLogProtestStartTimeEvent) event;
return protestEvent.getProtestTime();
}
}
return null;
@@ -6,21 +6,23 @@ import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
import com.sap.sailing.domain.abstractlog.race.RaceLogEventVisitor;
import com.sap.sailing.domain.abstractlog.race.RaceLogProtestStartTimeEvent;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.TimeRange;
public class RaceLogProtestStartTimeEventImpl extends RaceLogEventImpl implements RaceLogProtestStartTimeEvent {
private static final long serialVersionUID = -1800827552916395996L;
private final TimePoint protestStartTime;
private final TimeRange protestTime;
public RaceLogProtestStartTimeEventImpl(TimePoint createdAt, TimePoint pTimePoint, AbstractLogEventAuthor author,
Serializable pId, int pPassId, TimePoint protestStartTime) {
Serializable pId, int pPassId, TimeRange protestTime) {
super(createdAt, pTimePoint, author, pId, pPassId);
this.protestStartTime = protestStartTime;
assert protestTime != null && protestTime.from() != null && protestTime.to() != null;
this.protestTime = protestTime;
}
public RaceLogProtestStartTimeEventImpl(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int pPassId,
TimePoint protestStartTime) {
this(now(), logicalTimePoint, author, randId(), pPassId, protestStartTime);
TimeRange protestTime) {
this(now(), logicalTimePoint, author, randId(), pPassId, protestTime);
}
@Override
@@ -29,13 +31,13 @@ public class RaceLogProtestStartTimeEventImpl extends RaceLogEventImpl implement
}
@Override
public TimePoint getProtestStartTime() {
return protestStartTime;
public TimeRange getProtestTime() {
return protestTime;
}
@Override
public String getShortInfo() {
return "protestStartTime=" + protestStartTime;
return "protestStartTime=" + protestTime.from() + ", protestEndTime=" + protestTime.to();
}
}
@@ -19,6 +19,7 @@ import com.sap.sailing.domain.common.racelog.Flags;
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.TimeRange;
/**
* Extension to the {@link ReadonlyRaceState} allowing write-access to the state of a race.
@@ -142,9 +143,9 @@ public interface RaceState extends ReadonlyRaceState {
void setFinishedTime(TimePoint now);
/**
* Sets the protest (start) time.
* Sets the protest time.
*/
void setProtestTime(TimePoint now, TimePoint protestStartTime);
void setProtestTime(TimePoint now, TimeRange protestTime);
/**
* Signals the abort of this race.
@@ -14,6 +14,7 @@ import com.sap.sailing.domain.base.configuration.RegattaConfiguration;
import com.sap.sailing.domain.common.Wind;
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.TimeRange;
/**
* This interface gives you reading access to the state of a race. You can query various properties of the race
@@ -134,7 +135,7 @@ public interface ReadonlyRaceState extends RaceStateEventProcessor {
/**
* If there is a protest time set, returns the most recent one. Otherwise <code>null</code>.
*/
TimePoint getProtestTime();
TimeRange getProtestTime();
/**
* If there is a course set, returns the most recent one. Otherwise <code>null</code>.
@@ -45,6 +45,7 @@ import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
import com.sap.sse.common.Duration;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.TimeRange;
/**
* Write-enabled {@link RaceState}.
@@ -169,8 +170,9 @@ public class RaceStateImpl extends ReadonlyRaceStateImpl implements RaceState {
}
@Override
public void setProtestTime(TimePoint now, TimePoint timePoint) {
raceLog.add(new RaceLogProtestStartTimeEventImpl(now, author, raceLog.getCurrentPassId(), timePoint));
public void setProtestTime(TimePoint now, TimeRange protestTime) {
assert protestTime != null && protestTime.from() != null && protestTime.to() != null;
raceLog.add(new RaceLogProtestStartTimeEventImpl(now, author, raceLog.getCurrentPassId(), protestTime));
}
@Override
@@ -18,7 +18,7 @@ import com.sap.sailing.domain.abstractlog.race.analyzing.impl.FinishedTimeFinder
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.FinishingTimeFinder;
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.LastPublishedCourseDesignFinder;
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.LastWindFixFinder;
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.ProtestStartTimeFinder;
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.ProtestTimeFinder;
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceLogResolver;
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceStatusAnalyzer;
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceStatusAnalyzer.Clock;
@@ -42,6 +42,7 @@ import com.sap.sailing.domain.common.Wind;
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
import com.sap.sse.common.TimePoint;
import com.sap.sse.common.TimeRange;
import com.sap.sse.common.Util;
/**
@@ -116,7 +117,7 @@ public class ReadonlyRaceStateImpl implements ReadonlyRaceState, RaceLogChangedL
private final StartTimeFinder startTimeAnalyzer;
private final FinishingTimeFinder finishingTimeAnalyzer;
private final FinishedTimeFinder finishedTimeAnalyzer;
private final ProtestStartTimeFinder protestTimeAnalyzer;
private final ProtestTimeFinder protestTimeAnalyzer;
private final FinishPositioningListFinder finishPositioningListAnalyzer;
private final ConfirmedFinishPositioningListFinder confirmedFinishPositioningListAnalyzer;
@@ -141,7 +142,7 @@ public class ReadonlyRaceStateImpl implements ReadonlyRaceState, RaceLogChangedL
private StartTimeFinderResult cachedStartTimeFinderResult;
private TimePoint cachedFinishingTime;
private TimePoint cachedFinishedTime;
private TimePoint cachedProtestTime;
private TimeRange cachedProtest;
private CompetitorResults cachedPositionedCompetitors;
private CompetitorResults cachedConfirmedPositionedCompetitors;
private CourseBase cachedCourseDesign;
@@ -184,7 +185,7 @@ public class ReadonlyRaceStateImpl implements ReadonlyRaceState, RaceLogChangedL
this.startTimeAnalyzer = new StartTimeFinder(raceLogResolver, raceLog);
this.finishingTimeAnalyzer = new FinishingTimeFinder(raceLog);
this.finishedTimeAnalyzer = new FinishedTimeFinder(raceLog);
this.protestTimeAnalyzer = new ProtestStartTimeFinder(raceLog);
this.protestTimeAnalyzer = new ProtestTimeFinder(raceLog);
this.finishPositioningListAnalyzer = new FinishPositioningListFinder(raceLog);
this.confirmedFinishPositioningListAnalyzer = new ConfirmedFinishPositioningListFinder(raceLog);
this.courseDesignerAnalyzer = new LastPublishedCourseDesignFinder(raceLog, /* onlyCoursesWithValidWaypointList */ false);
@@ -318,8 +319,8 @@ public class ReadonlyRaceStateImpl implements ReadonlyRaceState, RaceLogChangedL
}
@Override
public TimePoint getProtestTime() {
return cachedProtestTime;
public TimeRange getProtestTime() {
return cachedProtest;
}
@Override
@@ -459,9 +460,9 @@ public class ReadonlyRaceStateImpl implements ReadonlyRaceState, RaceLogChangedL
changedListeners.onFinishedTimeChanged(this);
}
TimePoint protestTime = protestTimeAnalyzer.analyze();
if (!Util.equalsWithNull(cachedProtestTime, protestTime)) {
cachedProtestTime = protestTime;
TimeRange protest = protestTimeAnalyzer.analyze();
if (!Util.equalsWithNull(cachedProtest, protest)) {
cachedProtest = protest;
changedListeners.onProtestTimeChanged(this);
}