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
cc87e312e2
5 files changed
+28
-17
No files matched your search
+1
-1
@@ -179,7 +179,7 @@ public interface DomainFactory {
|
||||
* if not <code>null</code>, after creating the {@link TrackedRace}, the {@link RaceDefinition} is
|
||||
* {@link DynamicRaceDefinitionSet#addRaceDefinition(RaceDefinition) added} to that object.
|
||||
*/
|
||||
Pair<RaceDefinition, TrackedRace> getOrCreateRaceDefinitionAndTrackedRace(TrackedRegatta trackedRegatta, Race race,
|
||||
void getOrCreateRaceDefinitionAndTrackedRace(TrackedRegatta trackedRegatta, Race race,
|
||||
Course course, WindStore windStore, long delayToLiveInMillis, long millisecondsOverWhichToAverageWind,
|
||||
DynamicRaceDefinitionSet raceDefinitionSetToUpdate);
|
||||
|
||||
|
||||
+1
-1
@@ -99,7 +99,7 @@ public class RaceRecord {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
public String getEventName() {
|
||||
return regattaName;
|
||||
}
|
||||
|
||||
+11
-9
@@ -367,7 +367,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pair<RaceDefinition, TrackedRace> getOrCreateRaceDefinitionAndTrackedRace(TrackedRegatta trackedRegatta,
|
||||
public void getOrCreateRaceDefinitionAndTrackedRace(TrackedRegatta trackedRegatta,
|
||||
Race race, Course course, WindStore windStore, long delayToLiveInMillis, long millisecondsOverWhichToAverageWind,
|
||||
DynamicRaceDefinitionSet raceDefinitionSetToUpdate) {
|
||||
synchronized (raceCache) {
|
||||
@@ -377,21 +377,23 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
logger.info("Creating RaceDefinitionImpl for race "+race.getName());
|
||||
raceDefinition = new RaceDefinitionImpl(race.getName(), course, competitorsAndDominantBoatClass.getB(),
|
||||
competitorsAndDominantBoatClass.getA(), getRaceID(race));
|
||||
// add to domain Event only if boat class matches
|
||||
// add to existing regatta only if boat class matches
|
||||
if (raceDefinition.getBoatClass() == trackedRegatta.getRegatta().getBoatClass()) {
|
||||
trackedRegatta.getRegatta().addRace(raceDefinition);
|
||||
|
||||
createTrackedRace(trackedRegatta, raceDefinition, windStore,
|
||||
delayToLiveInMillis, millisecondsOverWhichToAverageWind, raceDefinitionSetToUpdate);
|
||||
logger.info("Added race "+raceDefinition+" to regatta "+trackedRegatta.getRegatta());
|
||||
|
||||
synchronized (raceCache) {
|
||||
raceCache.put(race, raceDefinition);
|
||||
raceCache.notifyAll();
|
||||
}
|
||||
} else {
|
||||
logger.warning("Not adding race "+raceDefinition+" to regatta "+trackedRegatta.getRegatta()+
|
||||
" because boat class "+raceDefinition.getBoatClass()+" doesn't match regatta's boat class "+
|
||||
trackedRegatta.getRegatta().getBoatClass());
|
||||
}
|
||||
TrackedRace trackedRace = createTrackedRace(trackedRegatta, raceDefinition, windStore,
|
||||
delayToLiveInMillis, millisecondsOverWhichToAverageWind, raceDefinitionSetToUpdate);
|
||||
synchronized (raceCache) {
|
||||
raceCache.put(race, raceDefinition);
|
||||
raceCache.notifyAll();
|
||||
}
|
||||
return new Pair<RaceDefinition, TrackedRace>(raceDefinition, trackedRace);
|
||||
} else {
|
||||
throw new RuntimeException("Race "+race.getName()+" already exists");
|
||||
}
|
||||
|
||||
+4
-3
@@ -10,6 +10,7 @@ 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;
|
||||
|
||||
@@ -42,9 +43,9 @@ public abstract class AbstractMongoDBTest {
|
||||
assertNotNull(db);
|
||||
}
|
||||
|
||||
private void dropAllCollections(DB theDB) {
|
||||
for (String collectionName : theDB.getCollectionNames()) {
|
||||
DBCollection c = theDB.getCollection(collectionName);
|
||||
private void dropAllCollections(DB theDB) throws InterruptedException {
|
||||
for (CollectionNames collectionName : CollectionNames.values()) {
|
||||
DBCollection c = theDB.getCollection(collectionName.name());
|
||||
c.drop();
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
@@ -27,6 +28,13 @@ import com.sap.sailing.domain.tracking.impl.WindImpl;
|
||||
public class TestStoringAndRetrievingWindData extends AbstractMongoDBTest {
|
||||
private static final String WIND_TEST_COLLECTION = "wind_test_collection";
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void dropTestDB() throws UnknownHostException, MongoException, InterruptedException {
|
||||
super.dropTestDB();
|
||||
db.getCollection(WIND_TEST_COLLECTION).drop();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDBConnection() throws UnknownHostException, MongoException {
|
||||
DBCollection coll = db.getCollection(WIND_TEST_COLLECTION);
|
||||
@@ -57,8 +65,8 @@ public class TestStoringAndRetrievingWindData extends AbstractMongoDBTest {
|
||||
DBCollection coll = db.getCollection(WIND_TEST_COLLECTION);
|
||||
assertNotNull(coll);
|
||||
DBObject object = coll.findOne();
|
||||
assertEquals(object.get("truebearingdeg"), 234.3);
|
||||
assertEquals(object.get("knotspeed"), 10.7);
|
||||
assertEquals(234.3, object.get("truebearingdeg"));
|
||||
assertEquals(10.7, object.get("knotspeed"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +82,7 @@ public class TestStoringAndRetrievingWindData extends AbstractMongoDBTest {
|
||||
}
|
||||
|
||||
{
|
||||
Thread.sleep(1000); // wait until MongoDB has recorded the change and made it visible
|
||||
Thread.sleep(3000); // wait until MongoDB has recorded the change and made it visible
|
||||
Mongo mongo = newMongo();
|
||||
assertNotNull(mongo);
|
||||
DB db = mongo.getDB(getDBConfiguration().getDatabaseName());
|
||||
|
||||
Reference in new issue
Block a user