mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 18:33:54 +00:00
Merge branch 'regatta-log'
This commit is contained in:
commit
ad8c1cd036
365 files changed
+6998
-3951
No files matched your search
@@ -596,8 +596,13 @@ if [[ "$@" == "build" ]] || [[ "$@" == "all" ]]; then
|
||||
PATH=$PATH:$ANDROID_HOME/platform-tools
|
||||
|
||||
RC_APP_VERSION=`grep "android:versionCode=" mobile/com.sap.$PROJECT_TYPE.racecommittee.app/AndroidManifest.xml | cut -d "\"" -f 2`
|
||||
echo "RC_APPVERSION=$RC_APP_VERSION"
|
||||
extra="$extra -Drc-app-api-version=$RC_APP_VERSION"
|
||||
echo "RC_APP_VERSION=$RC_APP_VERSION"
|
||||
extra="$extra -Drc-app-version=$RC_APP_VERSION"
|
||||
|
||||
TRACKING_APP_VERSION=`grep "android:versionCode=" mobile/com.sap.$PROJECT_TYPE.android.tracking.app/AndroidManifest.xml | cut -d "\"" -f 2`
|
||||
echo "TRACKING_APP_VERSION=$TRACKING_APP_VERSION"
|
||||
extra="$extra -Dtracking-app-version=$TRACKING_APP_VERSION"
|
||||
|
||||
|
||||
else
|
||||
echo "INFO: Deactivating mobile modules"
|
||||
|
||||
@@ -17,6 +17,9 @@ import org.osgi.util.tracker.ServiceTracker;
|
||||
import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
import com.sap.sailing.domain.persistence.MongoRaceLogStoreFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoRegattaLogStoreFactory;
|
||||
import com.sap.sailing.domain.racelog.RaceLogStore;
|
||||
import com.sap.sailing.domain.regattalog.RegattaLogStore;
|
||||
import com.sap.sailing.domain.tracking.RaceTracker;
|
||||
import com.sap.sailing.domain.tracking.TrackerManager;
|
||||
import com.sap.sailing.domain.tractracadapter.RaceRecord;
|
||||
@@ -77,17 +80,27 @@ public class TracTrac {
|
||||
regattaForRaceRecord = regatta.getRegattaIdentifier();
|
||||
}
|
||||
}
|
||||
getTracTracAdapter().addTracTracRace((TrackerManager)getService(), regattaForRaceRecord,
|
||||
record.getParamURL(), /*effectiveLiveURI*/ null,
|
||||
record.getStoredURI(), new URI(""),
|
||||
new MillisecondsTimePoint(record.getTrackingStartTime().asMillis()),
|
||||
new MillisecondsTimePoint(record.getTrackingEndTime().asMillis()),
|
||||
MongoRaceLogStoreFactory.INSTANCE.getMongoRaceLogStore(getService().getMongoObjectFactory(), getService().getDomainObjectFactory()),
|
||||
RaceTracker.TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS, /*simulateWithStartTimeNow*/false,
|
||||
/*tracTracUsername*/"", /*tracTracPassword*/"",
|
||||
record.getRaceStatus(), record.getRaceVisibility());
|
||||
RaceLogStore raceLogStore = MongoRaceLogStoreFactory.INSTANCE.getMongoRaceLogStore(getService()
|
||||
.getMongoObjectFactory(), getService().getDomainObjectFactory());
|
||||
RegattaLogStore regattaLogStore = MongoRegattaLogStoreFactory.INSTANCE.getMongoRegattaLogStore(
|
||||
getService().getMongoObjectFactory(), getService().getDomainObjectFactory());
|
||||
getTracTracAdapter().addTracTracRace(
|
||||
(TrackerManager) getService(),
|
||||
regattaForRaceRecord,
|
||||
record.getParamURL(), /* effectiveLiveURI */
|
||||
null,
|
||||
record.getStoredURI(),
|
||||
new URI(""),
|
||||
new MillisecondsTimePoint(record.getTrackingStartTime().asMillis()),
|
||||
new MillisecondsTimePoint(record.getTrackingEndTime().asMillis()),
|
||||
raceLogStore, regattaLogStore,
|
||||
RaceTracker.TIMEOUT_FOR_RECEIVING_RACE_DEFINITION_IN_MILLISECONDS, /* simulateWithStartTimeNow */
|
||||
false,
|
||||
/* tracTracUsername */"", /* tracTracPassword */"", record.getRaceStatus(),
|
||||
record.getRaceVisibility());
|
||||
} else {
|
||||
logger.info("Ignoring race " + record.getName() + " because it is in status " + record.getRaceStatus() + " and visibility " + record.getRaceVisibility());
|
||||
logger.info("Ignoring race " + record.getName() + " because it is in status "
|
||||
+ record.getRaceStatus() + " and visibility " + record.getRaceVisibility());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
package com.sap.sailing.domain.common.abstractlog;
|
||||
|
||||
public class NotRevokableException extends Exception {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class NotRevokableException extends Exception implements Serializable {
|
||||
private static final long serialVersionUID = 6825451915706047105L;
|
||||
|
||||
public NotRevokableException() {
|
||||
|
||||
+2
-2
@@ -23,11 +23,11 @@ public class RaceColumnDTO extends NamedDTO implements Serializable {
|
||||
private Map<FleetDTO, RaceDTO> racesPerFleet;
|
||||
private Double explicitFactor;
|
||||
private double effectiveFactor;
|
||||
|
||||
private Map<FleetDTO, RaceLogTrackingInfoDTO> raceLogTrackingInfos = new HashMap<FleetDTO, RaceLogTrackingInfoDTO>();
|
||||
private Map<FleetDTO, RaceLogTrackingInfoDTO> raceLogTrackingInfos;
|
||||
|
||||
public RaceColumnDTO() {
|
||||
trackedRaceIdentifiersPerFleet = new HashMap<FleetDTO, RegattaAndRaceIdentifier>();
|
||||
raceLogTrackingInfos = new HashMap<FleetDTO, RaceLogTrackingInfoDTO>();
|
||||
racesPerFleet = new HashMap<FleetDTO, RaceDTO>();
|
||||
fleets = new ArrayList<FleetDTO>();
|
||||
}
|
||||
|
||||
+18
-22
@@ -1,32 +1,28 @@
|
||||
package com.sap.sailing.domain.common.racelog.tracking;
|
||||
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogServletConstants;
|
||||
|
||||
/**
|
||||
* Shared between GWT and Android. Used for creating and deciphering the URL
|
||||
* encoded by the QRCode, which gives the tracking app all necessary information
|
||||
* for creating the device mapping.
|
||||
* This includes the leaderboard name, race-column name and fleet name to identify
|
||||
* which RaceLog to add the {@code DeviceMappingEvent} to. Also, either a competitor
|
||||
* or mark ID is added, to which the device should be mapped. Timestamps for the
|
||||
* beginning and the end of the mapping are also included.
|
||||
* Shared between GWT and Android. Used for creating and deciphering the URL encoded by the QRCode, which gives the
|
||||
* tracking app all necessary information for creating the device mapping of either the race or leaderboard/regatta.
|
||||
* <p>
|
||||
* The URL points to the apk-file of the app deployed to the {@code www} directory
|
||||
* of the server, with additional {@code GET}-parameters:
|
||||
* <ul>
|
||||
* <li>{@link RaceLogServletConstants#PARAMS_LEADERBOARD_NAME}</li>
|
||||
* <li>{@link RaceLogServletConstants#PARAMS_RACE_COLUMN_NAME}</li>
|
||||
* <li>{@link RaceLogServletConstants#PARAMS_RACE_FLEET_NAME}</li>
|
||||
* <li>either {@link #COMPETITOR_ID_AS_STRING} or {@link #MARK_ID_AS_STRING}</li>
|
||||
* <li>{@link #FROM_MILLIS}</li>
|
||||
* <li>{@link #TO_MILLIS}</li>
|
||||
* </ul>
|
||||
* The field that server for mapping a device for an individual race are deprecated (see {@link DeviceMappingOnRaceQRCodeWidget}).
|
||||
* <p>
|
||||
* The structure of the URL is documented in the <a href="http://wiki.sapsailing.com/wiki/tracking-app-api-v1-draft">Wiki</a>.
|
||||
* {@code http://<host>/tracking/checkin?event_id=<e>&leaderboard_name=<l>&competitor_id=<c>}
|
||||
*
|
||||
* @author Fredrik Teschke
|
||||
*/
|
||||
public interface DeviceMappingConstants {
|
||||
static final String COMPETITOR_ID_AS_STRING = "competitor";
|
||||
static final String MARK_ID_AS_STRING = "mark";
|
||||
static final String FROM_MILLIS = "from";
|
||||
static final String TO_MILLIS = "to";
|
||||
static final String URL_BASE = "/tracking/checkin";
|
||||
static final String EVENT_ID = "event_id";
|
||||
static final String LEADERBOARD_NAME = "leaderboardName";
|
||||
static final String COMPETITOR_ID_AS_STRING = "competitorId";
|
||||
static final String MARK_ID_AS_STRING = "markId";
|
||||
static final String DEVICE_UUID = "deviceUuid";
|
||||
static final String DEVICE_TYPE = "deviceType";
|
||||
static final String PUSH_DEVICE_ID = "pushDeviceId";
|
||||
static final String FROM_MILLIS = "fromMillis";
|
||||
static final String TO_MILLIS = "toMillis";
|
||||
@Deprecated
|
||||
static final String APK_PATH = "/apps/com.sap.sailing.android.tracking.app.apk";
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.sap.sailing.domain.common.racelog.tracking;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class DoesNotHaveRegattaLogException extends Exception implements Serializable {
|
||||
private static final long serialVersionUID = 963948633131929332L;
|
||||
}
|
||||
+1
-1
@@ -9,5 +9,5 @@ package com.sap.sailing.domain.common.racelog.tracking;
|
||||
*
|
||||
*/
|
||||
public interface MappableToDevice {
|
||||
|
||||
String getIdAsString();
|
||||
}
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
package com.sap.sailing.domain.common.racelog.tracking;
|
||||
|
||||
public class NoCorrespondingServiceRegisteredException extends RuntimeException {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class NoCorrespondingServiceRegisteredException extends RuntimeException implements Serializable {
|
||||
public String type;
|
||||
public String serviceInterface;
|
||||
private static final long serialVersionUID = -358955216089477585L;
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
package com.sap.sailing.domain.common.racelog.tracking;
|
||||
|
||||
public class NotDenotedForRaceLogTrackingException extends Exception {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class NotDenotedForRaceLogTrackingException extends Exception implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6721038282862173471L;
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
package com.sap.sailing.domain.common.racelog.tracking;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
public class TransformationException extends IOException {
|
||||
public class TransformationException extends IOException implements Serializable {
|
||||
private static final long serialVersionUID = -7795777645371428971L;
|
||||
|
||||
public TransformationException() {
|
||||
|
||||
@@ -21,7 +21,8 @@ Export-Package: com.sap.sailing.domain.persistence,
|
||||
com.sap.sailing.mongodb.test,
|
||||
com.sap.sailing.server.gateway.test,
|
||||
com.sap.sailing.domain.racelogtrackingadapter.testsupport,
|
||||
com.sap.sailing.domain.racelogtrackingadapter.test",
|
||||
com.sap.sailing.domain.racelogtrackingadapter.test,
|
||||
com.sap.sailing.server",
|
||||
com.sap.sailing.domain.persistence.media,
|
||||
com.sap.sailing.domain.persistence.racelog.tracking,
|
||||
com.sap.sailing.domain.persistence.racelog.tracking.impl;
|
||||
|
||||
+4
@@ -8,6 +8,7 @@ import java.util.Set;
|
||||
|
||||
import com.mongodb.DBObject;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
@@ -25,6 +26,7 @@ import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroupResolver;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardRegistry;
|
||||
import com.sap.sailing.domain.racelog.RaceLogIdentifier;
|
||||
import com.sap.sailing.domain.regattalike.RegattaLikeIdentifier;
|
||||
import com.sap.sailing.domain.tracking.TrackedRegattaRegistry;
|
||||
import com.sap.sailing.domain.tracking.WindTrack;
|
||||
|
||||
@@ -115,6 +117,8 @@ public interface DomainObjectFactory {
|
||||
Map<String, Regatta> loadRaceIDToRegattaAssociations(RegattaRegistry regattaRegistry);
|
||||
|
||||
RaceLog loadRaceLog(RaceLogIdentifier identifier);
|
||||
|
||||
RegattaLog loadRegattaLog(RegattaLikeIdentifier identifier);
|
||||
|
||||
/**
|
||||
* Loads all competitors, and resolves them via the domain factory.
|
||||
|
||||
+4
@@ -17,6 +17,7 @@ import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.LeaderboardGroup;
|
||||
import com.sap.sailing.domain.racelog.RaceLogIdentifier;
|
||||
import com.sap.sailing.domain.regattalike.RegattaLikeIdentifier;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
import com.sap.sailing.domain.tracking.TrackedRegatta;
|
||||
|
||||
@@ -130,7 +131,10 @@ public interface MongoObjectFactory {
|
||||
void storeDeviceConfiguration(DeviceConfigurationMatcher matcher, DeviceConfiguration configuration);
|
||||
|
||||
void removeDeviceConfiguration(DeviceConfigurationMatcher matcher);
|
||||
|
||||
void removeRaceLog(RaceLogIdentifier identifier);
|
||||
|
||||
void removeRegattaLog(RegattaLikeIdentifier identifier);
|
||||
|
||||
void storeResultUrl(String resultProviderName, URL url);
|
||||
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.sap.sailing.domain.persistence;
|
||||
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLogEventVisitor;
|
||||
import com.sap.sailing.domain.persistence.impl.MongoRegattaLogStoreFactoryImpl;
|
||||
import com.sap.sailing.domain.regattalike.RegattaLikeIdentifier;
|
||||
import com.sap.sailing.domain.regattalog.RegattaLogStore;
|
||||
|
||||
public interface MongoRegattaLogStoreFactory {
|
||||
MongoRegattaLogStoreFactory INSTANCE = new MongoRegattaLogStoreFactoryImpl();
|
||||
|
||||
/**
|
||||
* Gets the default Mongo store based on the properties mongo.hostname[=localhost], mongo.port[=27017]
|
||||
* and mongo.dbName[=<contents of constant {@link #DEFAULT_DB_NAME}>] specified in the bundle context
|
||||
*/
|
||||
RegattaLogStore getMongoRegattaLogStore(MongoObjectFactory mongoObjectFactory, DomainObjectFactory domainObjectFactory);
|
||||
|
||||
RegattaLogEventVisitor getMongoRegattaLogStoreVisitor(RegattaLikeIdentifier identifier, MongoObjectFactory mongoObjectFactory);
|
||||
}
|
||||
+3
@@ -71,8 +71,11 @@ public enum CollectionNames {
|
||||
* Stores competitors for smartphone tracking.
|
||||
*/
|
||||
COMPETITORS,
|
||||
|
||||
RACE_LOGS,
|
||||
|
||||
REGATTA_LOGS,
|
||||
|
||||
/**
|
||||
* Stores configurations for mobile devices.
|
||||
*/
|
||||
|
||||
+171
-31
@@ -30,7 +30,6 @@ import com.mongodb.DBObject;
|
||||
import com.mongodb.MongoException;
|
||||
import com.mongodb.util.JSON;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.RevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.impl.LogEventAuthorImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.CompetitorResults;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
@@ -46,22 +45,34 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogPassChangeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogPathfinderEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogProtestStartTimeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogRaceStatusEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogRevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartProcedureChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartTimeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogWindFixEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.CompetitorResultsImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationType;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.impl.AdditionalScoringInformationEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.CloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.PlaceHolderDeviceIdentifierSerializationHandler;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogRevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogCloseOpenEndedDeviceMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogDeviceCompetitorMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogDeviceMarkMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogRegisterCompetitorEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogRevokeEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.impl.RegattaLogImpl;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.ControlPoint;
|
||||
@@ -139,10 +150,15 @@ import com.sap.sailing.domain.leaderboard.impl.ThresholdBasedResultDiscardingRul
|
||||
import com.sap.sailing.domain.leaderboard.meta.LeaderboardGroupMetaLeaderboard;
|
||||
import com.sap.sailing.domain.persistence.DomainObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoRaceLogStoreFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoRegattaLogStoreFactory;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.impl.PlaceHolderDeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.racelog.RaceLogIdentifier;
|
||||
import com.sap.sailing.domain.racelog.RaceLogStore;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.impl.PlaceHolderDeviceIdentifierSerializationHandler;
|
||||
import com.sap.sailing.domain.regattalike.RegattaLikeIdentifier;
|
||||
import com.sap.sailing.domain.regattalog.RegattaLogStore;
|
||||
import com.sap.sailing.domain.tracking.TrackedRegattaRegistry;
|
||||
import com.sap.sailing.domain.tracking.Wind;
|
||||
import com.sap.sailing.domain.tracking.WindTrack;
|
||||
@@ -356,7 +372,8 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
ThresholdBasedResultDiscardingRule resultDiscardingRule = loadResultDiscardingRule(dbLeaderboard, FieldNames.LEADERBOARD_DISCARDING_THRESHOLDS);
|
||||
String regattaName = (String) dbLeaderboard.get(FieldNames.REGATTA_NAME.name());
|
||||
if (groupForMetaLeaderboard != null) {
|
||||
result = new LeaderboardGroupMetaLeaderboard(groupForMetaLeaderboard, loadScoringScheme(dbLeaderboard), resultDiscardingRule);
|
||||
result = new LeaderboardGroupMetaLeaderboard(groupForMetaLeaderboard,
|
||||
loadScoringScheme(dbLeaderboard), resultDiscardingRule);
|
||||
groupForMetaLeaderboard.setOverallLeaderboard(result);
|
||||
} else if (regattaName == null) {
|
||||
result = loadFlexibleLeaderboard(dbLeaderboard, resultDiscardingRule);
|
||||
@@ -463,6 +480,16 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private RaceLogStore getRaceLogStore() {
|
||||
return MongoRaceLogStoreFactory.INSTANCE.getMongoRaceLogStore(
|
||||
new MongoObjectFactoryImpl(database, serviceFinderFactory), this);
|
||||
}
|
||||
|
||||
private RegattaLogStore getRegattaLogStore() {
|
||||
return MongoRegattaLogStoreFactory.INSTANCE.getMongoRegattaLogStore(
|
||||
new MongoObjectFactoryImpl(database, serviceFinderFactory), this);
|
||||
}
|
||||
|
||||
private FlexibleLeaderboard loadFlexibleLeaderboard(DBObject dbLeaderboard,
|
||||
ThresholdBasedResultDiscardingRule resultDiscardingRule) {
|
||||
@@ -475,8 +502,6 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
result = null;
|
||||
} else {
|
||||
final ScoringScheme scoringScheme = loadScoringScheme(dbLeaderboard);
|
||||
RaceLogStore raceLogStore = MongoRaceLogStoreFactory.INSTANCE.getMongoRaceLogStore(
|
||||
new MongoObjectFactoryImpl(database), this);
|
||||
|
||||
Serializable courseAreaId = (Serializable) dbLeaderboard.get(FieldNames.COURSE_AREA_ID.name());
|
||||
CourseArea courseArea = null;
|
||||
@@ -485,8 +510,9 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
courseArea = baseDomainFactory.getExistingCourseAreaById(courseAreaUuid);
|
||||
}
|
||||
|
||||
result = new FlexibleLeaderboardImpl(raceLogStore, (String) dbLeaderboard.get(FieldNames.LEADERBOARD_NAME
|
||||
.name()), resultDiscardingRule, scoringScheme, courseArea);
|
||||
result = new FlexibleLeaderboardImpl(getRaceLogStore(), getRegattaLogStore(),
|
||||
(String) dbLeaderboard.get(FieldNames.LEADERBOARD_NAME.name()),
|
||||
resultDiscardingRule, scoringScheme, courseArea);
|
||||
// For a FlexibleLeaderboard, there should be only the default fleet for any race column
|
||||
for (Object dbRaceColumnAsObject : dbRaceColumns) {
|
||||
BasicDBObject dbRaceColumn = (BasicDBObject) dbRaceColumnAsObject;
|
||||
@@ -1088,9 +1114,6 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
}
|
||||
BasicDBList dbSeries = (BasicDBList) dbRegatta.get(FieldNames.REGATTA_SERIES.name());
|
||||
Iterable<Series> series = loadSeries(dbSeries, trackedRegattaRegistry);
|
||||
RaceLogStore raceLogStore = MongoRaceLogStoreFactory.INSTANCE.getMongoRaceLogStore(
|
||||
new MongoObjectFactoryImpl(database, serviceFinderFactory),
|
||||
this);
|
||||
Serializable courseAreaId = (Serializable) dbRegatta.get(FieldNames.COURSE_AREA_ID.name());
|
||||
CourseArea courseArea = null;
|
||||
if (courseAreaId != null) {
|
||||
@@ -1107,7 +1130,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
}
|
||||
}
|
||||
Boolean useStartTimeInference = (Boolean) dbRegatta.get(FieldNames.REGATTA_USE_START_TIME_INFERENCE.name());
|
||||
result = new RegattaImpl(raceLogStore, name, boatClass, startDate, endDate, series, /* persistent */true,
|
||||
result = new RegattaImpl(getRaceLogStore(), getRegattaLogStore(), name, boatClass, startDate, endDate, series, /* persistent */true,
|
||||
loadScoringScheme(dbRegatta), id, courseArea, useStartTimeInference == null ? true
|
||||
: useStartTimeInference);
|
||||
result.setRegattaConfiguration(configuration);
|
||||
@@ -1330,23 +1353,23 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
return loadRaceLogRaceLogProtestStartTimeEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(RaceLogWindFixEvent.class.getSimpleName())) {
|
||||
return loadRaceLogRaceLogWindFixEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(DeviceCompetitorMappingEvent.class.getSimpleName())) {
|
||||
} else if (eventClass.equals(RaceLogDeviceCompetitorMappingEvent.class.getSimpleName())) {
|
||||
return loadRaceLogDeviceCompetitorMappingEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(DeviceMarkMappingEvent.class.getSimpleName())) {
|
||||
} else if (eventClass.equals(RaceLogDeviceMarkMappingEvent.class.getSimpleName())) {
|
||||
return loadRaceLogDeviceMarkMappingEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(DenoteForTrackingEvent.class.getSimpleName())) {
|
||||
} else if (eventClass.equals(RaceLogDenoteForTrackingEvent.class.getSimpleName())) {
|
||||
return loadRaceLogDenoteForTrackingEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(StartTrackingEvent.class.getSimpleName())) {
|
||||
} else if (eventClass.equals(RaceLogStartTrackingEvent.class.getSimpleName())) {
|
||||
return loadRaceLogStartEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(RevokeEvent.class.getSimpleName())) {
|
||||
} else if (eventClass.equals(RaceLogRevokeEvent.class.getSimpleName())) {
|
||||
return loadRaceLogRevokeEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(RegisterCompetitorEvent.class.getSimpleName())) {
|
||||
} else if (eventClass.equals(RaceLogRegisterCompetitorEvent.class.getSimpleName())) {
|
||||
return loadRaceLogRegisterCompetitorEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(DefineMarkEvent.class.getSimpleName())) {
|
||||
} else if (eventClass.equals(RaceLogDefineMarkEvent.class.getSimpleName())) {
|
||||
return loadRaceLogDefineMarkEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(CloseOpenEndedDeviceMappingEvent.class.getSimpleName())) {
|
||||
} else if (eventClass.equals(RaceLogCloseOpenEndedDeviceMappingEvent.class.getSimpleName())) {
|
||||
return loadRaceLogCloseOpenEndedDeviceMappingEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(AdditionalScoringInformationEventImpl.class.getSimpleName())) {
|
||||
} else if (eventClass.equals(RaceLogAdditionalScoringInformationEvent.class.getSimpleName())) {
|
||||
return loadRaceLogAdditionalScoringInformationEvent(createdAt, author, logicalTimePoint, id, passId, competitors, dbObject);
|
||||
}
|
||||
|
||||
@@ -1419,8 +1442,9 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
|
||||
private RaceLogEvent loadRaceLogRegisterCompetitorEvent(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
assert competitors.size() == 1 : "Should have exactly one competitor for RegisterCompetitorEvent";
|
||||
return raceLogEventFactory.createRegisterCompetitorEvent(createdAt, author, logicalTimePoint, id, passId, competitors.get(0));
|
||||
Serializable competitorId = (Serializable) dbObject.get(FieldNames.RACE_LOG_COMPETITOR_ID.name());
|
||||
Competitor comp = baseDomainFactory.getCompetitorStore().getExistingCompetitorById(competitorId);
|
||||
return raceLogEventFactory.createRegisterCompetitorEvent(createdAt, author, logicalTimePoint, id, passId, comp);
|
||||
}
|
||||
|
||||
private RaceLogEvent loadRaceLogDefineMarkEvent(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
@@ -1572,7 +1596,123 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
RaceLogRaceStatus nextStatus = RaceLogRaceStatus.valueOf((String) dbObject.get(FieldNames.RACE_LOG_EVENT_NEXT_STATUS.name()));
|
||||
return raceLogEventFactory.createRaceStatusEvent(createdAt, author, logicalTimePoint, id, competitors, passId, nextStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegattaLog loadRegattaLog(RegattaLikeIdentifier identifier) {
|
||||
RegattaLog result = new RegattaLogImpl(RegattaLogImpl.class.getSimpleName(), identifier);
|
||||
try {
|
||||
BasicDBObject query = new BasicDBObject();
|
||||
query.put(FieldNames.REGATTA_LOG_IDENTIFIER_TYPE.name(), identifier.getIdentifierType());
|
||||
query.put(FieldNames.REGATTA_LOG_IDENTIFIER_NAME.name(), identifier.getName());
|
||||
loadRegattaLogEvents(result, query);
|
||||
} catch (Throwable t) {
|
||||
// something went wrong during DB access; report, then use empty new regatta log
|
||||
logger.log(Level.SEVERE, "Error connecting to MongoDB, unable to load recorded regatta log data. Check MongoDB settings.");
|
||||
logger.log(Level.SEVERE, "loadRegattaLog", t);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void loadRegattaLogEvents(RegattaLog targetRegattaLog, BasicDBObject query) {
|
||||
DBCollection collection = database.getCollection(CollectionNames.REGATTA_LOGS.name());
|
||||
for (DBObject o : collection.find(query)) {
|
||||
try {
|
||||
RegattaLogEvent event = loadRegattaLogEvent((DBObject) o.get(FieldNames.REGATTA_LOG_EVENT.name()));
|
||||
if (event != null) {
|
||||
targetRegattaLog.load(event);
|
||||
}
|
||||
} catch (IllegalStateException e) {
|
||||
logger.log(Level.SEVERE, "Couldn't load regatta log event "+o+": "+e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RegattaLogEvent loadRegattaLogEvent(DBObject dbObject) {
|
||||
TimePoint logicalTimePoint = loadTimePoint(dbObject);
|
||||
TimePoint createdAt = loadTimePoint(dbObject, FieldNames.REGATTA_LOG_EVENT_CREATED_AT);
|
||||
Serializable id = (Serializable) dbObject.get(FieldNames.REGATTA_LOG_EVENT_ID.name());
|
||||
final AbstractLogEventAuthor author;
|
||||
String authorName = (String) dbObject.get(FieldNames.REGATTA_LOG_EVENT_AUTHOR_NAME.name());
|
||||
Number authorPriority = (Number) dbObject.get(FieldNames.REGATTA_LOG_EVENT_AUTHOR_PRIORITY.name());
|
||||
author = new LogEventAuthorImpl(authorName, authorPriority.intValue());
|
||||
//CloseOpenEnded, DeviceCompMapping, DeviceMarkMapping, RegisterComp, Revoke
|
||||
String eventClass = (String) dbObject.get(FieldNames.REGATTA_LOG_EVENT_CLASS.name());
|
||||
if (eventClass.equals(RegattaLogDeviceCompetitorMappingEvent.class.getSimpleName())) {
|
||||
return loadRegattaLogDeviceCompetitorMappingEvent(createdAt, author, logicalTimePoint, id, dbObject);
|
||||
} else if (eventClass.equals(RegattaLogDeviceMarkMappingEvent.class.getSimpleName())) {
|
||||
return loadRegattaLogDeviceMarkMappingEvent(createdAt, author, logicalTimePoint, id, dbObject);
|
||||
} else if (eventClass.equals(RegattaLogCloseOpenEndedDeviceMappingEvent.class.getSimpleName())) {
|
||||
return loadRegattaLogCloseOpenEndedDeviceMappingEvent(createdAt, author, logicalTimePoint, id, dbObject);
|
||||
} else if (eventClass.equals(RegattaLogRegisterCompetitorEvent.class.getSimpleName())) {
|
||||
return loadRegattaLogRegisterCompetitorEvent(createdAt, author, logicalTimePoint, id, dbObject);
|
||||
} else if (eventClass.equals(RegattaLogRevokeEvent.class.getSimpleName())) {
|
||||
return loadRegattaLogRevokeEvent(createdAt, author, logicalTimePoint, id, dbObject);
|
||||
}
|
||||
|
||||
throw new IllegalStateException(String.format("Unknown RegattaLogEvent type %s", eventClass));
|
||||
}
|
||||
|
||||
private RegattaLogRevokeEvent loadRegattaLogRevokeEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable id, DBObject dbObject) {
|
||||
Serializable revokedEventId = Helpers.tryUuidConversion(
|
||||
(Serializable) dbObject.get(FieldNames.REGATTA_LOG_REVOKED_EVENT_ID.name()));
|
||||
String revokedEventType = (String) dbObject.get(FieldNames.REGATTA_LOG_REVOKED_EVENT_TYPE.name());
|
||||
String revokedEventShortInfo = (String) dbObject.get(FieldNames.REGATTA_LOG_REVOKED_EVENT_SHORT_INFO.name());
|
||||
String reason = (String) dbObject.get(FieldNames.REGATTA_LOG_REVOKED_REASON.name());
|
||||
return new RegattaLogRevokeEventImpl(createdAt, author, logicalTimePoint, id,
|
||||
revokedEventId, revokedEventType, revokedEventShortInfo, reason);
|
||||
}
|
||||
|
||||
private RegattaLogRegisterCompetitorEvent loadRegattaLogRegisterCompetitorEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable id, DBObject dbObject) {
|
||||
Serializable competitorId = (Serializable) dbObject.get(FieldNames.REGATTA_LOG_COMPETITOR_ID.name());
|
||||
Competitor comp = baseDomainFactory.getCompetitorStore().getExistingCompetitorById(competitorId);
|
||||
return new RegattaLogRegisterCompetitorEventImpl(createdAt, author, logicalTimePoint, id, comp);
|
||||
}
|
||||
|
||||
private RegattaLogCloseOpenEndedDeviceMappingEvent loadRegattaLogCloseOpenEndedDeviceMappingEvent(TimePoint createdAt,
|
||||
AbstractLogEventAuthor author, TimePoint logicalTimePoint, Serializable id, DBObject dbObject) {
|
||||
Serializable deviceMappingEventId = Helpers.tryUuidConversion((Serializable) dbObject.get(
|
||||
FieldNames.REGATTA_LOG_DEVICE_MAPPING_EVENT_ID.name()));
|
||||
TimePoint closingTimePoint = loadTimePoint(dbObject, FieldNames.REGATTA_LOG_CLOSING_TIMEPOINT);
|
||||
return new RegattaLogCloseOpenEndedDeviceMappingEventImpl(createdAt, author, logicalTimePoint, id,
|
||||
deviceMappingEventId, closingTimePoint);
|
||||
}
|
||||
|
||||
private RegattaLogDeviceMarkMappingEvent loadRegattaLogDeviceMarkMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable id, DBObject dbObject) {
|
||||
DeviceIdentifier device = null;
|
||||
try {
|
||||
device = loadDeviceId(deviceIdentifierServiceFinder,
|
||||
(DBObject) dbObject.get(FieldNames.DEVICE_ID.name()));
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING, "Could not load deviceId for RaceLogEvent", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
//have to load complete mark, as no order is guaranteed for loading of racelog events
|
||||
Mark mappedTo = loadMark((DBObject) dbObject.get(FieldNames.MARK.name()));
|
||||
TimePoint from = loadTimePoint(dbObject, FieldNames.REGATTA_LOG_FROM);
|
||||
TimePoint to = loadTimePoint(dbObject, FieldNames.REGATTA_LOG_TO);
|
||||
return new RegattaLogDeviceMarkMappingEventImpl(createdAt, author, logicalTimePoint, id, mappedTo, device, from, to);
|
||||
}
|
||||
|
||||
private RegattaLogDeviceCompetitorMappingEvent loadRegattaLogDeviceCompetitorMappingEvent(TimePoint createdAt,
|
||||
AbstractLogEventAuthor author, TimePoint logicalTimePoint, Serializable id, DBObject dbObject) {
|
||||
DeviceIdentifier device = null;
|
||||
try {
|
||||
device = loadDeviceId(deviceIdentifierServiceFinder,
|
||||
(DBObject) dbObject.get(FieldNames.DEVICE_ID.name()));
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING, "Could not load deviceId for RaceLogEvent", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
Competitor mappedTo = baseDomainFactory.getExistingCompetitorById(
|
||||
(Serializable) dbObject.get(FieldNames.COMPETITOR_ID.name()));
|
||||
TimePoint from = loadTimePoint(dbObject, FieldNames.REGATTA_LOG_FROM);
|
||||
TimePoint to = loadTimePoint(dbObject, FieldNames.REGATTA_LOG_TO);
|
||||
return new RegattaLogDeviceCompetitorMappingEventImpl(createdAt, author, logicalTimePoint, id, mappedTo, device, from, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* The old field name WAYPOINT_PASSINGSIDE has been replaced by WAYPOINT_PASSINGINSTRUCTIONS. If a race with the old
|
||||
* field is loaded, the value of PASSINGSIDE is used and then migrated to PASSINGINSTRUCTION. If the first or last
|
||||
|
||||
+8
-1
@@ -89,13 +89,20 @@ public enum FieldNames {
|
||||
RACE_LOG_POSITIONED_COMPETITORS, RACE_LOG_PATHFINDER_ID, RACE_LOG_GATE_LINE_OPENING_TIME, RACE_LOG_GOLF_DOWN_TIME, RACE_LOG_START_PROCEDURE_TYPE,
|
||||
RACE_LOG_PROTEST_START_TIME, RACE_LOG_COURSE_DESIGN_NAME, RACE_LOG_REVOKED_EVENT_ID, RACE_LOG_REVOKED_EVENT_TYPE, RACE_LOG_REVOKED_EVENT_SHORT_INFO,
|
||||
RACE_LOG_REVOKED_REASON, RACE_LOG_FROM, RACE_LOG_TO, RACE_LOG_MARK, RACE_LOG_DEVICE_MAPPING_EVENT_ID,
|
||||
RACE_LOG_CLOSING_TIMEPOINT, MARK,
|
||||
RACE_LOG_CLOSING_TIMEPOINT, MARK, RACE_LOG_COMPETITOR_ID,
|
||||
/** @deprecated Replaced by WAYPOINT_PASSINGINSTRUCTIONS, still used to migrate old races*/ @Deprecated WAYPOINT_PASSINGSIDE,
|
||||
/** @deprecated Replaced by CONTROLPOINTWITHTWOMARKS_ID, still used to migrate old races*/ @Deprecated GATE_ID,
|
||||
/** @deprecated Replaced by CONTROLPOINTWITHTWOMARKS_NAME, still used to migrate old races*/ @Deprecated GATE_NAME,
|
||||
/** @deprecated Replaced by CONTROLPOINTWITHTWOMARKS_LEFT, still used to migrate old races*/ @Deprecated GATE_LEFT,
|
||||
/** @deprecated Replaced by CONTROLPOINTWITHTWOMARKS_RIGHT, still used to migrate old races*/ @Deprecated GATE_RIGHT,
|
||||
|
||||
// regatta log
|
||||
// did not reuse RACE_LOG* types, as this would require handling old versions of all events
|
||||
REGATTA_LOG_IDENTIFIER_TYPE, REGATTA_LOG_IDENTIFIER_NAME, REGATTA_LOG_EVENT_ID, REGATTA_LOG_EVENT_CREATED_AT, REGATTA_LOG_EVENT_AUTHOR_NAME,
|
||||
REGATTA_LOG_EVENT_AUTHOR_PRIORITY, REGATTA_LOG_EVENT_CLASS, REGATTA_LOG_REVOKED_EVENT_ID, REGATTA_LOG_REVOKED_EVENT_TYPE, REGATTA_LOG_REVOKED_EVENT_SHORT_INFO,
|
||||
REGATTA_LOG_REVOKED_REASON, REGATTA_LOG_COMPETITOR_ID, REGATTA_LOG_DEVICE_MAPPING_EVENT_ID, REGATTA_LOG_CLOSING_TIMEPOINT,
|
||||
REGATTA_LOG_FROM, REGATTA_LOG_TO, REGATTA_LOG_EVENT,
|
||||
|
||||
// sailing server
|
||||
SERVER_NAME,
|
||||
SERVER_URL,
|
||||
|
||||
+127
-47
@@ -19,7 +19,6 @@ import com.mongodb.DBObject;
|
||||
import com.mongodb.WriteConcern;
|
||||
import com.mongodb.util.JSON;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.RevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogCourseAreaChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogCourseDesignChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
@@ -35,16 +34,21 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogRevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartProcedureChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartTimeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogWindFixEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.CloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogRevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.shared.events.DeviceMappingEvent;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.ControlPoint;
|
||||
import com.sap.sailing.domain.base.ControlPointWithTwoMarks;
|
||||
@@ -89,6 +93,8 @@ import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.impl.PlaceHolderDeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.racelog.RaceLogIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.regattalike.RegattaLikeIdentifier;
|
||||
import com.sap.sailing.domain.tracking.Positioned;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
import com.sap.sailing.domain.tracking.TrackedRegatta;
|
||||
@@ -101,7 +107,6 @@ import com.sap.sailing.server.gateway.serialization.impl.RegattaConfigurationJso
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.TimeRange;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.WithID;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
@@ -791,28 +796,28 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, DeviceCompetitorMappingEvent event) {
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, RaceLogDeviceCompetitorMappingEvent event) {
|
||||
BasicDBObject result = new BasicDBObject();
|
||||
storeRaceLogIdentifier(raceLogIdentifier, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT.name(), storeRaceLogDeviceCompetitorMappingEvent(event));
|
||||
return result;
|
||||
}
|
||||
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, DeviceMarkMappingEvent event) {
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, RaceLogDeviceMarkMappingEvent event) {
|
||||
BasicDBObject result = new BasicDBObject();
|
||||
storeRaceLogIdentifier(raceLogIdentifier, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT.name(), storeRaceLogDeviceMarkMappingEvent(event));
|
||||
return result;
|
||||
}
|
||||
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, DenoteForTrackingEvent event) {
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, RaceLogDenoteForTrackingEvent event) {
|
||||
BasicDBObject result = new BasicDBObject();
|
||||
storeRaceLogIdentifier(raceLogIdentifier, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT.name(), storeRaceLogDenoteForTrackingEvent(event));
|
||||
return result;
|
||||
}
|
||||
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, StartTrackingEvent event) {
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, RaceLogStartTrackingEvent event) {
|
||||
BasicDBObject result = new BasicDBObject();
|
||||
storeRaceLogIdentifier(raceLogIdentifier, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT.name(), storeRaceLogStartTrackingEvent(event));
|
||||
@@ -826,38 +831,38 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, RegisterCompetitorEvent event) {
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, RaceLogRegisterCompetitorEvent event) {
|
||||
BasicDBObject result = new BasicDBObject();
|
||||
storeRaceLogIdentifier(raceLogIdentifier, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT.name(), storeRaceLogRegisterCompetitorEvent(event));
|
||||
return result;
|
||||
}
|
||||
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, DefineMarkEvent event) {
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, RaceLogDefineMarkEvent event) {
|
||||
BasicDBObject result = new BasicDBObject();
|
||||
storeRaceLogIdentifier(raceLogIdentifier, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT.name(), storeRaceLogDefineMarkEvent(event));
|
||||
return result;
|
||||
}
|
||||
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, CloseOpenEndedDeviceMappingEvent event) {
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, RaceLogCloseOpenEndedDeviceMappingEvent event) {
|
||||
BasicDBObject result = new BasicDBObject();
|
||||
storeRaceLogIdentifier(raceLogIdentifier, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT.name(), storeRaceLogCloseOpenEndedDeviceMappingEvent(event));
|
||||
return result;
|
||||
}
|
||||
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, AdditionalScoringInformationEvent event) {
|
||||
public DBObject storeRaceLogEntry(RaceLogIdentifier raceLogIdentifier, RaceLogAdditionalScoringInformationEvent event) {
|
||||
BasicDBObject result = new BasicDBObject();
|
||||
storeRaceLogIdentifier(raceLogIdentifier, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT.name(), storeAdditionalScoringInformation(event));
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object storeAdditionalScoringInformation(AdditionalScoringInformationEvent event) {
|
||||
private Object storeAdditionalScoringInformation(RaceLogAdditionalScoringInformationEvent event) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeRaceLogEventProperties(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), event.getClass().getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogAdditionalScoringInformationEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_ADDITIONAL_SCORING_INFORMATION_TYPE.name(), event.getType().name());
|
||||
return result;
|
||||
}
|
||||
@@ -894,15 +899,12 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
private void storeRaceLogDeviceMappingEvent(DeviceMappingEvent<? extends WithID> event, DBObject result) {
|
||||
DBObject deviceId = null;
|
||||
try {
|
||||
deviceId = storeDeviceId(deviceIdentifierServiceFinder, event.getDevice());
|
||||
} catch (Exception e) {
|
||||
logger.log(Level.WARNING, "Could not store deviceId for RaceLogEvent", e);
|
||||
e.printStackTrace();
|
||||
private void storeDeviceMappingEvent(DeviceMappingEvent<?, ?> event, DBObject result) {
|
||||
try {
|
||||
result.put(FieldNames.DEVICE_ID.name(), storeDeviceId(deviceIdentifierServiceFinder, event.getDevice()));
|
||||
} catch (TransformationException | NoCorrespondingServiceRegisteredException e) {
|
||||
logger.log(Level.WARNING, "Could not store device identifier for mappng event", e);
|
||||
}
|
||||
result.put(FieldNames.DEVICE_ID.name(), deviceId);
|
||||
if (event.getFrom() != null) {
|
||||
storeTimePoint(event.getFrom(), result, FieldNames.RACE_LOG_FROM);
|
||||
}
|
||||
@@ -911,45 +913,45 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
}
|
||||
}
|
||||
|
||||
private Object storeRaceLogDeviceCompetitorMappingEvent(DeviceCompetitorMappingEvent event) {
|
||||
private Object storeRaceLogDeviceCompetitorMappingEvent(RaceLogDeviceCompetitorMappingEvent event) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeRaceLogEventProperties(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), DeviceCompetitorMappingEvent.class.getSimpleName());
|
||||
storeRaceLogDeviceMappingEvent(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogDeviceCompetitorMappingEvent.class.getSimpleName());
|
||||
storeDeviceMappingEvent(event, result);
|
||||
result.put(FieldNames.COMPETITOR_ID.name(), event.getMappedTo().getId());
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object storeRaceLogDeviceMarkMappingEvent(DeviceMarkMappingEvent event) {
|
||||
private Object storeRaceLogDeviceMarkMappingEvent(RaceLogDeviceMarkMappingEvent event) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeRaceLogEventProperties(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), DeviceMarkMappingEvent.class.getSimpleName());
|
||||
storeRaceLogDeviceMappingEvent(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogDeviceMarkMappingEvent.class.getSimpleName());
|
||||
storeDeviceMappingEvent(event, result);
|
||||
result.put(FieldNames.MARK.name(), storeMark(event.getMappedTo()));
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object storeRaceLogDenoteForTrackingEvent(DenoteForTrackingEvent event) {
|
||||
private Object storeRaceLogDenoteForTrackingEvent(RaceLogDenoteForTrackingEvent event) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeRaceLogEventProperties(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), DenoteForTrackingEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogDenoteForTrackingEvent.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;
|
||||
}
|
||||
|
||||
private Object storeRaceLogStartTrackingEvent(StartTrackingEvent event) {
|
||||
private Object storeRaceLogStartTrackingEvent(RaceLogStartTrackingEvent event) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeRaceLogEventProperties(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), StartTrackingEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogStartTrackingEvent.class.getSimpleName());
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object storeRaceLogRevokeEvent(RaceLogRevokeEvent event) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeRaceLogEventProperties(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RevokeEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogRevokeEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_REVOKED_EVENT_ID.name(), event.getRevokedEventId());
|
||||
result.put(FieldNames.RACE_LOG_REVOKED_EVENT_TYPE.name(), event.getRevokedEventType());
|
||||
result.put(FieldNames.RACE_LOG_REVOKED_EVENT_SHORT_INFO.name(), event.getRevokedEventShortInfo());
|
||||
@@ -957,25 +959,26 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object storeRaceLogRegisterCompetitorEvent(RegisterCompetitorEvent event) {
|
||||
private Object storeRaceLogRegisterCompetitorEvent(RaceLogRegisterCompetitorEvent event) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeRaceLogEventProperties(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RegisterCompetitorEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogRegisterCompetitorEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_COMPETITOR_ID.name(), event.getCompetitor().getId());
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object storeRaceLogDefineMarkEvent(DefineMarkEvent event) {
|
||||
private Object storeRaceLogDefineMarkEvent(RaceLogDefineMarkEvent event) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeRaceLogEventProperties(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), DefineMarkEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogDefineMarkEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_MARK.name(), storeMark(event.getMark()));
|
||||
return result;
|
||||
}
|
||||
|
||||
private Object storeRaceLogCloseOpenEndedDeviceMappingEvent(CloseOpenEndedDeviceMappingEvent event) {
|
||||
private Object storeRaceLogCloseOpenEndedDeviceMappingEvent(RaceLogCloseOpenEndedDeviceMappingEvent event) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeRaceLogEventProperties(event, result);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), CloseOpenEndedDeviceMappingEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogCloseOpenEndedDeviceMappingEvent.class.getSimpleName());
|
||||
result.put(FieldNames.RACE_LOG_DEVICE_MAPPING_EVENT_ID.name(), event.getDeviceMappingEventId());
|
||||
storeTimePoint(event.getClosingTimePoint(), result, FieldNames.RACE_LOG_CLOSING_TIMEPOINT);
|
||||
return result;
|
||||
@@ -1248,6 +1251,13 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
getRaceLogCollection().remove(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRegattaLog(RegattaLikeIdentifier identifier) {
|
||||
DBObject query = new BasicDBObject();
|
||||
addRegattaLikeIdentifier(identifier, query);
|
||||
getRegattaLogCollection().remove(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeResultUrl(String resultProviderName, URL url) {
|
||||
DBCollection resultUrlsCollection = database.getCollection(CollectionNames.RESULT_URLS.name());
|
||||
@@ -1264,4 +1274,74 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
.add(FieldNames.RESULT_URL.name(), url.toString()).get();
|
||||
resultUrlsCollection.remove(query);
|
||||
}
|
||||
|
||||
public DBCollection getRegattaLogCollection() {
|
||||
DBCollection result = database.getCollection(CollectionNames.REGATTA_LOGS.name());
|
||||
DBObject index = new BasicDBObject(FieldNames.REGATTA_LOG_IDENTIFIER_TYPE.name(), null);
|
||||
index.put(FieldNames.REGATTA_LOG_IDENTIFIER_NAME.name(), null);
|
||||
result.ensureIndex(index);
|
||||
return result;
|
||||
}
|
||||
|
||||
private DBObject createBasicRegattaLogEventDBObject(RegattaLogEvent event) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeTimed(event, result);
|
||||
storeTimePoint(event.getCreatedAt(), result, FieldNames.REGATTA_LOG_EVENT_CREATED_AT);
|
||||
result.put(FieldNames.REGATTA_LOG_EVENT_ID.name(), event.getId());
|
||||
result.put(FieldNames.REGATTA_LOG_EVENT_AUTHOR_NAME.name(), event.getAuthor().getName());
|
||||
result.put(FieldNames.REGATTA_LOG_EVENT_AUTHOR_PRIORITY.name(), event.getAuthor().getPriority());
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addRegattaLikeIdentifier(RegattaLikeIdentifier regattaLikeId, DBObject toObject) {
|
||||
toObject.put(FieldNames.REGATTA_LOG_IDENTIFIER_TYPE.name(), regattaLikeId.getIdentifierType());
|
||||
toObject.put(FieldNames.REGATTA_LOG_IDENTIFIER_NAME.name(), regattaLikeId.getName());
|
||||
}
|
||||
|
||||
private void storeRegattaLogEvent(RegattaLikeIdentifier regattaLikeId, DBObject innerObject) {
|
||||
DBObject result = new BasicDBObject(FieldNames.REGATTA_LOG_EVENT.name(), innerObject);
|
||||
addRegattaLikeIdentifier(regattaLikeId, result);
|
||||
getRegattaLogCollection().insert(result);
|
||||
}
|
||||
|
||||
public void storeRegattaLogEvent(RegattaLikeIdentifier regattaLikeId, RegattaLogDeviceCompetitorMappingEvent event) {
|
||||
DBObject result = createBasicRegattaLogEventDBObject(event);
|
||||
result.put(FieldNames.REGATTA_LOG_EVENT_CLASS.name(), RegattaLogDeviceCompetitorMappingEvent.class.getSimpleName());
|
||||
storeDeviceMappingEvent(event, result);
|
||||
result.put(FieldNames.COMPETITOR_ID.name(), event.getMappedTo().getId());
|
||||
storeRegattaLogEvent(regattaLikeId, result);
|
||||
}
|
||||
|
||||
public void storeRegattaLogEvent(RegattaLikeIdentifier regattaLikeId, RegattaLogDeviceMarkMappingEvent event) {
|
||||
DBObject result = createBasicRegattaLogEventDBObject(event);
|
||||
result.put(FieldNames.REGATTA_LOG_EVENT_CLASS.name(), RegattaLogDeviceMarkMappingEvent.class.getSimpleName());
|
||||
storeDeviceMappingEvent(event, result);
|
||||
result.put(FieldNames.MARK.name(), storeMark(event.getMappedTo()));
|
||||
storeRegattaLogEvent(regattaLikeId, result);
|
||||
}
|
||||
|
||||
public void storeRegattaLogEvent(RegattaLikeIdentifier regattaLikeId, RegattaLogRevokeEvent event) {
|
||||
DBObject result = createBasicRegattaLogEventDBObject(event);
|
||||
result.put(FieldNames.REGATTA_LOG_EVENT_CLASS.name(), RegattaLogRevokeEvent.class.getSimpleName());
|
||||
result.put(FieldNames.REGATTA_LOG_REVOKED_EVENT_ID.name(), event.getRevokedEventId());
|
||||
result.put(FieldNames.REGATTA_LOG_REVOKED_EVENT_TYPE.name(), event.getRevokedEventType());
|
||||
result.put(FieldNames.REGATTA_LOG_REVOKED_EVENT_SHORT_INFO.name(), event.getRevokedEventShortInfo());
|
||||
result.put(FieldNames.REGATTA_LOG_REVOKED_REASON.name(), event.getReason());
|
||||
storeRegattaLogEvent(regattaLikeId, result);
|
||||
}
|
||||
|
||||
public void storeRegattaLogEvent(RegattaLikeIdentifier regattaLikeId, RegattaLogRegisterCompetitorEvent event) {
|
||||
DBObject result = createBasicRegattaLogEventDBObject(event);
|
||||
result.put(FieldNames.REGATTA_LOG_EVENT_CLASS.name(), RegattaLogRegisterCompetitorEvent.class.getSimpleName());
|
||||
result.put(FieldNames.REGATTA_LOG_COMPETITOR_ID.name(), event.getCompetitor().getId());
|
||||
storeRegattaLogEvent(regattaLikeId, result);
|
||||
}
|
||||
|
||||
public void storeRegattaLogEvent(RegattaLikeIdentifier regattaLikeId, RegattaLogCloseOpenEndedDeviceMappingEvent event) {
|
||||
DBObject result = createBasicRegattaLogEventDBObject(event);
|
||||
result.put(FieldNames.REGATTA_LOG_EVENT_CLASS.name(), RegattaLogCloseOpenEndedDeviceMappingEvent.class.getSimpleName());
|
||||
result.put(FieldNames.REGATTA_LOG_DEVICE_MAPPING_EVENT_ID.name(), event.getDeviceMappingEventId());
|
||||
storeTimePoint(event.getClosingTimePoint(), result, FieldNames.REGATTA_LOG_CLOSING_TIMEPOINT);
|
||||
storeRegattaLogEvent(regattaLikeId, result);
|
||||
}
|
||||
}
|
||||
+16
-16
@@ -18,14 +18,14 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogRevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartProcedureChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartTimeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogWindFixEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.CloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
||||
import com.sap.sailing.domain.racelog.RaceLogIdentifier;
|
||||
|
||||
@@ -121,25 +121,25 @@ public class MongoRaceLogStoreVisitor implements RaceLogEventVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DeviceCompetitorMappingEvent event) {
|
||||
public void visit(RaceLogDeviceCompetitorMappingEvent event) {
|
||||
DBObject object = mongoObjectFactory.storeRaceLogEntry(raceLogIdentifier, event);
|
||||
mongoObjectFactory.storeRaceLogEventEvent(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DeviceMarkMappingEvent event) {
|
||||
public void visit(RaceLogDeviceMarkMappingEvent event) {
|
||||
DBObject object = mongoObjectFactory.storeRaceLogEntry(raceLogIdentifier, event);
|
||||
mongoObjectFactory.storeRaceLogEventEvent(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DenoteForTrackingEvent event) {
|
||||
public void visit(RaceLogDenoteForTrackingEvent event) {
|
||||
DBObject object = mongoObjectFactory.storeRaceLogEntry(raceLogIdentifier, event);
|
||||
mongoObjectFactory.storeRaceLogEventEvent(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(StartTrackingEvent event) {
|
||||
public void visit(RaceLogStartTrackingEvent event) {
|
||||
DBObject object = mongoObjectFactory.storeRaceLogEntry(raceLogIdentifier, event);
|
||||
mongoObjectFactory.storeRaceLogEventEvent(object);
|
||||
}
|
||||
@@ -151,25 +151,25 @@ public class MongoRaceLogStoreVisitor implements RaceLogEventVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RegisterCompetitorEvent event) {
|
||||
public void visit(RaceLogRegisterCompetitorEvent event) {
|
||||
DBObject object = mongoObjectFactory.storeRaceLogEntry(raceLogIdentifier, event);
|
||||
mongoObjectFactory.storeRaceLogEventEvent(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DefineMarkEvent event) {
|
||||
public void visit(RaceLogDefineMarkEvent event) {
|
||||
DBObject object = mongoObjectFactory.storeRaceLogEntry(raceLogIdentifier, event);
|
||||
mongoObjectFactory.storeRaceLogEventEvent(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CloseOpenEndedDeviceMappingEvent event) {
|
||||
public void visit(RaceLogCloseOpenEndedDeviceMappingEvent event) {
|
||||
DBObject object = mongoObjectFactory.storeRaceLogEntry(raceLogIdentifier, event);
|
||||
mongoObjectFactory.storeRaceLogEventEvent(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AdditionalScoringInformationEvent event) {
|
||||
public void visit(RaceLogAdditionalScoringInformationEvent event) {
|
||||
DBObject object = mongoObjectFactory.storeRaceLogEntry(raceLogIdentifier, event);
|
||||
mongoObjectFactory.storeRaceLogEventEvent(object);
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package com.sap.sailing.domain.persistence.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLogEventVisitor;
|
||||
import com.sap.sailing.domain.persistence.DomainObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoRegattaLogStoreFactory;
|
||||
import com.sap.sailing.domain.regattalike.RegattaLikeIdentifier;
|
||||
import com.sap.sailing.domain.regattalog.RegattaLogStore;
|
||||
|
||||
public class MongoRegattaLogStoreFactoryImpl implements MongoRegattaLogStoreFactory {
|
||||
@Override
|
||||
public RegattaLogStore getMongoRegattaLogStore(MongoObjectFactory mongoObjectFactory, DomainObjectFactory domainObjectFactory) {
|
||||
return new MongoRegattaLogStoreImpl(mongoObjectFactory, domainObjectFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegattaLogEventVisitor getMongoRegattaLogStoreVisitor(RegattaLikeIdentifier identifier, MongoObjectFactory mongoObjectFactory) {
|
||||
return new MongoRegattaLogStoreVisitor(identifier, mongoObjectFactory);
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.sap.sailing.domain.persistence.impl;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.persistence.DomainObjectFactory;
|
||||
import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
||||
import com.sap.sailing.domain.regattalike.RegattaLikeIdentifier;
|
||||
import com.sap.sailing.domain.regattalog.RegattaLogStore;
|
||||
|
||||
public class MongoRegattaLogStoreImpl implements RegattaLogStore {
|
||||
private final MongoObjectFactory mongoObjectFactory;
|
||||
private final DomainObjectFactory domainObjectFactory;
|
||||
private final Map<RegattaLikeIdentifier, RegattaLog> regattaLogCache;
|
||||
|
||||
public MongoRegattaLogStoreImpl(MongoObjectFactory mongoObjectFactory, DomainObjectFactory domainObjectFactory) {
|
||||
this.mongoObjectFactory = mongoObjectFactory;
|
||||
this.domainObjectFactory = domainObjectFactory;
|
||||
this.regattaLogCache = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegattaLog getRegattaLog(RegattaLikeIdentifier identifier, boolean ignoreCache) {
|
||||
final RegattaLog result;
|
||||
if (!ignoreCache && regattaLogCache.containsKey(identifier)) {
|
||||
result = regattaLogCache.get(identifier);
|
||||
} else {
|
||||
result = domainObjectFactory.loadRegattaLog(identifier);
|
||||
MongoRegattaLogStoreVisitor listener = new MongoRegattaLogStoreVisitor(identifier, mongoObjectFactory);
|
||||
result.addListener(listener);
|
||||
regattaLogCache.put(identifier, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRegattaLog(RegattaLikeIdentifier identifier) {
|
||||
regattaLogCache.remove(identifier);
|
||||
mongoObjectFactory.removeRegattaLog(identifier);
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.sap.sailing.domain.persistence.impl;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogRevokeEvent;
|
||||
import com.sap.sailing.domain.persistence.MongoObjectFactory;
|
||||
import com.sap.sailing.domain.regattalike.RegattaLikeIdentifier;
|
||||
|
||||
public class MongoRegattaLogStoreVisitor implements RegattaLogEventVisitor {
|
||||
|
||||
private final RegattaLikeIdentifier regattaLikeIdentifier;
|
||||
private final MongoObjectFactoryImpl mongoObjectFactory;
|
||||
|
||||
final static Logger logger = Logger.getLogger(MongoRegattaLogStoreVisitor.class.getName());
|
||||
|
||||
public MongoRegattaLogStoreVisitor(RegattaLikeIdentifier identifier, MongoObjectFactory mongoObjectFactory) {
|
||||
super();
|
||||
this.regattaLikeIdentifier = identifier;
|
||||
this.mongoObjectFactory = (MongoObjectFactoryImpl) mongoObjectFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RegattaLogRevokeEvent event) {
|
||||
mongoObjectFactory.storeRegattaLogEvent(regattaLikeIdentifier, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RegattaLogDeviceMarkMappingEvent event) {
|
||||
mongoObjectFactory.storeRegattaLogEvent(regattaLikeIdentifier, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RegattaLogDeviceCompetitorMappingEvent event) {
|
||||
mongoObjectFactory.storeRegattaLogEvent(regattaLikeIdentifier, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RegattaLogCloseOpenEndedDeviceMappingEvent event) {
|
||||
mongoObjectFactory.storeRegattaLogEvent(regattaLikeIdentifier, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RegattaLogRegisterCompetitorEvent event) {
|
||||
mongoObjectFactory.storeRegattaLogEvent(regattaLikeIdentifier, event);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.domain.persistence.racelog.tracking;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifierSerializationHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifierSerializationHandler;
|
||||
|
||||
public interface DeviceIdentifierMongoHandler extends DeviceIdentifierSerializationHandler<Object> {
|
||||
}
|
||||
+9
-9
@@ -14,11 +14,9 @@ import com.mongodb.DBCollection;
|
||||
import com.mongodb.DBCursor;
|
||||
import com.mongodb.DBObject;
|
||||
import com.mongodb.QueryBuilder;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMapping;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.DeviceCompetitorMappingFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.DeviceMarkMappingFinder;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLog;
|
||||
import com.sap.sailing.domain.abstractlog.shared.analyzing.DeviceCompetitorMappingFinder;
|
||||
import com.sap.sailing.domain.abstractlog.shared.analyzing.DeviceMarkMappingFinder;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.NoCorrespondingServiceRegisteredException;
|
||||
@@ -34,6 +32,8 @@ import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongo
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.GPSFixMongoHandler;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.MongoGPSFixStore;
|
||||
import com.sap.sailing.domain.racelog.tracking.GPSFixReceivedListener;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceMapping;
|
||||
import com.sap.sailing.domain.tracking.DynamicGPSFixTrack;
|
||||
import com.sap.sailing.domain.tracking.GPSFix;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
@@ -105,9 +105,9 @@ public class MongoGPSFixStoreImpl implements MongoGPSFixStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCompetitorTrack(DynamicGPSFixTrack<Competitor, GPSFixMoving> track, RaceLog raceLog, Competitor competitor)
|
||||
public void loadCompetitorTrack(DynamicGPSFixTrack<Competitor, GPSFixMoving> track, AbstractLog<?, ?> log, Competitor competitor)
|
||||
throws NoCorrespondingServiceRegisteredException, TransformationException{
|
||||
List<DeviceMapping<Competitor>> mappings = new DeviceCompetitorMappingFinder(raceLog).analyze().get(competitor);
|
||||
List<DeviceMapping<Competitor>> mappings = new DeviceCompetitorMappingFinder<>(log).analyze().get(competitor);
|
||||
|
||||
if (mappings != null) {
|
||||
for (DeviceMapping<Competitor> mapping : mappings) {
|
||||
@@ -117,9 +117,9 @@ public class MongoGPSFixStoreImpl implements MongoGPSFixStore {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadMarkTrack(DynamicGPSFixTrack<Mark, GPSFix> track, RaceLog raceLog, Mark mark)
|
||||
public void loadMarkTrack(DynamicGPSFixTrack<Mark, GPSFix> track, AbstractLog<?, ?> log, Mark mark)
|
||||
throws NoCorrespondingServiceRegisteredException, TransformationException{
|
||||
List<DeviceMapping<Mark>> mappings = new DeviceMarkMappingFinder(raceLog).analyze().get(mark);
|
||||
List<DeviceMapping<Mark>> mappings = new DeviceMarkMappingFinder<>(log).analyze().get(mark);
|
||||
|
||||
if (mappings != null) {
|
||||
for (DeviceMapping<Mark> mapping : mappings) {
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package com.sap.sailing.domain.persistence.racelog.tracking.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.PlaceHolderDeviceIdentifierSerializationHandler;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.impl.PlaceHolderDeviceIdentifierSerializationHandler;
|
||||
|
||||
public class PlaceHolderDeviceIdentifierMongoHandler extends PlaceHolderDeviceIdentifierSerializationHandler
|
||||
implements DeviceIdentifierMongoHandler {
|
||||
|
||||
@@ -13,7 +13,8 @@ Require-Bundle: org.junit4;bundle-version="4.8.2",
|
||||
org.hamcrest;bundle-version="1.1.0",
|
||||
com.mongodb.driver;bundle-version="2.6.2",
|
||||
com.sap.sse.common
|
||||
Import-Package: com.sap.sailing.domain.persistence.impl,
|
||||
Import-Package: com.sap.sailing.domain.abstractlog.regatta.events,
|
||||
com.sap.sailing.domain.persistence.impl,
|
||||
com.sap.sailing.domain.persistence.racelog.tracking.impl,
|
||||
com.sap.sailing.domain.tractracadapter,
|
||||
com.sap.sailing.server.impl,
|
||||
|
||||
+1
-1
@@ -11,7 +11,6 @@ import com.sap.sailing.domain.abstractlog.impl.LogEventAuthorImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventFactory;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
@@ -24,6 +23,7 @@ import com.sap.sailing.domain.racelog.tracking.GPSFixStore;
|
||||
import com.sap.sailing.domain.racelog.tracking.test.mock.MockDeviceAndSessionIdentifierWithGPSFixesDeserializer;
|
||||
import com.sap.sailing.domain.racelog.tracking.test.mock.MockSmartphoneImeiServiceFinderFactory;
|
||||
import com.sap.sailing.domain.racelog.tracking.test.mock.SmartphoneImeiIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.tracking.Track;
|
||||
import com.sap.sailing.domain.tracking.impl.GPSFixMovingImpl;
|
||||
|
||||
+108
-31
@@ -20,7 +20,9 @@ import org.junit.rules.ExpectedException;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventFactory;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogDeviceCompetitorMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogRegisterCompetitorEventImpl;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.DomainFactory;
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
@@ -33,12 +35,15 @@ import com.sap.sailing.domain.base.impl.SeriesImpl;
|
||||
import com.sap.sailing.domain.common.impl.DegreeBearingImpl;
|
||||
import com.sap.sailing.domain.common.impl.DegreePosition;
|
||||
import com.sap.sailing.domain.common.impl.KnotSpeedWithBearingImpl;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.NoCorrespondingServiceRegisteredException;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.NotDenotedForRaceLogTrackingException;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.leaderboard.RegattaLeaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.impl.HighPoint;
|
||||
import com.sap.sailing.domain.racelog.tracking.GPSFixStore;
|
||||
import com.sap.sailing.domain.racelog.tracking.test.mock.MockSmartphoneImeiServiceFinderFactory;
|
||||
import com.sap.sailing.domain.racelog.tracking.test.mock.SmartphoneImeiIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.RaceLogTrackingAdapter;
|
||||
import com.sap.sailing.domain.racelogtracking.impl.RaceLogTrackingAdapterFactoryImpl;
|
||||
import com.sap.sailing.domain.tracking.Track;
|
||||
@@ -70,11 +75,12 @@ public class CreateAndTrackWithRaceLogTest {
|
||||
gpsFixStore = service.getGPSFixStore();
|
||||
service.getMongoObjectFactory().getDatabase().dropDatabase();
|
||||
author = service.getServerAuthor();
|
||||
Series series = new SeriesImpl("series", false, Collections.singletonList(fleet), Collections.emptySet(), service);
|
||||
Series series = new SeriesImpl("series", false, Collections.singletonList(fleet), Collections.emptySet(),
|
||||
service);
|
||||
regatta = service.createRegatta(RegattaImpl.getDefaultName("regatta", "Laser"), "Laser",
|
||||
/*startDate*/ null, /*endDate*/ null, UUID.randomUUID(), Collections.<Series>singletonList(series),
|
||||
false, new HighPoint(), UUID.randomUUID(), /* useStartTimeInference */ true);
|
||||
series.addRaceColumn(columnName, /* trackedRegattaRegistry */ null);
|
||||
/* startDate */null, /* endDate */null, UUID.randomUUID(), Collections.<Series> singletonList(series), false,
|
||||
new HighPoint(), UUID.randomUUID(), /* useStartTimeInference */true);
|
||||
series.addRaceColumn(columnName, /* trackedRegattaRegistry */null);
|
||||
leaderboard = service.addRegattaLeaderboard(regatta.getRegattaIdentifier(), "RegattaLeaderboard", new int[] {});
|
||||
adapter = RaceLogTrackingAdapterFactoryImpl.INSTANCE.getAdapter(DomainFactory.INSTANCE);
|
||||
}
|
||||
@@ -88,11 +94,17 @@ public class CreateAndTrackWithRaceLogTest {
|
||||
return new MillisecondsTimePoint(time++);
|
||||
}
|
||||
|
||||
private TimePoint t(long millis) {
|
||||
return new MillisecondsTimePoint(millis);
|
||||
}
|
||||
|
||||
@Rule
|
||||
public ExpectedException exception = ExpectedException.none();
|
||||
|
||||
@Test
|
||||
public void cantAddBeforeDenoting() throws MalformedURLException, FileNotFoundException, URISyntaxException, Exception {
|
||||
RaceColumn column = leaderboard.getRaceColumnByName(columnName);
|
||||
public void cantAddBeforeDenoting() throws MalformedURLException, FileNotFoundException, URISyntaxException,
|
||||
Exception {
|
||||
RaceColumn column = leaderboard.getRaceColumnByName(columnName);
|
||||
exception.expect(NotDenotedForRaceLogTrackingException.class);
|
||||
adapter.startTracking(service, leaderboard, column, fleet);
|
||||
}
|
||||
@@ -103,52 +115,117 @@ public class CreateAndTrackWithRaceLogTest {
|
||||
track.unlockAfterRead();
|
||||
}
|
||||
|
||||
private void addFixes0(DeviceIdentifier dev1) throws TransformationException,
|
||||
NoCorrespondingServiceRegisteredException {
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), t(5), new KnotSpeedWithBearingImpl(
|
||||
10, new DegreeBearingImpl(5))));
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), t(15), new KnotSpeedWithBearingImpl(
|
||||
10, new DegreeBearingImpl(5))));
|
||||
}
|
||||
|
||||
private void addFixes1(TrackedRace race, Competitor comp1, DeviceIdentifier dev1) throws TransformationException,
|
||||
NoCorrespondingServiceRegisteredException {
|
||||
// one fix should have been loaded from store
|
||||
testSize(race.getTrack(comp1), 1);
|
||||
|
||||
// further fix arrives in race
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), t(7), new KnotSpeedWithBearingImpl(
|
||||
10, new DegreeBearingImpl(5))));
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), t(14), new KnotSpeedWithBearingImpl(
|
||||
10, new DegreeBearingImpl(5)))); // outside mapping range
|
||||
testSize(race.getTrack(comp1), 2);
|
||||
}
|
||||
|
||||
private void addFixes2(TrackedRace race, Competitor comp1, DeviceIdentifier dev1) throws TransformationException,
|
||||
NoCorrespondingServiceRegisteredException {
|
||||
// add another mapping on the fly, other old fixes should be loaded
|
||||
testSize(race.getTrack(comp1), 4);
|
||||
|
||||
// add another fix in new mapping range
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), t(18), new KnotSpeedWithBearingImpl(
|
||||
10, new DegreeBearingImpl(5))));
|
||||
testSize(race.getTrack(comp1), 5);
|
||||
}
|
||||
|
||||
private void addFixes3(TrackedRace race, Competitor comp1, DeviceIdentifier dev1) throws TransformationException,
|
||||
NoCorrespondingServiceRegisteredException {
|
||||
// stop tracking, then no more fixes arrive at race
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), t(8), new KnotSpeedWithBearingImpl(
|
||||
10, new DegreeBearingImpl(5))));
|
||||
testSize(race.getTrack(comp1), 5);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canDenote_Add_Track() throws MalformedURLException, FileNotFoundException, URISyntaxException, Exception {
|
||||
public void canDenote_Add_Track() throws MalformedURLException, FileNotFoundException, URISyntaxException,
|
||||
Exception {
|
||||
|
||||
RaceColumn column = leaderboard.getRaceColumnByName(columnName);
|
||||
RaceLog raceLog = column.getRaceLog(fleet);
|
||||
|
||||
//can denote racelog for tracking
|
||||
// can denote racelog for tracking
|
||||
assertTrue(raceLog.isEmpty());
|
||||
adapter.denoteRaceForRaceLogTracking(service, leaderboard, column, fleet, "race");
|
||||
assertFalse(raceLog.isEmpty());
|
||||
|
||||
//add a mapping and one fix in, one out of mapping
|
||||
// add a mapping and one fix in, one out of mapping
|
||||
Competitor comp1 = DomainFactory.INSTANCE.getOrCreateCompetitor("comp1", "comp1", null, null, null);
|
||||
DeviceIdentifier dev1 = new SmartphoneImeiIdentifier("dev1");
|
||||
raceLog.add(factory.createDeviceCompetitorMappingEvent(t(), author, dev1, comp1, 0, new MillisecondsTimePoint(0), new MillisecondsTimePoint(10)));
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), new MillisecondsTimePoint(5), new KnotSpeedWithBearingImpl(10, new DegreeBearingImpl(5))));
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), new MillisecondsTimePoint(15), new KnotSpeedWithBearingImpl(10, new DegreeBearingImpl(5))));
|
||||
|
||||
raceLog.add(factory.createDeviceCompetitorMappingEvent(t(), author, dev1, comp1, 0, t(0), t(10)));
|
||||
addFixes0(dev1);
|
||||
raceLog.add(factory.createRegisterCompetitorEvent(t(), author, 0, comp1));
|
||||
|
||||
//start tracking
|
||||
// start tracking
|
||||
adapter.startTracking(service, leaderboard, column, fleet);
|
||||
|
||||
//now there is a trackedrace
|
||||
// now there is a trackedrace
|
||||
TrackedRace race = column.getTrackedRace(fleet);
|
||||
assertNotNull(race);
|
||||
|
||||
//one fix should have been loaded from store
|
||||
testSize(race.getTrack(comp1), 1);
|
||||
race.waitForLoadingFromGPSFixStoreToFinishRunning(raceLog);
|
||||
addFixes1(race, comp1, dev1);
|
||||
raceLog.add(factory.createDeviceCompetitorMappingEvent(t(), author, dev1, comp1, 0, t(11), t(20)));
|
||||
|
||||
//further fix arrives in race
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), new MillisecondsTimePoint(7), new KnotSpeedWithBearingImpl(10, new DegreeBearingImpl(5))));
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), new MillisecondsTimePoint(14), new KnotSpeedWithBearingImpl(10, new DegreeBearingImpl(5)))); //outside mapping range
|
||||
testSize(race.getTrack(comp1), 2);
|
||||
// add another mapping on the fly, other old fixes should be loaded
|
||||
addFixes2(race, comp1, dev1);
|
||||
|
||||
//add another mapping on the fly, other old fixes should be loaded
|
||||
raceLog.add(factory.createDeviceCompetitorMappingEvent(t(), author, dev1, comp1, 0, new MillisecondsTimePoint(11), new MillisecondsTimePoint(20)));
|
||||
testSize(race.getTrack(comp1), 4);
|
||||
// stop tracking, then no more fixes arrive at race
|
||||
service.getRaceTrackerById(raceLog.getId()).stop(false);
|
||||
addFixes3(race, comp1, dev1);
|
||||
}
|
||||
|
||||
//add another fix in new mapping range
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), new MillisecondsTimePoint(18), new KnotSpeedWithBearingImpl(10, new DegreeBearingImpl(5))));
|
||||
testSize(race.getTrack(comp1), 5);
|
||||
@Test
|
||||
public void useEventsInRegattaLog() throws NotDenotedForRaceLogTrackingException, Exception {
|
||||
RaceColumn column = leaderboard.getRaceColumnByName(columnName);
|
||||
RegattaLog regattaLog = leaderboard.getRegattaLike().getRegattaLog();
|
||||
RaceLog raceLog = column.getRaceLog(fleet);
|
||||
|
||||
//stop tracking, then no more fixes arrive at race
|
||||
adapter.denoteRaceForRaceLogTracking(service, leaderboard, column, fleet, "race");
|
||||
|
||||
// add a mapping and one fix in, one out of mapping
|
||||
Competitor comp1 = DomainFactory.INSTANCE.getOrCreateCompetitor("comp1", "comp1", null, null, null);
|
||||
DeviceIdentifier dev1 = new SmartphoneImeiIdentifier("dev1");
|
||||
regattaLog.add(new RegattaLogDeviceCompetitorMappingEventImpl(t(), author, t(), UUID.randomUUID(), comp1, dev1,
|
||||
t(0), t(10)));
|
||||
addFixes0(dev1);
|
||||
regattaLog.add(new RegattaLogRegisterCompetitorEventImpl(t(), author, t(), UUID.randomUUID(), comp1));
|
||||
|
||||
// start tracking
|
||||
adapter.startTracking(service, leaderboard, column, fleet);
|
||||
|
||||
// now there is a trackedrace
|
||||
TrackedRace race = column.getTrackedRace(fleet);
|
||||
assertNotNull(race);
|
||||
|
||||
race.waitForLoadingFromGPSFixStoreToFinishRunning(regattaLog);
|
||||
addFixes1(race, comp1, dev1);
|
||||
|
||||
// add another mapping on the fly, other old fixes should be loaded
|
||||
regattaLog.add(new RegattaLogDeviceCompetitorMappingEventImpl(t(), author, t(), UUID.randomUUID(), comp1, dev1,
|
||||
t(11), t(20)));
|
||||
addFixes2(race, comp1, dev1);
|
||||
|
||||
// stop tracking, then no more fixes arrive at race
|
||||
service.getRaceTrackerById(raceLog.getId()).stop(/* preemptive */ false);
|
||||
gpsFixStore.storeFix(dev1, new GPSFixMovingImpl(new DegreePosition(0, 0), new MillisecondsTimePoint(8), new KnotSpeedWithBearingImpl(10, new DegreeBearingImpl(5))));
|
||||
testSize(race.getTrack(comp1), 5);
|
||||
addFixes3(race, comp1, dev1);
|
||||
}
|
||||
}
|
||||
+49
-38
@@ -1,6 +1,9 @@
|
||||
package com.sap.sailing.domain.racelogtracking.test.impl;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.lessThanOrEqualTo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -9,7 +12,6 @@ import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
@@ -26,7 +28,9 @@ import com.sap.sailing.domain.common.racelog.tracking.NoCorrespondingServiceRegi
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.racelog.impl.EmptyRaceLogStore;
|
||||
import com.sap.sailing.domain.racelog.tracking.test.mock.SmartphoneImeiIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.test.AbstractGPSFixStoreTest;
|
||||
import com.sap.sailing.domain.regattalog.impl.EmptyRegattaLogStore;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.tracking.TrackedRegatta;
|
||||
import com.sap.sailing.domain.tracking.impl.AbstractRaceChangeListener;
|
||||
@@ -37,24 +41,26 @@ import com.sap.sse.common.impl.TimeRangeImpl;
|
||||
|
||||
public class TrackedRaceLoadsFixesTest extends AbstractGPSFixStoreTest {
|
||||
private final BoatClass boatClass = DomainFactory.INSTANCE.getOrCreateBoatClass("49er");
|
||||
|
||||
|
||||
private int numberOfSwitchesBetweenLoadingRaceLogs = 0;
|
||||
private Integer previouslyLoading = null;
|
||||
private int numFixesReceived = 0;
|
||||
|
||||
|
||||
@Test
|
||||
public void areFixesStoredInDb() throws TransformationException, NoCorrespondingServiceRegisteredException, InterruptedException {
|
||||
public void areFixesStoredInDb() throws TransformationException, NoCorrespondingServiceRegisteredException,
|
||||
InterruptedException {
|
||||
Competitor comp2 = DomainFactory.INSTANCE.getOrCreateCompetitor("comp2", "comp2", null, null, null);
|
||||
Mark mark2 = DomainFactory.INSTANCE.getOrCreateMark("mark2");
|
||||
DeviceIdentifier device2 = new SmartphoneImeiIdentifier("imei2");
|
||||
DeviceIdentifier device3 = new SmartphoneImeiIdentifier("imei3");
|
||||
Course course = new CourseImpl("course", Arrays.asList(new Waypoint[] {
|
||||
new WaypointImpl(mark), new WaypointImpl(mark2)}));
|
||||
RaceDefinition race = new RaceDefinitionImpl("race", course, boatClass, Arrays.asList(new Competitor[] {comp, comp2}));
|
||||
Course course = new CourseImpl("course", Arrays.asList(new Waypoint[] { new WaypointImpl(mark),
|
||||
new WaypointImpl(mark2) }));
|
||||
RaceDefinition race = new RaceDefinitionImpl("race", course, boatClass, Arrays.asList(new Competitor[] { comp,
|
||||
comp2 }));
|
||||
|
||||
map(comp, device, 0, 20000);
|
||||
map(comp2, device2, 0, 600);
|
||||
//reuse device for two marks
|
||||
// reuse device for two marks
|
||||
map(mark, device3, 0, 600);
|
||||
map(mark2, device3, 0, 600);
|
||||
|
||||
@@ -63,16 +69,17 @@ public class TrackedRaceLoadsFixesTest extends AbstractGPSFixStoreTest {
|
||||
store.storeFix(device2, createFix(100, 10, 20, 30, 40));
|
||||
store.storeFix(device3, createFix(100, 10, 20, 30, 40));
|
||||
store.storeFix(device3, createFix(100, 10, 20, 30, 40));
|
||||
|
||||
for (int i=0; i<10000; i++) {
|
||||
store.storeFix(device, createFix(i+1000, 10, 20, 30, 40));
|
||||
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
store.storeFix(device, createFix(i + 1000, 10, 20, 30, 40));
|
||||
}
|
||||
|
||||
TrackedRegatta regatta = new DynamicTrackedRegattaImpl(new RegattaImpl(EmptyRaceLogStore.INSTANCE, RegattaImpl.getDefaultName("regatta", boatClass.getName()), boatClass,
|
||||
/*startDate*/ null, /*endDate*/ null, null, null, "a", null));
|
||||
DynamicTrackedRaceImpl trackedRace = new DynamicTrackedRaceImpl(regatta, race, Collections.<Sideline>emptyList(),
|
||||
EmptyWindStore.INSTANCE, store, 0, 0, 0);
|
||||
|
||||
TrackedRegatta regatta = new DynamicTrackedRegattaImpl(new RegattaImpl(EmptyRaceLogStore.INSTANCE,
|
||||
EmptyRegattaLogStore.INSTANCE, RegattaImpl.getDefaultName("regatta", boatClass.getName()), boatClass, /* startDate */
|
||||
null, /* endDate */null, null, null, "a", null));
|
||||
DynamicTrackedRaceImpl trackedRace = new DynamicTrackedRaceImpl(regatta, race,
|
||||
Collections.<Sideline> emptyList(), EmptyWindStore.INSTANCE, store, 0, 0, 0);
|
||||
|
||||
trackedRace.attachRaceLog(raceLog);
|
||||
trackedRace.waitForLoadingFromGPSFixStoreToFinishRunning(raceLog);
|
||||
|
||||
@@ -81,9 +88,9 @@ public class TrackedRaceLoadsFixesTest extends AbstractGPSFixStoreTest {
|
||||
testLength(trackedRace.getOrCreateTrack(mark), 1);
|
||||
testLength(trackedRace.getOrCreateTrack(mark2), 1);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void metadataStoredInDb() throws TransformationException, NoCorrespondingServiceRegisteredException {
|
||||
public void metadataStoredInDb() throws TransformationException, NoCorrespondingServiceRegisteredException {
|
||||
assertEquals(0, store.getNumberOfFixes(device));
|
||||
assertEquals(null, store.getTimeRangeCoveredByFixes(device));
|
||||
|
||||
@@ -91,36 +98,38 @@ public class TrackedRaceLoadsFixesTest extends AbstractGPSFixStoreTest {
|
||||
|
||||
store.storeFix(device, createFix(100, 10, 20, 30, 40));
|
||||
store.storeFix(device, createFix(200, 10, 20, 30, 40));
|
||||
|
||||
|
||||
assertEquals(2, store.getNumberOfFixes(device));
|
||||
assertEquals(TimeRangeImpl.create(100, 200), store.getTimeRangeCoveredByFixes(device));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void attachTwoRaceLogsAndSeeIfLoadingIsSerializedNicely()
|
||||
throws TransformationException, NoCorrespondingServiceRegisteredException, InterruptedException {
|
||||
Course course = new CourseImpl("course", Collections.<Waypoint>emptyList());
|
||||
RaceDefinition race = new RaceDefinitionImpl("race", course, boatClass, Arrays.asList(new Competitor[] {comp}));
|
||||
public void attachTwoRaceLogsAndSeeIfLoadingIsSerializedNicely() throws TransformationException,
|
||||
NoCorrespondingServiceRegisteredException, InterruptedException {
|
||||
Course course = new CourseImpl("course", Collections.<Waypoint> emptyList());
|
||||
RaceDefinition race = new RaceDefinitionImpl("race", course, boatClass,
|
||||
Arrays.asList(new Competitor[] { comp }));
|
||||
RaceLog raceLog2 = new RaceLogImpl("raceLog 2");
|
||||
|
||||
|
||||
final int numFixes = 10000;
|
||||
map(comp, device, 0, numFixes/2);
|
||||
map(raceLog2, comp, device, numFixes/2+1, numFixes);
|
||||
|
||||
for (int i=0; i<numFixes; i++) {
|
||||
map(comp, device, 0, numFixes / 2);
|
||||
map(raceLog2, comp, device, numFixes / 2 + 1, numFixes);
|
||||
|
||||
for (int i = 0; i < numFixes; i++) {
|
||||
store.storeFix(device, createFix(i, 10, 20, 30, 40));
|
||||
}
|
||||
|
||||
TrackedRegatta regatta = new DynamicTrackedRegattaImpl(new RegattaImpl(EmptyRaceLogStore.INSTANCE, RegattaImpl.getDefaultName("regatta", boatClass.getName()), boatClass,
|
||||
/*startDate*/ null, /*endDate*/ null, null, null, "a", null));
|
||||
DynamicTrackedRaceImpl trackedRace = new DynamicTrackedRaceImpl(regatta, race, Collections.<Sideline>emptyList(),
|
||||
EmptyWindStore.INSTANCE, store, 0, 0, 0);
|
||||
|
||||
TrackedRegatta regatta = new DynamicTrackedRegattaImpl(new RegattaImpl(EmptyRaceLogStore.INSTANCE,
|
||||
EmptyRegattaLogStore.INSTANCE, RegattaImpl.getDefaultName("regatta", boatClass.getName()), boatClass, /* startDate */
|
||||
null, /* endDate */null, null, null, "a", null));
|
||||
DynamicTrackedRaceImpl trackedRace = new DynamicTrackedRaceImpl(regatta, race,
|
||||
Collections.<Sideline> emptyList(), EmptyWindStore.INSTANCE, store, 0, 0, 0);
|
||||
|
||||
trackedRace.addListener(new AbstractRaceChangeListener() {
|
||||
@Override
|
||||
public void competitorPositionChanged(GPSFixMoving fix, Competitor competitor) {
|
||||
numFixesReceived++;
|
||||
int currentlyLoading = fix.getTimePoint().asMillis() <= numFixes/2 ? 1 : 2;
|
||||
int currentlyLoading = fix.getTimePoint().asMillis() <= numFixes / 2 ? 1 : 2;
|
||||
if (previouslyLoading == null) {
|
||||
previouslyLoading = currentlyLoading;
|
||||
} else if (previouslyLoading != currentlyLoading) {
|
||||
@@ -135,8 +144,10 @@ public class TrackedRaceLoadsFixesTest extends AbstractGPSFixStoreTest {
|
||||
|
||||
trackedRace.waitForLoadingFromGPSFixStoreToFinishRunning(raceLog);
|
||||
trackedRace.waitForLoadingFromGPSFixStoreToFinishRunning(raceLog2);
|
||||
|
||||
assertEquals(1, numberOfSwitchesBetweenLoadingRaceLogs);
|
||||
assertEquals(numFixes, numFixesReceived);
|
||||
|
||||
assertThat("switch at most once between the two race logs while loading",
|
||||
numberOfSwitchesBetweenLoadingRaceLogs, lessThanOrEqualTo(1));
|
||||
assertThat("number of fixes added to race equal to number of fixes in GPSFixStore", numFixesReceived,
|
||||
equalTo(numFixes));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.domain.racelog.tracking.test.mock;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
|
||||
|
||||
public class SmartphoneImeiIdentifier implements DeviceIdentifier {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.sap.sailing.domain.racelog.tracking.test.mock;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.server.gateway.serialization.racelog.tracking.DeviceIdentifierJsonHandler;
|
||||
|
||||
public class SmartphoneImeiJsonHandler extends SmartphoneImeiSerializationHandler
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package com.sap.sailing.domain.racelog.tracking.test.mock;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
|
||||
public class SmartphoneImeiMongoHandler extends SmartphoneImeiSerializationHandler
|
||||
implements DeviceIdentifierMongoHandler {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.sap.sailing.domain.racelog.tracking.test.mock;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sse.common.Util;
|
||||
|
||||
public class SmartphoneImeiSerializationHandler {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.domain.racelog.tracking.test.mock;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifierStringSerializationHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifierStringSerializationHandler;
|
||||
|
||||
public class SmartphoneImeiStringSerializationHandler extends SmartphoneImeiSerializationHandler
|
||||
implements DeviceIdentifierStringSerializationHandler {
|
||||
|
||||
-2
@@ -2,8 +2,6 @@ package com.sap.sailing.domain.racelogtracking;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
|
||||
/**
|
||||
* A device identifier used to identify a non-existent, virtual device, which is used only once as an
|
||||
* identifier to add a single fix to a track (i.e. pinging the location of that track's item).
|
||||
|
||||
+14
-7
@@ -4,9 +4,10 @@ import java.util.Set;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogCourseDesignChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.ControlPoint;
|
||||
import com.sap.sailing.domain.base.Fleet;
|
||||
@@ -32,7 +33,7 @@ public interface RaceLogTrackingAdapter {
|
||||
* <ul>
|
||||
* <li>Is the racelog denoted for tracking? If not, throw exception.</li>
|
||||
* <li>Is a {@link RaceLogRaceTracker} already listening for this racelog? If not, add one.</li>
|
||||
* <li>Is a {@link StartTrackingEvent} present in the racelog? If not, add one</li>
|
||||
* <li>Is a {@link RaceLogStartTrackingEvent} present in the racelog? If not, add one</li>
|
||||
* </ul>
|
||||
*/
|
||||
void startTracking(RacingEventService service, Leaderboard leaderboard, RaceColumn raceColumn, Fleet fleet)
|
||||
@@ -46,7 +47,7 @@ public interface RaceLogTrackingAdapter {
|
||||
boolean isRaceLogRaceTrackerAttached(RacingEventService service, RaceLog raceLog);
|
||||
|
||||
/**
|
||||
* Denotes the {@link RaceLog} for racelog-tracking, by inserting a {@link DenoteForTrackingEvent}.
|
||||
* Denotes the {@link RaceLog} for racelog-tracking, by inserting a {@link RaceLogDenoteForTrackingEvent}.
|
||||
*
|
||||
* @throws NotDenotableForRaceLogTrackingException
|
||||
* Fails, if no {@link RaceLog}, or a non-empty {@link RaceLog}, or one with attached
|
||||
@@ -57,7 +58,7 @@ public interface RaceLogTrackingAdapter {
|
||||
Fleet fleet, String raceName) throws NotDenotableForRaceLogTrackingException;
|
||||
|
||||
/**
|
||||
* Revoke the {@link DenoteForTrackingEvent}, and if it exists the {@link StartTrackingEvent}.
|
||||
* Revoke the {@link RaceLogDenoteForTrackingEvent}, and if it exists the {@link RaceLogStartTrackingEvent}.
|
||||
* This does not affect existing an {@link RaceLogRaceTracker}
|
||||
* or {@link TrackedRace} for this {@code RaceLog}.
|
||||
*/
|
||||
@@ -80,7 +81,7 @@ public interface RaceLogTrackingAdapter {
|
||||
* Duplicate the course and competitor registrations in the newest {@link RaceLogCourseDesignChangedEvent}
|
||||
* in {@code from} race log to the {@code to} race logs.
|
||||
* The {@link Mark}s and {@link ControlPoint}s are duplicated and not reused. This also inserts the necessary
|
||||
* {@link DefineMarkEvent}s into the {@code to} race logs.
|
||||
* {@link RaceLogDefineMarkEvent}s into the {@code to} race logs.
|
||||
*/
|
||||
void copyCourseAndCompetitors(RaceLog from, Set<RaceLog> to, SharedDomainFactory baseDomainFactory,
|
||||
RacingEventService service);
|
||||
@@ -90,4 +91,10 @@ public interface RaceLogTrackingAdapter {
|
||||
* and unregister all already registered competitors not in {@code competitors}.
|
||||
*/
|
||||
void registerCompetitors(RacingEventService service, RaceLog raceLog, Set<Competitor> competitors);
|
||||
|
||||
/**
|
||||
* If not yet registered, register the competitors in {@code competitors},
|
||||
* and unregister all already registered competitors not in {@code competitors}.
|
||||
*/
|
||||
void registerCompetitors(RacingEventService service, RegattaLog regattaLog, Set<Competitor> competitors);
|
||||
}
|
||||
+2
-2
@@ -11,12 +11,12 @@ import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceRegistration;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifierStringSerializationHandler;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.SmartphoneUUIDIdentifier;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TypeBasedServiceFinder;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifierStringSerializationHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.PingDeviceIdentifierImpl;
|
||||
import com.sap.sailing.domain.racelogtracking.RaceLogTrackingAdapterFactory;
|
||||
import com.sap.sailing.domain.racelogtracking.SmartphoneUUIDIdentifier;
|
||||
import com.sap.sailing.domain.trackfiles.TrackFileImportDeviceIdentifier;
|
||||
import com.sap.sailing.domain.tracking.GPSFix;
|
||||
import com.sap.sailing.server.gateway.deserialization.JsonDeserializer;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
package com.sap.sailing.domain.racelogtracking.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.server.gateway.serialization.racelog.tracking.DeviceIdentifierJsonHandler;
|
||||
|
||||
public class PingDeviceIdentifierJsonHandler extends PingDeviceIdentifierSerializationHandler
|
||||
|
||||
+1
-1
@@ -1,8 +1,8 @@
|
||||
package com.sap.sailing.domain.racelogtracking.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
|
||||
public class PingDeviceIdentifierMongoHandler extends PingDeviceIdentifierSerializationHandler
|
||||
implements DeviceIdentifierMongoHandler {
|
||||
|
||||
+1
-1
@@ -2,8 +2,8 @@ package com.sap.sailing.domain.racelogtracking.impl;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.PingDeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.PingDeviceIdentifierImpl;
|
||||
import com.sap.sse.common.Util;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.domain.racelogtracking.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifierStringSerializationHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifierStringSerializationHandler;
|
||||
|
||||
public class PingDeviceIdentifierStringSerializationHandler extends PingDeviceIdentifierSerializationHandler
|
||||
implements DeviceIdentifierStringSerializationHandler {
|
||||
|
||||
+13
@@ -1,7 +1,10 @@
|
||||
package com.sap.sailing.domain.racelogtracking.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RaceInformationFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RaceLogTrackingStateAnalyzer;
|
||||
@@ -14,6 +17,7 @@ import com.sap.sailing.domain.base.impl.RegattaImpl;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.RaceNotCreatedException;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.racelog.tracking.GPSFixStore;
|
||||
import com.sap.sailing.domain.regattalike.HasRegattaLike;
|
||||
import com.sap.sailing.domain.tracking.DynamicTrackedRegatta;
|
||||
import com.sap.sailing.domain.tracking.RaceTracker;
|
||||
import com.sap.sailing.domain.tracking.RaceTrackingConnectivityParameters;
|
||||
@@ -100,4 +104,13 @@ public class RaceLogConnectivityParams implements RaceTrackingConnectivityParame
|
||||
public DomainFactory getDomainFactory() {
|
||||
return domainFactory;
|
||||
}
|
||||
|
||||
public List<AbstractLog<?, ?>> getLogHierarchy() {
|
||||
List<AbstractLog<?, ?>> result = new ArrayList<>();
|
||||
result.add(getRaceLog());
|
||||
if (leaderboard instanceof HasRegattaLike) {
|
||||
result.add(((HasRegattaLike) leaderboard).getRegattaLike().getRegattaLog());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+122
-50
@@ -6,26 +6,36 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLog;
|
||||
import com.sap.sailing.domain.abstractlog.MultiLogAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.MultiLogAnalyzer.MapWithValueCollectionReducer;
|
||||
import com.sap.sailing.domain.abstractlog.MultiLogAnalyzer.SetReducer;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogCourseDesignChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.LastPublishedCourseDesignFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.BaseRaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMapping;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.DeviceCompetitorMappingFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.DeviceMappingFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.DeviceMarkMappingFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RaceInformationFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RaceLogTrackingStateAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RegisteredCompetitorsAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.RegattaLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.impl.BaseRegattaLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.shared.analyzing.DeviceCompetitorMappingFinder;
|
||||
import com.sap.sailing.domain.abstractlog.shared.analyzing.DeviceMarkMappingFinder;
|
||||
import com.sap.sailing.domain.abstractlog.shared.analyzing.RegisteredCompetitorsAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.shared.events.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.shared.events.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.ControlPoint;
|
||||
@@ -52,6 +62,9 @@ import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.markpassingcalculation.MarkPassingCalculator;
|
||||
import com.sap.sailing.domain.racelog.tracking.GPSFixReceivedListener;
|
||||
import com.sap.sailing.domain.racelog.tracking.GPSFixStore;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceMapping;
|
||||
import com.sap.sailing.domain.regattalike.IsRegattaLike;
|
||||
import com.sap.sailing.domain.tracking.DynamicGPSFixTrack;
|
||||
import com.sap.sailing.domain.tracking.DynamicTrackedRace;
|
||||
import com.sap.sailing.domain.tracking.DynamicTrackedRegatta;
|
||||
@@ -70,20 +83,22 @@ import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import difflib.PatchFailedException;
|
||||
|
||||
/**
|
||||
* Track a race using the data defined in the {@link RaceLog}. If the events suggest that the race is already in the
|
||||
* Track a race using the data defined in the {@link RaceLog} and possibly the Leaderboards
|
||||
* {@link IsRegattaLike#getRegattaLog RegattaLog}. If the events suggest that the race is already in the
|
||||
* {@link RaceLogTrackingState#TRACKING} state, tracking commences immediately and existing fixes are loaded immediately
|
||||
* from the database.
|
||||
* from the database.Thinkpad
|
||||
* <p>
|
||||
* Otherwise, the tracker waits until a {@link StartTrackingEvent} is received to perform these tasks.
|
||||
* Otherwise, the tracker waits until a {@link RaceLogStartTrackingEvent} is received to perform these tasks.
|
||||
*
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceTracker, GPSFixReceivedListener {
|
||||
public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener {
|
||||
private final RaceLogConnectivityParams params;
|
||||
private final WindStore windStore;
|
||||
private final GPSFixStore gpsFixStore;
|
||||
private final DynamicTrackedRegatta regatta;
|
||||
private final Map<AbstractLog<?, ?>, Object> visitors = new HashMap<AbstractLog<?, ?>, Object>();
|
||||
|
||||
private Map<Competitor, List<DeviceMapping<Competitor>>> competitorMappings = new HashMap<>();
|
||||
private Map<Mark, List<DeviceMapping<Mark>>> markMappings = new HashMap<>();
|
||||
@@ -102,8 +117,48 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
this.gpsFixStore = gpsFixStore;
|
||||
this.regatta = regatta;
|
||||
|
||||
// add a listener on the racelog, to be informed about relevant events
|
||||
params.getRaceLog().addListener(this);
|
||||
// add log listeners
|
||||
for (AbstractLog<?, ?> log : params.getLogHierarchy()) {
|
||||
if (log instanceof RaceLog) {
|
||||
RaceLogEventVisitor visitor = new BaseRaceLogEventVisitor() {
|
||||
@Override
|
||||
public void visit(RaceLogDeviceCompetitorMappingEvent event) {
|
||||
RaceLogRaceTracker.this.onDeviceCompetitorMappingEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RaceLogDeviceMarkMappingEvent event) {
|
||||
RaceLogRaceTracker.this.onDeviceMarkMappingEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RaceLogStartTrackingEvent event) {
|
||||
RaceLogRaceTracker.this.onStartTrackingEvent(event);
|
||||
};
|
||||
|
||||
@Override
|
||||
public void visit(RaceLogCourseDesignChangedEvent event) {
|
||||
RaceLogRaceTracker.this.onCourseDesignChangedEvent(event);
|
||||
}
|
||||
};
|
||||
visitors.put(log, visitor);
|
||||
((RaceLog) log).addListener(visitor);
|
||||
} else if (log instanceof RegattaLog) {
|
||||
RegattaLogEventVisitor visitor = new BaseRegattaLogEventVisitor() {
|
||||
@Override
|
||||
public void visit(RegattaLogDeviceCompetitorMappingEvent event) {
|
||||
RaceLogRaceTracker.this.onDeviceCompetitorMappingEvent(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RegattaLogDeviceMarkMappingEvent event) {
|
||||
RaceLogRaceTracker.this.onDeviceMarkMappingEvent(event);
|
||||
}
|
||||
};
|
||||
visitors.put(log, visitor);
|
||||
((RegattaLog) log).addListener(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(String.format("Created race-log tracker for: %s %s %s", params.getLeaderboard(),
|
||||
params.getRaceColumn(), params.getFleet()));
|
||||
@@ -116,15 +171,18 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
|
||||
@Override
|
||||
public void stop(boolean preemptive) {
|
||||
// mark passing calculator is automatically stopped, when the race status is set to {@link TrackedRaceStatusEnum#FINISHED}
|
||||
// mark passing calculator is automatically stopped, when the race status is set to {@link
|
||||
// TrackedRaceStatusEnum#FINISHED}
|
||||
trackedRace.setStatus(new TrackedRaceStatusImpl(TrackedRaceStatusEnum.FINISHED, 100));
|
||||
|
||||
// remove listener on racelog
|
||||
params.getRaceLog().removeListener(this);
|
||||
// remove listeners on logs
|
||||
for (Entry<AbstractLog<?, ?>, Object> visitor : visitors.entrySet()) {
|
||||
visitor.getKey().removeListener(visitor.getValue());
|
||||
}
|
||||
|
||||
// remove listener for fixes
|
||||
gpsFixStore.removeListener(this);
|
||||
|
||||
|
||||
logger.info(String.format("Stopped tracking race-log race %s %s %s", params.getLeaderboard(),
|
||||
params.getRaceColumn(), params.getFleet()));
|
||||
}
|
||||
@@ -170,11 +228,13 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
}
|
||||
|
||||
private Map<Competitor, List<DeviceMapping<Competitor>>> getNewCompetitorMappings() {
|
||||
return new DeviceCompetitorMappingFinder(params.getRaceLog()).analyze();
|
||||
return new MultiLogAnalyzer<>(new DeviceCompetitorMappingFinder.Factory(),
|
||||
new MapWithValueCollectionReducer<>(), params.getLogHierarchy()).analyze();
|
||||
}
|
||||
|
||||
private Map<Mark, List<DeviceMapping<Mark>>> getNewMarkMappings() {
|
||||
return new DeviceMarkMappingFinder(params.getRaceLog()).analyze();
|
||||
return new MultiLogAnalyzer<>(new DeviceMarkMappingFinder.Factory(), new MapWithValueCollectionReducer<>(),
|
||||
params.getLogHierarchy()).analyze();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,14 +342,20 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
updateStartAndEndOfTracking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DeviceMarkMappingEvent event) {
|
||||
private void onDeviceMarkMappingEvent(DeviceMarkMappingEvent<?> event) {
|
||||
if (trackedRace != null) {
|
||||
updateMarkMappings(true);
|
||||
gpsFixStore.addListener(this, event.getDevice());
|
||||
}
|
||||
}
|
||||
|
||||
private void onDeviceCompetitorMappingEvent(DeviceCompetitorMappingEvent<?> event) {
|
||||
if (trackedRace != null) {
|
||||
updateCompetitorMappings(true);
|
||||
gpsFixStore.addListener(this, event.getDevice());
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCompetitorMappings(boolean loadIfNotCovered) {
|
||||
// TODO remove fixes, if mappings have been removed
|
||||
|
||||
@@ -324,31 +390,22 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
updateStartAndEndOfTracking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DeviceCompetitorMappingEvent event) {
|
||||
if (trackedRace != null) {
|
||||
updateCompetitorMappings(true);
|
||||
gpsFixStore.addListener(this, event.getDevice());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(StartTrackingEvent event) {
|
||||
private void onStartTrackingEvent(RaceLogStartTrackingEvent event) {
|
||||
if (trackedRace == null)
|
||||
startTracking(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RaceLogCourseDesignChangedEvent event) {
|
||||
if (trackedRace == null) return;
|
||||
|
||||
|
||||
private void onCourseDesignChangedEvent(RaceLogCourseDesignChangedEvent event) {
|
||||
if (trackedRace == null)
|
||||
return;
|
||||
|
||||
CourseBase base = new LastPublishedCourseDesignFinder(params.getRaceLog()).analyze();
|
||||
List<Util.Pair<ControlPoint, PassingInstruction>> update = new ArrayList<>();
|
||||
|
||||
|
||||
for (Waypoint waypoint : base.getWaypoints()) {
|
||||
update.add(new Util.Pair<>(waypoint.getControlPoint(), waypoint.getPassingInstructions()));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
trackedRace.getRace().getCourse().update(update, params.getDomainFactory());
|
||||
} catch (PatchFailedException e) {
|
||||
@@ -356,12 +413,12 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
}
|
||||
}
|
||||
|
||||
private void startTracking(StartTrackingEvent event) {
|
||||
private void startTracking(RaceLogStartTrackingEvent event) {
|
||||
RaceLog raceLog = params.getRaceLog();
|
||||
RaceColumn raceColumn = params.getRaceColumn();
|
||||
Fleet fleet = params.getFleet();
|
||||
|
||||
DenoteForTrackingEvent denoteEvent = new RaceInformationFinder(raceLog).analyze();
|
||||
RaceLogDenoteForTrackingEvent denoteEvent = new RaceInformationFinder(raceLog).analyze();
|
||||
BoatClass boatClass = denoteEvent.getBoatClass();
|
||||
String raceName = denoteEvent.getRaceName();
|
||||
CourseBase courseBase = new LastPublishedCourseDesignFinder(raceLog).analyze();
|
||||
@@ -376,11 +433,15 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
try {
|
||||
raceLog.revokeEvent(params.getService().getServerAuthor(), event,
|
||||
"could not start tracking because tracked race already exists");
|
||||
} catch (NotRevokableException e) {}
|
||||
} catch (NotRevokableException e) {
|
||||
}
|
||||
throw new RaceNotCreatedException(String.format("Race for racelog (%s) has already been created", raceLog));
|
||||
}
|
||||
|
||||
Iterable<Competitor> competitors = new RegisteredCompetitorsAnalyzer(raceLog).analyze();
|
||||
// check both the racelog and regattalog for registered competitors
|
||||
Set<Competitor> competitors = new MultiLogAnalyzer<>(RegisteredCompetitorsAnalyzer.Factory.INSTANCE,
|
||||
new SetReducer<Competitor>(), params.getLogHierarchy()).analyze();
|
||||
|
||||
Serializable raceId = denoteEvent.getRaceId();
|
||||
final RaceDefinition raceDef = new RaceDefinitionImpl(raceName, course, boatClass, competitors, raceId);
|
||||
|
||||
@@ -396,17 +457,20 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
|
||||
trackedRace.setStatus(new TrackedRaceStatusImpl(TrackedRaceStatusEnum.TRACKING, 0));
|
||||
|
||||
//add listeners for devices in mappings
|
||||
for (List<DeviceMapping<WithID>> mappings : new DeviceMappingFinder<WithID>(params.getRaceLog()).analyze().values()) {
|
||||
for (DeviceMapping<WithID> mapping : mappings) {
|
||||
gpsFixStore.addListener(this, mapping.getDevice());
|
||||
//attach regatta logs
|
||||
for (AbstractLog<?, ?> log : params.getLogHierarchy()) {
|
||||
if (log instanceof RegattaLog) {
|
||||
trackedRace.attachRegattaLog((RegattaLog) log);
|
||||
}
|
||||
}
|
||||
|
||||
// update the device mappings (without loading the fixes, as the TrackedRace does this itself on startup)
|
||||
updateCompetitorMappings(false);
|
||||
updateMarkMappings(false);
|
||||
|
||||
// add listeners for devices in mappings already present
|
||||
addListeners(competitorMappings);
|
||||
addListeners(markMappings);
|
||||
|
||||
// add mark passing detection
|
||||
new MarkPassingCalculator(trackedRace, true);
|
||||
|
||||
@@ -417,6 +481,14 @@ public class RaceLogRaceTracker extends BaseRaceLogEventVisitor implements RaceT
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends WithID> void addListeners(Map<T, List<DeviceMapping<T>>> mappings) {
|
||||
for (List<DeviceMapping<T>> list : mappings.values()) {
|
||||
for (DeviceMapping<T> mapping : list) {
|
||||
gpsFixStore.addListener(this, mapping.getDevice());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RaceLogConnectivityParams getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
+44
-26
@@ -6,24 +6,27 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLog;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.Revokable;
|
||||
import com.sap.sailing.domain.abstractlog.impl.AllEventsOfTypeFinder;
|
||||
import com.sap.sailing.domain.abstractlog.impl.LastEventOfTypeFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventFactory;
|
||||
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.LastPublishedCourseDesignFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.AllEventsOfTypeFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.LastEventOfTypeFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RaceLogTrackingStateAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RegisteredCompetitorsAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogRegisterCompetitorEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.shared.analyzing.RegisteredCompetitorsAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.shared.events.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.ControlPoint;
|
||||
@@ -48,6 +51,7 @@ import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.leaderboard.FlexibleLeaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.Leaderboard;
|
||||
import com.sap.sailing.domain.leaderboard.RegattaLeaderboard;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.PingDeviceIdentifierImpl;
|
||||
import com.sap.sailing.domain.racelogtracking.RaceLogTrackingAdapter;
|
||||
import com.sap.sailing.domain.tracking.GPSFix;
|
||||
@@ -91,7 +95,7 @@ public class RaceLogTrackingAdapterImpl implements RaceLogTrackingAdapter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a {@link RaceLogRaceTracker}. If a {@link StartTrackingEvent} is already present in the {@code RaceLog}
|
||||
* Adds a {@link RaceLogRaceTracker}. If a {@link RaceLogStartTrackingEvent} is already present in the {@code RaceLog}
|
||||
* linked to the {@code raceColumn} and {@code fleet}, a {@code TrackedRace} is created immediately and tracking begins.
|
||||
* Otherwise, the {@code RaceLogRaceTracker} waits until a {@code StartTrackingEvent} is added to perform these actions.
|
||||
* The race first has to be denoted for racelog tracking.
|
||||
@@ -200,7 +204,7 @@ public class RaceLogTrackingAdapterImpl implements RaceLogTrackingAdapter {
|
||||
}
|
||||
|
||||
private void revokeAlreadyDefinedMarks(RaceLog raceLog, AbstractLogEventAuthor author) {
|
||||
List<RaceLogEvent> markEvents = new AllEventsOfTypeFinder(raceLog, true, DefineMarkEvent.class).analyze();
|
||||
List<RaceLogEvent> markEvents = new AllEventsOfTypeFinder<>(raceLog, true, RaceLogDefineMarkEvent.class).analyze();
|
||||
for (RaceLogEvent event : markEvents) {
|
||||
try {
|
||||
raceLog.revokeEvent(author, event, "removing mark that was already defined");
|
||||
@@ -214,14 +218,14 @@ public class RaceLogTrackingAdapterImpl implements RaceLogTrackingAdapter {
|
||||
public void copyCourseAndCompetitors(RaceLog fromRaceLog, Set<RaceLog> toRaceLogs, SharedDomainFactory baseDomainFactory,
|
||||
RacingEventService service) {
|
||||
CourseBase course = new LastPublishedCourseDesignFinder(fromRaceLog).analyze();
|
||||
Set<Competitor> competitors = new RegisteredCompetitorsAnalyzer(fromRaceLog).analyze();
|
||||
Set<Competitor> competitors = new RegisteredCompetitorsAnalyzer<>(fromRaceLog).analyze();
|
||||
|
||||
for (RaceLog toRaceLog : toRaceLogs) {
|
||||
CourseBase to = new CourseDataImpl("Copy of \"" + course.getName());
|
||||
TimePoint now = MillisecondsTimePoint.now();
|
||||
if (course == null || ! new RaceLogTrackingStateAnalyzer(toRaceLog).analyze().isForTracking()) {
|
||||
continue;
|
||||
}
|
||||
CourseBase to = new CourseDataImpl("Copy of \"" + course.getName());
|
||||
TimePoint now = MillisecondsTimePoint.now();
|
||||
int i = 0;
|
||||
Map<ControlPoint, ControlPoint> controlPointDuplicationCache = new HashMap<ControlPoint, ControlPoint>();
|
||||
revokeAlreadyDefinedMarks(toRaceLog, service.getServerAuthor());
|
||||
@@ -263,8 +267,8 @@ public class RaceLogTrackingAdapterImpl implements RaceLogTrackingAdapter {
|
||||
|
||||
@Override
|
||||
public void removeDenotationForRaceLogTracking(RacingEventService service, RaceLog raceLog) {
|
||||
Revokable denoteForTrackingEvent = (Revokable) new LastEventOfTypeFinder(raceLog, true, DenoteForTrackingEvent.class).analyze();
|
||||
Revokable startTrackingEvent = (Revokable) new LastEventOfTypeFinder(raceLog, true, StartTrackingEvent.class).analyze();
|
||||
RaceLogEvent denoteForTrackingEvent = new LastEventOfTypeFinder<>(raceLog, true, RaceLogDenoteForTrackingEvent.class).analyze();
|
||||
RaceLogEvent startTrackingEvent = new LastEventOfTypeFinder<>(raceLog, true, RaceLogStartTrackingEvent.class).analyze();
|
||||
try {
|
||||
raceLog.revokeEvent(service.getServerAuthor(), denoteForTrackingEvent, "remove denotation");
|
||||
raceLog.revokeEvent(service.getServerAuthor(), startTrackingEvent, "reset start time upon removing denotation");
|
||||
@@ -272,10 +276,11 @@ public class RaceLogTrackingAdapterImpl implements RaceLogTrackingAdapter {
|
||||
logger.log(Level.WARNING, "could not remove denotation by adding RevokeEvents", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCompetitors(RacingEventService service, RaceLog raceLog, Set<Competitor> competitors) {
|
||||
Set<Competitor> alreadyRegistered = new HashSet<Competitor>(new RegisteredCompetitorsAnalyzer(raceLog).analyze());
|
||||
|
||||
private <LogT extends AbstractLog<EventT, VisitorT>, EventT extends AbstractLogEvent<VisitorT>, VisitorT>
|
||||
void registerCompetitors(AbstractLogEventAuthor author, LogT log, Set<Competitor> competitors,
|
||||
Function<Competitor, EventT> registerEventFactory) {
|
||||
Set<Competitor> alreadyRegistered = new HashSet<Competitor>(new RegisteredCompetitorsAnalyzer<>(log).analyze());
|
||||
Set<Competitor> toBeRegistered = new HashSet<Competitor>();
|
||||
|
||||
for (Competitor c : competitors) {
|
||||
@@ -288,23 +293,36 @@ public class RaceLogTrackingAdapterImpl implements RaceLogTrackingAdapter {
|
||||
|
||||
//register
|
||||
for (Competitor c : toBeRegistered) {
|
||||
raceLog.add(RaceLogEventFactory.INSTANCE.createRegisterCompetitorEvent(MillisecondsTimePoint.now(),
|
||||
service.getServerAuthor(), raceLog.getCurrentPassId(), c));
|
||||
log.add(registerEventFactory.apply(c));
|
||||
}
|
||||
|
||||
//unregister
|
||||
for (RaceLogEvent event : raceLog.getUnrevokedEventsDescending()) {
|
||||
for (EventT event : log.getUnrevokedEventsDescending()) {
|
||||
if (event instanceof RegisterCompetitorEvent) {
|
||||
RegisterCompetitorEvent registerEvent = (RegisterCompetitorEvent) event;
|
||||
RegisterCompetitorEvent<?> registerEvent = (RegisterCompetitorEvent<?>) event;
|
||||
if (toBeRemoved.contains(registerEvent.getCompetitor())) {
|
||||
try {
|
||||
raceLog.revokeEvent(service.getServerAuthor(), (RegisterCompetitorEvent) event,
|
||||
log.revokeEvent(author, event,
|
||||
"unregistering competitor because no longer selected for registration");
|
||||
} catch (NotRevokableException e) {
|
||||
logger.log(Level.WARNING, "could not unregister competitor by adding RevokeEvent", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCompetitors(RacingEventService service, RaceLog raceLog, Set<Competitor> competitors) {
|
||||
registerCompetitors(service.getServerAuthor(), raceLog, competitors,
|
||||
c -> RaceLogEventFactory.INSTANCE.createRegisterCompetitorEvent(MillisecondsTimePoint.now(),
|
||||
service.getServerAuthor(), raceLog.getCurrentPassId(), c));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCompetitors(RacingEventService service, RegattaLog regattaLog, Set<Competitor> competitors) {
|
||||
registerCompetitors(service.getServerAuthor(), regattaLog, competitors,
|
||||
c -> new RegattaLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), service.getServerAuthor(),
|
||||
MillisecondsTimePoint.now(), UUID.randomUUID(), c));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
package com.sap.sailing.domain.racelogtracking.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.SmartphoneUUIDSerializationHandler;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.SmartphoneUUIDSerializationHandler;
|
||||
|
||||
public class SmartphoneUUIDMongoHandler extends SmartphoneUUIDSerializationHandler
|
||||
implements DeviceIdentifierMongoHandler {
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package com.sap.sailing.domain.racelogtracking.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifierStringSerializationHandler;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.SmartphoneUUIDSerializationHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifierStringSerializationHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.SmartphoneUUIDSerializationHandler;
|
||||
|
||||
public class SmartphoneUUIDStringSerializationHandler extends SmartphoneUUIDSerializationHandler
|
||||
implements DeviceIdentifierStringSerializationHandler {
|
||||
|
||||
+1
-1
@@ -4,8 +4,8 @@ import java.util.UUID;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.trackfiles.TrackFileImportDeviceIdentifier;
|
||||
import com.sap.sailing.domain.trackfiles.TrackFileImportDeviceIdentifierImpl;
|
||||
import com.sap.sailing.server.gateway.serialization.racelog.tracking.DeviceIdentifierJsonHandler;
|
||||
|
||||
+1
-1
@@ -4,9 +4,9 @@ import java.util.UUID;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.persistence.racelog.tracking.DeviceIdentifierMongoHandler;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.trackfiles.TrackFileImportDeviceIdentifier;
|
||||
import com.sap.sailing.domain.trackfiles.TrackFileImportDeviceIdentifierImpl;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@ package com.sap.sailing.domain.racelogtracking.impl;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifierStringSerializationHandler;
|
||||
import com.sap.sailing.domain.common.racelog.tracking.TransformationException;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifierStringSerializationHandler;
|
||||
import com.sap.sailing.domain.trackfiles.TrackFileImportDeviceIdentifier;
|
||||
import com.sap.sailing.domain.trackfiles.TrackFileImportDeviceIdentifierImpl;
|
||||
import com.sap.sse.common.Util;
|
||||
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
package com.sap.sailing.domain.racelog.analyzing.test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.MultiLogAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.impl.LogEventAuthorImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogDeviceCompetitorMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogRegisterCompetitorEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogDeviceCompetitorMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.events.impl.RegattaLogRegisterCompetitorEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.regatta.impl.RegattaLogImpl;
|
||||
import com.sap.sailing.domain.abstractlog.shared.analyzing.DeviceMappingFinder;
|
||||
import com.sap.sailing.domain.abstractlog.shared.analyzing.RegisteredCompetitorsAnalyzer;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.impl.CompetitorImpl;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceMapping;
|
||||
import com.sap.sailing.domain.racelogtracking.impl.SmartphoneUUIDIdentifierImpl;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.WithID;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
public class MultiLogAnalyzerTest {
|
||||
private static TimePoint now() {
|
||||
return MillisecondsTimePoint.now();
|
||||
}
|
||||
|
||||
private static TimePoint t(long millis) {
|
||||
return new MillisecondsTimePoint(millis);
|
||||
}
|
||||
|
||||
private static UUID uuid() {
|
||||
return UUID.randomUUID();
|
||||
}
|
||||
|
||||
private RaceLog raceLog;
|
||||
private RegattaLog regattaLog;
|
||||
private AbstractLogEventAuthor author;
|
||||
|
||||
private static Competitor createCompetitor(int n) {
|
||||
return new CompetitorImpl(n, n + "", null, null, null);
|
||||
}
|
||||
|
||||
private static DeviceIdentifier createDevice() {
|
||||
return new SmartphoneUUIDIdentifierImpl(UUID.randomUUID());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
raceLog = new RaceLogImpl(0);
|
||||
regattaLog = new RegattaLogImpl(0);
|
||||
author = new LogEventAuthorImpl("test", 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerCompetitorsInRaceAndRegattaLog() {
|
||||
Competitor c1 = createCompetitor(1);
|
||||
Competitor c2 = createCompetitor(2);
|
||||
Competitor c3 = createCompetitor(3);
|
||||
|
||||
raceLog.add(new RaceLogRegisterCompetitorEventImpl(now(), author, now(), uuid(), 0, c1));
|
||||
regattaLog.add(new RegattaLogRegisterCompetitorEventImpl(now(), author, now(), uuid(), c2));
|
||||
|
||||
raceLog.add(new RaceLogRegisterCompetitorEventImpl(now(), author, now(), uuid(), 0, c3));
|
||||
regattaLog.add(new RegattaLogRegisterCompetitorEventImpl(now(), author, now(), uuid(), c3));
|
||||
|
||||
Set<Competitor> result = new MultiLogAnalyzer<>(
|
||||
RegisteredCompetitorsAnalyzer.Factory.INSTANCE, new MultiLogAnalyzer.SetReducer<Competitor>(), raceLog,
|
||||
regattaLog).analyze();
|
||||
|
||||
assertThat("competitor 1 added", result, hasItem(c1));
|
||||
assertThat("competitor 2 added", result, hasItem(c2));
|
||||
assertThat("competitor 3 added", result, hasItem(c3));
|
||||
assertThat("only three items in total", result.size(), equalTo(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deviceMappingsInRaceAndRegattaLog() {
|
||||
Competitor c1 = createCompetitor(1);
|
||||
Competitor c2 = createCompetitor(2);
|
||||
|
||||
DeviceIdentifier d1 = createDevice();
|
||||
DeviceIdentifier d2 = createDevice();
|
||||
|
||||
raceLog.add(new RaceLogDeviceCompetitorMappingEventImpl(now(), author, now(), 0, 0, c1, d1, t(0), t(10)));
|
||||
raceLog.add(new RaceLogDeviceCompetitorMappingEventImpl(now(), author, now(), 1, 0, c1, d2, t(30), t(40)));
|
||||
regattaLog.add(new RegattaLogDeviceCompetitorMappingEventImpl(now(), author, now(), 2, c2, d2, t(10), t(20)));
|
||||
|
||||
// and one for same item (competitor) in other log
|
||||
regattaLog.add(new RegattaLogDeviceCompetitorMappingEventImpl(now(), author, now(), 3, c1, d1, t(10),
|
||||
t(20)));
|
||||
|
||||
Map<WithID, List<DeviceMapping<WithID>>> result = new MultiLogAnalyzer<>(
|
||||
new DeviceMappingFinder.Factory<>(), new MultiLogAnalyzer.MapWithValueCollectionReducer<>(), raceLog,
|
||||
regattaLog).analyze();
|
||||
|
||||
assertThat("mappings for two competitors", result.size(), equalTo(2));
|
||||
assertThat("three mappings for competitor 1 ", result.get(c1).size(), equalTo(3));
|
||||
assertThat("one mapping for competitor 2", result.get(c2).size(), equalTo(1));
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -17,7 +17,7 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventFactory;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogChangedVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.common.abstractlog.NotRevokableException;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.Util;
|
||||
@@ -107,7 +107,7 @@ public class RaceLogRevocationTest {
|
||||
|
||||
@Test
|
||||
public void sameEventRevokedByTwoClientsBeforeSync() throws NotRevokableException {
|
||||
DenoteForTrackingEvent event = RaceLogEventFactory.INSTANCE.createDenoteForTrackingEvent(
|
||||
RaceLogDenoteForTrackingEvent event = RaceLogEventFactory.INSTANCE.createDenoteForTrackingEvent(
|
||||
now(), serverAuthor, 0, "race", null, null);
|
||||
serverRaceLog.add(event);
|
||||
|
||||
|
||||
+4
-4
@@ -16,7 +16,7 @@ import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventFactory;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartTimeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.racelog.tracking.test.mock.SmartphoneImeiIdentifier;
|
||||
import com.sap.sailing.domain.test.AbstractLeaderboardTest;
|
||||
import com.sap.sse.common.Util;
|
||||
@@ -79,7 +79,7 @@ public class SerializeRaceLogEventsTest {
|
||||
|
||||
@Test
|
||||
public void testRaceLogSerializationWithEventContainingDeviceIdentifier() throws IOException, ClassNotFoundException {
|
||||
DeviceCompetitorMappingEvent mappingEvent = eventFactory.createDeviceCompetitorMappingEvent(
|
||||
RaceLogDeviceCompetitorMappingEvent mappingEvent = eventFactory.createDeviceCompetitorMappingEvent(
|
||||
MillisecondsTimePoint.now(), new LogEventAuthorImpl("Author Name", /* priority */0), new SmartphoneImeiIdentifier("1948364938463903"),
|
||||
AbstractLeaderboardTest.createCompetitor("Test Competitor"), 0, new MillisecondsTimePoint(0), new MillisecondsTimePoint(10));
|
||||
raceLog.add(mappingEvent);
|
||||
@@ -89,8 +89,8 @@ public class SerializeRaceLogEventsTest {
|
||||
raceLog.lockForRead();
|
||||
rl.lockForRead();
|
||||
try {
|
||||
DeviceCompetitorMappingEvent expected = ((DeviceCompetitorMappingEvent) raceLog.getFirstRawFix());
|
||||
DeviceCompetitorMappingEvent actual = ((DeviceCompetitorMappingEvent) rl.getFirstRawFix());
|
||||
RaceLogDeviceCompetitorMappingEvent expected = ((RaceLogDeviceCompetitorMappingEvent) raceLog.getFirstRawFix());
|
||||
RaceLogDeviceCompetitorMappingEvent actual = ((RaceLogDeviceCompetitorMappingEvent) rl.getFirstRawFix());
|
||||
|
||||
assertEquals(Util.size(raceLog.getRawFixes()), Util.size(rl.getRawFixes()));
|
||||
assertEquals(expected.getDevice().getIdentifierType(), actual.getDevice().getIdentifierType());
|
||||
|
||||
+4
-4
@@ -12,12 +12,12 @@ import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMapping;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.DeviceCompetitorMappingFinder;
|
||||
import com.sap.sailing.domain.abstractlog.shared.analyzing.DeviceCompetitorMappingFinder;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.impl.CompetitorImpl;
|
||||
import com.sap.sailing.domain.racelog.tracking.test.mock.SmartphoneImeiIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceMapping;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class DeviceMappingFinderTest extends AbstractRaceLogTrackingTest {
|
||||
private int time = 0;
|
||||
|
||||
private List<DeviceMapping<Competitor>> getMappings() {
|
||||
return new DeviceCompetitorMappingFinder(log).analyze().get(competitor);
|
||||
return new DeviceCompetitorMappingFinder<>(log).analyze().get(competitor);
|
||||
}
|
||||
|
||||
private TimePoint t() {
|
||||
|
||||
@@ -30,10 +30,13 @@ Export-Package: com.sap.sailing.domain.abstractlog,
|
||||
com.sap.sailing.domain.abstractlog.race.state.racingprocedure.rrs26.impl,
|
||||
com.sap.sailing.domain.abstractlog.race.tracking,
|
||||
com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl,
|
||||
com.sap.sailing.domain.abstractlog.race.tracking.events,
|
||||
com.sap.sailing.domain.abstractlog.race.tracking.impl,
|
||||
com.sap.sailing.domain.abstractlog.regatta,
|
||||
com.sap.sailing.domain.abstractlog.regatta.events,
|
||||
com.sap.sailing.domain.abstractlog.regatta.events.impl,
|
||||
com.sap.sailing.domain.abstractlog.regatta.impl,
|
||||
com.sap.sailing.domain.abstractlog.shared.analyzing,
|
||||
com.sap.sailing.domain.abstractlog.shared.events,
|
||||
com.sap.sailing.domain.base,
|
||||
com.sap.sailing.domain.base.configuration,
|
||||
com.sap.sailing.domain.base.configuration.impl,
|
||||
@@ -41,6 +44,8 @@ Export-Package: com.sap.sailing.domain.abstractlog,
|
||||
com.sap.sailing.domain.base.impl,
|
||||
com.sap.sailing.domain.base.racegroup,
|
||||
com.sap.sailing.domain.base.racegroup.impl,
|
||||
com.sap.sailing.domain.racelogtracking,
|
||||
com.sap.sailing.domain.racelogtracking.impl,
|
||||
com.sap.sailing.domain.tracking,
|
||||
com.sap.sailing.domain.tracking.impl,
|
||||
com.sap.sailing.util.impl
|
||||
+1
-1
@@ -44,7 +44,7 @@ extends Track<EventT>, WithID {
|
||||
/**
|
||||
* Remove a listener.
|
||||
*/
|
||||
void removeListener(VisitorT listener);
|
||||
void removeListener(Object listener);
|
||||
|
||||
/**
|
||||
* Removes all listeners
|
||||
|
||||
+7
-7
@@ -1,18 +1,17 @@
|
||||
package com.sap.sailing.domain.abstractlog;
|
||||
|
||||
|
||||
/**
|
||||
* Analyzer to perform a query over a given AbstractLog. Each subclass defines its <code>ResultType</code>.
|
||||
*
|
||||
* @param <ResultType>
|
||||
* @param <ResultT>
|
||||
* type of analysis result.
|
||||
*/
|
||||
public abstract class AbstractLogAnalyzer<LogT extends AbstractLog<EventT, VisitorT>,
|
||||
EventT extends AbstractLogEvent<VisitorT>, VisitorT, ResultType> {
|
||||
public abstract class BaseLogAnalyzer<LogT extends AbstractLog<EventT, VisitorT>, EventT extends AbstractLogEvent<VisitorT>, VisitorT, ResultT>
|
||||
implements LogAnalyzer<ResultT> {
|
||||
|
||||
protected LogT log;
|
||||
|
||||
public AbstractLogAnalyzer(LogT log) {
|
||||
public BaseLogAnalyzer(LogT log) {
|
||||
this.log = log;
|
||||
}
|
||||
|
||||
@@ -20,7 +19,8 @@ EventT extends AbstractLogEvent<VisitorT>, VisitorT, ResultType> {
|
||||
return log;
|
||||
}
|
||||
|
||||
public ResultType analyze() {
|
||||
@Override
|
||||
public ResultT analyze() {
|
||||
log.lockForRead();
|
||||
try {
|
||||
return performAnalysis();
|
||||
@@ -29,7 +29,7 @@ EventT extends AbstractLogEvent<VisitorT>, VisitorT, ResultType> {
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract ResultType performAnalysis();
|
||||
protected abstract ResultT performAnalysis();
|
||||
|
||||
protected Iterable<EventT> getAllEvents() {
|
||||
return log.getRawFixes();
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.sap.sailing.domain.abstractlog;
|
||||
|
||||
public interface LogAnalyzer<ResultType> {
|
||||
ResultType analyze();
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package com.sap.sailing.domain.abstractlog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Apply one kind of analyzer to multiple logs, and combine (reduce) their output into one result value.
|
||||
*/
|
||||
public class MultiLogAnalyzer<InterimResultT, FinalResultT>
|
||||
implements LogAnalyzer<FinalResultT> {
|
||||
private final List<AbstractLog<?, ?>> logs;
|
||||
private final AnalyzerFactory<InterimResultT> analyzerFactory;
|
||||
private final ResultReducer<InterimResultT, FinalResultT> resultReducer;
|
||||
|
||||
public interface AnalyzerFactory<InterimResultT> {
|
||||
LogAnalyzer<InterimResultT> createAnalyzer(AbstractLog<?, ?> log);
|
||||
}
|
||||
|
||||
public interface ResultReducer<InterimResultT, FinalResultT> {
|
||||
FinalResultT getInitialFinalResultValue();
|
||||
FinalResultT reduce(InterimResultT interimResult, FinalResultT reducedFinalResult);
|
||||
}
|
||||
|
||||
public static abstract class CollectionReducer<T, C extends Collection<T>> implements ResultReducer<Collection<T>, C> {
|
||||
@Override
|
||||
public C reduce(Collection<T> interimResult, C reducedFinalResult) {
|
||||
reducedFinalResult.addAll(interimResult);
|
||||
return reducedFinalResult;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SetReducer<T> extends CollectionReducer<T, Set<T>> {
|
||||
@Override
|
||||
public Set<T> getInitialFinalResultValue() {
|
||||
return new HashSet<T>();
|
||||
}
|
||||
}
|
||||
|
||||
public static class ListReducer<T> extends CollectionReducer<T, List<T>> {
|
||||
@Override
|
||||
public List<T> getInitialFinalResultValue() {
|
||||
return new ArrayList<T>();
|
||||
}
|
||||
}
|
||||
|
||||
public static class MapWithValueCollectionReducer<K, V, C extends Collection<V>>
|
||||
implements ResultReducer<Map<K, C>, Map<K, C>> {
|
||||
@Override
|
||||
public Map<K, C> getInitialFinalResultValue() {
|
||||
return new HashMap<K, C>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<K, C> reduce(Map<K, C> interimResult, Map<K, C> reducedFinalResult) {
|
||||
for (Entry<K, C> e : interimResult.entrySet()) {
|
||||
if (reducedFinalResult.containsKey(e.getKey())) {
|
||||
reducedFinalResult.get(e.getKey()).addAll(e.getValue());
|
||||
} else {
|
||||
reducedFinalResult.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
return reducedFinalResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public MultiLogAnalyzer(AnalyzerFactory< InterimResultT> analyzerFactory,
|
||||
ResultReducer<InterimResultT, FinalResultT> resultReducer, AbstractLog<?, ?>... logs) {
|
||||
this(analyzerFactory, resultReducer, Arrays.asList(logs));
|
||||
}
|
||||
|
||||
public MultiLogAnalyzer(AnalyzerFactory<InterimResultT> analyzerFactory,
|
||||
ResultReducer<InterimResultT, FinalResultT> resultReducer, List<AbstractLog<?, ?>> logs) {
|
||||
this.logs = new ArrayList<AbstractLog<?, ?>>(logs);
|
||||
this.analyzerFactory = analyzerFactory;
|
||||
this.resultReducer = resultReducer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FinalResultT analyze() {
|
||||
FinalResultT finalResult = resultReducer.getInitialFinalResultValue();
|
||||
for (AbstractLog<?, ?> log : logs) {
|
||||
if (log == null) {
|
||||
continue;
|
||||
}
|
||||
InterimResultT interimResult = analyzerFactory.createAnalyzer(log).analyze();
|
||||
finalResult = resultReducer.reduce(interimResult, finalResult);
|
||||
}
|
||||
return finalResult;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -16,6 +16,6 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public interface Revokable extends RaceLogEvent {
|
||||
public interface Revokable {
|
||||
|
||||
}
|
||||
+1
-1
@@ -215,7 +215,7 @@ extends TrackImpl<EventT> implements AbstractLog<EventT, VisitorT> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(VisitorT listener) {
|
||||
public void removeListener(Object listener) {
|
||||
synchronized (listeners) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.sap.sailing.domain.abstractlog.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLog;
|
||||
import com.sap.sailing.domain.abstractlog.BaseLogAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEvent;
|
||||
|
||||
/**
|
||||
* Finds all events in the log which is an {@code instanceof} {@link #ofType}.
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public class AllEventsOfTypeFinder<LogT extends AbstractLog<EventT, VisitorT>, EventT extends AbstractLogEvent<VisitorT>,
|
||||
VisitorT> extends BaseLogAnalyzer<LogT, EventT, VisitorT, List<EventT>> {
|
||||
private final Class<?> ofType;
|
||||
private final boolean onlyUnrevoked;
|
||||
|
||||
public AllEventsOfTypeFinder(LogT raceLog, boolean onlyUnrevoked, Class<?> ofType) {
|
||||
super(raceLog);
|
||||
this.ofType = ofType;
|
||||
this.onlyUnrevoked = onlyUnrevoked;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<EventT> performAnalysis() {
|
||||
List<EventT> result = new ArrayList<EventT>();
|
||||
Iterable<EventT> set = onlyUnrevoked ? getLog().getUnrevokedEventsDescending() : getAllEventsDescending();
|
||||
for (EventT event : set) {
|
||||
if (ofType.isAssignableFrom(event.getClass())) {
|
||||
result.add(event);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.sap.sailing.domain.abstractlog.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLog;
|
||||
import com.sap.sailing.domain.abstractlog.BaseLogAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEvent;
|
||||
|
||||
/**
|
||||
* Finds the most recent event in the log which is an {@code instanceof} {@link #ofType}.
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public class LastEventOfTypeFinder<LogT extends AbstractLog<EventT, VisitorT>, EventT extends AbstractLogEvent<VisitorT>,
|
||||
VisitorT> extends BaseLogAnalyzer<LogT, EventT, VisitorT, EventT> {
|
||||
private final Class<?> ofType;
|
||||
private final boolean onlyUnrevoked;
|
||||
|
||||
public LastEventOfTypeFinder(LogT log, boolean onlyUnrevoked, Class<?> ofType) {
|
||||
super(log);
|
||||
this.ofType = ofType;
|
||||
this.onlyUnrevoked = onlyUnrevoked;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EventT performAnalysis() {
|
||||
Iterable<EventT> set = onlyUnrevoked ? getLog().getUnrevokedEventsDescending() : getAllEventsDescending();
|
||||
for (EventT event : set) {
|
||||
if (ofType.isAssignableFrom(event.getClass())) {
|
||||
return event;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-5
@@ -3,6 +3,7 @@ package com.sap.sailing.domain.abstractlog.impl;
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.base.Timed;
|
||||
@@ -14,25 +15,25 @@ import com.sap.sailing.domain.tracking.impl.TimedComparator;
|
||||
*
|
||||
* If one of the passed objects is not a {@link RaceLogEvent}, sorting is done by {@link Timed#getTimePoint()}.
|
||||
*/
|
||||
public class AbstractLogEventComparator implements Comparator<Timed>, Serializable {
|
||||
public class LogEventComparator implements Comparator<Timed>, Serializable {
|
||||
private static final long serialVersionUID = -1337219742246147546L;
|
||||
private Comparator<Timed> timedComparator;
|
||||
|
||||
public AbstractLogEventComparator() {
|
||||
public LogEventComparator() {
|
||||
this.timedComparator = TimedComparator.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(Timed o1, Timed o2) {
|
||||
if (o1 instanceof RaceLogEvent && o2 instanceof RaceLogEvent) {
|
||||
return compareEvents((RaceLogEvent) o1, (RaceLogEvent) o2);
|
||||
if (o1 instanceof AbstractLogEvent && o2 instanceof AbstractLogEvent) {
|
||||
return compareEvents((AbstractLogEvent<?>) o1, (AbstractLogEvent<?>) o2);
|
||||
}
|
||||
|
||||
// fallback to timed comparison
|
||||
return timedComparator.compare(o1, o2);
|
||||
}
|
||||
|
||||
protected int compareEvents(RaceLogEvent e1, RaceLogEvent e2) {
|
||||
protected int compareEvents(AbstractLogEvent<?> e1, AbstractLogEvent<?> e2) {
|
||||
//compare author priorities
|
||||
int result = e1.getAuthor().compareTo(e2.getAuthor());
|
||||
if (result != 0) return result;
|
||||
+8
@@ -1,10 +1,13 @@
|
||||
package com.sap.sailing.domain.abstractlog.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.RevokeEvent;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
|
||||
public abstract class RevokeEventImpl<VisitorT> extends AbstractLogEventImpl<VisitorT> implements RevokeEvent<VisitorT> {
|
||||
private static final long serialVersionUID = -30864810737555657L;
|
||||
@@ -14,6 +17,11 @@ public abstract class RevokeEventImpl<VisitorT> extends AbstractLogEventImpl<Vis
|
||||
private final String revokedEventType;
|
||||
private final String revokedEventShortInfo;
|
||||
|
||||
public RevokeEventImpl(AbstractLogEventAuthor author, AbstractLogEvent<?> toRevoke, String reason) {
|
||||
this(MillisecondsTimePoint.now(), author, MillisecondsTimePoint.now(), UUID.randomUUID(),
|
||||
toRevoke.getId(), toRevoke.getClass().getName(), toRevoke.getShortInfo(), reason);
|
||||
}
|
||||
|
||||
public RevokeEventImpl(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
Serializable pId, Serializable revokedEventId, String revokedEventType,
|
||||
String revokedEventShortInfo, String reason) {
|
||||
|
||||
+1
-21
@@ -1,27 +1,7 @@
|
||||
package com.sap.sailing.domain.abstractlog.race;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEvent;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
|
||||
public interface RaceLogEvent extends AbstractLogEvent<RaceLogEventVisitor> {
|
||||
public interface RaceLogEvent extends AbstractLogEvent<RaceLogEventVisitor>, RaceLogEventData {
|
||||
|
||||
/**
|
||||
* Gets the event's pass identifier.
|
||||
*
|
||||
* Each {@link RaceLogEvent} is associated to a certain pass. A pass is every attempt to start and run a race. A
|
||||
* new pass is initiated when a new start time is proposed (e.g. after the race was aborted). There might be certain
|
||||
* event type that are not strictly bound to its pass.
|
||||
*
|
||||
*/
|
||||
int getPassId();
|
||||
|
||||
/**
|
||||
* Gets the list of associated {@link Competitor}s.
|
||||
*
|
||||
* A {@link RaceLogEvent} might be associated with a list of competitors, which are somehow relevant for this
|
||||
* kind of event. An example is a list of competitors who are marked for an individual recall.
|
||||
*/
|
||||
List<Competitor> getInvolvedBoats();
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.sap.sailing.domain.abstractlog.race;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
|
||||
public interface RaceLogEventData extends Serializable {
|
||||
|
||||
/**
|
||||
* Gets the event's pass identifier.
|
||||
*
|
||||
* Each {@link RaceLogEventData} is associated to a certain pass. A pass is every attempt to start and run a race. A
|
||||
* new pass is initiated when a new start time is proposed (e.g. after the race was aborted). There might be certain
|
||||
* event type that are not strictly bound to its pass.
|
||||
*
|
||||
*/
|
||||
int getPassId();
|
||||
|
||||
/**
|
||||
* Gets the list of associated {@link Competitor}s.
|
||||
*
|
||||
* A {@link RaceLogEventData} might be associated with a list of competitors, which are somehow relevant for this
|
||||
* kind of event. An example is a list of competitors who are marked for an individual recall.
|
||||
*/
|
||||
List<Competitor> getInvolvedBoats();
|
||||
}
|
||||
+17
-17
@@ -5,16 +5,15 @@ import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogEventFactoryImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationType;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.CloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CourseBase;
|
||||
@@ -22,6 +21,7 @@ import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.tracking.Wind;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
@@ -101,26 +101,26 @@ public interface RaceLogEventFactory {
|
||||
RaceLogWindFixEvent createWindFixEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
Serializable id, List<Competitor> competitors, int passId, Wind wind);
|
||||
|
||||
DeviceCompetitorMappingEvent createDeviceCompetitorMappingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
RaceLogDeviceCompetitorMappingEvent createDeviceCompetitorMappingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
DeviceIdentifier device, Competitor mappedTo, int passId, TimePoint from, TimePoint to);
|
||||
|
||||
DeviceMarkMappingEvent createDeviceMarkMappingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
RaceLogDeviceMarkMappingEvent createDeviceMarkMappingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
DeviceIdentifier device, Mark mappedTo, int passId, TimePoint from, TimePoint to);
|
||||
|
||||
DenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId,
|
||||
RaceLogDenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId,
|
||||
String raceName, BoatClass boatClass, Serializable raceId);
|
||||
|
||||
StartTrackingEvent createStartTrackingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId);
|
||||
RaceLogStartTrackingEvent createStartTrackingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId);
|
||||
|
||||
RaceLogRevokeEvent createRevokeEvent(AbstractLogEventAuthor author, int passId, RaceLogEvent toRevoke, String reason);
|
||||
|
||||
RegisterCompetitorEvent createRegisterCompetitorEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId, Competitor competitor);
|
||||
RaceLogRegisterCompetitorEvent createRegisterCompetitorEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId, Competitor competitor);
|
||||
|
||||
DefineMarkEvent createDefineMarkEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId, Mark mark);
|
||||
RaceLogDefineMarkEvent createDefineMarkEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId, Mark mark);
|
||||
|
||||
CloseOpenEndedDeviceMappingEvent createCloseOpenEndedDeviceMappingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId,
|
||||
RaceLogCloseOpenEndedDeviceMappingEvent createCloseOpenEndedDeviceMappingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId,
|
||||
Serializable deviceMappingEventId, TimePoint closingTimePoint);
|
||||
|
||||
AdditionalScoringInformationEvent createAdditionalScoringInformationEvent(TimePoint timePoint, Serializable id, AbstractLogEventAuthor author, int currentPassId,
|
||||
RaceLogAdditionalScoringInformationEvent createAdditionalScoringInformationEvent(TimePoint timePoint, Serializable id, AbstractLogEventAuthor author, int currentPassId,
|
||||
AdditionalScoringInformationType informationType);
|
||||
}
|
||||
+17
-17
@@ -5,16 +5,15 @@ import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogEventRestoreFactoryImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationType;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.CloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CourseBase;
|
||||
@@ -22,6 +21,7 @@ import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.tracking.Wind;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
@@ -70,32 +70,32 @@ public interface RaceLogEventRestoreFactory extends RaceLogEventFactory {
|
||||
RaceLogWindFixEvent createWindFixEvent(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
Serializable id, List<Competitor> competitors, Integer passId, Wind wind);
|
||||
|
||||
DeviceCompetitorMappingEvent createDeviceCompetitorMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
RaceLogDeviceCompetitorMappingEvent createDeviceCompetitorMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, DeviceIdentifier device, Competitor mappedTo, int passId, TimePoint from, TimePoint to);
|
||||
|
||||
DeviceMarkMappingEvent createDeviceMarkMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
RaceLogDeviceMarkMappingEvent createDeviceMarkMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, DeviceIdentifier device, Mark mappedTo, int passId, TimePoint from, TimePoint to);
|
||||
|
||||
DenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
RaceLogDenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId, String raceName, BoatClass boatClass, Serializable raceId);
|
||||
|
||||
StartTrackingEvent createStartTrackingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
RaceLogStartTrackingEvent createStartTrackingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId);
|
||||
|
||||
RaceLogRevokeEvent createRevokeEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId, Serializable revokedEventId,
|
||||
String revokedEventType, String revokedEventShortInfo, String reason);
|
||||
|
||||
RegisterCompetitorEvent createRegisterCompetitorEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
RaceLogRegisterCompetitorEvent createRegisterCompetitorEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId, Competitor competitor);
|
||||
|
||||
DefineMarkEvent createDefineMarkEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
RaceLogDefineMarkEvent createDefineMarkEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId, Mark mark);
|
||||
|
||||
CloseOpenEndedDeviceMappingEvent createCloseOpenEndedDeviceMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
RaceLogCloseOpenEndedDeviceMappingEvent createCloseOpenEndedDeviceMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId, Serializable deviceMappingEventId, TimePoint closingTimePoint);
|
||||
|
||||
AdditionalScoringInformationEvent createAdditionalScoringInformationEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
RaceLogAdditionalScoringInformationEvent createAdditionalScoringInformationEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, List<Competitor> competitors, int passId,
|
||||
AdditionalScoringInformationType informationType);
|
||||
}
|
||||
+16
-16
@@ -1,13 +1,13 @@
|
||||
package com.sap.sailing.domain.abstractlog.race;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.CloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
|
||||
|
||||
public interface RaceLogEventVisitor {
|
||||
@@ -39,19 +39,19 @@ public interface RaceLogEventVisitor {
|
||||
|
||||
public void visit(RaceLogWindFixEvent event);
|
||||
|
||||
public void visit(DeviceCompetitorMappingEvent event);
|
||||
public void visit(RaceLogDeviceCompetitorMappingEvent event);
|
||||
|
||||
public void visit(DeviceMarkMappingEvent event);
|
||||
public void visit(RaceLogDeviceMarkMappingEvent event);
|
||||
|
||||
public void visit(DenoteForTrackingEvent event);
|
||||
public void visit(RaceLogDenoteForTrackingEvent event);
|
||||
|
||||
public void visit(StartTrackingEvent event);
|
||||
public void visit(RaceLogStartTrackingEvent event);
|
||||
|
||||
public void visit(RegisterCompetitorEvent event);
|
||||
public void visit(RaceLogRegisterCompetitorEvent event);
|
||||
|
||||
public void visit(DefineMarkEvent event);
|
||||
public void visit(RaceLogDefineMarkEvent event);
|
||||
|
||||
public void visit(CloseOpenEndedDeviceMappingEvent event);
|
||||
public void visit(RaceLogCloseOpenEndedDeviceMappingEvent event);
|
||||
|
||||
public void visit(AdditionalScoringInformationEvent additionalScoringInformation);
|
||||
public void visit(RaceLogAdditionalScoringInformationEvent additionalScoringInformation);
|
||||
}
|
||||
+11
-11
@@ -5,11 +5,11 @@ import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationType;
|
||||
|
||||
/**
|
||||
* Returns all {@link AdditionalScoringInformationEvent}s from the race log
|
||||
* Returns all {@link RaceLogAdditionalScoringInformationEvent}s from the race log
|
||||
* that have not been revoked when using {@link #analyze()}. The resulting list
|
||||
* has the newest event first. The pass id is not relevant for the result.
|
||||
*
|
||||
@@ -21,7 +21,7 @@ import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformat
|
||||
*
|
||||
* @author Simon Marcel Pamies
|
||||
*/
|
||||
public class AdditionalScoringInformationFinder extends RaceLogAnalyzer<List<AdditionalScoringInformationEvent>> {
|
||||
public class AdditionalScoringInformationFinder extends RaceLogAnalyzer<List<RaceLogAdditionalScoringInformationEvent>> {
|
||||
|
||||
public AdditionalScoringInformationFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
@@ -31,10 +31,10 @@ public class AdditionalScoringInformationFinder extends RaceLogAnalyzer<List<Add
|
||||
* Analyze the race log for all events that match the given type filter. Returns only the <emph>newest</emph>
|
||||
* one as we assume that there can be only one unrevoked event of the same type.
|
||||
*/
|
||||
public AdditionalScoringInformationEvent analyze(AdditionalScoringInformationType filterBy) {
|
||||
AdditionalScoringInformationEvent result = null;
|
||||
final List<AdditionalScoringInformationEvent> allUnrevokedEventsFromNewestToOldest = analyze();
|
||||
for (AdditionalScoringInformationEvent event : allUnrevokedEventsFromNewestToOldest) {
|
||||
public RaceLogAdditionalScoringInformationEvent analyze(AdditionalScoringInformationType filterBy) {
|
||||
RaceLogAdditionalScoringInformationEvent result = null;
|
||||
final List<RaceLogAdditionalScoringInformationEvent> allUnrevokedEventsFromNewestToOldest = analyze();
|
||||
for (RaceLogAdditionalScoringInformationEvent event : allUnrevokedEventsFromNewestToOldest) {
|
||||
if (event != null && event.getType() == filterBy) {
|
||||
result = event;
|
||||
break;
|
||||
@@ -44,12 +44,12 @@ public class AdditionalScoringInformationFinder extends RaceLogAnalyzer<List<Add
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AdditionalScoringInformationEvent> performAnalysis() {
|
||||
final List<AdditionalScoringInformationEvent> result = new ArrayList<AdditionalScoringInformationEvent>();
|
||||
protected List<RaceLogAdditionalScoringInformationEvent> performAnalysis() {
|
||||
final List<RaceLogAdditionalScoringInformationEvent> result = new ArrayList<RaceLogAdditionalScoringInformationEvent>();
|
||||
// fetch all unrevoked events starting with newest going to oldest
|
||||
for (RaceLogEvent event : getLog().getUnrevokedEventsDescending()) {
|
||||
if (event instanceof AdditionalScoringInformationEvent) {
|
||||
result.add((AdditionalScoringInformationEvent) event);
|
||||
if (event instanceof RaceLogAdditionalScoringInformationEvent) {
|
||||
result.add((RaceLogAdditionalScoringInformationEvent) event);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.analyzing.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.BaseLogAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventVisitor;
|
||||
|
||||
public abstract class RaceLogAnalyzer<ResultType> extends AbstractLogAnalyzer
|
||||
public abstract class RaceLogAnalyzer<ResultType> extends BaseLogAnalyzer
|
||||
<RaceLog, RaceLogEvent, RaceLogEventVisitor, ResultType> {
|
||||
|
||||
public RaceLogAnalyzer(RaceLog raceLog) {
|
||||
|
||||
+16
-16
@@ -16,14 +16,14 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogRevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartProcedureChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartTimeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogWindFixEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.CloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
|
||||
public abstract class AbstractRaceLogChangedVisitor implements RaceLogEventVisitor {
|
||||
protected abstract void notifyListenerAboutEventAdded(RaceLogEvent event);
|
||||
@@ -88,22 +88,22 @@ public abstract class AbstractRaceLogChangedVisitor implements RaceLogEventVisit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DeviceCompetitorMappingEvent event) {
|
||||
public void visit(RaceLogDeviceCompetitorMappingEvent event) {
|
||||
notifyListenerAboutEventAdded(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DeviceMarkMappingEvent event) {
|
||||
public void visit(RaceLogDeviceMarkMappingEvent event) {
|
||||
notifyListenerAboutEventAdded(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DenoteForTrackingEvent event) {
|
||||
public void visit(RaceLogDenoteForTrackingEvent event) {
|
||||
notifyListenerAboutEventAdded(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(StartTrackingEvent event) {
|
||||
public void visit(RaceLogStartTrackingEvent event) {
|
||||
notifyListenerAboutEventAdded(event);
|
||||
}
|
||||
|
||||
@@ -113,22 +113,22 @@ public abstract class AbstractRaceLogChangedVisitor implements RaceLogEventVisit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RegisterCompetitorEvent event) {
|
||||
public void visit(RaceLogRegisterCompetitorEvent event) {
|
||||
notifyListenerAboutEventAdded(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DefineMarkEvent event) {
|
||||
public void visit(RaceLogDefineMarkEvent event) {
|
||||
notifyListenerAboutEventAdded(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CloseOpenEndedDeviceMappingEvent event) {
|
||||
public void visit(RaceLogCloseOpenEndedDeviceMappingEvent event) {
|
||||
notifyListenerAboutEventAdded(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AdditionalScoringInformationEvent additionalScoringInformation) {
|
||||
public void visit(RaceLogAdditionalScoringInformationEvent additionalScoringInformation) {
|
||||
notifyListenerAboutEventAdded(additionalScoringInformation);
|
||||
}
|
||||
}
|
||||
+16
-16
@@ -15,14 +15,14 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogRevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartProcedureChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartTimeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogWindFixEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.CloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
|
||||
/**
|
||||
* Base class implementing {@link RaceLogEventVisitor}. Every method is implemented as a no-op.
|
||||
@@ -95,22 +95,22 @@ public abstract class BaseRaceLogEventVisitor implements RaceLogEventVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DeviceCompetitorMappingEvent event) {
|
||||
public void visit(RaceLogDeviceCompetitorMappingEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DeviceMarkMappingEvent event) {
|
||||
public void visit(RaceLogDeviceMarkMappingEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DenoteForTrackingEvent event) {
|
||||
public void visit(RaceLogDenoteForTrackingEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(StartTrackingEvent event) {
|
||||
public void visit(RaceLogStartTrackingEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@@ -120,22 +120,22 @@ public abstract class BaseRaceLogEventVisitor implements RaceLogEventVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(RegisterCompetitorEvent event) {
|
||||
public void visit(RaceLogRegisterCompetitorEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(DefineMarkEvent event) {
|
||||
public void visit(RaceLogDefineMarkEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(CloseOpenEndedDeviceMappingEvent event) {
|
||||
public void visit(RaceLogCloseOpenEndedDeviceMappingEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(AdditionalScoringInformationEvent event) {
|
||||
public void visit(RaceLogAdditionalScoringInformationEvent event) {
|
||||
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class NoAddingRaceLogWrapper implements RaceLog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeListener(RaceLogEventVisitor listener) {
|
||||
public void removeListener(Object listener) {
|
||||
innerRaceLog.removeListener(listener);
|
||||
}
|
||||
|
||||
|
||||
+8
-5
@@ -3,8 +3,9 @@ package com.sap.sailing.domain.abstractlog.race.impl;
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.impl.AbstractLogEventComparator;
|
||||
import com.sap.sailing.domain.abstractlog.impl.LogEventComparator;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.base.Timed;
|
||||
|
||||
@@ -14,13 +15,15 @@ import com.sap.sailing.domain.base.Timed;
|
||||
*
|
||||
* If one of the passed objects is not a {@link RaceLogEvent}, sorting is done by {@link Timed#getTimePoint()}.
|
||||
*/
|
||||
public class RaceLogEventComparator extends AbstractLogEventComparator implements Comparator<Timed>, Serializable {
|
||||
public class RaceLogEventComparator extends LogEventComparator implements Comparator<Timed>, Serializable {
|
||||
private static final long serialVersionUID = 6146135178558781346L;
|
||||
|
||||
protected int compareEvents(RaceLogEvent e1, RaceLogEvent e2) {
|
||||
protected int compareEvents(AbstractLogEvent<?> e1, AbstractLogEvent<?> e2) {
|
||||
//compare passes
|
||||
int result = e1.getPassId() - e2.getPassId();
|
||||
if (result != 0) return result;
|
||||
if (e1 instanceof RaceLogEvent && e2 instanceof RaceLogEvent) {
|
||||
int result = ((RaceLogEvent) e1).getPassId() - ((RaceLogEvent) e2).getPassId();
|
||||
if (result != 0) return result;
|
||||
}
|
||||
|
||||
return super.compareEvents(e1, e2);
|
||||
}
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.impl;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventData;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
|
||||
public class RaceLogEventDataImpl implements RaceLogEventData {
|
||||
private static final long serialVersionUID = 61677173867866892L;
|
||||
private final List<Competitor> involvedBoats;
|
||||
private final int passId;
|
||||
|
||||
public RaceLogEventDataImpl(List<Competitor> involvedBoats, int passId) {
|
||||
if (involvedBoats == null) {
|
||||
this.involvedBoats = Collections.emptyList();
|
||||
} else {
|
||||
this.involvedBoats = involvedBoats;
|
||||
}
|
||||
this.passId = passId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Competitor> getInvolvedBoats() {
|
||||
return involvedBoats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPassId() {
|
||||
return passId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + ", involvedBoats: " + getInvolvedBoats() + ", passId: " + getPassId();
|
||||
}
|
||||
}
|
||||
+34
-35
@@ -23,24 +23,23 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogRevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartProcedureChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartTimeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogWindFixEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationType;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.impl.AdditionalScoringInformationEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.CloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.CloseOpenEndedDeviceMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.DefineMarkEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.DenoteForTrackingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.DeviceCompetitorMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.DeviceMarkMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.RegisterCompetitorEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.StartTrackingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.impl.RaceLogAdditionalScoringInformationEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogCloseOpenEndedDeviceMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogDefineMarkEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogDenoteForTrackingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogDeviceCompetitorMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogDeviceMarkMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogRegisterCompetitorEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogStartTrackingEventImpl;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CourseBase;
|
||||
@@ -48,6 +47,7 @@ import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.tracking.Wind;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
@@ -224,60 +224,59 @@ public class RaceLogEventFactoryImpl implements RaceLogEventFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceCompetitorMappingEvent createDeviceCompetitorMappingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
public RaceLogDeviceCompetitorMappingEvent createDeviceCompetitorMappingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
DeviceIdentifier device, Competitor mappedTo, int passId, TimePoint from, TimePoint to) {
|
||||
return new DeviceCompetitorMappingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(),
|
||||
return new RaceLogDeviceCompetitorMappingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(),
|
||||
passId, mappedTo, device, from, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceMarkMappingEvent createDeviceMarkMappingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
public RaceLogDeviceMarkMappingEvent createDeviceMarkMappingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
DeviceIdentifier device, Mark mappedTo, int passId, TimePoint from, TimePoint to) {
|
||||
return new DeviceMarkMappingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(),
|
||||
return new RaceLogDeviceMarkMappingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(),
|
||||
passId, mappedTo, device, from, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId,
|
||||
public RaceLogDenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId,
|
||||
String raceName, BoatClass boatClass, Serializable raceId) {
|
||||
return new DenoteForTrackingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(), passId, raceName,
|
||||
return new RaceLogDenoteForTrackingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(), passId, raceName,
|
||||
boatClass, raceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartTrackingEvent createStartTrackingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId) {
|
||||
return new StartTrackingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(), passId);
|
||||
public RaceLogStartTrackingEvent createStartTrackingEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author, int passId) {
|
||||
return new RaceLogStartTrackingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(), passId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogRevokeEvent createRevokeEvent(AbstractLogEventAuthor author, int passId, RaceLogEvent toRevoke, String reason) {
|
||||
return new RaceLogRevokeEventImpl(MillisecondsTimePoint.now(), author, MillisecondsTimePoint.now(), UUID.randomUUID(),
|
||||
passId, toRevoke.getId(), toRevoke.getClass().getName(), toRevoke.getShortInfo(), reason);
|
||||
return new RaceLogRevokeEventImpl(author, passId, toRevoke, reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegisterCompetitorEvent createRegisterCompetitorEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
public RaceLogRegisterCompetitorEvent createRegisterCompetitorEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
int passId, Competitor competitor) {
|
||||
return new RegisterCompetitorEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(), passId, competitor);
|
||||
return new RaceLogRegisterCompetitorEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(), passId, competitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefineMarkEvent createDefineMarkEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
public RaceLogDefineMarkEvent createDefineMarkEvent(TimePoint logicalTimePoint, AbstractLogEventAuthor author,
|
||||
int passId, Mark mark) {
|
||||
return new DefineMarkEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(), passId, mark);
|
||||
return new RaceLogDefineMarkEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint, UUID.randomUUID(), passId, mark);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloseOpenEndedDeviceMappingEvent createCloseOpenEndedDeviceMappingEvent(TimePoint logicalTimePoint,
|
||||
public RaceLogCloseOpenEndedDeviceMappingEvent createCloseOpenEndedDeviceMappingEvent(TimePoint logicalTimePoint,
|
||||
AbstractLogEventAuthor author, int passId, Serializable deviceMappingEventId, TimePoint closingTimePoint) {
|
||||
return new CloseOpenEndedDeviceMappingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint,
|
||||
return new RaceLogCloseOpenEndedDeviceMappingEventImpl(MillisecondsTimePoint.now(), author, logicalTimePoint,
|
||||
UUID.randomUUID(), passId, deviceMappingEventId, closingTimePoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalScoringInformationEvent createAdditionalScoringInformationEvent(TimePoint timePoint, Serializable id,
|
||||
public RaceLogAdditionalScoringInformationEvent createAdditionalScoringInformationEvent(TimePoint timePoint, Serializable id,
|
||||
AbstractLogEventAuthor author, int currentPassId, AdditionalScoringInformationType informationType) {
|
||||
return new AdditionalScoringInformationEventImpl(MillisecondsTimePoint.now(), author, timePoint, id, Collections.<Competitor>emptyList(), currentPassId,
|
||||
return new RaceLogAdditionalScoringInformationEventImpl(MillisecondsTimePoint.now(), author, timePoint, id, Collections.<Competitor>emptyList(), currentPassId,
|
||||
informationType);
|
||||
}
|
||||
}
|
||||
+8
-10
@@ -6,35 +6,33 @@ import java.util.List;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.impl.AbstractLogEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventData;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
public abstract class RaceLogEventImpl extends AbstractLogEventImpl<RaceLogEventVisitor> implements RaceLogEvent {
|
||||
private final List<Competitor> involvedBoats;
|
||||
private final int passId;
|
||||
|
||||
private static final long serialVersionUID = -2557594972618769182L;
|
||||
private final RaceLogEventData raceLogEventData;
|
||||
|
||||
public RaceLogEventImpl(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
Serializable pId, List<Competitor> pInvolvedBoats, int pPassId) {
|
||||
super(createdAt, author, logicalTimePoint, pId);
|
||||
this.involvedBoats = pInvolvedBoats;
|
||||
this.passId = pPassId;
|
||||
this.raceLogEventData = new RaceLogEventDataImpl(pInvolvedBoats, pPassId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Competitor> getInvolvedBoats() {
|
||||
return involvedBoats;
|
||||
return raceLogEventData.getInvolvedBoats();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getPassId() {
|
||||
return passId;
|
||||
return raceLogEventData.getPassId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString() + ", involvedBoats: " + getInvolvedBoats() + ", passId: " + getPassId();
|
||||
return raceLogEventData.toString();
|
||||
}
|
||||
}
|
||||
+33
-33
@@ -20,24 +20,23 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogRevokeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartProcedureChangedEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogStartTimeEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogWindFixEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationType;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.impl.AdditionalScoringInformationEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.CloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.StartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.CloseOpenEndedDeviceMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.DefineMarkEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.DenoteForTrackingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.DeviceCompetitorMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.DeviceMarkMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.RegisterCompetitorEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.StartTrackingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.impl.RaceLogAdditionalScoringInformationEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogCloseOpenEndedDeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDenoteForTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogRegisterCompetitorEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogStartTrackingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogCloseOpenEndedDeviceMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogDefineMarkEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogDenoteForTrackingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogDeviceCompetitorMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogDeviceMarkMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogRegisterCompetitorEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogStartTrackingEventImpl;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CourseBase;
|
||||
@@ -45,6 +44,7 @@ import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.domain.common.racelog.RacingProcedureType;
|
||||
import com.sap.sailing.domain.racelogtracking.DeviceIdentifier;
|
||||
import com.sap.sailing.domain.tracking.Wind;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
@@ -131,28 +131,28 @@ public class RaceLogEventRestoreFactoryImpl extends RaceLogEventFactoryImpl impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceCompetitorMappingEvent createDeviceCompetitorMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
public RaceLogDeviceCompetitorMappingEvent createDeviceCompetitorMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, DeviceIdentifier device, Competitor mappedTo, int passId, TimePoint from, TimePoint to) {
|
||||
return new DeviceCompetitorMappingEventImpl(createdAt, author, logicalTimePoint, pId, passId, mappedTo, device, from, to);
|
||||
return new RaceLogDeviceCompetitorMappingEventImpl(createdAt, author, logicalTimePoint, pId, passId, mappedTo, device, from, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceMarkMappingEvent createDeviceMarkMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
public RaceLogDeviceMarkMappingEvent createDeviceMarkMappingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, DeviceIdentifier device, Mark mappedTo, int passId, TimePoint from,
|
||||
TimePoint to) {
|
||||
return new DeviceMarkMappingEventImpl(createdAt, author, logicalTimePoint, pId, passId, mappedTo, device, from, to);
|
||||
return new RaceLogDeviceMarkMappingEventImpl(createdAt, author, logicalTimePoint, pId, passId, mappedTo, device, from, to);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
public RaceLogDenoteForTrackingEvent createDenoteForTrackingEvent(TimePoint createdAt, AbstractLogEventAuthor author,
|
||||
TimePoint logicalTimePoint, Serializable pId, int passId, String raceName, BoatClass boatClass, Serializable raceId) {
|
||||
return new DenoteForTrackingEventImpl(createdAt, author, logicalTimePoint, pId, passId, raceName, boatClass, raceId);
|
||||
return new RaceLogDenoteForTrackingEventImpl(createdAt, author, logicalTimePoint, pId, passId, raceName, boatClass, raceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StartTrackingEvent createStartTrackingEvent(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
public RaceLogStartTrackingEvent createStartTrackingEvent(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
Serializable pId, int passId) {
|
||||
return new StartTrackingEventImpl(createdAt, author, logicalTimePoint, pId, passId);
|
||||
return new RaceLogStartTrackingEventImpl(createdAt, author, logicalTimePoint, pId, passId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -162,29 +162,29 @@ public class RaceLogEventRestoreFactoryImpl extends RaceLogEventFactoryImpl impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public RegisterCompetitorEvent createRegisterCompetitorEvent(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
public RaceLogRegisterCompetitorEvent createRegisterCompetitorEvent(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
Serializable pId, int passId, Competitor competitor) {
|
||||
return new RegisterCompetitorEventImpl(createdAt, author, logicalTimePoint, pId, passId, competitor);
|
||||
return new RaceLogRegisterCompetitorEventImpl(createdAt, author, logicalTimePoint, pId, passId, competitor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DefineMarkEvent createDefineMarkEvent(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
public RaceLogDefineMarkEvent createDefineMarkEvent(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
Serializable pId, int passId, Mark mark) {
|
||||
return new DefineMarkEventImpl(createdAt, author, logicalTimePoint, pId, passId, mark);
|
||||
return new RaceLogDefineMarkEventImpl(createdAt, author, logicalTimePoint, pId, passId, mark);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloseOpenEndedDeviceMappingEvent createCloseOpenEndedDeviceMappingEvent(TimePoint createdAt,
|
||||
public RaceLogCloseOpenEndedDeviceMappingEvent createCloseOpenEndedDeviceMappingEvent(TimePoint createdAt,
|
||||
AbstractLogEventAuthor author, TimePoint logicalTimePoint, Serializable pId, int passId,
|
||||
Serializable deviceMappingEventId, TimePoint closingTimePoint) {
|
||||
return new CloseOpenEndedDeviceMappingEventImpl(createdAt, author, logicalTimePoint, pId, passId,
|
||||
return new RaceLogCloseOpenEndedDeviceMappingEventImpl(createdAt, author, logicalTimePoint, pId, passId,
|
||||
deviceMappingEventId, closingTimePoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdditionalScoringInformationEvent createAdditionalScoringInformationEvent(TimePoint createdAt,
|
||||
public RaceLogAdditionalScoringInformationEvent createAdditionalScoringInformationEvent(TimePoint createdAt,
|
||||
AbstractLogEventAuthor author, TimePoint logicalTimePoint, Serializable pId, List<Competitor> competitors, int passId,
|
||||
AdditionalScoringInformationType informationType) {
|
||||
return new AdditionalScoringInformationEventImpl(createdAt, author, logicalTimePoint, pId, competitors, passId, informationType);
|
||||
return new RaceLogAdditionalScoringInformationEventImpl(createdAt, author, logicalTimePoint, pId, competitors, passId, informationType);
|
||||
}
|
||||
}
|
||||
+17
-6
@@ -1,40 +1,51 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.impl.RevokeEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventData;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogRevokeEvent;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
public class RaceLogRevokeEventImpl extends RevokeEventImpl<RaceLogEventVisitor> implements RaceLogRevokeEvent {
|
||||
private final int passId;
|
||||
private static final long serialVersionUID = 1886722815573499311L;
|
||||
private final RaceLogEventData raceLogEventData;
|
||||
|
||||
public RaceLogRevokeEventImpl(AbstractLogEventAuthor author, int passId, RaceLogEvent toRevoke, String reason) {
|
||||
super(author, toRevoke, reason);
|
||||
this.raceLogEventData = new RaceLogEventDataImpl(null, passId);
|
||||
}
|
||||
|
||||
public RaceLogRevokeEventImpl(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
Serializable pId, int passId, Serializable revokedEventId, String revokedEventType, String revokedEventShortInfo,
|
||||
String reason) {
|
||||
super(createdAt, author, logicalTimePoint, pId, revokedEventId, revokedEventType, revokedEventShortInfo, reason);
|
||||
this.passId = passId;
|
||||
this.raceLogEventData = new RaceLogEventDataImpl(null, passId);
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1886722815573499311L;
|
||||
|
||||
@Override
|
||||
public int getPassId() {
|
||||
return passId;
|
||||
return raceLogEventData.getPassId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Competitor> getInvolvedBoats() {
|
||||
return Collections.emptyList();
|
||||
return raceLogEventData.getInvolvedBoats();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(RaceLogEventVisitor visitor) {
|
||||
visitor.visit(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return raceLogEventData.toString();
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -12,7 +12,7 @@ import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
*
|
||||
* @author Simon Marcel Pamies
|
||||
*/
|
||||
public interface AdditionalScoringInformationEvent extends RaceLogEvent, Revokable, InvalidatesLeaderboardCache {
|
||||
public interface RaceLogAdditionalScoringInformationEvent extends RaceLogEvent, Revokable, InvalidatesLeaderboardCache {
|
||||
|
||||
/**
|
||||
* @return the type of information this event holds
|
||||
+3
-3
@@ -6,17 +6,17 @@ import java.util.List;
|
||||
import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.race.impl.RaceLogEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationType;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
public class AdditionalScoringInformationEventImpl extends RaceLogEventImpl implements AdditionalScoringInformationEvent {
|
||||
public class RaceLogAdditionalScoringInformationEventImpl extends RaceLogEventImpl implements RaceLogAdditionalScoringInformationEvent {
|
||||
private static final long serialVersionUID = -7627714111951381979L;
|
||||
|
||||
private final AdditionalScoringInformationType informationType;
|
||||
|
||||
public AdditionalScoringInformationEventImpl(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
public RaceLogAdditionalScoringInformationEventImpl(TimePoint createdAt, AbstractLogEventAuthor author, TimePoint logicalTimePoint,
|
||||
Serializable pId, List<Competitor> competitors, int pPassId, AdditionalScoringInformationType informationType) {
|
||||
super(createdAt, author, logicalTimePoint, pId, competitors, pPassId);
|
||||
this.informationType = informationType;
|
||||
+2
-2
@@ -4,7 +4,7 @@ import com.sap.sailing.domain.abstractlog.AbstractLogEventAuthor;
|
||||
import com.sap.sailing.domain.abstractlog.race.CompetitorResults;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationType;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.racingprocedure.RacingProcedure;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.racingprocedure.RacingProcedurePrerequisite;
|
||||
@@ -142,7 +142,7 @@ public interface RaceState extends ReadonlyRaceState {
|
||||
void setWindFix(TimePoint now, Wind wind);
|
||||
|
||||
/**
|
||||
* Marks this race state with a new {@link AdditionalScoringInformationEvent} or revokes
|
||||
* Marks this race state with a new {@link RaceLogAdditionalScoringInformationEvent} or revokes
|
||||
* an already existing one.
|
||||
*/
|
||||
void setAdditionalScoringInformationEnabled(TimePoint creationTimePoint, boolean enable, AdditionalScoringInformationType informationType);
|
||||
|
||||
+3
-3
@@ -10,7 +10,7 @@ import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventFactory;
|
||||
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.AdditionalScoringInformationFinder;
|
||||
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceStatusAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.RaceLogAdditionalScoringInformationEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.scoring.AdditionalScoringInformationType;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.RaceState;
|
||||
import com.sap.sailing.domain.abstractlog.race.state.racingprocedure.RacingProcedure;
|
||||
@@ -169,7 +169,7 @@ public class RaceStateImpl extends ReadonlyRaceStateImpl implements RaceState {
|
||||
|
||||
@Override
|
||||
public void setAdditionalScoringInformationEnabled(TimePoint timePoint, boolean enable, AdditionalScoringInformationType informationType) {
|
||||
final AdditionalScoringInformationEvent event = new AdditionalScoringInformationFinder(raceLog).analyze(/*filterBy*/informationType);
|
||||
final RaceLogAdditionalScoringInformationEvent event = new AdditionalScoringInformationFinder(raceLog).analyze(/*filterBy*/informationType);
|
||||
if (enable) {
|
||||
if (event == null) {
|
||||
raceLog.add(factory.createAdditionalScoringInformationEvent(timePoint, UUID.randomUUID(), author, raceLog.getCurrentPassId(), informationType));
|
||||
@@ -188,7 +188,7 @@ public class RaceStateImpl extends ReadonlyRaceStateImpl implements RaceState {
|
||||
|
||||
@Override
|
||||
public boolean isAdditionalScoringInformationEnabled(AdditionalScoringInformationType informationType) {
|
||||
final AdditionalScoringInformationEvent event = new AdditionalScoringInformationFinder(raceLog).analyze(/*filterBy*/informationType);
|
||||
final RaceLogAdditionalScoringInformationEvent event = new AdditionalScoringInformationFinder(raceLog).analyze(/*filterBy*/informationType);
|
||||
return event != null;
|
||||
}
|
||||
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
|
||||
public interface DeviceCompetitorMappingEvent extends DeviceMappingEvent<Competitor> {
|
||||
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking;
|
||||
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
|
||||
public interface DeviceMarkMappingEvent extends DeviceMappingEvent<Mark> {
|
||||
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking;
|
||||
|
||||
import com.sap.sailing.domain.base.Timed;
|
||||
import com.sap.sse.common.TimeRange;
|
||||
|
||||
public interface DeviceWithTimeRange extends Timed {
|
||||
DeviceIdentifier getDevice();
|
||||
|
||||
TimeRange getTimeRange();
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.shared.events.CloseOpenEndedDeviceMappingEvent;
|
||||
|
||||
public interface RaceLogCloseOpenEndedDeviceMappingEvent extends RaceLogEvent,
|
||||
CloseOpenEndedDeviceMappingEvent<RaceLogEventVisitor> {
|
||||
|
||||
}
|
||||
+1
-1
@@ -9,6 +9,6 @@ import com.sap.sailing.domain.base.Mark;
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public interface DefineMarkEvent extends RaceLogEvent, Revokable {
|
||||
public interface RaceLogDefineMarkEvent extends RaceLogEvent, Revokable {
|
||||
Mark getMark();
|
||||
}
|
||||
+2
-1
@@ -5,6 +5,7 @@ import java.io.Serializable;
|
||||
import com.sap.sailing.domain.abstractlog.Revokable;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.shared.events.DeviceMappingEvent;
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
|
||||
/**
|
||||
@@ -16,7 +17,7 @@ import com.sap.sailing.domain.base.BoatClass;
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public interface DenoteForTrackingEvent extends RaceLogEvent, Revokable {
|
||||
public interface RaceLogDenoteForTrackingEvent extends RaceLogEvent, Revokable {
|
||||
String getRaceName();
|
||||
BoatClass getBoatClass();
|
||||
Serializable getRaceId();
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.shared.events.DeviceCompetitorMappingEvent;
|
||||
|
||||
public interface RaceLogDeviceCompetitorMappingEvent extends RaceLogEvent,
|
||||
DeviceCompetitorMappingEvent<RaceLogEventVisitor> {
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.shared.events.DeviceMarkMappingEvent;
|
||||
|
||||
public interface RaceLogDeviceMarkMappingEvent extends RaceLogEvent,
|
||||
DeviceMarkMappingEvent<RaceLogEventVisitor> {
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.abstractlog.shared.events.RegisterCompetitorEvent;
|
||||
|
||||
public interface RaceLogRegisterCompetitorEvent extends RaceLogEvent,
|
||||
RegisterCompetitorEvent<RaceLogEventVisitor> {
|
||||
|
||||
}
|
||||
+3
-3
@@ -3,15 +3,15 @@ package com.sap.sailing.domain.abstractlog.race.tracking;
|
||||
import com.sap.sailing.domain.abstractlog.Revokable;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.events.DeviceCompetitorMappingEventImpl;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.impl.RaceLogDeviceCompetitorMappingEventImpl;
|
||||
|
||||
/**
|
||||
* Closes the phase during which {@link DeviceCompetitorMappingEventImpl}s actually result
|
||||
* Closes the phase during which {@link RaceLogDeviceCompetitorMappingEventImpl}s actually result
|
||||
* in competitors being added, and indicates that the server should create a {@link TrackedRace}
|
||||
* using the information in this {@link RaceLog}.
|
||||
*
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public interface StartTrackingEvent extends RaceLogEvent, Revokable {
|
||||
public interface RaceLogStartTrackingEvent extends RaceLogEvent, Revokable {
|
||||
}
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceLogAnalyzer;
|
||||
|
||||
/**
|
||||
* Finds all events in the racelog which is an {@code instanceof} {@link #ofType}.
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public class AllEventsOfTypeFinder extends RaceLogAnalyzer<List<RaceLogEvent>> {
|
||||
private final Class<?> ofType;
|
||||
private final boolean onlyUnrevoked;
|
||||
|
||||
public AllEventsOfTypeFinder(RaceLog raceLog, boolean onlyUnrevoked, Class<?> ofType) {
|
||||
super(raceLog);
|
||||
this.ofType = ofType;
|
||||
this.onlyUnrevoked = onlyUnrevoked;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<RaceLogEvent> performAnalysis() {
|
||||
List<RaceLogEvent> result = new ArrayList<RaceLogEvent>();
|
||||
Iterable<RaceLogEvent> set = onlyUnrevoked ? getLog().getUnrevokedEventsDescending() : getAllEventsDescending();
|
||||
for (RaceLogEvent event : set) {
|
||||
if (ofType.isAssignableFrom(event.getClass())) {
|
||||
result.add(event);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceLogAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DefineMarkEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.RaceLogDefineMarkEvent;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
|
||||
public class DefinedMarkFinder extends RaceLogAnalyzer<Collection<Mark>> {
|
||||
@@ -19,8 +19,8 @@ public class DefinedMarkFinder extends RaceLogAnalyzer<Collection<Mark>> {
|
||||
protected Collection<Mark> performAnalysis() {
|
||||
List< Mark> result = new ArrayList<Mark>();
|
||||
for (RaceLogEvent event : getLog().getUnrevokedEvents()) {
|
||||
if (event instanceof DefineMarkEvent) {
|
||||
DefineMarkEvent dME = (DefineMarkEvent) event;
|
||||
if (event instanceof RaceLogDefineMarkEvent) {
|
||||
RaceLogDefineMarkEvent dME = (RaceLogDefineMarkEvent) event;
|
||||
result.add(dME.getMark());
|
||||
}
|
||||
}
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceCompetitorMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMappingEvent;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
|
||||
public class DeviceCompetitorMappingFinder extends DeviceMappingFinder<Competitor> {
|
||||
|
||||
public DeviceCompetitorMappingFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidMapping(DeviceMappingEvent<?> mapping) {
|
||||
return mapping instanceof DeviceCompetitorMappingEvent;
|
||||
}
|
||||
}
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMappingEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMarkMappingEvent;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
|
||||
public class DeviceMarkMappingFinder extends DeviceMappingFinder<Mark> {
|
||||
|
||||
public DeviceMarkMappingFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isValidMapping(DeviceMappingEvent<?> mapping) {
|
||||
return mapping instanceof DeviceMarkMappingEvent;
|
||||
}
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceLogAnalyzer;
|
||||
|
||||
/**
|
||||
* Finds the most recent event in the racelog which is an {@code instanceof} {@link #ofType}.
|
||||
* @author Fredrik Teschke
|
||||
*
|
||||
*/
|
||||
public class LastEventOfTypeFinder extends RaceLogAnalyzer<RaceLogEvent> {
|
||||
private final Class<?> ofType;
|
||||
private final boolean onlyUnrevoked;
|
||||
|
||||
public LastEventOfTypeFinder(RaceLog raceLog, boolean onlyUnrevoked, Class<?> ofType) {
|
||||
super(raceLog);
|
||||
this.ofType = ofType;
|
||||
this.onlyUnrevoked = onlyUnrevoked;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RaceLogEvent performAnalysis() {
|
||||
Iterable<RaceLogEvent> set = onlyUnrevoked ? getLog().getUnrevokedEventsDescending() : getAllEventsDescending();
|
||||
for (RaceLogEvent event : set) {
|
||||
if (ofType.isAssignableFrom(event.getClass())) {
|
||||
return event;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl;
|
||||
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLog;
|
||||
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
|
||||
import com.sap.sailing.domain.abstractlog.race.analyzing.impl.RaceLogAnalyzer;
|
||||
import com.sap.sailing.domain.abstractlog.race.tracking.DeviceMappingEvent;
|
||||
import com.sap.sse.common.WithID;
|
||||
|
||||
public class LastPingMappingEventFinder<T extends WithID> extends RaceLogAnalyzer<DeviceMappingEvent<T>> {
|
||||
private final WithID item;
|
||||
|
||||
public LastPingMappingEventFinder(RaceLog raceLog, WithID forItem) {
|
||||
super(raceLog);
|
||||
this.item = forItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DeviceMappingEvent<T> performAnalysis() {
|
||||
for (RaceLogEvent e : getLog().getUnrevokedEventsDescending()) {
|
||||
if (e instanceof DeviceMappingEvent) {
|
||||
DeviceMappingEvent<?> mappingEvent = (DeviceMappingEvent<?>) e;
|
||||
if (item.equals(mappingEvent.getMappedTo()) && mappingEvent.getFrom() != null &&
|
||||
mappingEvent.getTo() != null && mappingEvent.getFrom().equals(mappingEvent.getTo())) {
|
||||
@SuppressWarnings("unchecked")
|
||||
DeviceMappingEvent<T> cast = (DeviceMappingEvent<T>) mappingEvent;
|
||||
return cast;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 365 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user