mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-11 06:40:53 +00:00
Merge branch 'racecommittee_integrated' of ssh://sapsailing.com/home/trac/git into racecommittee_integrated
This commit is contained in:
commit
804615979c
26 files changed
+334
-194
No files matched your search
+38
-40
@@ -13,7 +13,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.bson.types.ObjectId;
|
||||
|
||||
|
||||
import com.mongodb.BasicDBList;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.BasicDBObjectBuilder;
|
||||
@@ -91,7 +90,7 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogCourseAreaChangedEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogCourseDesignChangedEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEventFactory;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEventRestoreFactory;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFlagEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogIdentifier;
|
||||
import com.sap.sailing.domain.racelog.RaceLogPassChangeEvent;
|
||||
@@ -110,12 +109,12 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
|
||||
private final DB database;
|
||||
|
||||
private RaceLogEventFactory raceLogEventFactory;
|
||||
|
||||
private RaceLogEventRestoreFactory raceLogEventFactory;
|
||||
|
||||
public DomainObjectFactoryImpl(DB db) {
|
||||
super();
|
||||
this.database = db;
|
||||
this.raceLogEventFactory = RaceLogEventFactory.INSTANCE;
|
||||
this.raceLogEventFactory = RaceLogEventRestoreFactory.INSTANCE;
|
||||
}
|
||||
|
||||
public Wind loadWind(DBObject object) {
|
||||
@@ -133,9 +132,16 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private TimePoint loadTimePoint(DBObject object, FieldNames field) {
|
||||
return new MillisecondsTimePoint((Long) object.get(field.name()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a {@link TimePoint} on the given object at {@link FieldNames#TIME_AS_MILLIS}.
|
||||
*/
|
||||
private TimePoint loadTimePoint(DBObject object) {
|
||||
return new MillisecondsTimePoint((Long) object.get(FieldNames.TIME_AS_MILLIS.name()));
|
||||
return loadTimePoint(object, FieldNames.TIME_AS_MILLIS);
|
||||
}
|
||||
|
||||
private SpeedWithBearing loadSpeedWithBearing(DBObject object) {
|
||||
@@ -980,45 +986,43 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
|
||||
public RaceLogEvent loadRaceLogEvent(DBObject dbObject) {
|
||||
TimePoint timePoint = loadTimePoint(dbObject);
|
||||
TimePoint createdAt = loadTimePoint(dbObject, FieldNames.RACE_LOG_EVENT_CREATED_AT);
|
||||
Serializable id = (Serializable) dbObject.get(FieldNames.RACE_LOG_EVENT_ID.name());
|
||||
Integer passId = (Integer) dbObject.get(FieldNames.RACE_LOG_EVENT_PASS_ID.name());
|
||||
BasicDBList dbList = (BasicDBList) dbObject.get(FieldNames.RACE_LOG_EVENT_INVOLVED_BOATS.name());
|
||||
List<Competitor> competitors = loadCompetitorsForRaceLogEvent(dbList);
|
||||
BasicDBList dbCompetitors = (BasicDBList) dbObject.get(FieldNames.RACE_LOG_EVENT_INVOLVED_BOATS.name());
|
||||
List<Competitor> competitors = loadCompetitorsForRaceLogEvent(dbCompetitors);
|
||||
|
||||
String eventClass = (String) dbObject.get(FieldNames.RACE_LOG_EVENT_CLASS.name());
|
||||
|
||||
if (eventClass.equals(RaceLogStartTimeEvent.class.getSimpleName())) {
|
||||
return loadRaceLogStartTimeEvent(timePoint, id, passId, competitors, dbObject);
|
||||
|
||||
return loadRaceLogStartTimeEvent(createdAt, timePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(RaceLogRaceStatusEvent.class.getSimpleName())) {
|
||||
return loadRaceLogRaceStatusEvent(timePoint, id, passId, competitors, dbObject);
|
||||
|
||||
return loadRaceLogRaceStatusEvent(createdAt, timePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(RaceLogFlagEvent.class.getSimpleName())) {
|
||||
return loadRaceLogFlagEvent(timePoint, id, passId, competitors, dbObject);
|
||||
|
||||
return loadRaceLogFlagEvent(createdAt, timePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(RaceLogPassChangeEvent.class.getSimpleName())) {
|
||||
return raceLogEventFactory.createRaceLogPassChangeEvent(timePoint, id, competitors, passId);
|
||||
|
||||
return loadRaceLogPassChangeEvent(createdAt, timePoint, id, passId, competitors);
|
||||
} else if (eventClass.equals(RaceLogCourseAreaChangedEvent.class.getSimpleName())) {
|
||||
return loadRaceLogCourseAreaChangedEvent(timePoint, id, passId, competitors, dbObject);
|
||||
|
||||
return loadRaceLogCourseAreaChangedEvent(createdAt, timePoint, id, passId, competitors, dbObject);
|
||||
} else if (eventClass.equals(RaceLogCourseDesignChangedEvent.class.getSimpleName())) {
|
||||
return loadRaceLogCourseDesignChangedEvent(timePoint, id, passId, competitors, dbObject);
|
||||
return loadRaceLogCourseDesignChangedEvent(createdAt, timePoint, id, passId, competitors, dbObject);
|
||||
}
|
||||
|
||||
return null;
|
||||
throw new IllegalStateException(String.format("Unknown RaceLogEvent type %s", eventClass));
|
||||
}
|
||||
|
||||
private RaceLogCourseDesignChangedEvent loadRaceLogCourseDesignChangedEvent(TimePoint timePoint, Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
private RaceLogEvent loadRaceLogPassChangeEvent(TimePoint createdAt, TimePoint timePoint, Serializable id,
|
||||
Integer passId, List<Competitor> competitors) {
|
||||
return raceLogEventFactory.createPassChangeEvent(createdAt, timePoint, id, competitors, passId);
|
||||
}
|
||||
|
||||
private RaceLogCourseDesignChangedEvent loadRaceLogCourseDesignChangedEvent(TimePoint createdAt, TimePoint timePoint, Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
CourseData courseData = loadCourseData((BasicDBList) dbObject.get(FieldNames.RACE_LOG_COURSE_DESIGN.name()));
|
||||
|
||||
return raceLogEventFactory.createCourseDesignChangedEvent(timePoint, id, competitors, passId, courseData);
|
||||
return raceLogEventFactory.createCourseDesignChangedEvent(createdAt, timePoint, id, competitors, passId, courseData);
|
||||
}
|
||||
|
||||
private RaceLogCourseAreaChangedEvent loadRaceLogCourseAreaChangedEvent(TimePoint timePoint, Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
private RaceLogCourseAreaChangedEvent loadRaceLogCourseAreaChangedEvent(TimePoint createdAt, TimePoint timePoint, Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
Serializable courseAreaId = (Serializable) dbObject.get(FieldNames.COURSE_AREA_ID.name());
|
||||
|
||||
return raceLogEventFactory.createRaceLogCourseAreaChangedEvent(timePoint, id, competitors, passId, courseAreaId);
|
||||
return raceLogEventFactory.createCourseAreaChangedEvent(createdAt, timePoint, id, competitors, passId, courseAreaId);
|
||||
}
|
||||
|
||||
private List<Competitor> loadCompetitorsForRaceLogEvent(BasicDBList dbCompetitorList) {
|
||||
@@ -1031,7 +1035,7 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
return competitors;
|
||||
}
|
||||
|
||||
private RaceLogFlagEvent loadRaceLogFlagEvent(TimePoint timePoint, Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
private RaceLogFlagEvent loadRaceLogFlagEvent(TimePoint createdAt, TimePoint timePoint, Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
Flags upperFlag = Flags.valueOf((String) dbObject.get(FieldNames.RACE_LOG_EVENT_FLAG_UPPER.name()));
|
||||
Flags lowerFlag = Flags.valueOf((String) dbObject.get(FieldNames.RACE_LOG_EVENT_FLAG_LOWER.name()));
|
||||
Boolean displayed = Boolean.valueOf((String) dbObject.get(FieldNames.RACE_LOG_EVENT_FLAG_DISPLAYED.name()));
|
||||
@@ -1040,23 +1044,17 @@ public class DomainObjectFactoryImpl implements DomainObjectFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
return raceLogEventFactory.createFlagEvent(timePoint, id, competitors, passId, upperFlag, lowerFlag, displayed);
|
||||
return raceLogEventFactory.createFlagEvent(createdAt, timePoint, id, competitors, passId, upperFlag, lowerFlag, displayed);
|
||||
}
|
||||
|
||||
private RaceLogStartTimeEvent loadRaceLogStartTimeEvent(TimePoint timePoint, Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
Long startTimeInMillis = (Long) dbObject.get(FieldNames.RACE_LOG_EVENT_START_TIME.name());
|
||||
if (startTimeInMillis == null) {
|
||||
return null;
|
||||
}
|
||||
TimePoint startTime = new MillisecondsTimePoint(startTimeInMillis);
|
||||
|
||||
return raceLogEventFactory.createStartTimeEvent(timePoint, id, competitors, passId, startTime);
|
||||
private RaceLogStartTimeEvent loadRaceLogStartTimeEvent(TimePoint createdAt, TimePoint timePoint, Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
TimePoint startTime = loadTimePoint(dbObject, FieldNames.RACE_LOG_EVENT_START_TIME);
|
||||
return raceLogEventFactory.createStartTimeEvent(createdAt, timePoint, id, competitors, passId, startTime);
|
||||
}
|
||||
|
||||
private RaceLogRaceStatusEvent loadRaceLogRaceStatusEvent(TimePoint timePoint, Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
private RaceLogRaceStatusEvent loadRaceLogRaceStatusEvent(TimePoint createdAt, TimePoint timePoint, Serializable id, Integer passId, List<Competitor> competitors, DBObject dbObject) {
|
||||
RaceLogRaceStatus nextStatus = RaceLogRaceStatus.valueOf((String) dbObject.get(FieldNames.RACE_LOG_EVENT_NEXT_STATUS.name()));
|
||||
|
||||
return raceLogEventFactory.createRaceStatusEvent(timePoint, id, competitors, passId, nextStatus);
|
||||
return raceLogEventFactory.createRaceStatusEvent(createdAt, timePoint, id, competitors, passId, nextStatus);
|
||||
}
|
||||
|
||||
private CourseData loadCourseData(BasicDBList dbCourseList) {
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public enum FieldNames {
|
||||
|
||||
// race log
|
||||
RACE_LOG_IDENTIFIER,
|
||||
RACE_LOG_EVENT, RACE_LOG_EVENT_PASS_ID, RACE_LOG_EVENT_ID, RACE_LOG_EVENT_INVOLVED_BOATS, RACE_LOG_EVENT_FLAG_UPPER, RACE_LOG_EVENT_FLAG_LOWER,
|
||||
RACE_LOG_EVENT, RACE_LOG_EVENT_PASS_ID, RACE_LOG_EVENT_ID, RACE_LOG_EVENT_CREATED_AT, RACE_LOG_EVENT_INVOLVED_BOATS, RACE_LOG_EVENT_FLAG_UPPER, RACE_LOG_EVENT_FLAG_LOWER,
|
||||
RACE_LOG_EVENT_FLAG_DISPLAYED, RACE_LOG_EVENT_START_TIME, RACE_LOG_EVENT_CLASS, RACE_LOG_EVENT_NEXT_STATUS, RACE_LOG_COURSE_DESIGN, WAYPOINT_ID,
|
||||
WAYPOINT_NAME, WAYPOINT_PASSINGSIDE, CONTROLPOINT, CONTROLPOINT_CLASS, MARK_ID, MARK_COLOR, MARK_NAME, MARK_PATTERN, MARK_SHAPE, MARK_TYPE,
|
||||
CONTROLPOINT_VALUE, GATE_ID, GATE_NAME, GATE_LEFT, GATE_RIGHT;
|
||||
|
||||
+9
-9
@@ -73,9 +73,13 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
storeSpeedWithBearing(wind, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void storeTimePoint(TimePoint timePoint, DBObject result, FieldNames field) {
|
||||
result.put(field.name(), timePoint.asMillis());
|
||||
}
|
||||
|
||||
private void storeTimed(Timed timed, DBObject result) {
|
||||
result.put(FieldNames.TIME_AS_MILLIS.name(), timed.getTimePoint().asMillis());
|
||||
storeTimePoint(timed.getTimePoint(), result, FieldNames.TIME_AS_MILLIS);
|
||||
}
|
||||
|
||||
private void storeSpeedWithBearing(SpeedWithBearing speedWithBearing, DBObject result) {
|
||||
@@ -557,19 +561,17 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
|
||||
private DBObject storeRaceLogStartTimeEvent(RaceLogStartTimeEvent startTimeEvent) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeTimed(startTimeEvent, result);
|
||||
storeRaceLogEventProperties(startTimeEvent, result);
|
||||
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogStartTimeEvent.class.getSimpleName());
|
||||
|
||||
result.put(FieldNames.RACE_LOG_EVENT_START_TIME.name(), startTimeEvent.getStartTime().asMillis());
|
||||
|
||||
storeTimePoint(startTimeEvent.getStartTime(), result, FieldNames.RACE_LOG_EVENT_START_TIME);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_NEXT_STATUS.name(), startTimeEvent.getNextStatus().name());
|
||||
return result;
|
||||
}
|
||||
|
||||
public DBObject storeRaceLogFlagEvent(RaceLogFlagEvent flagEvent) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeTimed(flagEvent, result);
|
||||
storeRaceLogEventProperties(flagEvent, result);
|
||||
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogFlagEvent.class.getSimpleName());
|
||||
@@ -581,6 +583,8 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
}
|
||||
|
||||
private void storeRaceLogEventProperties(RaceLogEvent event, DBObject result) {
|
||||
storeTimed(event, result);
|
||||
storeTimePoint(event.getCreatedAt(), result, FieldNames.RACE_LOG_EVENT_CREATED_AT);
|
||||
result.put(FieldNames.RACE_LOG_EVENT_ID.name(), event.getId());
|
||||
result.put(FieldNames.RACE_LOG_EVENT_PASS_ID.name(), event.getPassId());
|
||||
result.put(FieldNames.RACE_LOG_EVENT_INVOLVED_BOATS.name(), storeInvolvedBoatsForRaceLogEvent(event.getInvolvedBoats()));
|
||||
@@ -597,7 +601,6 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
|
||||
private DBObject storeRaceLogPassChangeEvent(RaceLogPassChangeEvent passChangeEvent) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeTimed(passChangeEvent, result);
|
||||
storeRaceLogEventProperties(passChangeEvent, result);
|
||||
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogPassChangeEvent.class.getSimpleName());
|
||||
@@ -606,7 +609,6 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
|
||||
private DBObject storeRaceLogRaceStatusEvent(RaceLogRaceStatusEvent raceStatusEvent) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeTimed(raceStatusEvent, result);
|
||||
storeRaceLogEventProperties(raceStatusEvent, result);
|
||||
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogRaceStatusEvent.class.getSimpleName());
|
||||
@@ -617,7 +619,6 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
|
||||
private DBObject storeRaceLogCourseAreaChangedEvent(RaceLogCourseAreaChangedEvent courseAreaChangedEvent) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeTimed(courseAreaChangedEvent, result);
|
||||
storeRaceLogEventProperties(courseAreaChangedEvent, result);
|
||||
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogCourseAreaChangedEvent.class.getSimpleName());
|
||||
@@ -628,7 +629,6 @@ public class MongoObjectFactoryImpl implements MongoObjectFactory {
|
||||
|
||||
private DBObject storeRaceLogCourseDesignChangedEvent(RaceLogCourseDesignChangedEvent courseDesignChangedEvent) {
|
||||
DBObject result = new BasicDBObject();
|
||||
storeTimed(courseDesignChangedEvent, result);
|
||||
storeRaceLogEventProperties(courseDesignChangedEvent, result);
|
||||
|
||||
result.put(FieldNames.RACE_LOG_EVENT_CLASS.name(), RaceLogCourseDesignChangedEvent.class.getSimpleName());
|
||||
|
||||
+46
-13
@@ -4,24 +4,59 @@ import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Timed;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.WithID;
|
||||
|
||||
/**
|
||||
* Records an event that is sent by the race log via the Race Committee Cockpit App.
|
||||
* The event is timed and may influence the state of a race depending on its context
|
||||
* the the current state of the RaceLog.
|
||||
* <p>
|
||||
* A {@link RaceLogEvent} is an entry in a race's log (typically a {@link RaceLog}.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Such an entry may influence the state of a race (scheduled, started, finished, ...), contain information about the
|
||||
* current displayed flags (AP, N, X, P, etc.) of a race or indicate some other change regarding the race. See
|
||||
* subclasses of {@link RaceLogEvent} for a full list of possibilities.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* A {@link RaceLogEvent} may be associated to a certain pass. For a race a new pass is initiated whenever a new start
|
||||
* time is proposed (e.g. after the race was aborted).
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Each {@link RaceLogEvent} carries two timestamps.
|
||||
*
|
||||
* The timestamp received with {@link RaceLogEvent#getCreatedAt()} denotes the point in time the event was created.
|
||||
*
|
||||
* The timestamp received with {@link RaceLogEvent#getTimePoint()} denotes the logical point in time the event has
|
||||
* occurred (sometimes called 'event time'). This timestamp might be different from {@link RaceLogEvent#getCreatedAt()}.
|
||||
* For example setting the start time of race to a point in time in the past, results in a {@link RaceLogEvent}
|
||||
* returning "now" on {@link RaceLogEvent#getCreatedAt()} and such a point in time that a complete startphase could have
|
||||
* occured on {@link RaceLogEvent#getTimePoint()}.
|
||||
*
|
||||
* To ensure an ordering there should be no two {@link RaceLogEvent}s returning the same point in time on
|
||||
* {@link RaceLogEvent#getTimePoint()} <b>per pass</b>.
|
||||
* </p>
|
||||
*
|
||||
* Subclasses may be flag events (AP, N, X, P, etc.) or operational race events.
|
||||
*
|
||||
*/
|
||||
public interface RaceLogEvent extends Timed, WithID {
|
||||
|
||||
/**
|
||||
* Gets the {@link TimePoint} this event was created at.
|
||||
*/
|
||||
TimePoint getCreatedAt();
|
||||
|
||||
/**
|
||||
* Gets the {@link TimePoint} denoting the logical event time.
|
||||
*/
|
||||
@Override
|
||||
TimePoint getTimePoint();
|
||||
|
||||
/**
|
||||
* 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).
|
||||
* 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).
|
||||
*
|
||||
*/
|
||||
int getPassId();
|
||||
@@ -29,15 +64,13 @@ public interface RaceLogEvent extends Timed, WithID {
|
||||
/**
|
||||
* 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.
|
||||
* 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();
|
||||
|
||||
/**
|
||||
* Visitor pattern to implement certain {@link RaceLogEvent} subclass specific
|
||||
* behavior.
|
||||
* Visitor pattern to implement certain {@link RaceLogEvent} subclass specific behavior.
|
||||
*/
|
||||
void accept(RaceLogEventVisitor visitor);
|
||||
}
|
||||
+4
-4
@@ -22,11 +22,11 @@ public interface RaceLogEventFactory {
|
||||
RaceLogRaceStatusEvent createRaceStatusEvent(TimePoint timePoint, Serializable id, List<Competitor> competitors, int passId, RaceLogRaceStatus nextStatus);
|
||||
RaceLogRaceStatusEvent createRaceStatusEvent(TimePoint timePoint, int passId, RaceLogRaceStatus nextStatus);
|
||||
|
||||
RaceLogPassChangeEvent createRaceLogPassChangeEvent(TimePoint timePoint, Serializable id, List<Competitor> competitors, int passId);
|
||||
RaceLogPassChangeEvent createRaceLogPassChangeEvent(TimePoint timePoint, int passId);
|
||||
RaceLogPassChangeEvent createPassChangeEvent(TimePoint timePoint, Serializable id, List<Competitor> competitors, int passId);
|
||||
RaceLogPassChangeEvent createPassChangeEvent(TimePoint timePoint, int passId);
|
||||
|
||||
RaceLogCourseAreaChangedEvent createRaceLogCourseAreaChangedEvent(TimePoint timePoint, Serializable id, List<Competitor> competitors, int passId, Serializable courseAreaId);
|
||||
RaceLogCourseAreaChangedEvent createRaceLogCourseAreaChangedEvent(TimePoint timePoint, int passId, Serializable courseAreaId);
|
||||
RaceLogCourseAreaChangedEvent createCourseAreaChangedEvent(TimePoint timePoint, Serializable id, List<Competitor> competitors, int passId, Serializable courseAreaId);
|
||||
RaceLogCourseAreaChangedEvent createCourseAreaChangedEvent(TimePoint timePoint, int passId, Serializable courseAreaId);
|
||||
|
||||
RaceLogCourseDesignChangedEvent createCourseDesignChangedEvent(TimePoint timePoint, Serializable id, List<Competitor> competitors, int passId, CourseData courseData);
|
||||
RaceLogCourseDesignChangedEvent createCourseDesignChangedEvent(TimePoint timePoint, int passId, CourseData courseData);
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.sap.sailing.domain.racelog;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CourseData;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.domain.racelog.impl.RaceLogEventRestoreFactoryImpl;
|
||||
|
||||
public interface RaceLogEventRestoreFactory extends RaceLogEventFactory {
|
||||
RaceLogEventRestoreFactory INSTANCE = new RaceLogEventRestoreFactoryImpl();
|
||||
|
||||
RaceLogFlagEvent createFlagEvent(TimePoint createdAt, TimePoint logicalTimePoint, Serializable id,
|
||||
List<Competitor> involvedBoats, int passId, Flags upperFlag, Flags lowerFlag, boolean isDisplayed);
|
||||
|
||||
RaceLogStartTimeEvent createStartTimeEvent(TimePoint createdAt, TimePoint logicalTimePoint, Serializable id,
|
||||
List<Competitor> involvedBoats, int passId, TimePoint startTime);
|
||||
|
||||
RaceLogRaceStatusEvent createRaceStatusEvent(TimePoint createdAt, TimePoint logicalTimePoint, Serializable id,
|
||||
List<Competitor> competitors, int passId, RaceLogRaceStatus nextStatus);
|
||||
|
||||
RaceLogPassChangeEvent createPassChangeEvent(TimePoint createdAt, TimePoint logicalTimePoint, Serializable id,
|
||||
List<Competitor> competitors, int passId);
|
||||
|
||||
RaceLogCourseAreaChangedEvent createCourseAreaChangedEvent(TimePoint createdAt, TimePoint logicalTimePoint,
|
||||
Serializable id, List<Competitor> competitors, int passId, Serializable courseAreaId);
|
||||
|
||||
RaceLogCourseDesignChangedEvent createCourseDesignChangedEvent(TimePoint createdAt, TimePoint logicalTimePoint,
|
||||
Serializable id, List<Competitor> competitors, int passId, CourseData courseData);
|
||||
}
|
||||
+7
@@ -1,7 +1,14 @@
|
||||
package com.sap.sailing.domain.racelog;
|
||||
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
|
||||
/**
|
||||
* A {@link RaceLogStartTimeEvent} denotes a new start time.
|
||||
*
|
||||
* Each {@link RaceLogStartTimeEvent} is also a {@link RaceLogRaceStatusEvent} with
|
||||
* {@link RaceLogRaceStatusEvent#getNextStatus()} returning {@link RaceLogRaceStatus#SCHEDULED}.
|
||||
*/
|
||||
public interface RaceLogStartTimeEvent extends RaceLogRaceStatusEvent {
|
||||
|
||||
TimePoint getStartTime();
|
||||
|
||||
+3
-3
@@ -14,9 +14,9 @@ RaceLogCourseAreaChangedEvent {
|
||||
|
||||
private Serializable courseAreaId;
|
||||
|
||||
public RaceLogCourseAreaChangeEventImpl(TimePoint pTimePoint,
|
||||
Serializable pId, List<Competitor> pInvolvedBoats, int pPassId, Serializable courseAreaId) {
|
||||
super(pTimePoint, pId, pInvolvedBoats, pPassId);
|
||||
public RaceLogCourseAreaChangeEventImpl(TimePoint createdAt,
|
||||
TimePoint pTimePoint, Serializable pId, List<Competitor> pInvolvedBoats, int pPassId, Serializable courseAreaId) {
|
||||
super(createdAt, pTimePoint, pId, pInvolvedBoats, pPassId);
|
||||
this.courseAreaId = courseAreaId;
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -14,9 +14,9 @@ public class RaceLogCourseDesignChangedEventImpl extends RaceLogEventImpl implem
|
||||
|
||||
private CourseData courseDesign;
|
||||
|
||||
public RaceLogCourseDesignChangedEventImpl(TimePoint pTimePoint,
|
||||
Serializable pId, List<Competitor> pInvolvedBoats, int pPassId, CourseData courseDesign) {
|
||||
super(pTimePoint, pId, pInvolvedBoats, pPassId);
|
||||
public RaceLogCourseDesignChangedEventImpl(TimePoint createdAt,
|
||||
TimePoint pTimePoint, Serializable pId, List<Competitor> pInvolvedBoats, int pPassId, CourseData courseDesign) {
|
||||
super(createdAt, pTimePoint, pId, pInvolvedBoats, pPassId);
|
||||
this.courseDesign = courseDesign;
|
||||
}
|
||||
|
||||
|
||||
+13
-12
@@ -7,6 +7,7 @@ import java.util.UUID;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CourseData;
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
@@ -23,7 +24,7 @@ public class RaceLogEventFactoryImpl implements RaceLogEventFactory {
|
||||
@Override
|
||||
public RaceLogFlagEvent createFlagEvent(TimePoint timePoint, Serializable id, List<Competitor> involvedBoats, int passId,
|
||||
Flags upperFlag, Flags lowerFlag, boolean isDisplayed) {
|
||||
return new RaceLogFlagEventImpl(timePoint, id, involvedBoats, passId, upperFlag, lowerFlag, isDisplayed);
|
||||
return new RaceLogFlagEventImpl(MillisecondsTimePoint.now(), timePoint, id, involvedBoats, passId, upperFlag, lowerFlag, isDisplayed);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,7 +36,7 @@ public class RaceLogEventFactoryImpl implements RaceLogEventFactory {
|
||||
@Override
|
||||
public RaceLogStartTimeEvent createStartTimeEvent(TimePoint timePoint, Serializable id, List<Competitor> involvedBoats, int passId,
|
||||
TimePoint startTime) {
|
||||
return new RaceLogStartTimeEventImpl(timePoint, id, involvedBoats, passId, RaceLogRaceStatus.SCHEDULED, startTime);
|
||||
return new RaceLogStartTimeEventImpl(MillisecondsTimePoint.now(), timePoint, id, involvedBoats, passId, startTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +47,7 @@ public class RaceLogEventFactoryImpl implements RaceLogEventFactory {
|
||||
@Override
|
||||
public RaceLogRaceStatusEvent createRaceStatusEvent(TimePoint timePoint,Serializable id, List<Competitor> competitors, int passId,
|
||||
RaceLogRaceStatus nextStatus) {
|
||||
return new RaceLogRaceStatusEventImpl(timePoint, id, competitors, passId, nextStatus);
|
||||
return new RaceLogRaceStatusEventImpl(MillisecondsTimePoint.now(), timePoint, id, competitors, passId, nextStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,32 +57,32 @@ public class RaceLogEventFactoryImpl implements RaceLogEventFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogPassChangeEvent createRaceLogPassChangeEvent(TimePoint timePoint, Serializable id, List<Competitor> competitors,
|
||||
public RaceLogPassChangeEvent createPassChangeEvent(TimePoint timePoint, Serializable id, List<Competitor> competitors,
|
||||
int passId) {
|
||||
return new RaceLogPassChangeEventImpl(timePoint, id, competitors, passId);
|
||||
return new RaceLogPassChangeEventImpl(MillisecondsTimePoint.now(), timePoint, id, competitors, passId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogPassChangeEvent createRaceLogPassChangeEvent(TimePoint timePoint, int passId) {
|
||||
return createRaceLogPassChangeEvent(timePoint, UUID.randomUUID(), new ArrayList<Competitor>(), passId);
|
||||
public RaceLogPassChangeEvent createPassChangeEvent(TimePoint timePoint, int passId) {
|
||||
return createPassChangeEvent(timePoint, UUID.randomUUID(), new ArrayList<Competitor>(), passId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogCourseAreaChangedEvent createRaceLogCourseAreaChangedEvent(TimePoint timePoint, Serializable id, List<Competitor> competitors,
|
||||
public RaceLogCourseAreaChangedEvent createCourseAreaChangedEvent(TimePoint timePoint, Serializable id, List<Competitor> competitors,
|
||||
int passId, Serializable courseAreaId) {
|
||||
return new RaceLogCourseAreaChangeEventImpl(timePoint, id, competitors, passId, courseAreaId);
|
||||
return new RaceLogCourseAreaChangeEventImpl(MillisecondsTimePoint.now(), timePoint, id, competitors, passId, courseAreaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogCourseAreaChangedEvent createRaceLogCourseAreaChangedEvent(
|
||||
public RaceLogCourseAreaChangedEvent createCourseAreaChangedEvent(
|
||||
TimePoint timePoint, int passId, Serializable courseAreaId) {
|
||||
return createRaceLogCourseAreaChangedEvent(timePoint, UUID.randomUUID(), new ArrayList<Competitor>(), passId, courseAreaId);
|
||||
return createCourseAreaChangedEvent(timePoint, UUID.randomUUID(), new ArrayList<Competitor>(), passId, courseAreaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogCourseDesignChangedEvent createCourseDesignChangedEvent(TimePoint timePoint, Serializable id,
|
||||
List<Competitor> competitors, int passId, CourseData courseData) {
|
||||
return new RaceLogCourseDesignChangedEventImpl(timePoint, id, competitors, passId, courseData);
|
||||
return new RaceLogCourseDesignChangedEventImpl(MillisecondsTimePoint.now(), timePoint, id, competitors, passId, courseData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+13
-6
@@ -11,21 +11,29 @@ public abstract class RaceLogEventImpl implements RaceLogEvent {
|
||||
|
||||
private static final long serialVersionUID = -5810258278984777732L;
|
||||
|
||||
private TimePoint timePoint;
|
||||
private TimePoint createdAt;
|
||||
private TimePoint logicalTimePoint;
|
||||
private Serializable id;
|
||||
private List<Competitor> involvedBoats;
|
||||
private int passId;
|
||||
|
||||
public RaceLogEventImpl(TimePoint pTimePoint, Serializable pId, List<Competitor> pInvolvedBoats, int pPassId) {
|
||||
this.timePoint = pTimePoint;
|
||||
public RaceLogEventImpl(TimePoint createdAt, TimePoint pTimePoint, Serializable pId,
|
||||
List<Competitor> pInvolvedBoats, int pPassId) {
|
||||
this.createdAt = createdAt;
|
||||
this.logicalTimePoint = pTimePoint;
|
||||
this.id = pId;
|
||||
this.involvedBoats = pInvolvedBoats;
|
||||
this.passId = pPassId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimePoint getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TimePoint getTimePoint() {
|
||||
return timePoint;
|
||||
return logicalTimePoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,8 +53,7 @@ public abstract class RaceLogEventImpl implements RaceLogEvent {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
return object instanceof RaceLogEvent
|
||||
&& timePoint.equals(((RaceLogEvent) object).getTimePoint())
|
||||
return object instanceof RaceLogEvent && logicalTimePoint.equals(((RaceLogEvent) object).getTimePoint())
|
||||
&& id.equals(((RaceLogEvent) object).getId())
|
||||
&& involvedBoats.equals(((RaceLogEvent) object).getInvolvedBoats())
|
||||
&& passId == ((RaceLogEvent) object).getPassId();
|
||||
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
package com.sap.sailing.domain.racelog.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.CourseData;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.domain.racelog.RaceLogCourseAreaChangedEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogCourseDesignChangedEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEventRestoreFactory;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFlagEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogPassChangeEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogRaceStatusEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogStartTimeEvent;
|
||||
|
||||
public class RaceLogEventRestoreFactoryImpl extends RaceLogEventFactoryImpl implements RaceLogEventRestoreFactory {
|
||||
|
||||
@Override
|
||||
public RaceLogFlagEvent createFlagEvent(TimePoint createdAt, TimePoint logicalTimePoint, Serializable id,
|
||||
List<Competitor> involvedBoats, int passId, Flags upperFlag, Flags lowerFlag, boolean isDisplayed) {
|
||||
return new RaceLogFlagEventImpl(createdAt, logicalTimePoint, id, involvedBoats, passId, upperFlag, lowerFlag, isDisplayed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogStartTimeEvent createStartTimeEvent(TimePoint createdAt, TimePoint logicalTimePoint, Serializable id,
|
||||
List<Competitor> involvedBoats, int passId, TimePoint startTime) {
|
||||
return new RaceLogStartTimeEventImpl(createdAt, logicalTimePoint, id, involvedBoats, passId, startTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogRaceStatusEvent createRaceStatusEvent(TimePoint createdAt, TimePoint logicalTimePoint,
|
||||
Serializable id, List<Competitor> competitors, int passId, RaceLogRaceStatus nextStatus) {
|
||||
return new RaceLogRaceStatusEventImpl(createdAt, logicalTimePoint, id, competitors, passId, nextStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogPassChangeEvent createPassChangeEvent(TimePoint createdAt, TimePoint logicalTimePoint,
|
||||
Serializable id, List<Competitor> competitors, int passId) {
|
||||
return new RaceLogPassChangeEventImpl(createdAt, logicalTimePoint, id, competitors, passId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogCourseAreaChangedEvent createCourseAreaChangedEvent(TimePoint createdAt, TimePoint logicalTimePoint,
|
||||
Serializable id, List<Competitor> competitors, int passId, Serializable courseAreaId) {
|
||||
return new RaceLogCourseAreaChangeEventImpl(createdAt, logicalTimePoint, id, competitors, passId, courseAreaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceLogCourseDesignChangedEvent createCourseDesignChangedEvent(TimePoint createdAt,
|
||||
TimePoint logicalTimePoint, Serializable id, List<Competitor> competitors, int passId, CourseData courseData) {
|
||||
return new RaceLogCourseDesignChangedEventImpl(createdAt, logicalTimePoint, id, competitors, passId, courseData);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+2
-2
@@ -16,8 +16,8 @@ public class RaceLogFlagEventImpl extends RaceLogEventImpl implements RaceLogFla
|
||||
private Flags lowerFlag;
|
||||
private boolean isDisplayed;
|
||||
|
||||
public RaceLogFlagEventImpl(TimePoint pTimePoint, Serializable pId, List<Competitor> pInvolvedBoats, int pPassId, Flags pUpperFlag, Flags pLowerFlag, boolean pIsDisplayed) {
|
||||
super(pTimePoint, pId, pInvolvedBoats, pPassId);
|
||||
public RaceLogFlagEventImpl(TimePoint createdAt, TimePoint pTimePoint, Serializable pId, List<Competitor> pInvolvedBoats, int pPassId, Flags pUpperFlag, Flags pLowerFlag, boolean pIsDisplayed) {
|
||||
super(createdAt, pTimePoint, pId, pInvolvedBoats, pPassId);
|
||||
this.upperFlag = pUpperFlag;
|
||||
this.lowerFlag = pLowerFlag;
|
||||
this.isDisplayed = pIsDisplayed;
|
||||
|
||||
+3
-3
@@ -11,9 +11,9 @@ import com.sap.sailing.domain.racelog.RaceLogPassChangeEvent;
|
||||
public class RaceLogPassChangeEventImpl extends RaceLogEventImpl implements RaceLogPassChangeEvent {
|
||||
private static final long serialVersionUID = -3737606977320640630L;
|
||||
|
||||
public RaceLogPassChangeEventImpl(TimePoint pTimePoint, Serializable pId,
|
||||
List<Competitor> pInvolvedBoats, int pPassId) {
|
||||
super(pTimePoint, pId, pInvolvedBoats, pPassId);
|
||||
public RaceLogPassChangeEventImpl(TimePoint createdAt, TimePoint pTimePoint,
|
||||
Serializable pId, List<Competitor> pInvolvedBoats, int pPassId) {
|
||||
super(createdAt, pTimePoint, pId, pInvolvedBoats, pPassId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-9
@@ -9,19 +9,14 @@ import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.racelog.RaceLogRaceStatusEvent;
|
||||
|
||||
public class RaceLogRaceStatusEventImpl extends RaceLogEventImpl implements
|
||||
RaceLogRaceStatusEvent {
|
||||
public class RaceLogRaceStatusEventImpl extends RaceLogEventImpl implements RaceLogRaceStatusEvent {
|
||||
private static final long serialVersionUID = -8809758843066724482L;
|
||||
|
||||
protected RaceLogRaceStatus nextStatus;
|
||||
|
||||
public RaceLogRaceStatusEventImpl(
|
||||
TimePoint pTimePoint,
|
||||
Serializable pId,
|
||||
List<Competitor> pInvolvedBoats,
|
||||
int pPassId,
|
||||
RaceLogRaceStatus nextStatus) {
|
||||
super(pTimePoint, pId, pInvolvedBoats, pPassId);
|
||||
public RaceLogRaceStatusEventImpl(TimePoint createdAt, TimePoint pTimePoint, Serializable pId,
|
||||
List<Competitor> pInvolvedBoats, int pPassId, RaceLogRaceStatus nextStatus) {
|
||||
super(createdAt, pTimePoint, pId, pInvolvedBoats, pPassId);
|
||||
this.nextStatus = nextStatus;
|
||||
}
|
||||
|
||||
|
||||
+6
-13
@@ -9,20 +9,14 @@ import com.sap.sailing.domain.common.racelog.RaceLogRaceStatus;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEventVisitor;
|
||||
import com.sap.sailing.domain.racelog.RaceLogStartTimeEvent;
|
||||
|
||||
public class RaceLogStartTimeEventImpl extends RaceLogRaceStatusEventImpl
|
||||
implements RaceLogStartTimeEvent {
|
||||
public class RaceLogStartTimeEventImpl extends RaceLogRaceStatusEventImpl implements RaceLogStartTimeEvent {
|
||||
|
||||
private static final long serialVersionUID = 8185811395997196162L;
|
||||
private TimePoint startTime;
|
||||
|
||||
public RaceLogStartTimeEventImpl(
|
||||
TimePoint pTimePoint,
|
||||
Serializable pId,
|
||||
List<Competitor> pInvolvedBoats,
|
||||
int pPassId,
|
||||
RaceLogRaceStatus nextStatus,
|
||||
TimePoint pStartTime) {
|
||||
super(pTimePoint, pId, pInvolvedBoats, pPassId, nextStatus);
|
||||
public RaceLogStartTimeEventImpl(TimePoint createdAt, TimePoint pTimePoint, Serializable pId,
|
||||
List<Competitor> pInvolvedBoats, int pPassId, TimePoint pStartTime) {
|
||||
super(createdAt, pTimePoint, pId, pInvolvedBoats, pPassId, RaceLogRaceStatus.SCHEDULED);
|
||||
this.startTime = pStartTime;
|
||||
}
|
||||
|
||||
@@ -38,9 +32,8 @@ implements RaceLogStartTimeEvent {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
/// TODO: please check the implementation of this method... why is this needed?
|
||||
return super.equals(object)
|
||||
&& object instanceof RaceLogStartTimeEvent
|
||||
// / TODO: please check the implementation of this method... why is this needed?
|
||||
return super.equals(object) && object instanceof RaceLogStartTimeEvent
|
||||
&& startTime.equals(((RaceLogStartTimeEvent) object).getStartTime());
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Fragment-Host: com.sap.sailing.mongodb
|
||||
Require-Bundle: com.sap.sailing.domain,
|
||||
Require-Bundle: org.eclipse.osgi,
|
||||
com.sap.sailing.domain,
|
||||
com.sap.sailing.domain.shared.android,
|
||||
com.sap.sailing.domain.test,
|
||||
com.tractrac.clientmodule;bundle-version="2.0.0",
|
||||
com.sap.sailing.domain.tractracadapter,
|
||||
org.eclipse.osgi,
|
||||
com.sap.sailing.domain.persistence,
|
||||
com.sap.sailing.server,
|
||||
com.sap.sailing.expeditionconnector,
|
||||
@@ -20,6 +20,6 @@ Require-Bundle: com.sap.sailing.domain,
|
||||
org.objenesis;bundle-version="1.3.0",
|
||||
org.mockito.mockito-core;bundle-version="1.9.5"
|
||||
Import-Package: com.sap.sailing.domain.common.impl,
|
||||
junit.framework;version="4.8.1",
|
||||
org.junit;version="4.8.1"
|
||||
junit.framework;version="4.8.2",
|
||||
org.junit;version="4.8.2"
|
||||
|
||||
+62
-48
@@ -2,6 +2,7 @@ package com.sap.sailing.mongodb.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -35,108 +36,121 @@ import com.sap.sailing.domain.racelog.RaceLogPassChangeEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogRaceStatusEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogStartTimeEvent;
|
||||
|
||||
public class StoreRaceLogEventsTest extends AbstractMongoDBTest {
|
||||
|
||||
protected MongoObjectFactoryImpl mongoFactory = (MongoObjectFactoryImpl) MongoFactory.INSTANCE.getMongoObjectFactory(getMongoService());
|
||||
protected DomainObjectFactoryImpl domainFactory = (DomainObjectFactoryImpl) MongoFactory.INSTANCE.getDomainObjectFactory(getMongoService());
|
||||
public class StoreAndLoadRaceLogEventsTest extends AbstractMongoDBTest {
|
||||
|
||||
protected MongoObjectFactoryImpl mongoFactory = (MongoObjectFactoryImpl) MongoFactory.INSTANCE
|
||||
.getMongoObjectFactory(getMongoService());
|
||||
protected DomainObjectFactoryImpl domainFactory = (DomainObjectFactoryImpl) MongoFactory.INSTANCE
|
||||
.getDomainObjectFactory(getMongoService());
|
||||
protected RaceLogEventFactory eventFactory = RaceLogEventFactory.INSTANCE;
|
||||
|
||||
|
||||
protected RaceLogIdentifier logIdentifier;
|
||||
|
||||
|
||||
protected TimePoint expectedEventTime = new MillisecondsTimePoint(42);
|
||||
protected Serializable expectedId = UUID.randomUUID();
|
||||
protected List<Competitor> expectedInvolvedBoats = Collections.emptyList();
|
||||
protected int expectedPassId = 42;
|
||||
|
||||
public StoreRaceLogEventsTest() throws UnknownHostException, MongoException {
|
||||
|
||||
public StoreAndLoadRaceLogEventsTest() throws UnknownHostException, MongoException {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
logIdentifier = mock(RaceLogIdentifier.class);
|
||||
when(logIdentifier.getIdentifier()).thenReturn(UUID.randomUUID());
|
||||
}
|
||||
|
||||
public void assertBaseFields(RaceLogEvent event) {
|
||||
assertNotNull(event);
|
||||
assertEquals(expectedEventTime, event.getTimePoint());
|
||||
assertEquals(expectedId, event.getId());
|
||||
assertEquals(expectedInvolvedBoats.size(), Util.size(event.getInvolvedBoats()));
|
||||
assertEquals(expectedPassId, event.getPassId());
|
||||
|
||||
public void assertBaseFields(RaceLogEvent expectedEvent, RaceLogEvent actualEvent) {
|
||||
assertNotNull(actualEvent);
|
||||
assertEquals(expectedEvent.getCreatedAt(), actualEvent.getCreatedAt());
|
||||
assertEquals(expectedEvent.getTimePoint(), actualEvent.getTimePoint());
|
||||
assertEquals(expectedEvent.getId(), actualEvent.getId());
|
||||
assertEquals(expectedEvent.getInvolvedBoats().size(), Util.size(actualEvent.getInvolvedBoats()));
|
||||
assertEquals(expectedEvent.getPassId(), actualEvent.getPassId());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStoreAndLoadFlagEvent() {
|
||||
Flags upperFlag = Flags.ALPHA;
|
||||
Flags lowerFlag = Flags.BRAVO;
|
||||
boolean isDisplayed = true;
|
||||
|
||||
RaceLogFlagEvent expectedEvent = eventFactory.createFlagEvent(expectedEventTime, expectedId, expectedInvolvedBoats, expectedPassId,
|
||||
upperFlag, lowerFlag, isDisplayed);
|
||||
|
||||
|
||||
RaceLogFlagEvent expectedEvent = eventFactory.createFlagEvent(expectedEventTime, expectedId,
|
||||
expectedInvolvedBoats, expectedPassId, upperFlag, lowerFlag, isDisplayed);
|
||||
|
||||
DBObject dbObject = mongoFactory.storeRaceLogEntry(logIdentifier, expectedEvent);
|
||||
RaceLogFlagEvent actualEvent = loadEvent(dbObject);
|
||||
|
||||
assertBaseFields(actualEvent);
|
||||
|
||||
assertBaseFields(expectedEvent, actualEvent);
|
||||
assertEquals(upperFlag, actualEvent.getUpperFlag());
|
||||
assertEquals(lowerFlag, actualEvent.getLowerFlag());
|
||||
assertEquals(isDisplayed, actualEvent.isDisplayed());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStoreAndLoadCourseAreaChangedEvent() {
|
||||
Serializable courseAreaId = UUID.randomUUID();
|
||||
|
||||
RaceLogCourseAreaChangedEvent expectedEvent = eventFactory.createRaceLogCourseAreaChangedEvent(expectedEventTime, expectedId, expectedInvolvedBoats, expectedPassId,
|
||||
courseAreaId);
|
||||
|
||||
|
||||
RaceLogCourseAreaChangedEvent expectedEvent = eventFactory.createCourseAreaChangedEvent(
|
||||
expectedEventTime, expectedId, expectedInvolvedBoats, expectedPassId, courseAreaId);
|
||||
|
||||
DBObject dbObject = mongoFactory.storeRaceLogEntry(logIdentifier, expectedEvent);
|
||||
RaceLogCourseAreaChangedEvent actualEvent = loadEvent(dbObject);
|
||||
|
||||
assertBaseFields(actualEvent);
|
||||
|
||||
assertBaseFields(expectedEvent, actualEvent);
|
||||
assertEquals(courseAreaId, actualEvent.getCourseAreaId());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStoreAndLoadPassChangeEvent() {
|
||||
RaceLogPassChangeEvent expectedEvent = eventFactory.createRaceLogPassChangeEvent(expectedEventTime, expectedId, expectedInvolvedBoats, expectedPassId);
|
||||
|
||||
RaceLogPassChangeEvent expectedEvent = eventFactory.createPassChangeEvent(expectedEventTime, expectedId,
|
||||
expectedInvolvedBoats, expectedPassId);
|
||||
|
||||
DBObject dbObject = mongoFactory.storeRaceLogEntry(logIdentifier, expectedEvent);
|
||||
RaceLogPassChangeEvent actualEvent = loadEvent(dbObject);
|
||||
|
||||
assertBaseFields(actualEvent);
|
||||
|
||||
assertBaseFields(expectedEvent, actualEvent);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStoreAndLoadRaceStatusEvent() {
|
||||
RaceLogRaceStatus status = RaceLogRaceStatus.SCHEDULED;
|
||||
RaceLogRaceStatusEvent expectedEvent = eventFactory.createRaceStatusEvent(expectedEventTime, expectedId, expectedInvolvedBoats, expectedPassId,
|
||||
status);
|
||||
|
||||
RaceLogRaceStatusEvent expectedEvent = eventFactory.createRaceStatusEvent(expectedEventTime, expectedId,
|
||||
expectedInvolvedBoats, expectedPassId, status);
|
||||
|
||||
DBObject dbObject = mongoFactory.storeRaceLogEntry(logIdentifier, expectedEvent);
|
||||
RaceLogRaceStatusEvent actualEvent = loadEvent(dbObject);
|
||||
|
||||
assertBaseFields(actualEvent);
|
||||
|
||||
assertBaseFields(expectedEvent, actualEvent);
|
||||
assertEquals(status, actualEvent.getNextStatus());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testStoreAndLoadStartTimeEvent() {
|
||||
TimePoint startTime = new MillisecondsTimePoint(1337);
|
||||
RaceLogStartTimeEvent expectedEvent = eventFactory.createStartTimeEvent(expectedEventTime, expectedId, expectedInvolvedBoats, expectedPassId,
|
||||
startTime);
|
||||
|
||||
RaceLogStartTimeEvent expectedEvent = eventFactory.createStartTimeEvent(expectedEventTime, expectedId,
|
||||
expectedInvolvedBoats, expectedPassId, startTime);
|
||||
|
||||
DBObject dbObject = mongoFactory.storeRaceLogEntry(logIdentifier, expectedEvent);
|
||||
RaceLogStartTimeEvent actualEvent = loadEvent(dbObject);
|
||||
|
||||
assertBaseFields(actualEvent);
|
||||
|
||||
assertBaseFields(expectedEvent, actualEvent);
|
||||
assertEquals(startTime, actualEvent.getStartTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Will always wait a couple of milliseconds to ensure that {@link RaceLogEvent#getCreatedAt()} has passed.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T extends RaceLogEvent> T loadEvent(DBObject dbObject) {
|
||||
RaceLogEvent dbEvent = domainFactory.loadRaceLogEvent((DBObject) dbObject.get(FieldNames.RACE_LOG_EVENT.name()));
|
||||
try {
|
||||
Thread.sleep(2);
|
||||
} catch (InterruptedException ie) {
|
||||
fail(ie.toString());
|
||||
}
|
||||
RaceLogEvent dbEvent = domainFactory
|
||||
.loadRaceLogEvent((DBObject) dbObject.get(FieldNames.RACE_LOG_EVENT.name()));
|
||||
T actualEvent = (T) dbEvent;
|
||||
return actualEvent;
|
||||
}
|
||||
+2
-2
@@ -78,7 +78,7 @@ public class TestStoringAndRetrievingRaceLogInLeaderboards extends RaceLogMongoD
|
||||
|
||||
@Test
|
||||
public void testStoreAndRetrieveSimpleLeaderboardWithRaceLogPassChangeEvent() {
|
||||
RaceLogPassChangeEvent event = RaceLogEventFactory.INSTANCE.createRaceLogPassChangeEvent(now, 0);
|
||||
RaceLogPassChangeEvent event = RaceLogEventFactory.INSTANCE.createPassChangeEvent(now, 0);
|
||||
|
||||
addAndStoreRaceLogEvent(leaderboard, raceColumnName, event);
|
||||
|
||||
@@ -100,7 +100,7 @@ public class TestStoringAndRetrievingRaceLogInLeaderboards extends RaceLogMongoD
|
||||
@Test
|
||||
public void testStoreAndRetrieveSimpleLeaderboardWithRaceLogCourseAreaChangeEvent() {
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
RaceLogCourseAreaChangedEvent event = RaceLogEventFactory.INSTANCE.createRaceLogCourseAreaChangedEvent(now, 0, uuid);
|
||||
RaceLogCourseAreaChangedEvent event = RaceLogEventFactory.INSTANCE.createCourseAreaChangedEvent(now, 0, uuid);
|
||||
|
||||
addAndStoreRaceLogEvent(leaderboard, raceColumnName, event);
|
||||
|
||||
|
||||
+2
-2
@@ -112,7 +112,7 @@ public class TestStoringAndRetrievingRaceLogInRegatta extends RaceLogMongoDBTest
|
||||
|
||||
@Test
|
||||
public void testStoreAndRetrieveSimpleLeaderboardWithRaceLogPassChangeEvent() {
|
||||
RaceLogPassChangeEvent event = RaceLogEventFactory.INSTANCE.createRaceLogPassChangeEvent(now, 0);
|
||||
RaceLogPassChangeEvent event = RaceLogEventFactory.INSTANCE.createPassChangeEvent(now, 0);
|
||||
|
||||
addAndStoreRaceLogEvent(regatta, raceColumnName, event);
|
||||
|
||||
@@ -134,7 +134,7 @@ public class TestStoringAndRetrievingRaceLogInRegatta extends RaceLogMongoDBTest
|
||||
@Test
|
||||
public void testStoreAndRetrieveSimpleLeaderboardWithRaceLogCourseAreaChangeEvent() {
|
||||
final UUID uuid = UUID.randomUUID();
|
||||
RaceLogCourseAreaChangedEvent event = RaceLogEventFactory.INSTANCE.createRaceLogCourseAreaChangedEvent(now, 0, uuid);
|
||||
RaceLogCourseAreaChangedEvent event = RaceLogEventFactory.INSTANCE.createCourseAreaChangedEvent(now, 0, uuid);
|
||||
|
||||
addAndStoreRaceLogEvent(regatta, raceColumnName, event);
|
||||
|
||||
|
||||
+14
-15
@@ -22,7 +22,8 @@ import com.sap.sailing.server.gateway.serialization.racelog.impl.BaseRaceLogEven
|
||||
public abstract class AbstractEventSerializerTest<EventType extends RaceLogEvent> {
|
||||
|
||||
protected final UUID expectedId = UUID.randomUUID();
|
||||
protected final long expectedTimestamp = 1337l;
|
||||
protected final long expectedCreatedAtTimestamp = 42l;
|
||||
protected final long expectedLogicalTimestamp = 1337l;
|
||||
protected final int expectedPassId = 42;
|
||||
|
||||
private JsonSerializer<Competitor> competitorSerializer;
|
||||
@@ -41,30 +42,28 @@ public abstract class AbstractEventSerializerTest<EventType extends RaceLogEvent
|
||||
serializer = createSerializer(competitorSerializer);
|
||||
event = createMockEvent();
|
||||
|
||||
TimePoint timePoint = mock(TimePoint.class);
|
||||
when(timePoint.asMillis()).thenReturn(expectedTimestamp);
|
||||
TimePoint createdAtTimePoint = mock(TimePoint.class);
|
||||
when(createdAtTimePoint.asMillis()).thenReturn(expectedCreatedAtTimestamp);
|
||||
TimePoint logicalTimePoint = mock(TimePoint.class);
|
||||
when(logicalTimePoint.asMillis()).thenReturn(expectedLogicalTimestamp);
|
||||
|
||||
when(event.getId()).thenReturn(expectedId);
|
||||
when(event.getTimePoint()).thenReturn(timePoint);
|
||||
when(event.getCreatedAt()).thenReturn(createdAtTimePoint);
|
||||
when(event.getTimePoint()).thenReturn(logicalTimePoint);
|
||||
when(event.getPassId()).thenReturn(expectedPassId);
|
||||
when(event.getInvolvedBoats()).thenReturn(
|
||||
Collections.<Competitor> emptyList());
|
||||
when(event.getInvolvedBoats()).thenReturn(Collections.<Competitor> emptyList());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSerializeBaseAttributes() {
|
||||
JSONObject json = serializer.serialize(event);
|
||||
|
||||
assertEquals(
|
||||
expectedId,
|
||||
UUID.fromString(json.get(
|
||||
BaseRaceLogEventSerializer.FIELD_ID).toString()));
|
||||
assertEquals(expectedTimestamp,
|
||||
json.get(BaseRaceLogEventSerializer.FIELD_TIMESTAMP));
|
||||
assertEquals(expectedPassId,
|
||||
json.get(BaseRaceLogEventSerializer.FIELD_PASS_ID));
|
||||
assertEquals(expectedId, UUID.fromString(json.get(BaseRaceLogEventSerializer.FIELD_ID).toString()));
|
||||
assertEquals(expectedCreatedAtTimestamp, json.get(BaseRaceLogEventSerializer.FIELD_CREATED_AT));
|
||||
assertEquals(expectedLogicalTimestamp, json.get(BaseRaceLogEventSerializer.FIELD_TIMESTAMP));
|
||||
assertEquals(expectedPassId, json.get(BaseRaceLogEventSerializer.FIELD_PASS_ID));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testIsParseable() throws ParseException {
|
||||
JSONObject json = serializer.serialize(event);
|
||||
|
||||
+2
-2
@@ -71,14 +71,14 @@ public class RaceLogEventSerializerChooserTest {
|
||||
@Test
|
||||
public void testChoosesCourseAreaChangedSerializer() {
|
||||
// we use the real event type here because we do not want to re-implement the dispatching.
|
||||
RaceLogEvent event = factory.createRaceLogCourseAreaChangedEvent(null, 0, null);
|
||||
RaceLogEvent event = factory.createCourseAreaChangedEvent(null, 0, null);
|
||||
assertEquals(courseAreaChangedEventSerializer, chooser.getSerializer(event));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChoosesPassChangedSerializer() {
|
||||
// we use the real event type here because we do not want to re-implement the dispatching.
|
||||
RaceLogEvent event = factory.createRaceLogPassChangeEvent(null, 0);
|
||||
RaceLogEvent event = factory.createPassChangeEvent(null, 0);
|
||||
assertEquals(passChangedSerializer, chooser.getSerializer(event));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ public class RaceLogCourseAreaChangedEventDeserializer extends BaseRaceLogEventD
|
||||
|
||||
String courseAreaId = object.get(RaceLogCourseAreaChangedEventSerializer.FIELD_COURSE_AREA_ID).toString();
|
||||
|
||||
return factory.createRaceLogCourseAreaChangedEvent(timePoint, id, Collections.<Competitor> emptyList(), passId,
|
||||
return factory.createCourseAreaChangedEvent(timePoint, id, Collections.<Competitor> emptyList(), passId,
|
||||
Helpers.tryUuidConversion(courseAreaId));
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -10,6 +10,7 @@ import com.sap.sailing.server.gateway.serialization.JsonSerializer;
|
||||
public abstract class BaseRaceLogEventSerializer implements JsonSerializer<RaceLogEvent> {
|
||||
public static final String FIELD_CLASS = "@class";
|
||||
public static final String FIELD_ID = "id";
|
||||
public static final Object FIELD_CREATED_AT = "createdAt";
|
||||
public static final String FIELD_TIMESTAMP = "timestamp";
|
||||
public static final String FIELD_PASS_ID = "passId";
|
||||
public static final String FIELD_COMPETITORS = "competitors";
|
||||
@@ -27,6 +28,7 @@ public abstract class BaseRaceLogEventSerializer implements JsonSerializer<RaceL
|
||||
JSONObject result = new JSONObject();
|
||||
result.put(FIELD_CLASS, getClassFieldValue());
|
||||
result.put(FIELD_ID, object.getId().toString());
|
||||
result.put(FIELD_CREATED_AT, object.getCreatedAt().asMillis());
|
||||
result.put(FIELD_TIMESTAMP, object.getTimePoint().asMillis());
|
||||
result.put(FIELD_PASS_ID, object.getPassId());
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ public class AppConstants {
|
||||
|
||||
public static String getServerBaseURL(Context context) {
|
||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return sp.getString(PREFERENCE_SERVICE_URL, "http://localhost:8888");
|
||||
return sp.getString(PREFERENCE_SERVICE_URL, "http://192.168.56.1:8888");
|
||||
}
|
||||
|
||||
public static boolean isSendingActive(Context context) {
|
||||
|
||||
+1
-1
@@ -125,7 +125,7 @@ public class RaceStateImpl implements RaceState, RaceLogChangedListener {
|
||||
RaceLogEvent abortEvent = RaceLogEventFactory.INSTANCE.createRaceStatusEvent(eventTime, raceLog.getCurrentPassId(), RaceLogRaceStatus.UNSCHEDULED);
|
||||
this.raceLog.add(abortEvent);
|
||||
|
||||
RaceLogEvent passChangeEvent = RaceLogEventFactory.INSTANCE.createRaceLogPassChangeEvent(eventTime, raceLog.getCurrentPassId() + 1);
|
||||
RaceLogEvent passChangeEvent = RaceLogEventFactory.INSTANCE.createPassChangeEvent(eventTime, raceLog.getCurrentPassId() + 1);
|
||||
this.raceLog.add(passChangeEvent);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user