mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-03 17:49:40 +00:00
Merge branch 'master' into test
This commit is contained in:
commit
339eee5d73
5 files changed
+44
-16
No files matched your search
+3
-1
@@ -161,7 +161,9 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
Patch<Waypoint> patch = DiffUtils.diff(courseWaypoints, newWaypointList);
|
||||
CourseAsWaypointList courseAsWaypointList = new CourseAsWaypointList(courseToUpdate);
|
||||
patch.applyToInPlace(courseAsWaypointList);
|
||||
synchronized (courseToUpdate) {
|
||||
patch.applyToInPlace(courseAsWaypointList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+31
-5
@@ -1,8 +1,10 @@
|
||||
package com.sap.sailing.domain.tractracadapter.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.maptrack.client.io.TypeController;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
@@ -15,12 +17,14 @@ import com.sap.sailing.domain.tracking.DynamicTrackedRace;
|
||||
import com.sap.sailing.domain.tracking.MarkPassing;
|
||||
import com.sap.sailing.domain.tractracadapter.DomainFactory;
|
||||
import com.sap.sailing.util.Util.Triple;
|
||||
import com.tractrac.clientmodule.ControlPoint;
|
||||
import com.tractrac.clientmodule.Race;
|
||||
import com.tractrac.clientmodule.RaceCompetitor;
|
||||
import com.tractrac.clientmodule.data.ICallbackData;
|
||||
import com.tractrac.clientmodule.data.MarkPassingsData;
|
||||
|
||||
public class MarkPassingReceiver extends AbstractReceiverWithQueue<RaceCompetitor, MarkPassingsData, Boolean> {
|
||||
private static final Logger logger = Logger.getLogger(MarkPassingReceiver.class.getName());
|
||||
private final DynamicTrackedEvent trackedEvent;
|
||||
private final com.tractrac.clientmodule.Event tractracEvent;
|
||||
|
||||
@@ -60,15 +64,37 @@ public class MarkPassingReceiver extends AbstractReceiverWithQueue<RaceCompetito
|
||||
DynamicTrackedRace trackedRace = trackedEvent.getTrackedRace(getDomainFactory().getRaceDefinition(event
|
||||
.getA().getRace()));
|
||||
Course course = trackedRace.getRace().getCourse();
|
||||
Iterator<Waypoint> waypointIter = course.getWaypoints().iterator();
|
||||
List<MarkPassing> markPassings = new ArrayList<MarkPassing>();
|
||||
Iterable<Waypoint> waypoints = course.getWaypoints();
|
||||
Map<com.sap.sailing.domain.base.ControlPoint, MarkPassing> passingsByControlPoint = new HashMap<com.sap.sailing.domain.base.ControlPoint, MarkPassing>();
|
||||
// Note: the entries always describe all mark passings for the competitor so far in the current race in order
|
||||
for (MarkPassingsData.Entry passing : event.getB().getPassings()) {
|
||||
Waypoint passed = waypointIter.next();
|
||||
ControlPoint controlPointPassed = passing.getControlPoint();
|
||||
com.sap.sailing.domain.base.ControlPoint domainControlPoint = getDomainFactory().getControlPoint(controlPointPassed);
|
||||
Waypoint passed = findWaypointForControlPoint(waypoints, domainControlPoint);
|
||||
if (passed != null) {
|
||||
TimePoint time = new MillisecondsTimePoint(passing.getTimestamp());
|
||||
MarkPassing markPassing = getDomainFactory().createMarkPassing(event.getA().getCompetitor(), passed, time);
|
||||
markPassings.add(markPassing);
|
||||
passingsByControlPoint.put(domainControlPoint, markPassing);
|
||||
} else {
|
||||
logger.warning("Didn't find waypoint in course "+course+" for mark passing around "+passing.getControlPoint());
|
||||
}
|
||||
}
|
||||
List<MarkPassing> markPassings = new ArrayList<MarkPassing>();
|
||||
for (Waypoint waypoint : waypoints) {
|
||||
MarkPassing passing = passingsByControlPoint.get(waypoint.getControlPoint());
|
||||
if (passing != null) {
|
||||
markPassings.add(passing);
|
||||
}
|
||||
}
|
||||
trackedRace.updateMarkPassings(getDomainFactory().getCompetitor(event.getA().getCompetitor()), markPassings);
|
||||
}
|
||||
|
||||
private Waypoint findWaypointForControlPoint(Iterable<Waypoint> waypoints, com.sap.sailing.domain.base.ControlPoint domainControlPoint) {
|
||||
for (Waypoint waypoint : waypoints) {
|
||||
if (waypoint.getControlPoint() == domainControlPoint) {
|
||||
return waypoint;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class CourseImpl extends NamedImpl implements Course {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWaypoint(int zeroBasedPosition, Waypoint waypointToAdd) {
|
||||
public synchronized void addWaypoint(int zeroBasedPosition, Waypoint waypointToAdd) {
|
||||
waypoints.add(zeroBasedPosition, waypointToAdd);
|
||||
int legStartWaypointIndex;
|
||||
if (zeroBasedPosition == waypoints.size()-1) { // added to end
|
||||
@@ -72,7 +72,7 @@ public class CourseImpl extends NamedImpl implements Course {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeWaypoint(int zeroBasedPosition) {
|
||||
public synchronized void removeWaypoint(int zeroBasedPosition) {
|
||||
if (zeroBasedPosition >= 0) {
|
||||
boolean isLast = zeroBasedPosition == waypoints.size()-1;
|
||||
Waypoint removedWaypoint = waypoints.remove(zeroBasedPosition);
|
||||
@@ -111,17 +111,17 @@ public class CourseImpl extends NamedImpl implements Course {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Leg> getLegs() {
|
||||
public synchronized List<Leg> getLegs() {
|
||||
return Collections.unmodifiableList(legs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Waypoint> getWaypoints() {
|
||||
return waypoints;
|
||||
public synchronized Iterable<Waypoint> getWaypoints() {
|
||||
return new ArrayList<Waypoint>(waypoints);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public synchronized String toString() {
|
||||
StringBuilder result = new StringBuilder(getName());
|
||||
result.append(": ");
|
||||
boolean first = true;
|
||||
@@ -162,12 +162,12 @@ public class CourseImpl extends NamedImpl implements Course {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Waypoint getFirstWaypoint() {
|
||||
public synchronized Waypoint getFirstWaypoint() {
|
||||
return waypoints.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Waypoint getLastWaypoint() {
|
||||
public synchronized Waypoint getLastWaypoint() {
|
||||
return waypoints.get(waypoints.size()-1);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user