mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-07 12:51:02 +00:00
Merge branch 'master' of ssh://kielweek.web4sap.com/home/trac/git
This commit is contained in:
commit
5a6f7c74c8
27 files changed
+454
-80
No files matched your search
+6
-4
@@ -35,9 +35,12 @@ public class AdminConsoleEntryPoint extends AbstractEntryPoint implements Regatt
|
||||
tabPanel.setAnimationEnabled(true);
|
||||
rootPanel.add(tabPanel); //, 10, 10);
|
||||
tabPanel.setSize("95%", "95%");
|
||||
|
||||
tabPanel.add(new EventStructureManagementPanel(sailingService, this, stringMessages), stringMessages.regattas());
|
||||
|
||||
regattaDisplayers = new HashSet<RegattaDisplayer>();
|
||||
|
||||
EventStructureManagementPanel eventStructureManagementPanel = new EventStructureManagementPanel(sailingService, this, stringMessages, this);
|
||||
tabPanel.add(eventStructureManagementPanel, stringMessages.regattas());
|
||||
regattaDisplayers.add(eventStructureManagementPanel);
|
||||
TracTracEventManagementPanel tractracEventManagementPanel = new TracTracEventManagementPanel(sailingService, this, this, stringMessages);
|
||||
regattaDisplayers.add(tractracEventManagementPanel);
|
||||
tractracEventManagementPanel.setSize("90%", "90%");
|
||||
@@ -101,9 +104,8 @@ public class AdminConsoleEntryPoint extends AbstractEntryPoint implements Regatt
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
reportError("Remote Procedure Call listEvents() - Failure");
|
||||
reportError("Remote Procedure Call getRegattas() - Failure");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+21
-30
@@ -34,6 +34,8 @@ import com.sap.sailing.domain.common.Color;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.common.impl.Util.Triple;
|
||||
import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
||||
import com.sap.sailing.gwt.ui.client.RegattaDisplayer;
|
||||
import com.sap.sailing.gwt.ui.client.RegattaRefresher;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
@@ -48,7 +50,7 @@ import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
* @author Frank Mittag (C5163974)
|
||||
*
|
||||
*/
|
||||
public class EventStructureManagementPanel extends SimplePanel {
|
||||
public class EventStructureManagementPanel extends SimplePanel implements RegattaDisplayer {
|
||||
private final SailingServiceAsync sailingService;
|
||||
private final ErrorReporter errorReporter;
|
||||
private final StringMessages stringMessages;
|
||||
@@ -63,15 +65,17 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
private CellTable<RegattaDTO> regattaTable;
|
||||
private SingleSelectionModel<RegattaDTO> regattaSelectionModel;
|
||||
private ListDataProvider<RegattaDTO> regattaProvider;
|
||||
private final RegattaRefresher regattaRefresher;
|
||||
|
||||
private final AdminConsoleTableResources tableRes = GWT.create(AdminConsoleTableResources.class);
|
||||
private boolean supportEvents = false;
|
||||
|
||||
public EventStructureManagementPanel(SailingServiceAsync sailingService, ErrorReporter errorReporter,
|
||||
StringMessages stringMessages) {
|
||||
StringMessages stringMessages, RegattaRefresher regattaRefresher) {
|
||||
this.sailingService = sailingService;
|
||||
this.stringMessages = stringMessages;
|
||||
this.errorReporter = errorReporter;
|
||||
this.regattaRefresher = regattaRefresher;
|
||||
|
||||
events = new ArrayList<EventDTO>();
|
||||
selectedEvent = null;
|
||||
@@ -115,8 +119,6 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
} else {
|
||||
createEventDetailsPanel();
|
||||
mainPanel.add(eventDetailsCaptionPanel);
|
||||
|
||||
fillRegattas();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +137,15 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
}
|
||||
|
||||
private void createRegattaDetails(Panel parentPanel) {
|
||||
Button addRegattaBtn = new Button("Add regatta");
|
||||
parentPanel.add(addRegattaBtn);
|
||||
addRegattaBtn.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openCreateRegattaDialog();
|
||||
}
|
||||
});
|
||||
|
||||
// regatta table
|
||||
TextColumn<RegattaDTO> regattaNameColumn = new TextColumn<RegattaDTO>() {
|
||||
@Override
|
||||
@@ -223,15 +234,6 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
regattaProvider = new ListDataProvider<RegattaDTO>();
|
||||
regattaProvider.addDataDisplay(regattaTable);
|
||||
parentPanel.add(regattaTable);
|
||||
|
||||
Button addRegattaBtn = new Button("Add regatta");
|
||||
parentPanel.add(addRegattaBtn);
|
||||
addRegattaBtn.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openCreateRegattaDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void onEventSelectionChanged() {
|
||||
@@ -306,22 +308,6 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
}
|
||||
}
|
||||
|
||||
private void fillRegattas() {
|
||||
// load the regattas for this event
|
||||
sailingService.getRegattas(new AsyncCallback<List<RegattaDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to read regattas of event " + selectedEvent.name + ": " + t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<RegattaDTO> regattas) {
|
||||
regattaProvider.getList().clear();
|
||||
regattaProvider.getList().addAll(regattas);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createNewEvent(final EventDTO newEvent) {
|
||||
sailingService.createEvent(newEvent.name, newEvent.venue.name, new AsyncCallback<EventDTO>() {
|
||||
@Override
|
||||
@@ -358,7 +344,7 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
|
||||
@Override
|
||||
public void onSuccess(RegattaDTO regatta) {
|
||||
regattaProvider.getList().add(regatta);
|
||||
regattaRefresher.fillRegattas();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -393,4 +379,9 @@ public class EventStructureManagementPanel extends SimplePanel {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillRegattas(List<RegattaDTO> regattas) {
|
||||
regattaProvider.getList().clear();
|
||||
regattaProvider.getList().addAll(regattas);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -264,7 +264,7 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
fleetsGrid.setCellSpacing(4);
|
||||
|
||||
fleetsGrid.setHTML(0, 0, stringConstants.name());
|
||||
fleetsGrid.setHTML(0, 1, stringConstants.no());
|
||||
fleetsGrid.setHTML(0, 1, stringConstants.rank());
|
||||
fleetsGrid.setHTML(0, 2, stringConstants.color());
|
||||
|
||||
for(int i = 0; i < fleetCount; i++) {
|
||||
|
||||
+57
-7
@@ -34,10 +34,12 @@ import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
import com.google.gwt.view.client.MultiSelectionModel;
|
||||
import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
import com.sap.sailing.domain.common.RegattaName;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
||||
import com.sap.sailing.gwt.ui.client.RegattaRefresher;
|
||||
import com.sap.sailing.gwt.ui.client.RaceSelectionModel;
|
||||
import com.sap.sailing.gwt.ui.client.RegattaRefresher;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
@@ -73,7 +75,9 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
|
||||
private final ListBox previousConfigurationsComboBox;
|
||||
private final Grid grid;
|
||||
private final List<TracTracRaceRecordDTO> availableTracTracRaces;
|
||||
|
||||
private Iterable<RegattaDTO> allRegattas;
|
||||
private final ListBox regattaListBox;
|
||||
|
||||
public TracTracEventManagementPanel(final SailingServiceAsync sailingService, ErrorReporter errorReporter,
|
||||
RegattaRefresher regattaRefresher, StringMessages stringConstants) {
|
||||
super(sailingService, regattaRefresher, errorReporter, new RaceSelectionModel(), stringConstants);
|
||||
@@ -271,6 +275,18 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
|
||||
trackedRacesCaptionPanel.setStyleName("bold");
|
||||
|
||||
// text box for filtering the cell table
|
||||
// the regatta selection for a tracked race
|
||||
HorizontalPanel regattaPanel = new HorizontalPanel();
|
||||
racesPanel.add(regattaPanel);
|
||||
Label lblRegattas = new Label("Regatta used for the tracked race:");
|
||||
lblRegattas.setWordWrap(false);
|
||||
regattaPanel.setCellVerticalAlignment(lblRegattas, HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
regattaPanel.setSpacing(5);
|
||||
regattaPanel.add(lblRegattas);
|
||||
regattaListBox = new ListBox();
|
||||
regattaPanel.add(regattaListBox);
|
||||
regattaPanel.setCellVerticalAlignment(regattaListBox, HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
|
||||
HorizontalPanel filterPanel = new HorizontalPanel();
|
||||
filterPanel.setSpacing(5);
|
||||
racesPanel.add(filterPanel);
|
||||
@@ -453,10 +469,15 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
|
||||
private void trackSelectedRaces(boolean trackWind, boolean correctWindByDeclination) {
|
||||
String liveURI = liveURIBox.getValue();
|
||||
String storedURI = storedURIBox.getValue();
|
||||
RegattaDTO selectedRegatta = getSelectedRegatta();
|
||||
RegattaIdentifier regattaIdentifier = null;
|
||||
if(selectedRegatta != null) {
|
||||
regattaIdentifier = new RegattaName(selectedRegatta.name);
|
||||
}
|
||||
for (final TracTracRaceRecordDTO rr : raceList.getList()) {
|
||||
if (raceTable.getSelectionModel().isSelected(rr)) {
|
||||
sailingService.trackWithTracTrac(/* regattaToAddTo */ null, // TODO allow user to optionally select a pre-defined regatta
|
||||
rr, liveURI, storedURI, trackWind, correctWindByDeclination, new AsyncCallback<Void>() {
|
||||
sailingService.trackWithTracTrac(regattaIdentifier, rr, liveURI, storedURI, trackWind,
|
||||
correctWindByDeclination, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to register race " + rr.name + " for tracking: "
|
||||
@@ -487,10 +508,39 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillRegattas(List<RegattaDTO> result) {
|
||||
trackedRacesListComposite.fillRegattas(result);
|
||||
public void fillRegattas(List<RegattaDTO> regattas) {
|
||||
trackedRacesListComposite.fillRegattas(regattas);
|
||||
|
||||
RegattaDTO oldRegattaSelection = getSelectedRegatta();
|
||||
regattaListBox.clear();
|
||||
regattaListBox.addItem("No regatta");
|
||||
if (!regattas.isEmpty()) {
|
||||
regattaListBox.addItem("No regatta");
|
||||
for (RegattaDTO regatta : regattas) {
|
||||
regattaListBox.addItem(regatta.name);
|
||||
if(oldRegattaSelection != null && oldRegattaSelection.name.equals(regatta.name)) {
|
||||
regattaListBox.setSelectedIndex(regattaListBox.getItemCount()-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
allRegattas = new ArrayList<RegattaDTO>(regattas);
|
||||
}
|
||||
|
||||
|
||||
public RegattaDTO getSelectedRegatta() {
|
||||
RegattaDTO result = null;
|
||||
int selIndex = regattaListBox.getSelectedIndex();
|
||||
if(selIndex > 0) { // the zero index represents the 'no selection' text
|
||||
String itemText = regattaListBox.getItemText(selIndex);
|
||||
for(RegattaDTO regattaDTO: allRegattas) {
|
||||
if(regattaDTO.name.equals(itemText)) {
|
||||
result = regattaDTO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void fillRaceListFromAvailableRacesApplyingFilter(String text) {
|
||||
List<String> wordsToFilter = Arrays.asList(text.split(" "));
|
||||
raceList.getList().clear();
|
||||
|
||||
+11
-11
@@ -81,7 +81,7 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
private ListDataProvider<RaceDTO> raceList;
|
||||
|
||||
private Iterable<RaceDTO> allRaces;
|
||||
|
||||
|
||||
private final VerticalPanel panel;
|
||||
|
||||
private DateTimeFormatRenderer dateFormatter = new DateTimeFormatRenderer(
|
||||
@@ -124,9 +124,6 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
public TrackedRacesListComposite(final SailingServiceAsync sailingService, final ErrorReporter errorReporter,
|
||||
final RegattaRefresher regattaRefresher, RaceSelectionProvider raceSelectionProvider,
|
||||
StringMessages stringMessages, boolean hasMultiSelection) {
|
||||
if (regattaRefresher == null) {
|
||||
throw new IllegalArgumentException("regattaRefresher must not be null");
|
||||
}
|
||||
this.sailingService = sailingService;
|
||||
this.errorReporter = errorReporter;
|
||||
this.regattaRefresher = regattaRefresher;
|
||||
@@ -141,13 +138,14 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
settings.setDelayToLiveInSeconds(DEFAULT_LIVE_DELAY_IN_MILLISECONDS / 1000l);
|
||||
panel = new VerticalPanel();
|
||||
setWidget(panel);
|
||||
|
||||
HorizontalPanel filterPanel = new HorizontalPanel();
|
||||
panel.add(filterPanel);
|
||||
Label lblFilterEvents = new Label(stringMessages.filterRacesByName() + ":");
|
||||
lblFilterEvents.setWordWrap(false);
|
||||
Label lblFilterRaces = new Label(stringMessages.filterRacesByName() + ":");
|
||||
lblFilterRaces.setWordWrap(false);
|
||||
filterPanel.setSpacing(5);
|
||||
filterPanel.add(lblFilterEvents);
|
||||
filterPanel.setCellVerticalAlignment(lblFilterEvents, HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
filterPanel.add(lblFilterRaces);
|
||||
filterPanel.setCellVerticalAlignment(lblFilterRaces, HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
filterRacesTextbox = new TextBox();
|
||||
filterRacesTextbox.addKeyUpHandler(new KeyUpHandler() {
|
||||
@Override
|
||||
@@ -438,8 +436,8 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillRegattas(List<RegattaDTO> events) {
|
||||
if (events.isEmpty()) {
|
||||
public void fillRegattas(List<RegattaDTO> regattas) {
|
||||
if (regattas.isEmpty()) {
|
||||
raceTable.setVisible(false);
|
||||
btnUntrack.setVisible(false);
|
||||
btnRemoveRace.setVisible(false);
|
||||
@@ -455,8 +453,10 @@ public class TrackedRacesListComposite extends SimplePanel implements Component<
|
||||
btnSetDelayToLive.setVisible(true);
|
||||
}
|
||||
List<RaceDTO> newAllRaces = new ArrayList<RaceDTO>();
|
||||
List<RegattaDTO> newAllRegattas = new ArrayList<RegattaDTO>();
|
||||
List<RegattaAndRaceIdentifier> newAllRaceIdentifiers = new ArrayList<RegattaAndRaceIdentifier>();
|
||||
for (RegattaDTO regatta : events) {
|
||||
for (RegattaDTO regatta : regattas) {
|
||||
newAllRegattas.add(regatta);
|
||||
for (RaceDTO race : regatta.races) {
|
||||
if (race != null) {
|
||||
newAllRaces.add(race);
|
||||
|
||||
@@ -6,4 +6,6 @@ Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: org.junit4;bundle-version="4.8.2",
|
||||
com.sap.sailing.kiworesultimport
|
||||
com.sap.sailing.kiworesultimport,
|
||||
com.sap.sailing.domain.common,
|
||||
com.sap.sailing.domain
|
||||
+38
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.kiworesultimport.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -8,6 +9,9 @@ import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
@@ -17,9 +21,17 @@ import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.common.impl.Util;
|
||||
import com.sap.sailing.kiworesultimport.Boat;
|
||||
import com.sap.sailing.kiworesultimport.Crewmember;
|
||||
import com.sap.sailing.kiworesultimport.Race;
|
||||
import com.sap.sailing.kiworesultimport.Races;
|
||||
import com.sap.sailing.kiworesultimport.ResultList;
|
||||
import com.sap.sailing.kiworesultimport.ResultListParser;
|
||||
import com.sap.sailing.kiworesultimport.ResultListParserFactory;
|
||||
import com.sap.sailing.kiworesultimport.Skipper;
|
||||
import com.sap.sailing.kiworesultimport.Verteilung;
|
||||
|
||||
public class ParserTest {
|
||||
private static final String RESOURCES = "resources/";
|
||||
@@ -52,5 +64,31 @@ public class ParserTest {
|
||||
assertNotNull(resultList);
|
||||
assertEquals("D:\\Programme\\KWSailing\\eventlogos\\KielerWoche_Ergebnislistenkopf_2011.jpg", resultList.getImagePfad());
|
||||
assertEquals(new String(new byte[] { (byte) 160 /* non-breaking space */}), resultList.getLegende());
|
||||
final Verteilung verteilung = resultList.getVerteilung();
|
||||
assertNotNull(verteilung);
|
||||
Iterable<Boat> boats = verteilung.getBoats();
|
||||
assertFalse(Util.isEmpty(boats));
|
||||
assertEquals(48, Util.size(boats));
|
||||
Boat DEN9 = verteilung.getBoatBySailID("DEN 9");
|
||||
assertNotNull(DEN9);
|
||||
assertEquals(7, (int) DEN9.getPosition());
|
||||
Skipper DEN9Skipper = DEN9.getCrew().getSkipper();
|
||||
assertEquals("Norregaard, Allan (1981) Kolding", DEN9Skipper.getName());
|
||||
assertEquals(new URL("http://www.sailing.org/biog.php?id=DENAN1"), DEN9Skipper.getIsaf());
|
||||
Iterable<Crewmember> DEN9Crewmembers = DEN9.getCrew().getCrewmembers();
|
||||
assertEquals(1, Util.size(DEN9Crewmembers));
|
||||
Crewmember DEN9Crewmember = DEN9Crewmembers.iterator().next();
|
||||
assertEquals("Lang, Peter (1989) Kolding Sejlklub", DEN9Crewmember.getName());
|
||||
Races DEN9Races = DEN9.getRaces();
|
||||
assertNotNull(DEN9Races);
|
||||
assertEquals(2, Util.size(DEN9Races.getRaces()));
|
||||
Iterator<Race> i = DEN9Races.getRaces().iterator();
|
||||
Race r1 = i.next();
|
||||
assertEquals(9.00, r1.getPoints(), 0.0000000001);
|
||||
assertEquals(1, (int) r1.getNumber());
|
||||
Race r2 = i.next();
|
||||
assertEquals(1.00, r2.getPoints(), 0.0000000001);
|
||||
assertEquals(2, (int) r2.getNumber());
|
||||
assertEquals(new MillisecondsTimePoint(new GregorianCalendar(2011, 05, 18, 16, 26).getTime()), resultList.getTimePoint());
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,7 @@ Bundle-SymbolicName: com.sap.sailing.kiworesultimport
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: com.sap.sailing.server
|
||||
Require-Bundle: com.sap.sailing.server,
|
||||
com.sap.sailing.domain.common,
|
||||
com.sap.sailing.domain
|
||||
Export-Package: com.sap.sailing.kiworesultimport
|
||||
@@ -6,4 +6,8 @@ public interface Boat extends Named {
|
||||
Integer getPosition();
|
||||
|
||||
String getPreis();
|
||||
|
||||
Crew getCrew();
|
||||
|
||||
Races getRaces();
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.sap.sailing.kiworesultimport;
|
||||
|
||||
public interface Crew {
|
||||
Skipper getSkipper();
|
||||
|
||||
Iterable<Crewmember> getCrewmembers();
|
||||
}
|
||||
+1
-1
@@ -3,5 +3,5 @@ package com.sap.sailing.kiworesultimport;
|
||||
public interface Race {
|
||||
Double getPoints();
|
||||
|
||||
Double getNumber();
|
||||
Integer getNumber();
|
||||
}
|
||||
@@ -2,4 +2,6 @@ package com.sap.sailing.kiworesultimport;
|
||||
|
||||
public interface Races {
|
||||
Double getTotalPoints();
|
||||
|
||||
Iterable<Race> getRaces();
|
||||
}
|
||||
+6
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.kiworesultimport;
|
||||
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
|
||||
public interface ResultList {
|
||||
String getLegende();
|
||||
|
||||
@@ -14,4 +16,8 @@ public interface ResultList {
|
||||
String getTime();
|
||||
|
||||
String getDate();
|
||||
|
||||
TimePoint getTimePoint();
|
||||
|
||||
Verteilung getVerteilung();
|
||||
}
|
||||
+4
-1
@@ -1,7 +1,10 @@
|
||||
package com.sap.sailing.kiworesultimport;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
|
||||
public interface Skipper extends Named {
|
||||
URL getIsaf();
|
||||
URL getIsaf() throws MalformedURLException, DOMException;
|
||||
}
|
||||
+8
-1
@@ -1,5 +1,12 @@
|
||||
package com.sap.sailing.kiworesultimport;
|
||||
|
||||
public interface Verteilung {
|
||||
|
||||
Iterable<Boat> getBoats();
|
||||
|
||||
/**
|
||||
* Matches <code>sailID</code> with {@link Boat#getSailingNumber()}
|
||||
*
|
||||
* @return <code>null</code> if no such {@link Boat} is found in {@link #getBoats}, or the boat found otherwise.
|
||||
*/
|
||||
Boat getBoatBySailID(String sailID);
|
||||
}
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.sap.sailing.kiworesultimport.Boat;
|
||||
import com.sap.sailing.kiworesultimport.Crew;
|
||||
import com.sap.sailing.kiworesultimport.Races;
|
||||
|
||||
public class BoatImpl extends NamedImpl implements Boat {
|
||||
|
||||
public BoatImpl(Node node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSailingNumber() {
|
||||
return getNode().getAttributes().getNamedItem("sailingnumber").getNodeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getPosition() {
|
||||
return Integer.valueOf(getNode().getAttributes().getNamedItem("position").getNodeValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreis() {
|
||||
return getNode().getAttributes().getNamedItem("preis").getNodeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Crew getCrew() {
|
||||
final NodeList crew = ((Element) getNode()).getElementsByTagName("Crew");
|
||||
return new CrewImpl(crew.item(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Races getRaces() {
|
||||
final NodeList races = ((Element) getNode()).getElementsByTagName("Races");
|
||||
return new RacesImpl(races.item(0));
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.sap.sailing.kiworesultimport.Crew;
|
||||
import com.sap.sailing.kiworesultimport.Crewmember;
|
||||
import com.sap.sailing.kiworesultimport.Skipper;
|
||||
|
||||
public class CrewImpl extends AbstractNodeWrapper implements Crew {
|
||||
|
||||
public CrewImpl(Node node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Skipper getSkipper() {
|
||||
return new SkipperImpl(((Element) getNode()).getElementsByTagName("Skipper").item(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Crewmember> getCrewmembers() {
|
||||
List<Crewmember> result = new ArrayList<Crewmember>();
|
||||
final NodeList crewmembers = ((Element) getNode()).getElementsByTagName("Crewmember");
|
||||
for (int i=0; i<crewmembers.getLength(); i++) {
|
||||
result.add(new CrewmemberImpl(crewmembers.item(i)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sap.sailing.kiworesultimport.Crewmember;
|
||||
|
||||
public class CrewmemberImpl extends NamedImpl implements Crewmember {
|
||||
|
||||
public CrewmemberImpl(Node node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sap.sailing.kiworesultimport.Named;
|
||||
|
||||
public class NamedImpl extends AbstractNodeWrapper implements Named {
|
||||
|
||||
public NamedImpl(Node node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getNode().getAttributes().getNamedItem("name").getNodeValue();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sap.sailing.kiworesultimport.Race;
|
||||
|
||||
public class RaceImpl extends AbstractNodeWrapper implements Race {
|
||||
|
||||
public RaceImpl(Node node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getPoints() {
|
||||
return Double.valueOf(getNode().getAttributes().getNamedItem("points").getNodeValue().replace(',', '.'));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getNumber() {
|
||||
return Integer.valueOf(getNode().getAttributes().getNamedItem("number").getNodeValue());
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+34
@@ -0,0 +1,34 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.sap.sailing.kiworesultimport.Race;
|
||||
import com.sap.sailing.kiworesultimport.Races;
|
||||
|
||||
public class RacesImpl extends AbstractNodeWrapper implements Races {
|
||||
|
||||
public RacesImpl(Node node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getTotalPoints() {
|
||||
return Double.valueOf(getNode().getAttributes().getNamedItem("totalpoints").getNodeValue().replace(',', '.'));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Race> getRaces() {
|
||||
List<Race> result = new ArrayList<Race>();
|
||||
final NodeList races = ((Element) getNode()).getElementsByTagName("Race");
|
||||
for (int i=0; i<races.getLength(); i++) {
|
||||
result.add(new RaceImpl(races.item(i)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+37
-10
@@ -1,10 +1,24 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.kiworesultimport.ResultList;
|
||||
import com.sap.sailing.kiworesultimport.Verteilung;
|
||||
|
||||
public class ResultListImpl extends AbstractNodeWrapper implements ResultList {
|
||||
private static final Logger logger = Logger.getLogger(ResultListImpl.class.getName());
|
||||
|
||||
private static final SimpleDateFormat df = new SimpleDateFormat("dd. MMM yyyy hh:mm", Locale.GERMAN);
|
||||
|
||||
public ResultListImpl(Node node) {
|
||||
super(node);
|
||||
}
|
||||
@@ -21,31 +35,44 @@ public class ResultListImpl extends AbstractNodeWrapper implements ResultList {
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return getNode().getAttributes().getNamedItem("status").getNodeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBoatClass() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return getNode().getAttributes().getNamedItem("class").getNodeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEvent() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return getNode().getAttributes().getNamedItem("event").getNodeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTime() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return getNode().getAttributes().getNamedItem("time").getNodeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDate() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return getNode().getAttributes().getNamedItem("date").getNodeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Verteilung getVerteilung() {
|
||||
return new VerteilungImpl(((Element) getNode()).getElementsByTagName("Verteilung").item(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimePoint getTimePoint() {
|
||||
TimePoint result = null;
|
||||
String dateTime = getDate()+" "+getTime();
|
||||
try {
|
||||
Date d = df.parse(dateTime);
|
||||
result = new MillisecondsTimePoint(d);
|
||||
} catch (ParseException e) {
|
||||
logger.info("Failed to parse result list date/time "+dateTime);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sap.sailing.kiworesultimport.Skipper;
|
||||
|
||||
public class SkipperImpl extends NamedImpl implements Skipper {
|
||||
|
||||
public SkipperImpl(Node node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getIsaf() throws MalformedURLException, DOMException {
|
||||
return new URL(getNode().getAttributes().getNamedItem("isaf").getNodeValue());
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import com.sap.sailing.kiworesultimport.Boat;
|
||||
import com.sap.sailing.kiworesultimport.Verteilung;
|
||||
|
||||
public class VerteilungImpl extends AbstractNodeWrapper implements Verteilung {
|
||||
|
||||
public VerteilungImpl(Node node) {
|
||||
super(node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Boat> getBoats() {
|
||||
List<Boat> result = new ArrayList<Boat>();
|
||||
final NodeList boats = ((Element) getNode()).getElementsByTagName("Boat");
|
||||
for (int i=0; i<boats.getLength(); i++) {
|
||||
result.add(new BoatImpl(boats.item(i)));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boat getBoatBySailID(String sailID) {
|
||||
for (Boat boat : getBoats()) {
|
||||
if (sailID.equals(boat.getSailingNumber())) {
|
||||
return boat;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+9
-1
@@ -7,6 +7,7 @@ import java.net.UnknownHostException;
|
||||
import org.junit.Before;
|
||||
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.DBCollection;
|
||||
import com.mongodb.Mongo;
|
||||
import com.mongodb.MongoException;
|
||||
import com.sap.sailing.mongodb.MongoDBConfiguration;
|
||||
@@ -36,11 +37,18 @@ public abstract class AbstractMongoDBTest {
|
||||
public void dropTestDB() throws UnknownHostException, MongoException, InterruptedException {
|
||||
mongo = newMongo();
|
||||
assertNotNull(mongo);
|
||||
mongo.dropDatabase(getDBConfiguration().getDatabaseName());
|
||||
db = mongo.getDB(getDBConfiguration().getDatabaseName());
|
||||
dropAllCollections(db);
|
||||
assertNotNull(db);
|
||||
}
|
||||
|
||||
private void dropAllCollections(DB theDB) {
|
||||
for (String collectionName : theDB.getCollectionNames()) {
|
||||
DBCollection c = theDB.getCollection(collectionName);
|
||||
c.drop();
|
||||
}
|
||||
}
|
||||
|
||||
protected MongoDBService getMongoService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
-5
@@ -45,7 +45,6 @@ import com.sap.sailing.domain.leaderboard.RegattaLeaderboard;
|
||||
import com.sap.sailing.domain.persistence.DomainObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.impl.CollectionNames;
|
||||
import com.sap.sailing.domain.test.AbstractLeaderboardTest;
|
||||
import com.sap.sailing.domain.test.MockedTrackedRaceWithFixedRank;
|
||||
import com.sap.sailing.domain.tracking.DynamicTrackedRegatta;
|
||||
@@ -89,8 +88,6 @@ public class TestStoringAndLoadingEventsAndRegattas extends AbstractMongoDBTest
|
||||
|
||||
@Test
|
||||
public void testLoadStoreSimpleRegattaLeaderboard() {
|
||||
// explicitly drop; it seems that the overall dropDatabase isn't always effective yet when this test is run
|
||||
getMongoService().getDB().getCollection(CollectionNames.LEADERBOARDS.name()).drop();
|
||||
RacingEventService res = new RacingEventServiceImpl(getMongoService());
|
||||
final int numberOfQualifyingRaces = 5;
|
||||
final int numberOfFinalRaces = 7;
|
||||
@@ -116,8 +113,6 @@ public class TestStoringAndLoadingEventsAndRegattas extends AbstractMongoDBTest
|
||||
|
||||
@Test
|
||||
public void testLoadStoreRegattaLeaderboardWithScoreCorrections() {
|
||||
// explicitly drop; it seems that the overall dropDatabase isn't always effective yet when this test is run
|
||||
getMongoService().getDB().getCollection(CollectionNames.LEADERBOARDS.name()).drop();
|
||||
Competitor hasso = AbstractLeaderboardTest.createCompetitor("Dr. Hasso Plattner");
|
||||
BoatClass boatClass = DomainFactory.INSTANCE.getOrCreateBoatClass("29erXX", /* typicallyStartsUpwind */ true);
|
||||
final DynamicTrackedRegatta[] trackedRegatta = new DynamicTrackedRegatta[1];
|
||||
|
||||
+8
-6
@@ -223,6 +223,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
|
||||
private void loadStoredRegattas() {
|
||||
for (Regatta regatta : domainObjectFactory.loadAllRegattas(this)) {
|
||||
logger.info("putting regatta "+regatta.getName()+" ("+regatta.hashCode()+") into regattasByName");
|
||||
regattasByName.put(regatta.getName(), regatta);
|
||||
}
|
||||
}
|
||||
@@ -517,7 +518,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
Regatta result = regattasByName.get(regatta.getName());
|
||||
if (result == null) {
|
||||
result = regatta;
|
||||
logger.info("Created regatta "+result.getName()+" ("+hashCode()+")");
|
||||
logger.info("Created regatta "+result.getName()+" ("+hashCode()+") on "+this);
|
||||
cacheAndReplicateDefaultRegatta(result);
|
||||
}
|
||||
return result;
|
||||
@@ -528,7 +529,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
Iterable<? extends Series> series, boolean persistent) {
|
||||
Regatta regatta = new RegattaImpl(baseEventName,
|
||||
com.sap.sailing.domain.base.DomainFactory.INSTANCE.getOrCreateBoatClass(boatClassName), series, persistent);
|
||||
logger.info("Created regatta " + regatta.getName() + " (" + hashCode() + ")");
|
||||
logger.info("Created regatta " + regatta.getName() + " (" + hashCode() + ") on "+this);
|
||||
cacheAndReplicateSpecificRegattaWithoutRaceColumns(regatta);
|
||||
if (persistent) {
|
||||
updateStoredRegatta(regatta);
|
||||
@@ -663,7 +664,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
*/
|
||||
private void cacheAndReplicateSpecificRegattaWithoutRaceColumns(Regatta regatta) {
|
||||
if (!regattasByName.containsKey(regatta.getName())) {
|
||||
logger.info("putting regatta "+regatta.getName()+" ("+regatta.hashCode()+") into regattasByName");
|
||||
logger.info("putting regatta "+regatta.getName()+" ("+regatta.hashCode()+") into regattasByName of "+this);
|
||||
regattasByName.put(regatta.getName(), regatta);
|
||||
regatta.addRegattaListener(this);
|
||||
replicate(new AddSpecificRegatta(regatta.getBaseName(), regatta.getBoatClass() == null ? null : regatta
|
||||
@@ -695,7 +696,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
*/
|
||||
private void cacheAndReplicateDefaultRegatta(Regatta regatta) {
|
||||
if (!regattasByName.containsKey(regatta.getName())) {
|
||||
logger.info("putting regatta "+regatta.getName()+" ("+regatta.hashCode()+") into regattasByName");
|
||||
logger.info("putting regatta "+regatta.getName()+" ("+regatta.hashCode()+") into regattasByName of "+this);
|
||||
regattasByName.put(regatta.getName(), regatta);
|
||||
regatta.addRegattaListener(this);
|
||||
replicate(new AddDefaultRegatta(regatta.getBaseName(), regatta.getBoatClass() == null ? null : regatta.getBoatClass().getName()));
|
||||
@@ -886,7 +887,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
stopTracking(regatta);
|
||||
if (regatta != null) {
|
||||
if (regatta.getName() != null) {
|
||||
logger.info("Removing regatta "+regatta.getName()+" ("+regatta.hashCode()+") from RacingEventServiceImpl");
|
||||
logger.info("Removing regatta "+regatta.getName()+" ("+regatta.hashCode()+") from "+this);
|
||||
regattasByName.remove(regatta.getName());
|
||||
regattaTrackingCache.remove(regatta);
|
||||
regatta.removeRegattaListener(this);
|
||||
@@ -1022,7 +1023,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
// remove the race from the regatta if the regatta is not persistently stored
|
||||
regatta.removeRace(race);
|
||||
if (!regatta.isPersistent() && Util.isEmpty(regatta.getAllRaces())) {
|
||||
logger.info("Removing regatta "+regatta.getName()+" from service "+this);
|
||||
logger.info("Removing regatta "+regatta.getName()+" ("+regatta.hashCode()+") from service "+this);
|
||||
regattasByName.remove(regatta.getName());
|
||||
regatta.removeRegattaListener(this);
|
||||
}
|
||||
@@ -1346,6 +1347,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
|
||||
@SuppressWarnings("unchecked") // the type-parameters in the casts of the de-serialized collection objects can't be checked
|
||||
@Override
|
||||
public synchronized void initiallyFillFrom(ObjectInputStream ois) throws IOException, ClassNotFoundException {
|
||||
logger.info("Performing initial replication load on "+this);
|
||||
ClassLoader oldContextClassloader = Thread.currentThread().getContextClassLoader();
|
||||
try {
|
||||
// Use this object's class's class loader as the context class loader which will then be used for
|
||||
|
||||
Reference in new issue
Block a user