refs bug 1354

# UI changes to course area of FlexibleLeaderboard are sent to server
# Added replication for changes to course area of FlexibleLeaderboard
This commit is contained in:
Lukas Niemeier committed 2013-05-25 18:01:55 +02:00
1 parent 63f4b22ba0
commit 9f46c7a24e
5 files changed
+21 -6

No files matched your search

@@ -1023,7 +1023,7 @@ public class LeaderboardConfigPanel extends FormPanel implements SelectedLeaderb
private void updateLeaderboard(final String oldLeaderboardName, final LeaderboardDescriptor leaderboardToUpdate) {
sailingService.updateLeaderboard(oldLeaderboardName, leaderboardToUpdate.getName(), leaderboardToUpdate.getDisplayName(),
leaderboardToUpdate.getDiscardThresholds(), new AsyncCallback<Void>() {
leaderboardToUpdate.getDiscardThresholds(), leaderboardToUpdate.getCourseAreaIdAsString(), new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable t) {
errorReporter.reportError("Error trying to update leaderboard " + oldLeaderboardName + ": "
@@ -1038,6 +1038,7 @@ public class LeaderboardConfigPanel extends FormPanel implements SelectedLeaderb
dao.name = leaderboardToUpdate.getName();
dao.displayName = leaderboardToUpdate.getDisplayName();
dao.discardThresholds = leaderboardToUpdate.getDiscardThresholds();
dao.defaultCourseAreaIdAsString = leaderboardToUpdate.getCourseAreaIdAsString();
break;
}
}
@@ -122,7 +122,7 @@ public interface SailingService extends RemoteService {
List<StrippedLeaderboardDTO> getLeaderboardsByEvent(RegattaDTO regatta);
void updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThreasholds);
void updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThreasholds, String newCourseAreaIdAsString);
StrippedLeaderboardDTO createFlexibleLeaderboard(String leaderboardName, String leaderboardDisplayName, int[] discardThresholds, ScoringSchemeType scoringSchemeType, String courseAreaId);
@@ -190,7 +190,7 @@ public interface SailingServiceAsync {
void getLeaderboardsByRace(RaceDTO race, AsyncCallback<List<StrippedLeaderboardDTO>> callback);
void updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName,
int[] newDiscardingThreasholds, AsyncCallback<Void> callback);
int[] newDiscardingThreasholds, String newCourseAreaIdAsId, AsyncCallback<Void> callback);
void createFlexibleLeaderboard(String leaderboardName, String leaderboardDisplayName, int[] discardThresholds, ScoringSchemeType scoringSchemeType, String courseAreaId,
AsyncCallback<StrippedLeaderboardDTO> asyncCallback);
@@ -1617,8 +1617,9 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
}
@Override
public void updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThresholds) {
getService().apply(new UpdateLeaderboard(leaderboardName, newLeaderboardName, newLeaderboardDisplayName, newDiscardingThresholds));
public void updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThresholds, String newCourseAreaIdAsString) {
UUID newCourseAreaUuid = convertIdentifierStringToUuid(newCourseAreaIdAsString);
getService().apply(new UpdateLeaderboard(leaderboardName, newLeaderboardName, newLeaderboardDisplayName, newDiscardingThresholds, newCourseAreaUuid));
}
@Override
@@ -1,7 +1,10 @@
package com.sap.sailing.server.operationaltransformation;
import java.io.Serializable;
import java.util.Arrays;
import com.sap.sailing.domain.base.CourseArea;
import com.sap.sailing.domain.leaderboard.FlexibleLeaderboard;
import com.sap.sailing.domain.leaderboard.Leaderboard;
import com.sap.sailing.domain.leaderboard.impl.ResultDiscardingRuleImpl;
import com.sap.sailing.server.RacingEventService;
@@ -12,12 +15,14 @@ public class UpdateLeaderboard extends AbstractLeaderboardOperation<Void> {
private final String newLeaderboardName;
private final String newLeaderboardDisplayName;
private final int[] newDiscardingThresholds;
private final Serializable newCourseAreaId;
public UpdateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThresholds) {
public UpdateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThresholds, Serializable newCourseAreaId) {
super(leaderboardName);
this.newLeaderboardName = newLeaderboardName;
this.newLeaderboardDisplayName = newLeaderboardDisplayName;
this.newDiscardingThresholds = newDiscardingThresholds;
this.newCourseAreaId = newCourseAreaId;
}
@Override
@@ -42,6 +47,14 @@ public class UpdateLeaderboard extends AbstractLeaderboardOperation<Void> {
leaderboard.setResultDiscardingRule(new ResultDiscardingRuleImpl(newDiscardingThresholds));
}
leaderboard.setDisplayName(newLeaderboardDisplayName);
if (leaderboard instanceof FlexibleLeaderboard) {
FlexibleLeaderboard flexibleLeaderboard = (FlexibleLeaderboard) leaderboard;
CourseArea newCourseArea = toState.getCourseArea(newCourseAreaId);
if (newCourseArea != flexibleLeaderboard.getDefaultCourseArea()) {
flexibleLeaderboard.setDefaultCourseArea(newCourseArea);
}
}
updateStoredLeaderboard(toState, leaderboard);
return null;
}