Merge branch 'master' of ssh://kielweek.web4sap.com/home/trac/git

This commit is contained in:
Marcus Kammer committed 2012-06-08 18:01:04 +02:00
commit ac5c48a6b8
29 files changed
+438 -65

No files matched your search

@@ -44,6 +44,8 @@ import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.SelectionChangeEvent;
import com.google.gwt.view.client.SingleSelectionModel;
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
import com.sap.sailing.domain.common.RegattaIdentifier;
import com.sap.sailing.domain.common.RegattaName;
import com.sap.sailing.domain.common.RegattaNameAndRaceName;
import com.sap.sailing.domain.common.impl.Util.Pair;
import com.sap.sailing.gwt.ui.client.ErrorReporter;
@@ -89,6 +91,7 @@ public class LeaderboardConfigPanel extends FormPanel implements RegattaDisplaye
private final CaptionPanel selectedLeaderBoardPanel;
private final CaptionPanel trackedRacesCaptionPanel;
private final List<RegattaDTO> allRegattas;
private TextBox filterLeaderboardTextbox;
@@ -120,6 +123,7 @@ public class LeaderboardConfigPanel extends FormPanel implements RegattaDisplaye
this.stringMessages = theStringConstants;
this.sailingService = sailingService;
leaderboardList = new ListDataProvider<StrippedLeaderboardDTO>();
allRegattas = new ArrayList<RegattaDTO>();
raceColumnAndFleetNameList = new ListDataProvider<Pair<RaceColumnDTO, String>>();
this.errorReporter = errorReporter;
this.availableLeaderboardList = new ArrayList<StrippedLeaderboardDTO>();
@@ -213,7 +217,8 @@ public class LeaderboardConfigPanel extends FormPanel implements RegattaDisplaye
otherExistingLeaderboard.addAll(availableLeaderboardList);
otherExistingLeaderboard.remove(object);
LeaderboardEditDialog dialog = new LeaderboardEditDialog(Collections
.unmodifiableCollection(otherExistingLeaderboard), object, stringMessages, errorReporter,
.unmodifiableCollection(otherExistingLeaderboard), Collections.unmodifiableCollection(allRegattas),
object, stringMessages, errorReporter,
new AsyncCallback<StrippedLeaderboardDTO>() {
@Override
public void onFailure(Throwable arg0) {
@@ -758,8 +763,11 @@ public class LeaderboardConfigPanel extends FormPanel implements RegattaDisplaye
}
@Override
public void fillRegattas(List<RegattaDTO> result) {
trackedRacesListComposite.fillRegattas(result);
public void fillRegattas(List<RegattaDTO> regattas) {
trackedRacesListComposite.fillRegattas(regattas);
allRegattas.clear();
allRegattas.addAll(regattas);
}
@Override
@@ -773,8 +781,8 @@ public class LeaderboardConfigPanel extends FormPanel implements RegattaDisplaye
}
private void addNewLeaderboard() {
LeaderboardCreateDialog dialog = new LeaderboardCreateDialog(Collections.unmodifiableCollection(availableLeaderboardList)
, stringMessages, errorReporter, new AsyncCallback<StrippedLeaderboardDTO>() {
LeaderboardCreateDialog dialog = new LeaderboardCreateDialog(Collections.unmodifiableCollection(availableLeaderboardList),
Collections.unmodifiableCollection(allRegattas), stringMessages, errorReporter, new AsyncCallback<StrippedLeaderboardDTO>() {
@Override
public void onFailure(Throwable arg0) {
}
@@ -788,24 +796,45 @@ public class LeaderboardConfigPanel extends FormPanel implements RegattaDisplaye
}
private void createNewLeaderboard(final StrippedLeaderboardDTO newLeaderboard) {
sailingService.createFlexibleLeaderboard(newLeaderboard.name, newLeaderboard.discardThresholds,
new AsyncCallback<StrippedLeaderboardDTO>() {
@Override
public void onFailure(Throwable t) {
errorReporter.reportError("Error trying to create new leaderboard " + newLeaderboard.name
+ ": " + t.getMessage());
}
if(newLeaderboard.regatta == null) {
sailingService.createFlexibleLeaderboard(newLeaderboard.name, newLeaderboard.discardThresholds,
new AsyncCallback<StrippedLeaderboardDTO>() {
@Override
public void onFailure(Throwable t) {
errorReporter.reportError("Error trying to create new flexible leaderboard " + newLeaderboard.name
+ ": " + t.getMessage());
}
@Override
public void onSuccess(StrippedLeaderboardDTO result) {
leaderboardList.getList().add(result);
availableLeaderboardList.add(result);
selectedLeaderboard = result;
leaderboardSelectionChanged();
}
});
@Override
public void onSuccess(StrippedLeaderboardDTO result) {
addLeaderboard(result);
}
});
} else {
RegattaIdentifier regattaIdentifier = new RegattaName(newLeaderboard.regatta.name);
sailingService.createRegattaLeaderboard(regattaIdentifier, newLeaderboard.discardThresholds,
new AsyncCallback<StrippedLeaderboardDTO>() {
@Override
public void onFailure(Throwable t) {
errorReporter.reportError("Error trying to create new regatta leaderboard " + newLeaderboard.name
+ ": " + t.getMessage());
}
@Override
public void onSuccess(StrippedLeaderboardDTO result) {
addLeaderboard(result);
}
});
}
}
private void addLeaderboard(StrippedLeaderboardDTO result) {
leaderboardList.getList().add(result);
availableLeaderboardList.add(result);
selectedLeaderboard = result;
leaderboardSelectionChanged();
}
private void updateLeaderboard(final String oldLeaderboardName, final StrippedLeaderboardDTO leaderboardToUdate) {
sailingService.updateLeaderboard(oldLeaderboardName, leaderboardToUdate.name,
leaderboardToUdate.discardThresholds, new AsyncCallback<Void>() {
@@ -6,16 +6,20 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.LongBox;
import com.sap.sailing.gwt.ui.client.ErrorReporter;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
public class LeaderboardCreateDialog extends LeaderboardDialog {
public LeaderboardCreateDialog(Collection<StrippedLeaderboardDTO> existingLeaderboards, StringMessages stringConstants,
public LeaderboardCreateDialog(Collection<StrippedLeaderboardDTO> existingLeaderboards, Collection<RegattaDTO> existingRegattas, StringMessages stringConstants,
ErrorReporter errorReporter, AsyncCallback<StrippedLeaderboardDTO> callback) {
super(new StrippedLeaderboardDTO(), stringConstants, errorReporter, new LeaderboardDialog.LeaderboardParameterValidator(stringConstants, existingLeaderboards), callback);
super(new StrippedLeaderboardDTO(), existingRegattas, stringConstants, errorReporter, new LeaderboardDialog.LeaderboardParameterValidator(stringConstants, existingLeaderboards), callback);
entryField = createTextBox(null);
regattaListBox = createListBox(false);
regattaListBox.setEnabled(true);
discardThresholdBoxes = new LongBox[MAX_NUMBER_OF_DISCARDED_RESULTS];
for (int i = 0; i < discardThresholdBoxes.length; i++) {
discardThresholdBoxes[i] = createLongBoxWithOptionalValue(null, 2);
@@ -7,6 +7,7 @@ import java.util.List;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.LongBox;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
@@ -14,6 +15,7 @@ import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.gwt.ui.client.DataEntryDialog;
import com.sap.sailing.gwt.ui.client.ErrorReporter;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
@@ -21,6 +23,8 @@ public abstract class LeaderboardDialog extends DataEntryDialog<StrippedLeaderbo
protected final StringMessages stringConstants;
protected TextBox entryField;
protected StrippedLeaderboardDTO leaderboard;
protected ListBox regattaListBox;
protected Collection<RegattaDTO> existingRegattas;
protected LongBox[] discardThresholdBoxes;
protected static final int MAX_NUMBER_OF_DISCARDED_RESULTS = 4;
@@ -69,10 +73,11 @@ public abstract class LeaderboardDialog extends DataEntryDialog<StrippedLeaderbo
}
}
public LeaderboardDialog(StrippedLeaderboardDTO leaderboardDTO, StringMessages stringConstants,
public LeaderboardDialog(StrippedLeaderboardDTO leaderboardDTO, Collection<RegattaDTO> existingRegattas, StringMessages stringConstants,
ErrorReporter errorReporter, LeaderboardParameterValidator validator, AsyncCallback<StrippedLeaderboardDTO> callback) {
super(stringConstants.leaderboardName(), null, stringConstants.ok(),
stringConstants.cancel(), validator, callback);
this.existingRegattas = existingRegattas;
this.stringConstants = stringConstants;
this.leaderboard = leaderboardDTO;
}
@@ -92,6 +97,7 @@ public abstract class LeaderboardDialog extends DataEntryDialog<StrippedLeaderbo
}
leaderboard.name = entryField.getValue();
leaderboard.discardThresholds = discardThresholdsBoxContents;
leaderboard.regatta = getSelectedRegatta();
return leaderboard;
}
@@ -103,8 +109,20 @@ public abstract class LeaderboardDialog extends DataEntryDialog<StrippedLeaderbo
panel.add(additionalWidget);
}
panel.add(entryField);
HorizontalPanel regattaPanel = new HorizontalPanel();
regattaPanel.setSpacing(3);
regattaPanel.add(new Label(stringConstants.regatta() + ":"));
regattaListBox.addItem(stringConstants.noRegatta());
for (RegattaDTO regatta : existingRegattas) {
regattaListBox.addItem(regatta.name);
}
regattaPanel.add(regattaListBox);
panel.add(regattaPanel);
panel.add(new Label(stringConstants.discardRacesFromHowManyStartedRacesOn()));
HorizontalPanel hp = new HorizontalPanel();
hp.setSpacing(3);
for (int i = 0; i < discardThresholdBoxes.length; i++) {
hp.add(new Label("" + (i + 1) + "."));
hp.add(discardThresholdBoxes[i]);
@@ -113,6 +131,21 @@ public abstract class LeaderboardDialog extends DataEntryDialog<StrippedLeaderbo
return panel;
}
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: existingRegattas) {
if(regattaDTO.name.equals(itemText)) {
result = regattaDTO;
break;
}
}
}
return result;
}
@Override
public void show() {
super.show();
@@ -6,18 +6,22 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.LongBox;
import com.sap.sailing.gwt.ui.client.ErrorReporter;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
public class LeaderboardEditDialog extends LeaderboardDialog {
public LeaderboardEditDialog(Collection<StrippedLeaderboardDTO> otherExistingLeaderboards,
public LeaderboardEditDialog(Collection<StrippedLeaderboardDTO> otherExistingLeaderboards, Collection<RegattaDTO> existingRegattas,
StrippedLeaderboardDTO leaderboard, StringMessages stringConstants, ErrorReporter errorReporter,
AsyncCallback<StrippedLeaderboardDTO> callback) {
super(leaderboard, stringConstants, errorReporter, new LeaderboardDialog.LeaderboardParameterValidator(
super(leaderboard, existingRegattas, stringConstants, errorReporter, new LeaderboardDialog.LeaderboardParameterValidator(
stringConstants, otherExistingLeaderboards), callback);
entryField = createTextBox(leaderboard.name);
regattaListBox = createListBox(false);
regattaListBox.setEnabled(false);
discardThresholdBoxes = new LongBox[MAX_NUMBER_OF_DISCARDED_RESULTS];
for (int i = 0; i < super.discardThresholdBoxes.length; i++) {
if (i < leaderboard.discardThresholds.length) {
@@ -513,9 +513,8 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
RegattaDTO oldRegattaSelection = getSelectedRegatta();
regattaListBox.clear();
regattaListBox.addItem("No regatta");
regattaListBox.addItem(stringConstants.noRegatta());
if (!regattas.isEmpty()) {
regattaListBox.addItem("No regatta");
for (RegattaDTO regatta : regattas) {
regattaListBox.addItem(regatta.name);
if(oldRegattaSelection != null && oldRegattaSelection.name.equals(regatta.name)) {
@@ -318,4 +318,5 @@ public interface StringMessages extends Messages {
String color();
String medalSeries();
String noColor();
String noRegatta();
}
@@ -316,3 +316,4 @@ splitFleet=Split fleet
color=Color
medalSeries=Medal Series
noColor=No color
noRegatta=No regatta
@@ -317,3 +317,4 @@ splitFleet=Aufteilung in Gruppen
color=Farbe
medalSeries=Medal Series
noColor=Keine Farbe
noRegatta=Keine Regatta
@@ -18,6 +18,7 @@ public abstract class AbstractLeaderboardDTO implements IsSerializable {
public Map<CompetitorDTO, LeaderboardRowDTO> rows;
public boolean hasCarriedPoints;
public int[] discardThresholds;
public RegattaDTO regatta;
public AbstractLeaderboardDTO() {
races = new ArrayList<RaceColumnDTO>();
@@ -3,6 +3,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 static org.junit.Assert.assertNull;
import java.io.File;
import java.io.FileInputStream;
@@ -29,7 +30,7 @@ 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.ParserFactory;
import com.sap.sailing.kiworesultimport.Skipper;
import com.sap.sailing.kiworesultimport.Verteilung;
@@ -57,9 +58,33 @@ public class ParserTest {
return getInputStream("2011-06-18_49er_Wettfahrt_2_Extra.xml");
}
@Test
public void testEmptyIsafID() throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
ResultListParser parser = ParserFactory.INSTANCE.createResultListParser();
ResultList resultList = parser.parse(getSampleInputStream());
assertNotNull(resultList);
assertNull(resultList.getVerteilung().getBoatBySailID("SWE 1196").getCrew().getSkipper().getIsaf());
}
@Test
public void testEmptyStatus() throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
ResultListParser parser = ParserFactory.INSTANCE.createResultListParser();
ResultList resultList = parser.parse(getSampleInputStream());
assertNotNull(resultList);
assertNull(resultList.getVerteilung().getBoatBySailID("SWE 1196").getRaces().getRaces().iterator().next().getStatus());
}
@Test
public void testNonEmptyStatus() throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
ResultListParser parser = ParserFactory.INSTANCE.createResultListParser();
ResultList resultList = parser.parse(getSampleInputStream());
assertNotNull(resultList);
assertEquals("DNC", resultList.getVerteilung().getBoatBySailID("GER 1199").getRaces().getRaces().iterator().next().getStatus());
}
@Test
public void testObtainingResultList() throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
ResultListParser parser = ResultListParserFactory.INSTANCE.createResultListParser();
ResultListParser parser = ParserFactory.INSTANCE.createResultListParser();
ResultList resultList = parser.parse(getSampleInputStream());
assertNotNull(resultList);
assertEquals("D:\\Programme\\KWSailing\\eventlogos\\KielerWoche_Ergebnislistenkopf_2011.jpg", resultList.getImagePfad());
@@ -0,0 +1,29 @@
package com.sap.sailing.kiworesultimport.test;
import static org.junit.Assert.assertTrue;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.junit.Test;
public class ZipStreamTest {
private final static String ZIP_EXAMPLE_FILE = "resources/Kieler_Woche_2011_Export.zip";
@Test
public void testOpenZip() throws IOException {
ZipInputStream zis = new ZipInputStream(new FileInputStream(ZIP_EXAMPLE_FILE));
boolean foundStartberichteDir = false;
ZipEntry nextEntry = zis.getNextEntry();
while (nextEntry != null) {
if (nextEntry.getName().startsWith("Startberichte\\")) {
foundStartberichteDir = true;
}
nextEntry = zis.getNextEntry();
}
zis.close();
assertTrue(foundStartberichteDir);
}
}
@@ -0,0 +1,11 @@
package com.sap.sailing.kiworesultimport;
import com.sap.sailing.kiworesultimport.impl.ParserFactoryImpl;
public interface ParserFactory {
ParserFactory INSTANCE = new ParserFactoryImpl();
ResultListParser createResultListParser();
StartberichtParser createStartberichtParser();
}
@@ -1,7 +1,13 @@
package com.sap.sailing.kiworesultimport;
import com.sap.sailing.domain.common.MaxPointsReason;
public interface Race {
String getStatus();
Double getPoints();
Integer getNumber();
MaxPointsReason getMaxPointsReason();
}
@@ -1,9 +0,0 @@
package com.sap.sailing.kiworesultimport;
import com.sap.sailing.kiworesultimport.impl.ResultListParserFactoryImpl;
public interface ResultListParserFactory {
ResultListParserFactory INSTANCE = new ResultListParserFactoryImpl();
ResultListParser createResultListParser();
}
@@ -0,0 +1,27 @@
package com.sap.sailing.kiworesultimport;
import java.text.ParseException;
import com.sap.sailing.domain.common.TimePoint;
public interface Start {
String getBootsklasse();
Integer getWettfahrt();
String getStartgruppe();
String getKurs();
String getStartzeit();
TimePoint getTimePoint() throws ParseException;
String getStartflagge();
String getBemerkung();
Boolean getDoppelteWertung();
Boolean getStreichbar();
}
@@ -0,0 +1,21 @@
package com.sap.sailing.kiworesultimport;
import java.text.ParseException;
import com.sap.sailing.domain.common.TimePoint;
public interface Startbericht {
String getDatum();
TimePoint getTimePoint() throws ParseException;
String getRegattabahn();
String getKompasskurs();
String getWindstaerke();
String getWindrichtung();
Iterable<Start> getStarts();
}
@@ -0,0 +1,7 @@
package com.sap.sailing.kiworesultimport;
import java.io.InputStream;
public interface StartberichtParser {
Startbericht parse(InputStream inputStream);
}
@@ -0,0 +1,18 @@
package com.sap.sailing.kiworesultimport.impl;
import com.sap.sailing.kiworesultimport.ParserFactory;
import com.sap.sailing.kiworesultimport.ResultListParser;
import com.sap.sailing.kiworesultimport.StartberichtParser;
public class ParserFactoryImpl implements ParserFactory {
@Override
public ResultListParser createResultListParser() {
return new ResultListParserImpl();
}
@Override
public StartberichtParser createStartberichtParser() {
return new StartberichtParserImpl();
}
}
@@ -2,6 +2,7 @@ package com.sap.sailing.kiworesultimport.impl;
import org.w3c.dom.Node;
import com.sap.sailing.domain.common.MaxPointsReason;
import com.sap.sailing.kiworesultimport.Race;
public class RaceImpl extends AbstractNodeWrapper implements Race {
@@ -20,4 +21,21 @@ public class RaceImpl extends AbstractNodeWrapper implements Race {
return Integer.valueOf(getNode().getAttributes().getNamedItem("number").getNodeValue());
}
@Override
public String getStatus() {
final Node namedItem = getNode().getAttributes().getNamedItem("status");
return namedItem == null || namedItem.getNodeValue() == null || namedItem.getNodeValue().trim().length() == 0 ? null : namedItem.getNodeValue();
}
@Override
public MaxPointsReason getMaxPointsReason() {
MaxPointsReason result;
String status = getStatus();
if (status != null) {
result = MaxPointsReason.valueOf(status);
} else {
result = MaxPointsReason.NONE;
}
return result;
}
}
@@ -1,13 +0,0 @@
package com.sap.sailing.kiworesultimport.impl;
import com.sap.sailing.kiworesultimport.ResultListParser;
import com.sap.sailing.kiworesultimport.ResultListParserFactory;
public class ResultListParserFactoryImpl implements ResultListParserFactory {
@Override
public ResultListParser createResultListParser() {
return new ResultListParserImpl();
}
}
@@ -16,7 +16,11 @@ public class SkipperImpl extends NamedImpl implements Skipper {
@Override
public URL getIsaf() throws MalformedURLException, DOMException {
return new URL(getNode().getAttributes().getNamedItem("isaf").getNodeValue());
final String nodeValue = getNode().getAttributes().getNamedItem("isaf").getNodeValue();
URL result = null;
if (nodeValue != null && nodeValue.trim().length() > 0) {
result = new URL(nodeValue);
}
return result;
}
}
@@ -0,0 +1,70 @@
package com.sap.sailing.kiworesultimport.impl;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
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.Start;
public class StartImpl extends AbstractNodeWrapper implements Start {
private static final DateFormat df = new SimpleDateFormat("yyyy-MM-ddX");
public StartImpl(Node node) {
super(node);
}
@Override
public String getBootsklasse() {
return getNode().getAttributes().getNamedItem("bootsklasse").getNodeValue();
}
@Override
public Integer getWettfahrt() {
return Integer.valueOf(getNode().getAttributes().getNamedItem("wettfahrt").getNodeValue());
}
@Override
public String getStartgruppe() {
return getNode().getAttributes().getNamedItem("startgruppe").getNodeValue();
}
@Override
public String getKurs() {
return getNode().getAttributes().getNamedItem("kurs").getNodeValue();
}
@Override
public String getStartzeit() {
return getNode().getAttributes().getNamedItem("startzeit").getNodeValue();
}
@Override
public TimePoint getTimePoint() throws ParseException {
return new MillisecondsTimePoint(df.parse(getStartzeit()));
}
@Override
public String getStartflagge() {
return getNode().getAttributes().getNamedItem("startflagge").getNodeValue();
}
@Override
public String getBemerkung() {
return getNode().getAttributes().getNamedItem("bemerkung").getNodeValue();
}
@Override
public Boolean getDoppelteWertung() {
return Boolean.valueOf(getNode().getAttributes().getNamedItem("doppelte_Wertung").getNodeValue());
}
@Override
public Boolean getStreichbar() {
return Boolean.valueOf(getNode().getAttributes().getNamedItem("streichbar").getNodeValue());
}
}
@@ -0,0 +1,66 @@
package com.sap.sailing.kiworesultimport.impl;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
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.domain.base.impl.MillisecondsTimePoint;
import com.sap.sailing.domain.common.TimePoint;
import com.sap.sailing.kiworesultimport.Start;
import com.sap.sailing.kiworesultimport.Startbericht;
public class StartberichtImpl extends AbstractNodeWrapper implements Startbericht {
private static final DateFormat df = new SimpleDateFormat("yyyy-MM-ddX");
public StartberichtImpl(Node node) {
super(node);
}
@Override
public String getDatum() {
return getNode().getAttributes().getNamedItem("datum").getNodeValue();
}
@Override
public TimePoint getTimePoint() throws ParseException {
String datum = getDatum();
return datum == null || datum.trim().length() == 0 ? null : new MillisecondsTimePoint(df.parse(datum));
}
@Override
public String getRegattabahn() {
return getNode().getAttributes().getNamedItem("regattabahn").getNodeValue();
}
@Override
public String getKompasskurs() {
return getNode().getAttributes().getNamedItem("kompasskurs").getNodeValue();
}
@Override
public String getWindstaerke() {
return getNode().getAttributes().getNamedItem("windstaerke").getNodeValue();
}
@Override
public String getWindrichtung() {
return getNode().getAttributes().getNamedItem("windrichtung").getNodeValue();
}
@Override
public Iterable<Start> getStarts() {
List<Start> result = new ArrayList<Start>();
final NodeList starts = ((Element) getNode()).getElementsByTagName("start");
for (int i=0; i<starts.getLength(); i++) {
result.add(new StartImpl(starts.item(i)));
}
return result;
}
}
@@ -0,0 +1,16 @@
package com.sap.sailing.kiworesultimport.impl;
import java.io.InputStream;
import com.sap.sailing.kiworesultimport.Startbericht;
import com.sap.sailing.kiworesultimport.StartberichtParser;
public class StartberichtParserImpl implements StartberichtParser {
@Override
public Startbericht parse(InputStream inputStream) {
// TODO Auto-generated method stub
return null;
}
}
@@ -7,10 +7,8 @@ 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.domain.persistence.impl.CollectionNames;
import com.sap.sailing.mongodb.MongoDBConfiguration;
import com.sap.sailing.mongodb.MongoDBService;
@@ -44,10 +42,7 @@ public abstract class AbstractMongoDBTest {
}
private void dropAllCollections(DB theDB) throws InterruptedException {
for (CollectionNames collectionName : CollectionNames.values()) {
DBCollection c = theDB.getCollection(collectionName.name());
c.drop();
}
db.dropDatabase();
}
protected MongoDBService getMongoService() {
@@ -45,6 +45,7 @@ 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;
@@ -113,6 +114,9 @@ public class TestStoringAndLoadingEventsAndRegattas extends AbstractMongoDBTest
@Test
public void testLoadStoreRegattaLeaderboardWithScoreCorrections() {
// for some reason the dropping of collections doesn't work reliably on Linux... explicitly drop those collections that we depend on
getMongoService().getDB().getCollection(CollectionNames.LEADERBOARDS.name()).drop();
getMongoService().getDB().getCollection(CollectionNames.REGATTAS.name()).drop();
Competitor hasso = AbstractLeaderboardTest.createCompetitor("Dr. Hasso Plattner");
BoatClass boatClass = DomainFactory.INSTANCE.getOrCreateBoatClass("29erXX", /* typicallyStartsUpwind */ true);
final DynamicTrackedRegatta[] trackedRegatta = new DynamicTrackedRegatta[1];
@@ -82,7 +82,7 @@ public class TestStoringAndRetrievingWindData extends AbstractMongoDBTest {
}
{
Thread.sleep(3000); // wait until MongoDB has recorded the change and made it visible
Thread.sleep(1000); // wait until MongoDB has recorded the change and made it visible
Mongo mongo = newMongo();
assertNotNull(mongo);
DB db = mongo.getDB(getDBConfiguration().getDatabaseName());
@@ -293,11 +293,16 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
@Override
public RaceColumn addColumnToLeaderboard(String columnName, String leaderboardName, boolean medalRace) {
Leaderboard leaderboard = getLeaderboardByName(leaderboardName);
if (leaderboard != null && leaderboard instanceof FlexibleLeaderboard) {
// uses the default fleet as the single fleet for the new column
RaceColumn result = ((FlexibleLeaderboard) leaderboard).addRaceColumn(columnName, medalRace, leaderboard.getFleet(null));
updateStoredFlexibleLeaderboard((FlexibleLeaderboard) leaderboard);
return result;
if (leaderboard != null) {
if (leaderboard instanceof FlexibleLeaderboard) {
// uses the default fleet as the single fleet for the new column
RaceColumn result = ((FlexibleLeaderboard) leaderboard).addRaceColumn(columnName, medalRace,
leaderboard.getFleet(null));
updateStoredFlexibleLeaderboard((FlexibleLeaderboard) leaderboard);
return result;
} else {
throw new IllegalArgumentException("Leaderboard named " + leaderboardName + " is not a FlexibleLeaderboard");
}
} else {
throw new IllegalArgumentException("Leaderboard named " + leaderboardName + " not found");
}