Fixed several issues related to regatta leaderboard creation

- Replication issues
- Bug 1249 - Sort regattas in "Create regatta leaderboard" dialog
- Bug 1250 - Display name not applied by Create Regatta Leaderboard dialog
This commit is contained in:
fmittag committed 2013-03-03 14:53:19 +01:00
1 parent 3b0ef2bb01
commit be38ea453c
26 files changed
+157 -96

No files matched your search

@@ -236,9 +236,9 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
*
* @return the leaderboard created
*/
FlexibleLeaderboard addFlexibleLeaderboard(String name, int[] discardThresholds, ScoringScheme scoringScheme);
FlexibleLeaderboard addFlexibleLeaderboard(String leaderboardName, String leaderboardDisplayName, int[] discardThresholds, ScoringScheme scoringScheme);
RegattaLeaderboard addRegattaLeaderboard(RegattaIdentifier regattaIdentifier, int[] discardThresholds);
RegattaLeaderboard addRegattaLeaderboard(RegattaIdentifier regattaIdentifier, String leaderboardDisplayName, int[] discardThresholds);
void removeLeaderboard(String leaderboardName);
@@ -6,6 +6,7 @@ import com.sap.sailing.operationaltransformation.Operation;
import com.sap.sailing.operationaltransformation.Transformer;
import com.sap.sailing.server.operationaltransformation.AddColumnToLeaderboard;
import com.sap.sailing.server.operationaltransformation.CreateFlexibleLeaderboard;
import com.sap.sailing.server.operationaltransformation.CreateRegattaLeaderboard;
import com.sap.sailing.server.operationaltransformation.MoveLeaderboardColumnDown;
import com.sap.sailing.server.operationaltransformation.MoveLeaderboardColumnUp;
import com.sap.sailing.server.operationaltransformation.RemoveLeaderboard;
@@ -56,9 +57,13 @@ public interface RacingEventServiceOperation<ResultType> extends Operation<Racin
RacingEventServiceOperation<?> transformRenameLeaderboardColumnServerOp(RenameLeaderboardColumn renameLeaderboardColumnServerOp);
RacingEventServiceOperation<?> transformAddLeaderboardClientOp(CreateFlexibleLeaderboard addLeaderboard);
RacingEventServiceOperation<?> transformAddFlexibleLeaderboardClientOp(CreateFlexibleLeaderboard addLeaderboard);
RacingEventServiceOperation<?> transformAddLeaderboardServerOp(CreateFlexibleLeaderboard addLeaderboard);
RacingEventServiceOperation<?> transformAddFlexibleLeaderboardServerOp(CreateFlexibleLeaderboard addLeaderboard);
RacingEventServiceOperation<?> transformAddRegattaLeaderboardClientOp(CreateRegattaLeaderboard addLeaderboard);
RacingEventServiceOperation<?> transformAddRegattaLeaderboardServerOp(CreateRegattaLeaderboard addLeaderboard);
RacingEventServiceOperation<?> transformRemoveLeaderboardClientOp(RemoveLeaderboard removeLeaderboard);
@@ -227,7 +227,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
delayToLiveInMillis = TrackedRace.DEFAULT_LIVE_DELAY_IN_MILLISECONDS;
// Add one default leaderboard that aggregates all races currently tracked by this service.
// This is more for debugging purposes than for anything else.
addFlexibleLeaderboard(LeaderboardNameConstants.DEFAULT_LEADERBOARD_NAME, new int[] { 5, 8 },
addFlexibleLeaderboard(LeaderboardNameConstants.DEFAULT_LEADERBOARD_NAME, null, new int[] { 5, 8 },
tractracDomainFactory.getBaseDomainFactory().createScoringScheme(ScoringSchemeType.LOW_POINT));
loadStoredRegattas();
loadRaceIDToRegattaAssociations();
@@ -297,13 +297,14 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
}
@Override
public FlexibleLeaderboard addFlexibleLeaderboard(String name, int[] discardThresholds, ScoringScheme scoringScheme) {
logger.info("adding flexible leaderboard "+name);
FlexibleLeaderboard result = new FlexibleLeaderboardImpl(name, new ScoreCorrectionImpl(), new ResultDiscardingRuleImpl(
public FlexibleLeaderboard addFlexibleLeaderboard(String leaderboardName, String leaderboardDisplayName, int[] discardThresholds, ScoringScheme scoringScheme) {
logger.info("adding flexible leaderboard "+leaderboardName);
FlexibleLeaderboard result = new FlexibleLeaderboardImpl(leaderboardName, new ScoreCorrectionImpl(), new ResultDiscardingRuleImpl(
discardThresholds), scoringScheme);
result.setDisplayName(leaderboardDisplayName);
synchronized (leaderboardsByName) {
if (getLeaderboardByName(name) != null) {
throw new IllegalArgumentException("Leaderboard with name "+name+" already exists");
if (getLeaderboardByName(leaderboardName) != null) {
throw new IllegalArgumentException("Leaderboard with name "+leaderboardName+" already exists");
}
addLeaderboard(result);
}
@@ -312,7 +313,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
}
@Override
public RegattaLeaderboard addRegattaLeaderboard(RegattaIdentifier regattaIdentifier, int[] discardThresholds) {
public RegattaLeaderboard addRegattaLeaderboard(RegattaIdentifier regattaIdentifier, String leaderboardDisplayName, int[] discardThresholds) {
Regatta regatta = getRegatta(regattaIdentifier);
logger.info("adding regatta leaderboard for regatta "
+ (regatta == null ? "null" : (regatta.getName() + " (" + regatta.hashCode() + ")")) + " to " + this);
@@ -320,6 +321,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
if (regatta != null) {
result = new RegattaLeaderboardImpl(regatta, new ScoreCorrectionImpl(), new ResultDiscardingRuleImpl(
discardThresholds));
result.setDisplayName(leaderboardDisplayName);
synchronized (leaderboardsByName) {
if (getLeaderboardByName(result.getName()) != null) {
throw new IllegalArgumentException("Leaderboard with name " + result.getName() + " already exists in "+this);
@@ -48,12 +48,22 @@ public abstract class AbstractRacingEventServiceOperation<ResultType> implements
}
@Override
public RacingEventServiceOperation<?> transformAddLeaderboardClientOp(CreateFlexibleLeaderboard addLeaderboard) {
public RacingEventServiceOperation<?> transformAddFlexibleLeaderboardClientOp(CreateFlexibleLeaderboard addLeaderboard) {
return addLeaderboard;
}
@Override
public RacingEventServiceOperation<?> transformAddLeaderboardServerOp(CreateFlexibleLeaderboard addLeaderboard) {
public RacingEventServiceOperation<?> transformAddFlexibleLeaderboardServerOp(CreateFlexibleLeaderboard addLeaderboard) {
return addLeaderboard;
}
@Override
public RacingEventServiceOperation<?> transformAddRegattaLeaderboardClientOp(CreateRegattaLeaderboard addLeaderboard) {
return addLeaderboard;
}
@Override
public RacingEventServiceOperation<?> transformAddRegattaLeaderboardServerOp(CreateRegattaLeaderboard addLeaderboard) {
return addLeaderboard;
}
@@ -12,9 +12,11 @@ public class CreateFlexibleLeaderboard extends AbstractLeaderboardOperation<Flex
private static final long serialVersionUID = 891352705068098580L;
private final int[] discardThresholds;
private final ScoringScheme scoringScheme;
private final String leaderboardDisplayName;
public CreateFlexibleLeaderboard(String leaderboardName, int[] discardThresholds, ScoringScheme scoringScheme) {
public CreateFlexibleLeaderboard(String leaderboardName, String leaderboardDisplayName, int[] discardThresholds, ScoringScheme scoringScheme) {
super(leaderboardName);
this.leaderboardDisplayName = leaderboardDisplayName;
this.discardThresholds = discardThresholds;
this.scoringScheme = scoringScheme;
}
@@ -23,7 +25,7 @@ public class CreateFlexibleLeaderboard extends AbstractLeaderboardOperation<Flex
public FlexibleLeaderboard internalApplyTo(RacingEventService toState) {
FlexibleLeaderboard result = null;
if (toState.getLeaderboardByName(getLeaderboardName()) == null) {
result = toState.addFlexibleLeaderboard(getLeaderboardName(), discardThresholds, scoringScheme);
result = toState.addFlexibleLeaderboard(getLeaderboardName(), leaderboardDisplayName, discardThresholds, scoringScheme);
} else {
logger.warning("Cannot replicate creation of flexible leaderboard "+getLeaderboardName()+" because it already exists in the replica");
}
@@ -32,12 +34,11 @@ public class CreateFlexibleLeaderboard extends AbstractLeaderboardOperation<Flex
@Override
public RacingEventServiceOperation<?> transformClientOp(RacingEventServiceOperation<?> serverOp) {
return serverOp.transformAddLeaderboardClientOp(this);
return serverOp.transformAddFlexibleLeaderboardClientOp(this);
}
@Override
public RacingEventServiceOperation<?> transformServerOp(RacingEventServiceOperation<?> clientOp) {
return clientOp.transformAddLeaderboardServerOp(this);
return clientOp.transformAddFlexibleLeaderboardServerOp(this);
}
}
@@ -1,36 +1,45 @@
package com.sap.sailing.server.operationaltransformation;
import java.util.logging.Logger;
import com.sap.sailing.domain.common.RegattaIdentifier;
import com.sap.sailing.domain.common.RegattaName;
import com.sap.sailing.domain.leaderboard.RegattaLeaderboard;
import com.sap.sailing.server.RacingEventService;
import com.sap.sailing.server.RacingEventServiceOperation;
public class CreateRegattaLeaderboard extends AbstractRacingEventServiceOperation<RegattaLeaderboard> {
public class CreateRegattaLeaderboard extends AbstractLeaderboardOperation<RegattaLeaderboard> {
private static final Logger logger = Logger.getLogger(CreateRegattaLeaderboard.class.getName());
private static final long serialVersionUID = 891352705068098580L;
private final int[] discardThresholds;
private final RegattaIdentifier regattaIdentifier;
private final String leaderboardDisplayName;
public CreateRegattaLeaderboard(RegattaIdentifier regattaIdentifier, int[] discardThresholds) {
public CreateRegattaLeaderboard(RegattaIdentifier regattaIdentifier, String leaderboardDisplayName, int[] discardThresholds) {
super(((RegattaName) regattaIdentifier).getRegattaName());
this.leaderboardDisplayName = leaderboardDisplayName;
this.regattaIdentifier = regattaIdentifier;
this.discardThresholds = discardThresholds;
}
@Override
public RegattaLeaderboard internalApplyTo(RacingEventService toState) {
RegattaLeaderboard result = toState.addRegattaLeaderboard(regattaIdentifier, discardThresholds);
RegattaLeaderboard result = null;
if (toState.getLeaderboardByName(getLeaderboardName()) == null) {
result = toState.addRegattaLeaderboard(regattaIdentifier, leaderboardDisplayName, discardThresholds);
} else {
logger.warning("Cannot replicate creation of flexible leaderboard "+getLeaderboardName()+" because it already exists in the replica");
}
return result;
}
@Override
public RacingEventServiceOperation<?> transformClientOp(RacingEventServiceOperation<?> serverOp) {
// TODO
return null;
return serverOp.transformAddRegattaLeaderboardClientOp(this);
}
@Override
public RacingEventServiceOperation<?> transformServerOp(RacingEventServiceOperation<?> clientOp) {
// TODO
return null;
return clientOp.transformAddRegattaLeaderboardServerOp(this);
}
}