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
f43348c8f4
16 files changed
+158
-82
No files matched your search
@@ -10,4 +10,4 @@ Require-Bundle: com.sap.sailing.mongodb,
|
||||
com.mongodb.driver;bundle-version="2.6.2",
|
||||
com.sap.sailing.domain.common
|
||||
Export-Package: com.sap.sailing.domain.persistence,
|
||||
com.sap.sailing.domain.persistence.impl;x-friends:="com.sap.sailing.mongodb.test"
|
||||
com.sap.sailing.domain.persistence.impl;x-friends:="com.sap.sailing.mongodb.test,com.sap.sailing.domain.swisstimingadapter.test"
|
||||
@@ -13,7 +13,8 @@ Require-Bundle: com.sap.sailing.domain.swisstimingadapter.persistence,
|
||||
com.sap.sailing.mongodb,
|
||||
com.googlecode.java-diff-utils;bundle-version="1.3.0",
|
||||
com.sap.sailing.server,
|
||||
com.sap.sailing.domain.common
|
||||
com.sap.sailing.domain.common,
|
||||
com.sap.sailing.domain.persistence
|
||||
Bundle-ClassPath: resources/,
|
||||
.
|
||||
Import-Package: com.sap.sailing.server,
|
||||
|
||||
+8
-7
@@ -69,6 +69,7 @@ public class EndToEndListeningStoreAndFowardTest {
|
||||
logger.info("EndToEndListeningStoreAndFowardTest.setUp");
|
||||
MongoDBService mongoDBService = MongoDBService.INSTANCE;
|
||||
db = mongoDBService.getDB();
|
||||
db.getCollection(com.sap.sailing.domain.persistence.impl.CollectionNames.REGATTAS.name()).drop();
|
||||
swissTimingAdapterPersistence = SwissTimingAdapterPersistence.INSTANCE;
|
||||
swissTimingAdapterPersistence.dropAllMessageData();
|
||||
swissTimingAdapterPersistence.dropAllRaceMasterData();
|
||||
@@ -83,7 +84,7 @@ public class EndToEndListeningStoreAndFowardTest {
|
||||
lastMessageCountCollection.update(new BasicDBObject(),
|
||||
new BasicDBObject().append(FieldNames.LAST_MESSAGE_COUNT.name(), 0l),
|
||||
/* upsert */true, /* multi */false);
|
||||
racingEventService = new RacingEventServiceImpl();
|
||||
racingEventService = new RacingEventServiceImpl(mongoDBService);
|
||||
raceHandles = new ArrayList<RacesHandle>();
|
||||
}
|
||||
|
||||
@@ -105,9 +106,9 @@ public class EndToEndListeningStoreAndFowardTest {
|
||||
setUpUsingScript(racesToTrack, scriptName);
|
||||
|
||||
Set<TrackedRace> allTrackedRaces = new HashSet<TrackedRace>();
|
||||
Iterable<Regatta> allEvents = racingEventService.getAllRegattas();
|
||||
for (Regatta event : allEvents) {
|
||||
DynamicTrackedRegatta trackedRegatta = racingEventService.getTrackedRegatta(event);
|
||||
Iterable<Regatta> allRegattas = racingEventService.getAllRegattas();
|
||||
for (Regatta regatta : allRegattas) {
|
||||
DynamicTrackedRegatta trackedRegatta = racingEventService.getTrackedRegatta(regatta);
|
||||
Iterable<TrackedRace> trackedRaces = trackedRegatta.getTrackedRaces();
|
||||
for (TrackedRace trackedRace : trackedRaces) {
|
||||
allTrackedRaces.add(trackedRace);
|
||||
@@ -134,9 +135,9 @@ public class EndToEndListeningStoreAndFowardTest {
|
||||
setUpUsingScript(racesToTrack, scriptName1, scriptName2);
|
||||
|
||||
Set<TrackedRace> allTrackedRaces = new HashSet<TrackedRace>();
|
||||
Iterable<Regatta> allEvents = racingEventService.getAllRegattas();
|
||||
for (Regatta event : allEvents) {
|
||||
DynamicTrackedRegatta trackedRegatta = racingEventService.getTrackedRegatta(event);
|
||||
Iterable<Regatta> allRegattas = racingEventService.getAllRegattas();
|
||||
for (Regatta regatta : allRegattas) {
|
||||
DynamicTrackedRegatta trackedRegatta = racingEventService.getTrackedRegatta(regatta);
|
||||
Iterable<TrackedRace> trackedRaces = trackedRegatta.getTrackedRaces();
|
||||
for (TrackedRace trackedRace : trackedRaces) {
|
||||
allTrackedRaces.add(trackedRace);
|
||||
|
||||
+11
-9
@@ -23,16 +23,16 @@ import org.w3c.dom.Node;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.common.MaxPointsReason;
|
||||
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.ParserFactory;
|
||||
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.ParserFactory;
|
||||
import com.sap.sailing.kiworesultimport.Skipper;
|
||||
import com.sap.sailing.kiworesultimport.Verteilung;
|
||||
|
||||
public class ParserTest {
|
||||
private static final String RESOURCES = "resources/";
|
||||
@@ -63,7 +63,7 @@ public class ParserTest {
|
||||
ResultListParser parser = ParserFactory.INSTANCE.createResultListParser();
|
||||
ResultList resultList = parser.parse(getSampleInputStream());
|
||||
assertNotNull(resultList);
|
||||
assertNull(resultList.getVerteilung().getBoatBySailID("SWE 1196").getCrew().getSkipper().getIsaf());
|
||||
assertNull(resultList.getBoatBySailID("SWE 1196").getCrew().getSkipper().getIsaf());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,7 +71,9 @@ public class ParserTest {
|
||||
ResultListParser parser = ParserFactory.INSTANCE.createResultListParser();
|
||||
ResultList resultList = parser.parse(getSampleInputStream());
|
||||
assertNotNull(resultList);
|
||||
assertNull(resultList.getVerteilung().getBoatBySailID("SWE 1196").getRaces().getRaces().iterator().next().getStatus());
|
||||
assertNull(resultList.getBoatBySailID("SWE 1196").getRaces().getRaces().iterator().next().getStatus());
|
||||
assertEquals(MaxPointsReason.NONE, resultList.getBoatBySailID("SWE 1196").getRaces().getRaces()
|
||||
.iterator().next().getMaxPointsReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -79,7 +81,9 @@ public class ParserTest {
|
||||
ResultListParser parser = ParserFactory.INSTANCE.createResultListParser();
|
||||
ResultList resultList = parser.parse(getSampleInputStream());
|
||||
assertNotNull(resultList);
|
||||
assertEquals("DNC", resultList.getVerteilung().getBoatBySailID("GER 1199").getRaces().getRaces().iterator().next().getStatus());
|
||||
assertEquals("DNC", resultList.getBoatBySailID("GER 1199").getRaces().getRaces().iterator().next().getStatus());
|
||||
assertEquals(MaxPointsReason.DNC, resultList.getBoatBySailID("GER 1199").getRaces().getRaces()
|
||||
.iterator().next().getMaxPointsReason());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -89,12 +93,10 @@ 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();
|
||||
Iterable<Boat> boats = resultList.getBoats();
|
||||
assertFalse(Util.isEmpty(boats));
|
||||
assertEquals(48, Util.size(boats));
|
||||
Boat DEN9 = verteilung.getBoatBySailID("DEN 9");
|
||||
Boat DEN9 = resultList.getBoatBySailID("DEN 9");
|
||||
assertNotNull(DEN9);
|
||||
assertEquals(7, (int) DEN9.getPosition());
|
||||
Skipper DEN9Skipper = DEN9.getCrew().getSkipper();
|
||||
|
||||
+2
@@ -8,4 +8,6 @@ public interface ParserFactory {
|
||||
ResultListParser createResultListParser();
|
||||
|
||||
StartberichtParser createStartberichtParser();
|
||||
|
||||
ZipFileParser createZipFileParser();
|
||||
}
|
||||
+11
-1
@@ -17,7 +17,17 @@ public interface ResultList {
|
||||
|
||||
String getDate();
|
||||
|
||||
/**
|
||||
* Point in time when this result list was published
|
||||
*/
|
||||
TimePoint getTimePoint();
|
||||
|
||||
Verteilung getVerteilung();
|
||||
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);
|
||||
}
|
||||
+3
-3
@@ -5,11 +5,11 @@ import java.text.ParseException;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
|
||||
public interface Start {
|
||||
String getBootsklasse();
|
||||
String getBoatClass();
|
||||
|
||||
Integer getWettfahrt();
|
||||
Integer getRaceNumber();
|
||||
|
||||
String getStartgruppe();
|
||||
String getFleetName();
|
||||
|
||||
String getKurs();
|
||||
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
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);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.sap.sailing.kiworesultimport;
|
||||
|
||||
public interface ZipFile {
|
||||
Iterable<Startbericht> getStartberichte();
|
||||
|
||||
Iterable<ResultList> getResultLists();
|
||||
}
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
package com.sap.sailing.kiworesultimport;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
public interface ZipFileParser {
|
||||
ZipFile parse(InputStream inputStream);
|
||||
}
|
||||
+6
@@ -3,6 +3,7 @@ package com.sap.sailing.kiworesultimport.impl;
|
||||
import com.sap.sailing.kiworesultimport.ParserFactory;
|
||||
import com.sap.sailing.kiworesultimport.ResultListParser;
|
||||
import com.sap.sailing.kiworesultimport.StartberichtParser;
|
||||
import com.sap.sailing.kiworesultimport.ZipFileParser;
|
||||
|
||||
public class ParserFactoryImpl implements ParserFactory {
|
||||
|
||||
@@ -15,4 +16,9 @@ public class ParserFactoryImpl implements ParserFactory {
|
||||
public StartberichtParser createStartberichtParser() {
|
||||
return new StartberichtParserImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZipFileParser createZipFileParser() {
|
||||
return new ZipFileParserImpl();
|
||||
}
|
||||
}
|
||||
+24
-6
@@ -2,17 +2,20 @@ package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
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.Boat;
|
||||
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());
|
||||
@@ -58,11 +61,6 @@ public class ResultListImpl extends AbstractNodeWrapper implements ResultList {
|
||||
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;
|
||||
@@ -75,4 +73,24 @@ public class ResultListImpl extends AbstractNodeWrapper implements ResultList {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Boat> getBoats() {
|
||||
List<Boat> result = new ArrayList<Boat>();
|
||||
final NodeList boats = ((Element) ((Element) getNode()).getElementsByTagName("Verteilung").item(0)).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;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -18,17 +18,17 @@ public class StartImpl extends AbstractNodeWrapper implements Start {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBootsklasse() {
|
||||
public String getBoatClass() {
|
||||
return getNode().getAttributes().getNamedItem("bootsklasse").getNodeValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getWettfahrt() {
|
||||
public Integer getRaceNumber() {
|
||||
return Integer.valueOf(getNode().getAttributes().getNamedItem("wettfahrt").getNodeValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStartgruppe() {
|
||||
public String getFleetName() {
|
||||
return getNode().getAttributes().getNamedItem("startgruppe").getNodeValue();
|
||||
}
|
||||
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sap.sailing.domain.common.impl.Util.Triple;
|
||||
import com.sap.sailing.kiworesultimport.ResultList;
|
||||
import com.sap.sailing.kiworesultimport.Start;
|
||||
import com.sap.sailing.kiworesultimport.Startbericht;
|
||||
import com.sap.sailing.kiworesultimport.ZipFile;
|
||||
|
||||
public class ZipFileImpl implements ZipFile {
|
||||
private final Iterable<Startbericht> startberichte;
|
||||
private final Map<Triple<String, Integer, String>, Start> startsByBoatclassAndWettfahrtAndFleet;
|
||||
private final List<ResultList> resultLists;
|
||||
private final Map<String, Map<Integer, Set<String>>> fleetsPerBoatClassAndRace;
|
||||
|
||||
public ZipFileImpl(Iterable<Startbericht> startberichte, Iterable<ResultList> resultLists) {
|
||||
this.fleetsPerBoatClassAndRace = new HashMap<String, Map<Integer, Set<String>>>();
|
||||
this.startberichte = new ArrayList<Startbericht>();
|
||||
this.startsByBoatclassAndWettfahrtAndFleet = new HashMap<Triple<String, Integer, String>, Start>();
|
||||
this.resultLists = new ArrayList<ResultList>();
|
||||
for (Startbericht startbericht : startberichte) {
|
||||
for (Start start : startbericht.getStarts()) {
|
||||
startsByBoatclassAndWettfahrtAndFleet.put(
|
||||
new Triple<String, Integer, String>(start.getBoatClass(), start.getRaceNumber(), start
|
||||
.getFleetName()), start);
|
||||
Map<Integer, Set<String>> fleetsForBoatClass = fleetsPerBoatClassAndRace.get(start.getBoatClass());
|
||||
if (fleetsForBoatClass == null) {
|
||||
fleetsForBoatClass = new HashMap<Integer, Set<String>>();
|
||||
fleetsPerBoatClassAndRace.put(start.getBoatClass(), fleetsForBoatClass);
|
||||
}
|
||||
Set<String> fleetsForTheBoatClassAndRace = fleetsForBoatClass.get(start.getRaceNumber());
|
||||
if (fleetsForTheBoatClassAndRace == null) {
|
||||
fleetsForTheBoatClassAndRace = new HashSet<String>();
|
||||
fleetsForBoatClass.put(start.getRaceNumber(), fleetsForTheBoatClassAndRace);
|
||||
}
|
||||
fleetsForTheBoatClassAndRace.add(start.getFleetName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Startbericht> getStartberichte() {
|
||||
return startberichte;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<ResultList> getResultLists() {
|
||||
return resultLists;
|
||||
}
|
||||
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.sap.sailing.kiworesultimport.impl;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.sap.sailing.kiworesultimport.ZipFile;
|
||||
import com.sap.sailing.kiworesultimport.ZipFileParser;
|
||||
|
||||
public class ZipFileParserImpl implements ZipFileParser {
|
||||
|
||||
@Override
|
||||
public ZipFile parse(InputStream inputStream) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user