removed more Mongo specifics from the factory interfaces

This commit is contained in:
Axel Uhl
2011-07-29 17:22:34 +02:00
parent b0c2cdfa41
commit 86c4eaa1b0
5 changed files with 6 additions and 17 deletions
@@ -24,6 +24,7 @@ import com.sap.sailing.domain.tracking.impl.WindImpl;
import com.sap.sailing.mongodb.DomainObjectFactory;
import com.sap.sailing.mongodb.MongoObjectFactory;
import com.sap.sailing.mongodb.impl.DomainObjectFactoryImpl;
import com.sap.sailing.mongodb.impl.MongoObjectFactoryImpl;
import com.sap.sailing.mongodb.impl.MongoWindStoreFactoryImpl;
public class TestStoringAndRetrievingWindData implements MongoDBTest {
@@ -86,7 +87,7 @@ public class TestStoringAndRetrievingWindData implements MongoDBTest {
Wind wind = new WindImpl(new DegreePosition(123, 45), now, new KnotSpeedWithBearingImpl(10.4,
new DegreeBearingImpl(355.5)));
{
DBObject windForMongo = MongoObjectFactory.INSTANCE.storeWind(wind);
DBObject windForMongo = ((MongoObjectFactoryImpl) MongoObjectFactory.INSTANCE).storeWind(wind);
DBCollection coll = db.getCollection(WIND_TEST_COLLECTION);
coll.insert(windForMongo);
}
@@ -1,6 +1,5 @@
package com.sap.sailing.mongodb;
import com.mongodb.DBObject;
import com.sap.sailing.domain.base.Event;
import com.sap.sailing.domain.base.RaceDefinition;
import com.sap.sailing.domain.tracking.WindSource;
@@ -10,7 +9,7 @@ import com.sap.sailing.mongodb.impl.DomainObjectFactoryImpl;
import com.sap.sailing.mongodb.impl.MongoWindStoreFactoryImpl;
/**
* Offers methods to construct domain objects from {@link DBObject MongoDB objects}.
* Offers methods to load domain objects from a Mongo DB
*
* @author Axel Uhl (d043530)
*
@@ -1,12 +1,10 @@
package com.sap.sailing.mongodb;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
import com.sap.sailing.domain.base.Event;
import com.sap.sailing.domain.base.RaceDefinition;
import com.sap.sailing.domain.tracking.TrackedEvent;
import com.sap.sailing.domain.tracking.TrackedRace;
import com.sap.sailing.domain.tracking.Wind;
import com.sap.sailing.domain.tracking.WindSource;
import com.sap.sailing.domain.tractracadapter.TracTracConfiguration;
import com.sap.sailing.mongodb.impl.MongoObjectFactoryImpl;
@@ -21,8 +19,6 @@ import com.sap.sailing.mongodb.impl.MongoWindStoreFactoryImpl;
public interface MongoObjectFactory {
MongoObjectFactory INSTANCE = new MongoObjectFactoryImpl(MongoWindStoreFactoryImpl.getDefaultInstance().getDB());
DBObject storeWind(Wind wind);
/**
* Registers for changes of the wind coming from <code>windSource</code> on the <code>trackedRace</code>. Each
* update received will be appended to the MongoDB and can later be retrieved. The key used to identify the race is
@@ -30,10 +26,6 @@ public interface MongoObjectFactory {
*/
void addWindTrackDumper(TrackedEvent trackedEvent, TrackedRace trackedRace, WindSource windSource);
DBCollection getWindTrackCollection();
DBObject storeWindTrackEntry(Event event, RaceDefinition race, WindSource windSource, Wind wind);
/**
* Inserts/updates based on the {@link TracTracConfiguration#getName() name}. Any equally-named
* config previously contained in the DB will be replaced / updated. Afterwards,
@@ -27,7 +27,6 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
this.database = database;
}
@Override
public DBObject storeWind(Wind wind) {
DBObject result = new BasicDBObject();
storePositioned(wind, result);
@@ -67,12 +66,10 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
windTrack.addListener(new MongoWindListener(trackedEvent, trackedRace, windSource, this, database));
}
@Override
public DBCollection getWindTrackCollection() {
return database.getCollection(CollectionNames.WIND_TRACKS.name());
}
@Override
public DBObject storeWindTrackEntry(Event event, RaceDefinition race, WindSource windSource, Wind wind) {
BasicDBObject result = new BasicDBObject();
result.put(FieldNames.EVENT_NAME.name(), event.getName());
@@ -13,7 +13,7 @@ public class MongoWindListener implements com.sap.sailing.domain.tracking.WindLi
private final TrackedEvent trackedEvent;
private final TrackedRace trackedRace;
private final WindSource windSource;
private final MongoObjectFactory mongoObjectFactory;
private final MongoObjectFactoryImpl mongoObjectFactory;
private final DBCollection windTracksCollection;
public MongoWindListener(TrackedEvent trackedEvent, TrackedRace trackedRace, WindSource windSource,
@@ -22,8 +22,8 @@ public class MongoWindListener implements com.sap.sailing.domain.tracking.WindLi
this.trackedEvent = trackedEvent;
this.trackedRace = trackedRace;
this.windSource = windSource;
this.mongoObjectFactory = mongoObjectFactory;
this.windTracksCollection = mongoObjectFactory.getWindTrackCollection();
this.mongoObjectFactory = (MongoObjectFactoryImpl) mongoObjectFactory;
this.windTracksCollection = this.mongoObjectFactory.getWindTrackCollection();
}
@Override