mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-10 22:30:56 +00:00
Merge branch 'racecommittee_app' into racecommittee_regattaoverview
Conflicts: java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties
This commit is contained in:
commit
c65488eafd
41 files changed
+1061
-462
No files matched your search
+2
-2
@@ -1,8 +1,8 @@
|
||||
package com.sap.sailing.domain.common.racelog;
|
||||
|
||||
public enum StartProcedureType {
|
||||
RRS26("Fix Line Start (RRS26)"),
|
||||
GateStart("Gate Start"),
|
||||
//RRS26("Fix Line Start (RRS26)"),
|
||||
//GateStart("Gate Start"),
|
||||
ESS("\"Extreme Sailing Series\"-Start");
|
||||
|
||||
private String displayName;
|
||||
|
||||
+5
@@ -400,6 +400,11 @@ public class MockedTrackedRace implements DynamicTrackedRace {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultCourseArea(CourseArea newCourseArea) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,17 @@ import com.sap.sailing.domain.tracking.TrackedRegatta;
|
||||
public interface Regatta extends Named, WithID {
|
||||
ScoringScheme getScoringScheme();
|
||||
|
||||
/**
|
||||
* Gets the course area for all races of this {@link Regatta}.
|
||||
* @return the {@link CourseArea} object.
|
||||
*/
|
||||
CourseArea getDefaultCourseArea();
|
||||
|
||||
/**
|
||||
* Sets the course area for all races of this {@link Regatta}.
|
||||
* @param newCourseArea {@link CourseArea} to be set.
|
||||
*/
|
||||
void setDefaultCourseArea(CourseArea newCourseArea);
|
||||
|
||||
/**
|
||||
* A regatta consists of one or more series.
|
||||
|
||||
@@ -48,7 +48,9 @@ public class RegattaImpl extends NamedImpl implements Regatta, RaceColumnListene
|
||||
private final ScoringScheme scoringScheme;
|
||||
private final Serializable id;
|
||||
private transient RaceLogStore raceLogStore;
|
||||
private final CourseArea courseArea;
|
||||
|
||||
// Can be changed...
|
||||
private CourseArea courseArea;
|
||||
|
||||
/**
|
||||
* Regattas may be constructed as implicit default regattas in which case they won't need to be stored
|
||||
@@ -335,4 +337,9 @@ public class RegattaImpl extends NamedImpl implements Regatta, RaceColumnListene
|
||||
return courseArea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultCourseArea(CourseArea newCourseArea) {
|
||||
this.courseArea = newCourseArea;
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.domain.leaderboard;
|
||||
|
||||
import com.sap.sailing.domain.base.CourseArea;
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
@@ -68,4 +69,10 @@ public interface FlexibleLeaderboard extends Leaderboard, Renamable {
|
||||
void removeRaceColumn(String columnName);
|
||||
|
||||
void updateIsMedalRace(String raceName, boolean isMedalRace);
|
||||
|
||||
/**
|
||||
* Sets the default {@link CourseArea} of this leaderboard.
|
||||
* @param newCourseArea the {@link CourseArea} to be set.
|
||||
*/
|
||||
void setDefaultCourseArea(CourseArea newCourseArea);
|
||||
}
|
||||
+6
-1
@@ -45,7 +45,7 @@ public class FlexibleLeaderboardImpl extends AbstractLeaderboardImpl implements
|
||||
private final ScoringScheme scoringScheme;
|
||||
private String name;
|
||||
private transient RaceLogStore raceLogStore;
|
||||
private final CourseArea courseArea;
|
||||
private CourseArea courseArea;
|
||||
|
||||
public FlexibleLeaderboardImpl(String name, SettableScoreCorrection scoreCorrection,
|
||||
ThresholdBasedResultDiscardingRule resultDiscardingRule, ScoringScheme scoringScheme, CourseArea courseArea) {
|
||||
@@ -235,4 +235,9 @@ public class FlexibleLeaderboardImpl extends AbstractLeaderboardImpl implements
|
||||
return courseArea;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultCourseArea(CourseArea newCourseArea) {
|
||||
this.courseArea = newCourseArea;
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -400,6 +400,12 @@ public class MockedTrackedRace implements DynamicTrackedRace {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDefaultCourseArea(CourseArea newCourseArea) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -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<StrippedLeaderboardDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to update leaderboard " + oldLeaderboardName + ": "
|
||||
@@ -1031,16 +1031,16 @@ public class LeaderboardConfigPanel extends FormPanel implements SelectedLeaderb
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
public void onSuccess(StrippedLeaderboardDTO updatedLeaderboard) {
|
||||
int indexOfLeaderboard = 0;
|
||||
for (int i = 0; i < leaderboardList.getList().size(); i++) {
|
||||
StrippedLeaderboardDTO dao = leaderboardList.getList().get(i);
|
||||
if (dao.name.equals(oldLeaderboardName)) {
|
||||
dao.name = leaderboardToUpdate.getName();
|
||||
dao.displayName = leaderboardToUpdate.getDisplayName();
|
||||
dao.discardThresholds = leaderboardToUpdate.getDiscardThresholds();
|
||||
indexOfLeaderboard = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
leaderboardList.getList().set(indexOfLeaderboard, updatedLeaderboard);
|
||||
leaderboardList.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
+3
-1
@@ -9,6 +9,7 @@ import com.sap.sailing.gwt.ui.client.shared.components.ImagesBarCell;
|
||||
|
||||
public class RegattaConfigImagesBarCell extends ImagesBarCell {
|
||||
static final String ACTION_REMOVE = "ACTION_REMOVE";
|
||||
public static final String ACTION_EDIT = "ACTION_EDIT";
|
||||
private final StringMessages stringMessages;
|
||||
private static AdminConsoleResources resources = GWT.create(AdminConsoleResources.class);
|
||||
|
||||
@@ -24,6 +25,7 @@ public class RegattaConfigImagesBarCell extends ImagesBarCell {
|
||||
|
||||
@Override
|
||||
protected Iterable<ImageSpec> getImageSpecs() {
|
||||
return Arrays.asList(new ImageSpec(ACTION_REMOVE, stringMessages.actionRemove(), makeImagePrototype(resources.removeIcon())));
|
||||
return Arrays.asList(new ImageSpec(ACTION_EDIT, stringMessages.actionEdit(), makeImagePrototype(resources.editIcon())),
|
||||
new ImageSpec(ACTION_REMOVE, stringMessages.actionRemove(), makeImagePrototype(resources.removeIcon())));
|
||||
}
|
||||
}
|
||||
+68
-15
@@ -2,6 +2,8 @@ package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,6 +39,8 @@ import com.sap.sailing.gwt.ui.client.RegattaRefresher;
|
||||
import com.sap.sailing.gwt.ui.client.RegattaSelectionProvider;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.DataEntryDialog.DialogCallback;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
|
||||
public class RegattaListComposite extends Composite implements RegattaDisplayer {
|
||||
@@ -67,14 +71,15 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
}
|
||||
}
|
||||
|
||||
public RegattaListComposite(final SailingServiceAsync sailingService, final RegattaSelectionProvider regattaSelectionProvider,
|
||||
RegattaRefresher regattaRefresher, final ErrorReporter errorReporter, final StringMessages stringMessages) {
|
||||
public RegattaListComposite(final SailingServiceAsync sailingService,
|
||||
final RegattaSelectionProvider regattaSelectionProvider, RegattaRefresher regattaRefresher,
|
||||
final ErrorReporter errorReporter, final StringMessages stringMessages) {
|
||||
this.sailingService = sailingService;
|
||||
this.regattaSelectionProvider = regattaSelectionProvider;
|
||||
this.regattaRefresher = regattaRefresher;
|
||||
this.errorReporter = errorReporter;
|
||||
this.stringMessages = stringMessages;
|
||||
|
||||
|
||||
mainPanel = new SimplePanel();
|
||||
panel = new VerticalPanel();
|
||||
mainPanel.setWidget(panel);
|
||||
@@ -94,7 +99,7 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
}
|
||||
});
|
||||
filterPanel.add(filterRegattasTextbox);
|
||||
|
||||
|
||||
noRegattasLabel = new Label(stringMessages.noRegattasYet());
|
||||
noRegattasLabel.setWordWrap(false);
|
||||
panel.add(noRegattasLabel);
|
||||
@@ -102,7 +107,7 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
regattaListDataProvider = new ListDataProvider<RegattaDTO>();
|
||||
regattaTable = createRegattaTable();
|
||||
regattaTable.setVisible(false);
|
||||
|
||||
|
||||
regattaSelectionModel = new SingleSelectionModel<RegattaDTO>();
|
||||
regattaSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
|
||||
@Override
|
||||
@@ -116,9 +121,9 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
}
|
||||
});
|
||||
regattaTable.setSelectionModel(regattaSelectionModel);
|
||||
|
||||
|
||||
panel.add(regattaTable);
|
||||
|
||||
|
||||
initWidget(mainPanel);
|
||||
}
|
||||
|
||||
@@ -163,21 +168,23 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
regattaActionColumn.setFieldUpdater(new FieldUpdater<RegattaDTO, String>() {
|
||||
@Override
|
||||
public void update(int index, RegattaDTO regatta, String value) {
|
||||
if (RegattaConfigImagesBarCell.ACTION_REMOVE.equals(value)) {
|
||||
if (RegattaConfigImagesBarCell.ACTION_EDIT.equals(value)) {
|
||||
editRegatta(regatta);
|
||||
} else if (RegattaConfigImagesBarCell.ACTION_REMOVE.equals(value)) {
|
||||
if (Window.confirm(stringMessages.doYouReallyWantToRemoveRegatta(regatta.name))) {
|
||||
removeRegatta(regatta);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
table.addColumn(regattaNameColumn, stringMessages.regattaName());
|
||||
table.addColumn(regattaBoatClassColumn, stringMessages.boatClass());
|
||||
table.addColumn(regattaActionColumn, stringMessages.actions());
|
||||
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
|
||||
private void updateFilteredRegattasList() {
|
||||
String text = filterRegattasTextbox.getText();
|
||||
List<String> wordsToFilter = Arrays.asList(text.split(" "));
|
||||
@@ -188,8 +195,8 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
for (String word : wordsToFilter) {
|
||||
String textAsUppercase = word.toUpperCase().trim();
|
||||
if (!regattaDTO.name.toUpperCase().contains(textAsUppercase)
|
||||
&& (regattaDTO.boatClass == null || !regattaDTO.boatClass.name.toUpperCase().contains(textAsUppercase))
|
||||
&& !regattaDTO.name.toUpperCase().contains(textAsUppercase)) {
|
||||
&& (regattaDTO.boatClass == null || !regattaDTO.boatClass.name.toUpperCase().contains(
|
||||
textAsUppercase)) && !regattaDTO.name.toUpperCase().contains(textAsUppercase)) {
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
@@ -221,7 +228,53 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void editRegatta(final RegattaDTO toBeEdited) {
|
||||
final Collection<RegattaDTO> existingRegattas = getAllRegattas();
|
||||
sailingService.getEvents(new AsyncCallback<List<EventDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
openEditRegattaDialog(toBeEdited, existingRegattas, Collections.<EventDTO> emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<EventDTO> events) {
|
||||
openEditRegattaDialog(toBeEdited, existingRegattas, Collections.unmodifiableList(events));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void openEditRegattaDialog(RegattaDTO regatta, Collection<RegattaDTO> existingRegattas,
|
||||
List<EventDTO> existingEvents) {
|
||||
RegattaWithSeriesAndFleetsDialog dialog = new RegattaWithSeriesAndFleetsEditDialog(regatta, existingRegattas,
|
||||
existingEvents, stringMessages, new DialogCallback<RegattaDTO>() {
|
||||
@Override
|
||||
public void cancel() { }
|
||||
|
||||
@Override
|
||||
public void ok(RegattaDTO editedRegatta) {
|
||||
commitEditedRegatta(editedRegatta);
|
||||
}
|
||||
});
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void commitEditedRegatta(final RegattaDTO editedRegatta) {
|
||||
final RegattaIdentifier regattaName = new RegattaName(editedRegatta.name);
|
||||
|
||||
sailingService.updateRegatta(regattaName, editedRegatta.defaultCourseAreaIdAsString, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to update regatta " + editedRegatta.name + ": " + caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
regattaRefresher.fillRegattas();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<RegattaDTO> getSelectedRegattas() {
|
||||
List<RegattaDTO> result = new ArrayList<RegattaDTO>();
|
||||
if (regattaListDataProvider != null) {
|
||||
@@ -250,7 +303,7 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
}
|
||||
allRegattas = newAllRegattas;
|
||||
updateFilteredRegattasList();
|
||||
regattaSelectionProvider.setAllRegattas(newAllRegattaIdentifiers);
|
||||
regattaSelectionProvider.setAllRegattas(newAllRegattaIdentifiers);
|
||||
}
|
||||
|
||||
public List<RegattaDTO> getAllRegattas() {
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ public class RegattaStructureManagementPanel extends SimplePanel implements Rega
|
||||
newRegatta.scoringScheme, newRegatta.defaultCourseAreaIdAsString, new AsyncCallback<RegattaDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to create new regatta" + newRegatta.name + ": " + t.getMessage());
|
||||
errorReporter.reportError("Error trying to create new regatta " + newRegatta.name + ": " + t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-169
@@ -7,43 +7,20 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.dom.client.Style.FontWeight;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.ListBox;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.gwt.ui.client.DataEntryDialog;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.leaderboard.ScoringSchemeTypeFormatter;
|
||||
import com.sap.sailing.gwt.ui.shared.CourseAreaDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
|
||||
public class RegattaWithSeriesAndFleetsCreateDialog extends DataEntryDialog<RegattaDTO> {
|
||||
|
||||
private StringMessages stringConstants;
|
||||
private RegattaDTO regatta;
|
||||
|
||||
private TextBox nameEntryField;
|
||||
private TextBox boatClassEntryField;
|
||||
private ListBox scoringSchemeListBox;
|
||||
private ListBox courseAreaListBox;
|
||||
private ListBox sailingEventsListBox;
|
||||
|
||||
private List<SeriesDTO> createdSeries;
|
||||
|
||||
private Grid seriesGrid;
|
||||
public class RegattaWithSeriesAndFleetsCreateDialog extends RegattaWithSeriesAndFleetsDialog {
|
||||
|
||||
private List<EventDTO> existingEvents;
|
||||
protected Grid seriesGrid;
|
||||
|
||||
protected static class RegattaParameterValidator implements Validator<RegattaDTO> {
|
||||
|
||||
@@ -118,87 +95,15 @@ public class RegattaWithSeriesAndFleetsCreateDialog extends DataEntryDialog<Rega
|
||||
|
||||
}
|
||||
|
||||
public RegattaWithSeriesAndFleetsCreateDialog(Collection<RegattaDTO> existingRegattas, List<EventDTO> existingEvents,
|
||||
StringMessages stringConstants, DialogCallback<RegattaDTO> callback) {
|
||||
super(stringConstants.regatta(), null, stringConstants.ok(), stringConstants.cancel(),
|
||||
public RegattaWithSeriesAndFleetsCreateDialog(Collection<RegattaDTO> existingRegattas,
|
||||
List<EventDTO> existingEvents, StringMessages stringConstants, DialogCallback<RegattaDTO> callback) {
|
||||
super(new RegattaDTO(), existingEvents, stringConstants.addRegatta(), stringConstants.ok(), stringConstants,
|
||||
new RegattaParameterValidator(stringConstants, existingRegattas), callback);
|
||||
this.stringConstants = stringConstants;
|
||||
this.regatta = new RegattaDTO();
|
||||
this.existingEvents = existingEvents;
|
||||
|
||||
nameEntryField = createTextBox(null);
|
||||
nameEntryField.setVisibleLength(40);
|
||||
boatClassEntryField = createTextBox(null);
|
||||
boatClassEntryField.setVisibleLength(20);
|
||||
scoringSchemeListBox = createListBox(false);
|
||||
for (ScoringSchemeType scoringSchemeType: ScoringSchemeType.values()) {
|
||||
scoringSchemeListBox.addItem(ScoringSchemeTypeFormatter.format(scoringSchemeType, stringConstants));
|
||||
}
|
||||
|
||||
sailingEventsListBox = createSailingEventListBox();
|
||||
this.courseAreaListBox = createListBox(false);
|
||||
this.courseAreaListBox.setEnabled(false);
|
||||
|
||||
createdSeries = new ArrayList<SeriesDTO>();
|
||||
seriesGrid = new Grid(0, 0);
|
||||
this.seriesGrid = new Grid(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RegattaDTO getResult() {
|
||||
regatta.name = nameEntryField.getText();
|
||||
regatta.boatClass = new BoatClassDTO(boatClassEntryField.getText(), 0.0);
|
||||
regatta.scoringScheme = getSelectedScoringSchemeType();
|
||||
regatta.series = new ArrayList<SeriesDTO>();
|
||||
regatta.series.addAll(createdSeries);
|
||||
setCourseAreaInRegatta(regatta);
|
||||
return regatta;
|
||||
}
|
||||
|
||||
private void setCourseAreaInRegatta(RegattaDTO regatta) {
|
||||
CourseAreaDTO courseArea = getSelectedCourseArea();
|
||||
if (courseArea == null) {
|
||||
regatta.defaultCourseAreaIdAsString = null;
|
||||
} else {
|
||||
regatta.defaultCourseAreaIdAsString = courseArea.id;
|
||||
regatta.defaultCourseAreaName = courseArea.name;
|
||||
}
|
||||
}
|
||||
|
||||
public ScoringSchemeType getSelectedScoringSchemeType() {
|
||||
ScoringSchemeType result = null;
|
||||
int selIndex = scoringSchemeListBox.getSelectedIndex();
|
||||
if(selIndex >= 0) {
|
||||
String itemText = scoringSchemeListBox.getItemText(selIndex);
|
||||
for(ScoringSchemeType scoringSchemeType: ScoringSchemeType.values()) {
|
||||
if(ScoringSchemeTypeFormatter.format(scoringSchemeType, stringConstants).equals(itemText)) {
|
||||
result = scoringSchemeType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget getAdditionalWidget() {
|
||||
final VerticalPanel panel = new VerticalPanel();
|
||||
Widget additionalWidget = super.getAdditionalWidget();
|
||||
if (additionalWidget != null) {
|
||||
panel.add(additionalWidget);
|
||||
}
|
||||
Grid formGrid = new Grid(5, 2);
|
||||
panel.add(formGrid);
|
||||
formGrid.setWidget(0, 0, new Label(stringConstants.name() + ":"));
|
||||
formGrid.setWidget(0, 1, nameEntryField);
|
||||
formGrid.setWidget(1, 0, new Label(stringConstants.boatClass() + ":"));
|
||||
formGrid.setWidget(1, 1, boatClassEntryField);
|
||||
formGrid.setWidget(2, 0, new Label(stringConstants.scoringSystem() + ":"));
|
||||
formGrid.setWidget(2, 1, scoringSchemeListBox);
|
||||
formGrid.setWidget(3, 0, new Label(stringConstants.event() + ":"));
|
||||
formGrid.setWidget(3, 1, sailingEventsListBox);
|
||||
formGrid.setWidget(4, 0, new Label(stringConstants.courseArea() + ":"));
|
||||
formGrid.setWidget(4, 1, courseAreaListBox);
|
||||
|
||||
protected void setupAdditionalWidgetsOnPanel(final VerticalPanel panel) {
|
||||
panel.add(createHeadlineLabel(stringConstants.series()));
|
||||
panel.add(seriesGrid);
|
||||
Button addSeriesButton = new Button("Add series");
|
||||
@@ -214,7 +119,7 @@ public class RegattaWithSeriesAndFleetsCreateDialog extends DataEntryDialog<Rega
|
||||
|
||||
@Override
|
||||
public void ok(SeriesDTO newSeries) {
|
||||
createdSeries.add(newSeries);
|
||||
series.add(newSeries);
|
||||
updateSeriesGrid(panel);
|
||||
}
|
||||
});
|
||||
@@ -222,19 +127,18 @@ public class RegattaWithSeriesAndFleetsCreateDialog extends DataEntryDialog<Rega
|
||||
}
|
||||
});
|
||||
panel.add(addSeriesButton);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void updateSeriesGrid(VerticalPanel parentPanel) {
|
||||
int widgetIndex = parentPanel.getWidgetIndex(seriesGrid);
|
||||
parentPanel.remove(seriesGrid);
|
||||
|
||||
int seriesCount = createdSeries.size();
|
||||
int seriesCount = series.size();
|
||||
seriesGrid = new Grid(seriesCount * 2, 3);
|
||||
seriesGrid.setCellSpacing(3);
|
||||
|
||||
for (int i = 0; i < seriesCount; i++) {
|
||||
SeriesDTO seriesDTO = createdSeries.get(i);
|
||||
SeriesDTO seriesDTO = series.get(i);
|
||||
Label seriesLabel = new Label((i + 1) + ". " + stringConstants.series() + ":");
|
||||
seriesLabel.setWordWrap(false);
|
||||
seriesLabel.getElement().getStyle().setFontWeight(FontWeight.BOLD);
|
||||
@@ -256,68 +160,5 @@ public class RegattaWithSeriesAndFleetsCreateDialog extends DataEntryDialog<Rega
|
||||
super.show();
|
||||
nameEntryField.setFocus(true);
|
||||
}
|
||||
|
||||
protected ListBox createSailingEventListBox() {
|
||||
ListBox eventListBox = createListBox(false);
|
||||
eventListBox.addItem("Please select a sailing event...");
|
||||
for (EventDTO event: existingEvents) {
|
||||
eventListBox.addItem(event.name);
|
||||
}
|
||||
eventListBox.addChangeHandler(new ChangeHandler() {
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
onEventSelectionChanged();
|
||||
}
|
||||
});
|
||||
return eventListBox;
|
||||
}
|
||||
|
||||
protected void onEventSelectionChanged() {
|
||||
EventDTO selectedEvent = getSelectedEvent();
|
||||
courseAreaListBox.clear();
|
||||
courseAreaListBox.setEnabled(false);
|
||||
if (selectedEvent != null) {
|
||||
fillCourseAreaListBox(selectedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private void fillCourseAreaListBox(EventDTO selectedEvent) {
|
||||
courseAreaListBox.addItem("Please select a course area...");
|
||||
for (CourseAreaDTO courseArea : selectedEvent.venue.getCourseAreas()) {
|
||||
courseAreaListBox.addItem(courseArea.name);
|
||||
}
|
||||
courseAreaListBox.setEnabled(true);
|
||||
}
|
||||
|
||||
public EventDTO getSelectedEvent() {
|
||||
EventDTO result = null;
|
||||
int selIndex = sailingEventsListBox.getSelectedIndex();
|
||||
if(selIndex > 0) { // the zero index represents the 'no selection' text
|
||||
String itemText = sailingEventsListBox.getItemText(selIndex);
|
||||
for(EventDTO eventDTO: existingEvents) {
|
||||
if(eventDTO.name.equals(itemText)) {
|
||||
result = eventDTO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public CourseAreaDTO getSelectedCourseArea() {
|
||||
CourseAreaDTO result = null;
|
||||
EventDTO event = getSelectedEvent();
|
||||
int selIndex = courseAreaListBox.getSelectedIndex();
|
||||
if(selIndex > 0 && event != null) { // the zero index represents the 'no selection' text
|
||||
String itemText = courseAreaListBox.getItemText(selIndex);
|
||||
for(CourseAreaDTO courseAreaDTO: event.venue.getCourseAreas()) {
|
||||
if(courseAreaDTO.name.equals(itemText)) {
|
||||
result = courseAreaDTO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.ListBox;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.gwt.ui.client.DataEntryDialog;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.leaderboard.ScoringSchemeTypeFormatter;
|
||||
import com.sap.sailing.gwt.ui.shared.CourseAreaDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
|
||||
public abstract class RegattaWithSeriesAndFleetsDialog extends DataEntryDialog<RegattaDTO> {
|
||||
|
||||
protected StringMessages stringConstants;
|
||||
protected RegattaDTO regatta;
|
||||
|
||||
protected TextBox nameEntryField;
|
||||
protected TextBox boatClassEntryField;
|
||||
protected ListBox scoringSchemeListBox;
|
||||
protected ListBox courseAreaListBox;
|
||||
protected ListBox sailingEventsListBox;
|
||||
|
||||
protected List<SeriesDTO> series;
|
||||
protected List<EventDTO> existingEvents;
|
||||
|
||||
protected abstract void setupAdditionalWidgetsOnPanel(VerticalPanel panel);
|
||||
|
||||
public RegattaWithSeriesAndFleetsDialog(RegattaDTO regatta, List<EventDTO> existingEvents, String title,
|
||||
String okButton, StringMessages stringConstants, Validator<RegattaDTO> validator,
|
||||
DialogCallback<RegattaDTO> callback) {
|
||||
super(title, null, okButton, stringConstants.cancel(), validator, callback);
|
||||
|
||||
this.stringConstants = stringConstants;
|
||||
|
||||
this.regatta = regatta;
|
||||
this.existingEvents = existingEvents;
|
||||
this.series = new ArrayList<SeriesDTO>();
|
||||
|
||||
nameEntryField = createTextBox(null);
|
||||
nameEntryField.setVisibleLength(40);
|
||||
nameEntryField.setText(regatta.name);
|
||||
|
||||
boatClassEntryField = createTextBox(null);
|
||||
boatClassEntryField.setVisibleLength(20);
|
||||
if (regatta.boatClass != null) {
|
||||
boatClassEntryField.setText(regatta.boatClass.name);
|
||||
}
|
||||
|
||||
scoringSchemeListBox = createListBox(false);
|
||||
for (ScoringSchemeType scoringSchemeType : ScoringSchemeType.values()) {
|
||||
scoringSchemeListBox.addItem(ScoringSchemeTypeFormatter.format(scoringSchemeType, stringConstants),
|
||||
String.valueOf(scoringSchemeType.ordinal()));
|
||||
if (scoringSchemeType == regatta.scoringScheme) {
|
||||
scoringSchemeListBox.setSelectedIndex(scoringSchemeListBox.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
sailingEventsListBox = createListBox(false);
|
||||
courseAreaListBox = createListBox(false);
|
||||
setupEventAndCourseAreaListBoxes(stringConstants);
|
||||
|
||||
courseAreaListBox.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget getAdditionalWidget() {
|
||||
final VerticalPanel panel = new VerticalPanel();
|
||||
Widget additionalWidget = super.getAdditionalWidget();
|
||||
if (additionalWidget != null) {
|
||||
panel.add(additionalWidget);
|
||||
}
|
||||
Grid formGrid = new Grid(5, 2);
|
||||
panel.add(formGrid);
|
||||
formGrid.setWidget(0, 0, new Label(stringConstants.name() + ":"));
|
||||
formGrid.setWidget(0, 1, nameEntryField);
|
||||
formGrid.setWidget(1, 0, new Label(stringConstants.boatClass() + ":"));
|
||||
formGrid.setWidget(1, 1, boatClassEntryField);
|
||||
formGrid.setWidget(2, 0, new Label(stringConstants.scoringSystem() + ":"));
|
||||
formGrid.setWidget(2, 1, scoringSchemeListBox);
|
||||
formGrid.setWidget(3, 0, new Label(stringConstants.event() + ":"));
|
||||
formGrid.setWidget(3, 1, sailingEventsListBox);
|
||||
formGrid.setWidget(4, 0, new Label(stringConstants.courseArea() + ":"));
|
||||
formGrid.setWidget(4, 1, courseAreaListBox);
|
||||
setupAdditionalWidgetsOnPanel(panel);
|
||||
return panel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RegattaDTO getResult() {
|
||||
regatta.name = nameEntryField.getText();
|
||||
regatta.boatClass = new BoatClassDTO(boatClassEntryField.getText(), 0.0);
|
||||
regatta.scoringScheme = getSelectedScoringSchemeType();
|
||||
regatta.series = new ArrayList<SeriesDTO>();
|
||||
regatta.series.addAll(series);
|
||||
setCourseAreaInRegatta(regatta);
|
||||
return regatta;
|
||||
}
|
||||
|
||||
private void setCourseAreaInRegatta(RegattaDTO regatta) {
|
||||
CourseAreaDTO courseArea = getSelectedCourseArea();
|
||||
if (courseArea == null) {
|
||||
regatta.defaultCourseAreaIdAsString = null;
|
||||
} else {
|
||||
regatta.defaultCourseAreaIdAsString = courseArea.id;
|
||||
regatta.defaultCourseAreaName = courseArea.name;
|
||||
}
|
||||
}
|
||||
|
||||
public ScoringSchemeType getSelectedScoringSchemeType() {
|
||||
int index = scoringSchemeListBox.getSelectedIndex();
|
||||
if (index >= 0) {
|
||||
return ScoringSchemeType.values()[Integer.valueOf(scoringSchemeListBox.getValue(index))];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isCourseAreaInEvent(EventDTO event, String courseAreaIdAsString) {
|
||||
if (event.venue == null) {
|
||||
return false;
|
||||
}
|
||||
for (CourseAreaDTO courseArea : event.venue.getCourseAreas()) {
|
||||
if (courseArea.id == courseAreaIdAsString) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setupEventAndCourseAreaListBoxes(StringMessages stringConstants) {
|
||||
sailingEventsListBox.addItem(stringConstants.selectSailingEvent());
|
||||
for (EventDTO event : existingEvents) {
|
||||
sailingEventsListBox.addItem(event.name);
|
||||
if (isCourseAreaInEvent(event, regatta.defaultCourseAreaIdAsString)) {
|
||||
sailingEventsListBox.setSelectedIndex(sailingEventsListBox.getItemCount() - 1);
|
||||
fillCourseAreaListBox(event);
|
||||
}
|
||||
}
|
||||
sailingEventsListBox.addChangeHandler(new ChangeHandler() {
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
onEventSelectionChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onEventSelectionChanged() {
|
||||
EventDTO selectedEvent = getSelectedEvent();
|
||||
courseAreaListBox.clear();
|
||||
courseAreaListBox.setEnabled(false);
|
||||
if (selectedEvent != null) {
|
||||
fillCourseAreaListBox(selectedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private void fillCourseAreaListBox(EventDTO selectedEvent) {
|
||||
courseAreaListBox.addItem(stringConstants.selectCourseArea());
|
||||
for (CourseAreaDTO courseArea : selectedEvent.venue.getCourseAreas()) {
|
||||
courseAreaListBox.addItem(courseArea.name);
|
||||
if (courseArea.id == regatta.defaultCourseAreaIdAsString) {
|
||||
courseAreaListBox.setSelectedIndex(courseAreaListBox.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
courseAreaListBox.setEnabled(true);
|
||||
}
|
||||
|
||||
public EventDTO getSelectedEvent() {
|
||||
EventDTO result = null;
|
||||
int selIndex = sailingEventsListBox.getSelectedIndex();
|
||||
if (selIndex > 0) { // the zero index represents the 'no selection' text
|
||||
String itemText = sailingEventsListBox.getItemText(selIndex);
|
||||
for (EventDTO eventDTO : existingEvents) {
|
||||
if (eventDTO.name.equals(itemText)) {
|
||||
result = eventDTO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public CourseAreaDTO getSelectedCourseArea() {
|
||||
CourseAreaDTO result = null;
|
||||
EventDTO event = getSelectedEvent();
|
||||
int selIndex = courseAreaListBox.getSelectedIndex();
|
||||
if (selIndex > 0 && event != null) { // the zero index represents the 'no selection' text
|
||||
String itemText = courseAreaListBox.getItemText(selIndex);
|
||||
for (CourseAreaDTO courseAreaDTO : event.venue.getCourseAreas()) {
|
||||
if (courseAreaDTO.name.equals(itemText)) {
|
||||
result = courseAreaDTO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
|
||||
public class RegattaWithSeriesAndFleetsEditDialog extends RegattaWithSeriesAndFleetsDialog {
|
||||
|
||||
public RegattaWithSeriesAndFleetsEditDialog(RegattaDTO regatta, Collection<RegattaDTO> existingRegattas,
|
||||
List<EventDTO> existingEvents, StringMessages stringConstants, DialogCallback<RegattaDTO> callback) {
|
||||
super(regatta, existingEvents, stringConstants.editRegatta(), stringConstants.ok(), stringConstants,
|
||||
null, callback);
|
||||
nameEntryField.setEnabled(false);
|
||||
boatClassEntryField.setEnabled(false);
|
||||
scoringSchemeListBox.setEnabled(false);
|
||||
|
||||
sailingEventsListBox.setEnabled(true);
|
||||
courseAreaListBox.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
super.show();
|
||||
courseAreaListBox.setFocus(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setupAdditionalWidgetsOnPanel(VerticalPanel panel) {
|
||||
// nothing yet
|
||||
}
|
||||
|
||||
}
|
||||
+3
-1
@@ -122,7 +122,7 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
List<StrippedLeaderboardDTO> getLeaderboardsByEvent(RegattaDTO regatta);
|
||||
|
||||
void updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThreasholds);
|
||||
StrippedLeaderboardDTO updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThreasholds, String newCourseAreaIdAsString);
|
||||
|
||||
StrippedLeaderboardDTO createFlexibleLeaderboard(String leaderboardName, String leaderboardDisplayName, int[] discardThresholds, ScoringSchemeType scoringSchemeType, String courseAreaId);
|
||||
|
||||
@@ -148,6 +148,8 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
void removeRegatta(RegattaIdentifier regattaIdentifier);
|
||||
|
||||
void updateRegatta(RegattaIdentifier regattaIdentifier, String defaultCourseAreaId);
|
||||
|
||||
List<RaceColumnInSeriesDTO> addRaceColumnsToSeries(RegattaIdentifier regattaIdentifier, String seriesName, List<String> columnNames);
|
||||
|
||||
RaceColumnInSeriesDTO addRaceColumnToSeries(RegattaIdentifier regattaIdentifier, String seriesName, String columnName);
|
||||
|
||||
+3
-1
@@ -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<StrippedLeaderboardDTO> callback);
|
||||
|
||||
void createFlexibleLeaderboard(String leaderboardName, String leaderboardDisplayName, int[] discardThresholds, ScoringSchemeType scoringSchemeType, String courseAreaId,
|
||||
AsyncCallback<StrippedLeaderboardDTO> asyncCallback);
|
||||
@@ -434,6 +434,8 @@ public interface SailingServiceAsync {
|
||||
void getRegattaOverviewEntriesForEvent(String eventIdAsString, AsyncCallback<List<RegattaOverviewEntryDTO>> asyncCallback);
|
||||
|
||||
void getEventByIdAsString(String eventIdAsString, AsyncCallback<EventDTO> asyncCallback);
|
||||
|
||||
void updateRegatta(RegattaIdentifier regattaIdentifier, String defaultCourseAreaId, AsyncCallback<Void> callback);
|
||||
|
||||
}
|
||||
|
||||
+4
@@ -588,6 +588,10 @@ public interface StringMessages extends Messages {
|
||||
String filterNothing();
|
||||
String topNCompetitorsByRaceRank(int n);
|
||||
String topNCompetitorsByTotalRank(int n);
|
||||
|
||||
String editRegatta();
|
||||
String selectSailingEvent();
|
||||
String selectCourseArea();
|
||||
|
||||
/*Start of simulator related messages*/
|
||||
String simulator();
|
||||
|
||||
+3
@@ -630,6 +630,9 @@ raceLabel=Race
|
||||
competitorLabel=Competitor
|
||||
freemode=Keep Bearings
|
||||
whatIfCourse=What-If Course
|
||||
editRegatta=Edit Regatta...
|
||||
selectSailingEvent=Please select a sailing event...
|
||||
selectCourseArea=Please select a course area..
|
||||
courseAreaOverview=Area overview
|
||||
courseDesignOverview=Course design overview
|
||||
regattaOverview=Regatta overview
|
||||
|
||||
+3
@@ -629,6 +629,9 @@ raceLabel=Race
|
||||
competitorLabel=Competitor
|
||||
freemode=Winkel erhalten
|
||||
whatIfCourse=What-If Course
|
||||
editRegatta=Regatta bearbeiten...
|
||||
selectSailingEvent=Bitte Event auswählen...
|
||||
selectCourseArea=Bitte Bahn auswählen...
|
||||
courseAreaOverview=Rennbahnübersicht
|
||||
courseDesignOverview=Kursübersicht
|
||||
regattaOverview=Rennbahnenübersicht
|
||||
|
||||
+11
-2
@@ -257,6 +257,7 @@ import com.sap.sailing.server.operationaltransformation.UpdateLeaderboardMaxPoin
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateLeaderboardScoreCorrection;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateLeaderboardScoreCorrectionMetadata;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateRaceDelayToLive;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateSpecificRegatta;
|
||||
import com.sap.sailing.server.replication.ReplicaDescriptor;
|
||||
import com.sap.sailing.server.replication.ReplicationFactory;
|
||||
import com.sap.sailing.server.replication.ReplicationMasterDescriptor;
|
||||
@@ -1626,8 +1627,10 @@ 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 StrippedLeaderboardDTO updateLeaderboard(String leaderboardName, String newLeaderboardName, String newLeaderboardDisplayName, int[] newDiscardingThresholds, String newCourseAreaIdAsString) {
|
||||
UUID newCourseAreaUuid = convertIdentifierStringToUuid(newCourseAreaIdAsString);
|
||||
Leaderboard updatedLeaderboard = getService().apply(new UpdateLeaderboard(leaderboardName, newLeaderboardName, newLeaderboardDisplayName, newDiscardingThresholds, newCourseAreaUuid));
|
||||
return createStrippedLeaderboardDTO(updatedLeaderboard, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2462,6 +2465,12 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
return raceColumnInSeriesDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRegatta(RegattaIdentifier regattaName, String defaultCourseAreaId) {
|
||||
UUID courseAreaUuid = convertIdentifierStringToUuid(defaultCourseAreaId);
|
||||
getService().apply(new UpdateSpecificRegatta(regattaName, courseAreaUuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RaceColumnInSeriesDTO> addRaceColumnsToSeries(RegattaIdentifier regattaIdentifier, String seriesName, List<String> columnNames) {
|
||||
List<RaceColumnInSeriesDTO> result = new ArrayList<RaceColumnInSeriesDTO>();
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ public class RaceLogEventSerializerChooserTest {
|
||||
@Test
|
||||
public void testStartProcedureTypeChangedSerializer() {
|
||||
// we use the real event type here because we do not want to re-implement the dispatching.
|
||||
RaceLogEvent event = factory.createStartProcedureChangedEvent(null, 0, StartProcedureType.GateStart);
|
||||
RaceLogEvent event = factory.createStartProcedureChangedEvent(null, 0, StartProcedureType.ESS);
|
||||
assertEquals(startProcedureTypeChangedEventSerializer, chooser.getSerializer(event));
|
||||
}
|
||||
|
||||
|
||||
+47
@@ -44,6 +44,53 @@ public class RegattaReplicationTest extends AbstractServerReplicationTest {
|
||||
assertNull(replicatedRegatta.getDefaultCourseArea());
|
||||
assertTrue(regattaId.equals(replicatedRegatta.getId()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateSpecificRegattaReplication() throws InterruptedException {
|
||||
Regatta replicatedRegatta;
|
||||
|
||||
final UUID alphaCourseAreaId = UUID.randomUUID();
|
||||
final UUID tvCourseAreaId = UUID.randomUUID();
|
||||
|
||||
Event event = master.addEvent("Event", "Venue", ".", true, UUID.randomUUID(), Collections.<String>emptyList());
|
||||
master.addCourseArea(event.getId(), "Alpha", alphaCourseAreaId);
|
||||
master.addCourseArea(event.getId(), "TV", tvCourseAreaId);
|
||||
|
||||
UUID currentCourseAreaId = null;
|
||||
Regatta masterRegatta = master.createRegatta("Kiel Week 2012", "49er", UUID.randomUUID(), Collections.<Series>emptyList(),
|
||||
/* persistent */ true, DomainFactory.INSTANCE.createScoringScheme(ScoringSchemeType.LOW_POINT), currentCourseAreaId);
|
||||
|
||||
// Test for 'null'
|
||||
master.updateRegatta(new RegattaName(masterRegatta.getName()), currentCourseAreaId);
|
||||
Thread.sleep(1000);
|
||||
replicatedRegatta = replica.getRegatta(new RegattaName(masterRegatta.getName()));
|
||||
assertNotNull(replicatedRegatta);
|
||||
assertNull(replicatedRegatta.getDefaultCourseArea());
|
||||
|
||||
// Test for 'alpha'
|
||||
currentCourseAreaId = alphaCourseAreaId;
|
||||
master.updateRegatta(new RegattaName(masterRegatta.getName()), currentCourseAreaId);
|
||||
Thread.sleep(1000);
|
||||
replicatedRegatta = replica.getRegatta(new RegattaName(masterRegatta.getName()));
|
||||
assertNotNull(replicatedRegatta);
|
||||
assertEquals(currentCourseAreaId, replicatedRegatta.getDefaultCourseArea().getId());
|
||||
|
||||
// Test for 'tv'
|
||||
currentCourseAreaId = tvCourseAreaId;
|
||||
master.updateRegatta(new RegattaName(masterRegatta.getName()), currentCourseAreaId);
|
||||
Thread.sleep(1000);
|
||||
replicatedRegatta = replica.getRegatta(new RegattaName(masterRegatta.getName()));
|
||||
assertNotNull(replicatedRegatta);
|
||||
assertEquals(currentCourseAreaId, replicatedRegatta.getDefaultCourseArea().getId());
|
||||
|
||||
// Test back to 'null'
|
||||
currentCourseAreaId = null;
|
||||
master.updateRegatta(new RegattaName(masterRegatta.getName()), currentCourseAreaId);
|
||||
Thread.sleep(1000);
|
||||
replicatedRegatta = replica.getRegatta(new RegattaName(masterRegatta.getName()));
|
||||
assertNotNull(replicatedRegatta);
|
||||
assertNull(replicatedRegatta.getDefaultCourseArea());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultRegattaReplication() throws InterruptedException {
|
||||
|
||||
@@ -378,6 +378,8 @@ public interface RacingEventService extends TrackedRegattaRegistry, RegattaFetch
|
||||
* @param series the series must not have any {@link RaceColumn}s yet
|
||||
*/
|
||||
Regatta createRegatta(String regattaBaseName, String boatClassName, Serializable id, Iterable<? extends Series> series, boolean persistent, ScoringScheme scoringScheme, Serializable defaultCourseAreaId);
|
||||
|
||||
Regatta updateRegatta(RegattaIdentifier regattaIdentifier, Serializable newDefaultCourseAreaId);
|
||||
|
||||
/**
|
||||
* Adds <code>raceDefinition</code> to the {@link Regatta} such that it will appear in {@link Regatta#getAllRaces()}
|
||||
|
||||
+17
@@ -127,6 +127,7 @@ import com.sap.sailing.server.operationaltransformation.UpdateEvent;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateMarkPassings;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateRaceDelayToLive;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateRaceTimes;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateSpecificRegatta;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateTrackedRaceStatus;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateWindAveragingTime;
|
||||
import com.sap.sailing.server.operationaltransformation.UpdateWindSourcesToExclude;
|
||||
@@ -1173,6 +1174,22 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
regatta.removeRaceColumnListener(raceLogScoringReplicator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Regatta updateRegatta(RegattaIdentifier regattaIdentifier, Serializable newDefaultCourseAreaId) {
|
||||
// We're not doing any renaming of the regatta itself, therefore we don't have to sync on the maps.
|
||||
Regatta regatta = getRegatta(regattaIdentifier);
|
||||
synchronized(regatta) {
|
||||
CourseArea newCourseArea = getCourseArea(newDefaultCourseAreaId);
|
||||
if (newCourseArea != regatta.getDefaultCourseArea()) {
|
||||
regatta.setDefaultCourseArea(newCourseArea);
|
||||
mongoObjectFactory.storeRegatta(regatta);
|
||||
}
|
||||
|
||||
replicate(new UpdateSpecificRegatta(regattaIdentifier, newDefaultCourseAreaId));
|
||||
}
|
||||
return regatta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRace(Regatta regatta, RaceDefinition race) throws MalformedURLException,
|
||||
IOException, InterruptedException {
|
||||
|
||||
+17
-4
@@ -1,23 +1,28 @@
|
||||
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;
|
||||
import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class UpdateLeaderboard extends AbstractLeaderboardOperation<Void> {
|
||||
public class UpdateLeaderboard extends AbstractLeaderboardOperation<Leaderboard> {
|
||||
private static final long serialVersionUID = -8040361040050151768L;
|
||||
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
|
||||
@@ -33,7 +38,7 @@ public class UpdateLeaderboard extends AbstractLeaderboardOperation<Void> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void internalApplyTo(RacingEventService toState) {
|
||||
public Leaderboard internalApplyTo(RacingEventService toState) {
|
||||
if (!getLeaderboardName().equals(newLeaderboardName)) {
|
||||
toState.renameLeaderboard(getLeaderboardName(), newLeaderboardName);
|
||||
}
|
||||
@@ -42,8 +47,16 @@ 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;
|
||||
return leaderboard;
|
||||
}
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.sap.sailing.server.operationaltransformation;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.server.RacingEventServiceOperation;
|
||||
|
||||
public class UpdateSpecificRegatta extends AbstractRacingEventServiceOperation<Regatta>{
|
||||
private static final long serialVersionUID = 8755035775682718882L;
|
||||
|
||||
private final RegattaIdentifier regattaIdentifier;
|
||||
private final Serializable newDefaultCourseAreaId;
|
||||
|
||||
public UpdateSpecificRegatta(RegattaIdentifier regattaIdentifier, Serializable newDefaultCourseAreaId) {
|
||||
this.regattaIdentifier = regattaIdentifier;
|
||||
this.newDefaultCourseAreaId = newDefaultCourseAreaId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Regatta internalApplyTo(RacingEventService toState) throws Exception {
|
||||
return toState.updateRegatta(regattaIdentifier, newDefaultCourseAreaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformClientOp(RacingEventServiceOperation<?> serverOp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacingEventServiceOperation<?> transformServerOp(RacingEventServiceOperation<?> clientOp) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user