mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 18:20:14 +00:00
include race id in denoteForTrackingEvent -> allows choosing custom stable ID
This commit is contained in:
1 parent
70ae0e9543
commit
ec15b110c8
16 files changed
+44
-25
No files matched your search
+2
-1
@@ -1262,7 +1262,8 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
String raceName = (String) dbObject.get(FieldNames.RACE_NAME.name());
|
||||
BoatClass boatClass = baseDomainFactory.getOrCreateBoatClass((String) dbObject.get(FieldNames.BOAT_CLASS_NAME.name()));
|
||||
return raceLogEventFactory.createDenoteForTrackingEvent(createdAt, author, logicalTimePoint, id, passId, raceName, boatClass);
|
||||
Serializable raceId = (Serializable) dbObject.get(FieldNames.RACE_ID.name());
|
||||
return raceLogEventFactory.createDenoteForTrackingEvent(createdAt, author, logicalTimePoint, id, passId, raceName, boatClass, raceId);
|
||||
}
|
||||
|
||||
private RaceLogEvent loadRaceLogStartEvent(TimePoint createdAt, RaceLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
|
||||
+1
@@ -844,6 +844,7 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), DenoteForTrackingEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_NAME.name(), event.getRaceName());
|
||||
result.put(FieldNames.BOAT_CLASS_NAME.name(), event.getBoatClass().getName());
|
||||
result.put(FieldNames.RACE_ID.name(), event.getRaceId());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class RaceLogConnectivityParams implements RaceTrackingConnectivityParame
|
||||
public RaceTracker createRaceTracker(Regatta regatta, TrackedRegattaRegistry trackedRegattaRegistry,
|
||||
WindStore windStore, GPSFixStore gpsFixStore) {
|
||||
if (regatta == null) {
|
||||
BoatClass boatClass = new RaceInformationFinder(getRaceLog()).analyze().getB();
|
||||
BoatClass boatClass = new RaceInformationFinder(getRaceLog()).analyze().getBoatClass();
|
||||
regatta = service.getOrCreateDefaultRegatta("RaceLog-tracking default Regatta", boatClass.getName(),
|
||||
UUID.randomUUID());
|
||||
}
|
||||
|
||||
+10
-6
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.domain.racelogtracking.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -39,6 +40,7 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogCourseDesignChangedEvent;
|
||||
import com.sap.sailing.domain.racelog.analyzing.impl.LastPublishedCourseDesignFinder;
|
||||
import com.sap.sailing.domain.racelog.impl.BaseRaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.racelog.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.racelog.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.racelog.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelog.tracking.DeviceMapping;
|
||||
@@ -341,15 +343,16 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
RaceColumn raceColumn = params.getRaceColumn();
|
||||
Fleet fleet = params.getFleet();
|
||||
|
||||
Pair<String, BoatClass> raceInfo = new RaceInformationFinder(raceLog).analyze();
|
||||
BoatClass boatClass = raceInfo.getB();
|
||||
DenoteForTrackingEvent denoteEvent = new RaceInformationFinder(raceLog).analyze();
|
||||
BoatClass boatClass = denoteEvent.getBoatClass();
|
||||
String raceName = denoteEvent.getRaceName();
|
||||
CourseBase courseBase = new LastPublishedCourseDesignFinder(raceLog).analyze();
|
||||
if (courseBase == null) {
|
||||
courseBase = new CourseDataImpl("Default course for " + raceInfo.getA());
|
||||
logger.log(Level.FINE, "Using empty course in creation of race " + raceInfo.getA());
|
||||
courseBase = new CourseDataImpl("Default course for " + raceName);
|
||||
logger.log(Level.FINE, "Using empty course in creation of race " + raceName);
|
||||
}
|
||||
|
||||
Course course = new CourseImpl(raceInfo.getA() + " course", courseBase.getWaypoints());
|
||||
Course course = new CourseImpl(raceName + " course", courseBase.getWaypoints());
|
||||
|
||||
if (raceColumn.getTrackedRace(fleet) != null) {
|
||||
try {
|
||||
@@ -359,7 +362,8 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
}
|
||||
|
||||
Iterable<Competitor> competitors = new RegisteredCompetitorsAnalyzer(raceLog).analyze();
|
||||
final RaceDefinition raceDef = new RaceDefinitionImpl(raceInfo.getA(), course, boatClass, competitors);
|
||||
Serializable raceId = denoteEvent.getRaceId();
|
||||
final RaceDefinition raceDef = new RaceDefinitionImpl(raceName, course, boatClass, competitors, raceId);
|
||||
|
||||
Iterable<Sideline> sidelines = Collections.<Sideline> emptyList();
|
||||
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ public class RaceLogTrackingAdapterImpl implements RaceLogTrackingAdapter {
|
||||
}
|
||||
|
||||
RaceLogEvent event = RaceLogEventFactory.INSTANCE.createDenoteForTrackingEvent(MillisecondsTimePoint.now(),
|
||||
service.getServerAuthor(), raceLog.getCurrentPassId(), raceName, boatClass);
|
||||
service.getServerAuthor(), raceLog.getCurrentPassId(), raceName, boatClass, UUID.randomUUID());
|
||||
raceLog.add(event);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ public interface RaceLogEventFactory {
|
||||
DeviceIdentifier device, Mark mappedTo, int passId, TimePoint from, TimePoint to);
|
||||
|
||||
DenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint logicalTimePoint, RaceLogEventAuthor author, int passId,
|
||||
String raceName, BoatClass boatClass);
|
||||
String raceName, BoatClass boatClass, Serializable raceId);
|
||||
|
||||
StartTrackingEvent createStartTrackingEvent(TimePoint logicalTimePoint, RaceLogEventAuthor author, int passId);
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ public interface RaceLogEventRestoreFactory extends RaceLogEventFactory {
|
||||
TimePoint logicalTimePoint, Serializable pId, DeviceIdentifier device, Mark mappedTo, int passId, TimePoint from, TimePoint to);
|
||||
|
||||
DenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint createdAt, RaceLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId, String raceName, BoatClass boatClass);
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId, String raceName, BoatClass boatClass, Serializable raceId);
|
||||
|
||||
StartTrackingEvent createStartTrackingEvent(TimePoint createdAt, RaceLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId);
|
||||
|
||||
+3
-2
@@ -235,8 +235,9 @@ public class RaceLogEventFactoryImpl implements RaceLogEventFactory {
|
||||
|
||||
@Override
|
||||
public DenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint logicalTimePoint, RaceLogEventAuthor author, int passId,
|
||||
String raceName, BoatClass boatClass) {
|
||||
return new DenoteForTrackingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(), passId, raceName, boatClass);
|
||||
String raceName, BoatClass boatClass, Serializable raceId) {
|
||||
return new DenoteForTrackingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(), passId, raceName,
|
||||
boatClass, raceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -143,8 +143,8 @@ public class RaceLogEventRestoreFactoryImpl extends RaceLogEventFactoryImpl impl
|
||||
|
||||
@Override
|
||||
public DenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint createdAt, RaceLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId, String raceName, BoatClass boatClass) {
|
||||
return new DenoteForTrackingEventImpl(createdAt, author, logicalTimePoint, pId, passId, raceName, boatClass);
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId, String raceName, BoatClass boatClass, Serializable raceId) {
|
||||
return new DenoteForTrackingEventImpl(createdAt, author, logicalTimePoint, pId, passId, raceName, boatClass, raceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
@@ -1,5 +1,7 @@
|
||||
package com.sap.sailing.domain.racelog.tracking;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
@@ -17,4 +19,5 @@ import com.sap.sailing.domain.racelog.Revokable;
|
||||
public interface DenoteForTrackingEvent extends RaceLogEvent, Revokable {
|
||||
String getRaceName();
|
||||
BoatClass getBoatClass();
|
||||
Serializable getRaceId();
|
||||
}
|
||||
+3
-6
@@ -1,23 +1,20 @@
|
||||
package com.sap.sailing.domain.racelog.tracking.analyzing.impl;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.analyzing.impl.RaceLogAnalyzer;
|
||||
import com.sap.sailing.domain.racelog.tracking.DenoteForTrackingEvent;
|
||||
|
||||
public class RaceInformationFinder extends RaceLogAnalyzer<Pair<String, BoatClass>> {
|
||||
public class RaceInformationFinder extends RaceLogAnalyzer<DenoteForTrackingEvent> {
|
||||
public RaceInformationFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Pair<String, BoatClass> performAnalysis() {
|
||||
protected DenoteForTrackingEvent performAnalysis() {
|
||||
for (RaceLogEvent event : getAllEvents()) {
|
||||
if (event instanceof DenoteForTrackingEvent) {
|
||||
DenoteForTrackingEvent e = (DenoteForTrackingEvent) event;
|
||||
return new Pair<String, BoatClass>(e.getRaceName(), e.getBoatClass());
|
||||
return (DenoteForTrackingEvent) event;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -17,14 +17,16 @@ DenoteForTrackingEvent {
|
||||
|
||||
private final String raceName;
|
||||
private final BoatClass boatClass;
|
||||
private final Serializable raceId;
|
||||
|
||||
public DenoteForTrackingEventImpl(TimePoint createdAt,
|
||||
RaceLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
Serializable pId, int pPassId,
|
||||
String raceName, BoatClass boatClass) {
|
||||
String raceName, BoatClass boatClass, Serializable raceId) {
|
||||
super(createdAt, author, logicalTimePoint, pId, Collections.<Competitor>emptyList(), pPassId);
|
||||
this.raceName = raceName;
|
||||
this.boatClass = boatClass;
|
||||
this.raceId = raceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -42,4 +44,8 @@ DenoteForTrackingEvent {
|
||||
return boatClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getRaceId() {
|
||||
return raceId;
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -214,8 +214,10 @@ public class StoreAndLoadRaceLogEventsTest extends AbstractMongoDBTest {
|
||||
public void testStoreAndLoadDenoteForTrackingEvent() {
|
||||
String raceName = "race";
|
||||
BoatClass boatClass = DomainFactory.INSTANCE.getOrCreateBoatClass("49er");
|
||||
UUID raceId = UUID.randomUUID();
|
||||
DenoteForTrackingEvent expectedEvent = eventFactory.createDenoteForTrackingEvent(
|
||||
expectedEventTime, author, expectedEventTime, expectedId, expectedPassId, raceName, boatClass);
|
||||
expectedEventTime, author, expectedEventTime, expectedId, expectedPassId, raceName, boatClass,
|
||||
raceId);
|
||||
|
||||
DBObject dbObject = mongoFactory.storeRaceLogEntry(logIdentifier, expectedEvent);
|
||||
DenoteForTrackingEvent actualEvent = loadEvent(dbObject);
|
||||
@@ -223,6 +225,7 @@ public class StoreAndLoadRaceLogEventsTest extends AbstractMongoDBTest {
|
||||
assertBaseFields(expectedEvent, actualEvent);
|
||||
assertEquals(boatClass, actualEvent.getBoatClass());
|
||||
assertEquals(raceName, actualEvent.getRaceName());
|
||||
assertEquals(raceId, actualEvent.getRaceId());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -205,7 +205,7 @@ public class RaceLogEventSerializerTest {
|
||||
@Test
|
||||
public void testDenoteForTrackingSerializer() {
|
||||
// we use the real event type here because we do not want to re-implement the dispatching.
|
||||
RaceLogEvent event = factory.createDenoteForTrackingEvent(null, author, 0, "", null);
|
||||
RaceLogEvent event = factory.createDenoteForTrackingEvent(null, author, 0, "", null, null);
|
||||
serializer.serialize(event);
|
||||
verify(denoteForTrackingEventSerializer).serialize(event);
|
||||
}
|
||||
|
||||
+2
-1
@@ -26,7 +26,8 @@ public class RaceLogDenoteForTrackingEventDeserializer extends BaseRaceLogEventD
|
||||
String raceName = (String) object.get(RaceLogDenoteForTrackingEventSerializer.FIELD_RACE_NAME);
|
||||
BoatClass boatClass = DomainFactory.INSTANCE.getOrCreateBoatClass(
|
||||
(String) object.get(RaceLogDenoteForTrackingEventSerializer.FIELD_BOAT_CLASS));
|
||||
Serializable raceId = (Serializable) object.get(RaceLogDenoteForTrackingEventSerializer.FIELD_RACE_ID);
|
||||
|
||||
return factory.createDenoteForTrackingEvent(createdAt, author, timePoint, id, passId, raceName, boatClass);
|
||||
return factory.createDenoteForTrackingEvent(createdAt, author, timePoint, id, passId, raceName, boatClass, raceId);
|
||||
}
|
||||
}
|
||||
+2
@@ -11,6 +11,7 @@ public class RaceLogDenoteForTrackingEventSerializer extends BaseRaceLogEventSer
|
||||
public static final String VALUE_CLASS = DenoteForTrackingEvent.class.getSimpleName();
|
||||
public static final String FIELD_RACE_NAME = "raceName";
|
||||
public static final String FIELD_BOAT_CLASS = "boatClass";
|
||||
public static final String FIELD_RACE_ID = "raceId";
|
||||
|
||||
public RaceLogDenoteForTrackingEventSerializer(
|
||||
JsonSerializer<Competitor> competitorSerializer) {
|
||||
@@ -29,6 +30,7 @@ public class RaceLogDenoteForTrackingEventSerializer extends BaseRaceLogEventSer
|
||||
JSONObject result = super.serialize(event);
|
||||
result.put(FIELD_RACE_NAME, event.getRaceName());
|
||||
result.put(FIELD_BOAT_CLASS, event.getBoatClass().getName());
|
||||
result.put(FIELD_RACE_ID, event.getRaceId());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user