Provide getRegattaLog method on RaceColumn and use RegattaLog to determine competitor set

This commit is contained in:
Jan Broß committed 2015-11-27 15:06:11 +01:00
1 parent 70609813f0
commit dfe73bfc9e
7 files changed
+53 -6

No files matched your search

@@ -46,6 +46,14 @@ public interface RaceColumn extends Named {
*/
RaceLog getRaceLog(Fleet fleet);
/**
* Gets the regatta log associated with race column's race and the passed fleet. Note that the result may be <code>null</code>
* particularly for columns in a {@link MetaLeaderboard}.
*
* @return the regatta log or <code>null</code> in case this column belongs to a {@link MetaLeaderboard}
*/
RegattaLog getRegattaLog();
/**
* @return the fleets for each of which this column has a single race and therefore optionally a {@link TrackedRace}, in
* ascending order; best fleets first
@@ -10,7 +10,8 @@ import java.util.Set;
import java.util.logging.Logger;
import com.sap.sailing.domain.abstractlog.race.RaceLog;
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceLogRegisteredCompetitorsAnalyzer;
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RegisteredCompetitorsAnalyzer;
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.base.Fleet;
import com.sap.sailing.domain.base.RaceColumn;
@@ -56,7 +57,7 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
return raceLogs.get(fleet);
}
}
@Override
public RaceLogIdentifier getRaceLogIdentifier(Fleet fleet) {
return new RaceLogIdentifierImpl(regattaLikeParent, getName(), fleet);
@@ -227,11 +228,13 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
if (trackedRace != null) {
Util.addAll(trackedRace.getRace().getCompetitors(), result);
} else {
// if no tracked race is found, use competitors from race log; this assumes that if a tracked
// if no tracked race is found, use competitors from race/regatta log depending on whether
// the mapping event is present or not; this assumes that if a tracked
// race exists, its competitors set takes precedence over what's in the race log. Usually,
// the tracked race will have the same competitors as those in the race log, or more because
// those from the regatta log are added to the tracked race as well.
Set<Competitor> viaRaceLog = new RaceLogRegisteredCompetitorsAnalyzer(getRaceLog(fleet)).analyze();
RegattaLog regattaLog = getRegattaLog();
Set<Competitor> viaRaceLog = new RegisteredCompetitorsAnalyzer(getRaceLog(fleet), regattaLog).analyze();
result.addAll(viaRaceLog);
}
}
@@ -245,11 +248,13 @@ public abstract class AbstractRaceColumn extends SimpleAbstractRaceColumn implem
if (trackedRace != null) {
result = trackedRace.getRace().getCompetitors();
} else {
// if no tracked race is found, use competitors from race log; this assumes that if a tracked
// if no tracked race is found, use competitors from race/regatta log depending on whether
// the mapping event is present or not; this assumes that if a tracked
// race exists, its competitors set takes precedence over what's in the race log. Usually,
// the tracked race will have the same competitors as those in the race log, or more because
// those from the regatta log are added to the tracked race as well.
Set<Competitor> viaRaceLog = new RaceLogRegisteredCompetitorsAnalyzer(getRaceLog(fleet)).analyze();
RegattaLog regattaLog = getRegattaLog();
Set<Competitor> viaRaceLog = new RegisteredCompetitorsAnalyzer(getRaceLog(fleet), regattaLog).analyze();
result = viaRaceLog;
}
return result;
@@ -3,6 +3,7 @@ package com.sap.sailing.domain.base.impl;
import java.util.Iterator;
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
import com.sap.sailing.domain.base.Fleet;
import com.sap.sailing.domain.base.RaceColumnInSeries;
import com.sap.sailing.domain.base.RaceDefinition;
@@ -131,4 +132,10 @@ public class RaceColumnInSeriesImpl extends AbstractRaceColumn implements RaceCo
}
return result;
}
@Override
public RegattaLog getRegattaLog() {
Regatta regatta = getRegatta();
return regatta.getRegattaLog();
}
}
@@ -1,8 +1,10 @@
package com.sap.sailing.domain.leaderboard;
import com.sap.sailing.domain.base.RaceColumn;
import com.sap.sailing.domain.regattalike.IsRegattaLike;
public interface FlexibleRaceColumn extends RaceColumn {
void setName(String newName);
void setIsMedalRace(boolean isMedalRace);
void setRegattaLikeHelper(IsRegattaLike regattaLikeHelper);
}
@@ -151,6 +151,7 @@ public class FlexibleLeaderboardImpl extends AbstractLeaderboardImpl implements
column.addRaceColumnListener(this);
races.add(column);
column.setRaceLogInformation(raceLogStore, new FlexibleLeaderboardAsRegattaLikeIdentifier(this));
column.setRegattaLikeHelper(regattaLikeHelper);
getRaceColumnListeners().notifyListenersAboutRaceColumnAddedToContainer(column);
}
return column;
@@ -2,9 +2,11 @@ package com.sap.sailing.domain.leaderboard.impl;
import java.util.Collections;
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
import com.sap.sailing.domain.base.Fleet;
import com.sap.sailing.domain.base.impl.AbstractRaceColumn;
import com.sap.sailing.domain.leaderboard.FlexibleRaceColumn;
import com.sap.sailing.domain.regattalike.IsRegattaLike;
import com.sap.sailing.domain.tracking.RaceExecutionOrderProvider;
public class RaceColumnImpl extends AbstractRaceColumn implements FlexibleRaceColumn {
@@ -13,6 +15,7 @@ public class RaceColumnImpl extends AbstractRaceColumn implements FlexibleRaceCo
private boolean medalRace;
private final RaceExecutionOrderProvider raceExecutionOrderProvider;
private IsRegattaLike regattaLikeHelper;
public RaceColumnImpl(String name, boolean medalRace, RaceExecutionOrderProvider raceExecutionOrderProvider) {
super();
@@ -51,4 +54,18 @@ public class RaceColumnImpl extends AbstractRaceColumn implements FlexibleRaceCo
public RaceExecutionOrderProvider getRaceExecutionOrderProvider() {
return raceExecutionOrderProvider;
}
@Override
public void setRegattaLikeHelper(IsRegattaLike regattaLikeHelper) {
this.regattaLikeHelper = regattaLikeHelper;
}
@Override
public RegattaLog getRegattaLog() {
if (regattaLikeHelper != null){
return regattaLikeHelper.getRegattaLog();
} else {
return null;
}
}
}
@@ -4,6 +4,7 @@ import java.util.Collections;
import com.sap.sailing.domain.abstractlog.race.RaceLog;
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
import com.sap.sailing.domain.base.Competitor;
import com.sap.sailing.domain.base.Fleet;
import com.sap.sailing.domain.base.RaceColumn;
@@ -41,6 +42,12 @@ public class MetaLeaderboardColumn extends SimpleAbstractRaceColumn implements R
public RaceLog getRaceLog(Fleet fleet) {
return null;
}
@Override
public RegattaLog getRegattaLog(Fleet fleet) {
return null;
}
public Leaderboard getLeaderboard() {
return leaderboard;